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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll X; cin >> X;
    // N 回目まで全部右移動すると 1+2+...+N=N(N+1)/2 動く
    // N(N+1)/2がXと等しいもしくは少しだけ大きくなるところまで行き，あとはどこを右移動しないか決める
    ll ans;
    ll x1 = floor(sqrt(2 * X));

    if (x1 * (x1 + 1) / 2 >= X){
        ans = x1;
    } else {
        ans = x1 + 1;
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	ll N; cin >> N;
	ll T[100];
	ll sum = 0;
	repe(i, 1, N) {
		cin >> T[i];
		sum += T[i];
	}
	ll M; cin >> M;
	ll P[100], X[100];
	repe(i, 1, M) {
		cin >> P[i] >> X[i];
	}
	repe(i, 1, M) {
		cout << sum - T[P[i]] + X[i] << endl;
	}

	return 0;
}

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

/*
問題
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B&lang=jp

*/

int n, W;
const int MAX_N = 105;
const int MAX_W = 10005;
int w[MAX_N], v[MAX_N];
int dp[MAX_N][MAX_W];

int main() {
    cin >> n >> W;
    rep(i, n) {
        cin >> v[i] >> w[i];
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= W; j++) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j + w[i] <= W) {
                dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
            }
        }
    }
    cout << dp[n][W] << endl;

    return 0;
}


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

int main()
{
    ll a, b;
    cin >> a >> b;
    ll ans = 0;
    if (a == b)
    {
        cout << a << endl;
        return 0;
    }
    if ((a ^ (a + 1)) != 1)
        ans = a, a++;
    ll p = (b + 1 - a) % 4;
    if (p == 0)
        ans = ans;
    else if (p == 1)
        ans = ans ^ b;
    else if (p == 2)
        ans = ans ^ b ^ (b - 1);
    else
        ans = ans ^ b ^ (b - 1) ^ (b - 2);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int l;
    l=s.size();
    for(int i=0; i<l; i++)
    {
        if(s[i]=='1')
        {
            cout << '9';
        }
        else if(s[i]=='9')
        {
            cout << '1';
        }
    }
    return 0;
}


Measured memory_bytes: 256
H, W = [int(_) for _ in input().split()]
A = [input() for i in range(H)]

def solve(H, W, A):
    ssum = sum(row.count("#") for row in A)
    if ssum != H + W - 1:
        return False
    x, y = 0, 0
    if A[y][x] != "#":
        return False
    while 1:
        if y == H - 1 and x == W - 1:
            return True
        if (x + 1) < W and A[y][x + 1] == "#":
            x += 1
        elif (y + 1) < H and A[y + 1][x] == "#":
            y += 1
        else:
            return False

result = solve(H, W, A)

if result:
    print("Possible")
else:
    print("Impossible")


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

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> cnt(N);
  for (int i = 0; i < N; ++i)
  {
    int a;
    cin >> a;
    ++cnt[a - 1];
  }
  sort(cnt.rbegin(), cnt.rend());
  cout << N - accumulate(cnt.begin(), cnt.begin() + K, 0);
  return 0;
}


Measured memory_bytes: 1024
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let h: Vec<i32> = (0..n).map(|_| iter.next().unwrap().parse().unwrap()).collect();
    let mut ans = 0;
    let mut cnt = 0;
    for i in 0..n-1 {
        if h[i] >= h[i+1] {
            cnt += 1;
            ans = std::cmp::max(ans, cnt);
        }else {
            cnt = 0;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func popCount(v int) int {
	cnt := 0
	for v > 0 {
		if v&1 == 1 {
			cnt++
		}
		v = v >> 1
	}
	return cnt
}

func main() {
	defer write.Flush()

	var n, m int
	fmt.Fscan(read, &n, &m)

	var l1, r1 int
	var l2, r2 int
	fmt.Fscan(read, &l1, &r1)
	for i := 0; i < m-1; i++ {
		fmt.Fscan(read, &l2, &r2)
		if l1 < l2 {
			l1 = l2
		}
		if r1 > r2 {
			r1 = r2
		}
	}
	ans := r1 - l1 + 1
	if ans < 0 {
		ans = 0
	}
	fmt.Fprintln(write, ans)
}


Measured memory_bytes: 1792
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
using namespace std;
const int maxn = 100000 + 10;

int n;
char s[maxn];

inline void fail() {
  puts("-1");
  exit(0);
}

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	if(s[1] == '0') fail();
	if(s[n] == '1') fail();
	for(int i = 1;i < n;i ++) {
	  if(s[i] != s[n - i]) fail();
	}
	int rt = 1;
	for(int i = 1;i < n;i ++) {
	  printf("%d %d\n", rt, i + 1);
	  if(s[i] == '1') rt = i + 1;
	}
  return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,a,n) for(int i=a;i<n;i++)
typedef pair<int,int> P;
typedef long long ll;
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    rep(i,1,20000){
        if(i*2/25==a&&i/10==b){
            cout<<i;return 0;
        }
    }
    cout<<-1;return 0;
}

Measured memory_bytes: 256
using System;
    class test
    {
        static void Main()
        {
            int count = 0;
            string ward = Console.ReadLine();
            while (true)
            {
                string[] text = Console.ReadLine().Split(' ');
                if (text[0] == "END_OF_TEXT") break;
                for (int i = 0; i < text.Length; i++)
                    if (string.Equals(ward,text[i],StringComparison.OrdinalIgnoreCase)) count++;
            }
            Console.WriteLine(count);
        }
    }

Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
using namespace std;


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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

	ll a,b;
	char c;
	cin >> a >> c >> b;

	a = (c == '+' ? a + b : a - b);

	cout << a << endl;

	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define db double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<double , double>
#define pll pair<long long int,long long int>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define inf 1e18
#define eps 0.000001
#define endl '\n'
int main()
{  
    fastio;
    //#ifndef ONLINE_JUDGE
        //freopen("input.txt", "rt", stdin);
        //freopen("output.txt", "wt", stdout);
    //#endif
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll x=0,f=0;
    for(ll i=0;i<n;i++)
    {
        x++;
        if(x==k)
        {
            f++;
            i--;
            x=0;
        }
    }
    if(x!=1)
        f++;
    cout<<f;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;




int main() {
	int n;

	cin >> n;
	int v0[100001];
	int v1[100001];

	for (int i = 0; i <= 100000; i++) {
		v0[i] = 0;
		v1[i] = 0;
	}

	int max_v0 = 0;
	int max_index_v0 = -1;
	int max_v1 = 0;
	int max_index_v1 = -1;

	int count = n / 2;


	for (int i = 0; i < n; i++) {
		int v;
		cin >> v;
		if (i % 2 == 0) {
			v0[v]++;
			if (max_v0 < v0[v]) {
				max_v0 = v0[v];
				max_index_v0 = v; 
			}
		} else {
			v1[v]++;
			if (max_v1 < v1[v]) {
				max_v1 = v1[v];
				max_index_v1 = v; 
			}
		}
	}
	if (max_index_v0 != max_index_v1) {
		cout << n - max_v0 - max_v1 << endl;
		return 0;
	}
	sort(v0, v0 + 100001);
	sort(v1, v1 + 100001);

	int v0_change = n - max_v1 - v0[100001 - 2];
	int v1_change = n - max_v0 - v1[100001 - 2];

	cout << min(v0_change, v1_change) << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;


int main(void){
    string s;
    cin>>s;
    int ans=0,temp=0;
    rep(i,3){
        if(s[i]=='R') temp++;
        else{
            ans=max(ans,temp);
            temp=0;
        }
    }
    cout<<max(ans,temp)<<endl;
    return 0;
}

Measured memory_bytes: 3620
program main
    implicit none
    INTEGER :: a, b, c, x, sum = 0, ans = 0, i, j, k
    READ(*, *) a, b, c, x
    do i = 0, a
        do j = 0, b
            do k = 0, c
                sum = 500 * i + 100 * j + 50 * k
                if(sum == x) ans = ans + 1
                sum = 0
            enddo
        enddo
    enddo
    WRITE(*, *) ans
end program main

Measured memory_bytes: 2856
//#pragma GCC optimize ("O3,unrolled-loops")
#include <bits/stdc++.h>

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int N = 1e3+5;
const int MOD = 1e9+7;
int grid[N][N];

signed main(){
	fastio
	int n,m;
	cin >> n >> m;
	for(int i = 0;i < n;i++) for(int j = 0;j < m;j++){
		char tmp;
		cin >> tmp;
		if(tmp=='#') grid[i][j] = 1;
	}
	int dp[n][m];
	memset(dp,0,sizeof dp);
	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			if(grid[i][j]) dp[i][j] = 0;
			else if(i==0&&j==0) dp[i][j] = 1;
			else if(i==0) dp[i][j] = dp[i][j-1];
			else if(j==0) dp[i][j] = dp[i-1][j];
			else dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
		}
	}
	cout << dp[n-1][m-1] << "\n";
}

Measured memory_bytes: 19272
#include <stdio.h>
 
#define MINF (1LL<<63)
#define MAX(a, b) ((a)<(b)?(b):(a))
 
long long int A[1000][1000];
 
int main(){
  int n, m, i, j, k;
  scanf("%d%d", &n, &m);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j] = MINF;
    }
    A[i][i] = 0;
  }
  for(i=0;i<m;i++){
    int x, y, z;
    scanf("%d%d%d",&x,&y,&z);
    A[x-1][y-1]=z;
  }
  for(k=0;k<n;k++){
    for(i=0;i<n;i++){
      if(A[i][k]==MINF) continue;
      for(j=0;j<n;j++){
        if(A[k][j]==MINF) continue;
        A[i][j] = MAX(A[i][j], A[i][k] + A[k][j]);
      }
    }
  }
  for(i=0;i<n;i++){
    if(A[i][i]>0 && A[0][i] != MINF && A[i][n-1] != MINF){
      puts("inf"); return 0;
    }
  }
  printf("%lld\n", A[0][n-1]);
  return 0;
}


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

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

    string s;
    cin >> s;

    if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R'){
    	cout << 3;
    } else if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')){
    	cout << 2;
    } else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R'){
    	cout << 1;
    } else {
    	cout << 0;
    }

    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    double a,b,c,d,e,f;
    double x,y;
    while(cin >> a >> b >> c >> d >> e >> f){
        x = (double)((e*c-b*f) / (a*e-b*d));
        y = (double)((-(d*c)+a*f) / (a*e-b*d));
        if(x == 0){x = 0;}
        if(y == 0){y = 0;}
        printf("%.3f %.3f\n",x,y);
    }
}

Measured memory_bytes: 3060
import sys
from sys import stdin,stdout
import math
import random
import heapq
from collections import Counter
from functools import lru_cache
#@lru_cache(maxsize=None) #for optimizing the execution time of callable objects/functions(placed above callable functions)
try:
    for _ in range(1):
        x=int(input())
        if x==0:
            print(1)
        else:
            print(0)






    
except EOFError as e:
    print(e)


Measured memory_bytes: 76660
import sys
X = int(input())

A = 0
while True:
    for B in range(A+1):
        if A ** 5 + B ** 5 == X:
            print(A, -B)
            sys.exit()
        if A ** 5 - B ** 5 == X:
            print(A, B)
            sys.exit()
        if - A ** 5 + B ** 5  == X:
            print(-A, -B)
            sys.exit()
    A += 1

Measured memory_bytes: 9200
N=int(input())
A,B=map(int,input().split())
P=list(map(int,input().split()))
a=0
ab=0
b=0
for i in range(N):
    if P[i]<=A:
        a+=1
    elif A+1<=P[i] and P[i]<=B:
        ab+=1
    else:
        b+=1
C=[a,ab,b]
print(min(C))

Measured memory_bytes: 61784
import java.util.Scanner;

 class Main {



    public static long primeFactors(long n)
    {
        // Print the number of 2s that divide n
        long count=0;
        if(n%2==0)
            count++;
        while (n%2==0)
        {
            //System.out.print(2 + " ");
            n /= 2;

        }

        // n must be odd at this point.  So we can
        // skip one element (Note i = i +2)
        for (int i = 3; i <= Math.sqrt(n); i+= 2)
        {
            // While i divides n, print i and divide n
            if(n%i==0)
                count++;
            while (n%i == 0)
            {
                //System.out.print(i + " ");

                n /= i;
            }
        }

        // This condition is to handle the case whien
        // n is a prime number greater than 2
        if (n > 2) {
            //System.out.print(n);
            count++;
        }

        return  count;
    }


    static long gcd(long a, long b){
        if(b==0)
            return a;
        return gcd(b, a%b);
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long a= in.nextLong();
        long b= in.nextLong();

        long gcd= gcd(a, b);
       // System.out.println(gcd);
        long ans=primeFactors(gcd);
        ans++;
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <cstdio>
#define SIZE 244140625

int Hash(const char* c)
{
    int Hash = 0;
    while(*c){
        Hash *= 5;
        switch(*c){
        case 'A':
            Hash += 1; break;
        case 'C':
            Hash += 2; break;
        case 'G':
            Hash += 3; break;
        case 'T':
            Hash += 4; break;
        }
        ++c;
    }
    return Hash;
}
int main()
{
    bool* dic = new bool[SIZE];
    int n;
    std::scanf("%d", &n);
    char command[7];
    char str[13];
    for(int i = 0; i < n; ++i){
        std::scanf("%s %s", command, str);
        if(command[0] == 'i'){
            dic[Hash(str)] = true;
        }else{
            std::printf((dic[Hash(str)] ? "yes\n" : "no\n"));
        }
    }
    return 0;
 }

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

int main() {
    ll S,K;
    cin>>K>>S;
    ll cnt(0);
    for (int x(0);x<=K;x++){
      for (int y(0);y<=K;y++){
        if (x+y>=S-K&&x+y<=S)cnt++;
      }
    }
    cout<<cnt<<endl;
}


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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  ll n,k; cin>>n>>k;
  vector<ll> a(n);
  rep(i, n) cin>>a[i];
  vector<double> b(n);
  rep(i, n) b[i] = (1.0*a[i]+1)/2;

  double ans = 0;

  double t = 0;
  rep(i, n) {
    t += b[i];
    if (i >= k) t -= b[i-k];
    ans = max(ans, t);
  }

  printf("%.10lf\n", ans);

  return 0;
}


Measured memory_bytes: 6420
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using i_i = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const ll mod = 1000000007LL;
const int inf = 2000000000;


const int maxE = 100001;
int parent[maxE];
int parent_rank[maxE];


void init(int max_element) {
	for (int i = 0; i < max_element; i++) {
		parent[i] = i;
		parent_rank[i] = 0; 
	}
}

int find(int x) {
	if (x == parent[x]) return x;
	
	parent[x] = find(parent[x]);
	return parent[x];
}

bool same(int x, int y) {
	return find(x) == find(y);
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;

	if (parent_rank[x] > parent_rank[y]) {
		parent[y] = x;
		return;
	}
	parent[x] = y;
	if (parent_rank[x] == parent_rank[y]) {
		parent_rank[y]++;
	}
}

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

	init(n);

	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--;b--;
		unite(a, b);
	}
	set<int> st;

	rep(i,n) {
		st.insert(find(i));
	}
	cout << st.size() - 1 << endl;

	return 0;
}


Measured memory_bytes: 7696
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>

using namespace std;

int main() {
    int a, b, c;
    int count = 0;
    cin >> a >> b >> c;
    for (int i = a; i <= b; i++) {
        if (c % i == 0) {
            count++;
        }
    }
    cout << count << endl;

}


Measured memory_bytes: 3104
#!/usr/bin/env python3

S = input()

class RL:
    a = 0
    b = 0
    r_moji = 0
    l_moji = 0
    def __init__(self, s_pos, e_pos, rl_pos):
        rl_pos = rl_pos - s_pos
        self.r_moji = rl_pos + 1
        self.l_moji = (e_pos - s_pos) - (rl_pos + 1)
        self.a = (self.r_moji + 1) // 2 + self.l_moji // 2
        self.b = self.r_moji // 2 + (self.l_moji + 1) // 2
    def print(self):
        for i in range(self.r_moji - 1):
            print("0", end=" ")
        print(self.a, self.b, end=" ")
        for i in range(self.l_moji - 1):
            print("0", end=" ")
    
A = []
start_pos = 0
rl_pos = 0
for i in range(1,len(S)):
    if S[i-1] == 'R' and S[i] == 'L':
        rl_pos = i-1
    if S[i-1] == 'L' and S[i] == 'R':
        A.append(RL(start_pos, i, rl_pos))
        start_pos = i
A.append(RL(start_pos,len(S), rl_pos))

for a in A:
    a.print()
print()
        
        




Measured memory_bytes: 17508
#include <stdio.h>
int main(){
  int a,b,c,d;
  char e,f;
  d=scanf("%d%c%d%c%d",&a,&e,&b,&f,&c);
if(a*b<c){
printf("%d", a*b);
}else{
printf("%d",c);
}
}


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

int main() {
  int r, D, x, ans;
  cin >> r >> D >> x;
  
  ans = x;
  
  for (int i = 0; i < 10; i++) {
    ans = r*ans-D;
    cout << ans << endl;
  }
}

Measured memory_bytes: 3576
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		double sum = 0;
 
		for (int i = 0; i < n; i++) {
			sum += 1 / scan.nextDouble();
		}
		System.out.println(1 / sum);
	}
}

Measured memory_bytes: 24532
#include<iostream>
#include<math.h>
using namespace std;

int main(){
	long long int n;
	long long int k;
	long long int x;
	long long int m;

	cin>>n>>k;
	x=n%k;
	m=abs(x-k);
	if(m<x){
		cout<<m<<endl;
	}
	else
	{
	cout<<x<<endl;
		
	}
}


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

const int MAX = 3005;
int dp[MAX][2*MAX];
P items[MAX];
int n, t;

void solve() {
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j < 2*MAX; ++j) {
      int a = items[i].first, b = items[i].second;
      if (j-a < 0) dp[i][j] = dp[i-1][j];
      else if (j-a < t) dp[i][j] = max(dp[i-1][j], dp[i-1][j-a]+b);
      else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    }
  }
  cout << dp[n][2*MAX-1] << endl;
}

int main() {
  cin >> n >> t;
  rep(i, n) cin >> items[i+1].first >> items[i+1].second;
  sort(items, items+n+1);
  solve();
  return 0;
}

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

#define inrep int t; cin >> t; for(int tc=1; tc<=t; tc++)
#define fi first
#define sc second

int main()
{
	int n; cin >> n;
	int a = 0, b = 0, ta = 0;
	for(int i=0; i<n; i++) {
		int t, x, y; cin >> t >> x >> y;
		t -= ta;
		long long sum = abs(x - a) + abs(y - b);
		if (sum > t) {
			cout << "No" << "\n";
			return 0;
		}
		else if ((sum & 1) && !(t & 1)) {
			cout << "No\n"; return 0;
		}
		else if (!(sum & 1) && (t & 1)) {
			cout << "No\n"; return 0;
		}
		a = x, b = y; ta += t;
	}
	cout << "Yes" << "\n";
}

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

group = 0
parents = [-1]*N

def find(x):#xの根を返す
    global parents
    if parents[x] < 0:
        return x
    else:
        parents[x] = find(parents[x])
        return parents[x]

def union(x,y):
    global parents
    X = find(x)
    Y = find(y)

    if X==Y:
        return

    if parents[X] > parents[Y]:
        X,Y = Y,X

    parents[X] += parents[Y]
    parents[Y] = X

for q in range(M):
    union(AB[q][0]-1,AB[q][1]-1)

for p in range(N):
    if parents[p] < 0:
        group += 1

print(group-1)



Measured memory_bytes: 29116
#include <stdio.h>
#define MAX 100

int main(){
  int n,i,j,k,l,p[MAX+1],m[MAX+1][MAX+1];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }

  for(i=1;i<=n;i++){
    m[i][i]=0;
  }
  
  for(k=2;k<=n;k++){
    for(i=1;i<=n-k+1;i++){
      j=i+k-1;
      m[i][j]=(1<<21);
      for(l=i;l<=j-1;l++){
	if(m[i][j]>m[i][l]+m[l+1][j]+p[i-1]*p[l]*p[j]){
	  m[i][j]=m[i][l]+m[l+1][j]+p[i-1]*p[l]*p[j];
	}
      }
    }
    
  }
  printf("%d\n",m[1][n]);
 

  return 0;
}

    

Measured memory_bytes: 636
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			int n = scanner.nextInt();
			int count = 0;
			for (int i = 0; i < 10; i++) {
				for (int j = 0; j < 10; j++) {
					for (int k = 0; k < 10; k++) {
						for (int l = 0; l < 10; l++) {
							if (i + j + k + l == n) {
								count++;
							}
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

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


int main()
{
	int n,a,b,ans=0;
	cin>>n>>a>>b;
	for(int i = a; i <= n; i++)
	{
		int tem = i , k = 0;
		while( tem / 10 )
		{
			k+=tem%10;
			tem/=10;
			if(k > b)
				break;
		}
		k += tem;
		if( k>=a && k<=b)
		{
			
			ans+=i;
		}
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 256
n,a=map(int,input().split())
A=list(map(int,input().split()))
for i in range(n):
  A[i]=A[i]-a
B=[]
c=0
for i in range(n):
  if A[i]==0:
    c=c+1
  else:
    B.append(A[i])
n=len(B)
dp=[[0]*5010 for i in range(n+1)]#0と2505を対応
for i in range(1,n+1):
  dp[i]=dp[i-1][0:5010]
  dp[i][2505+B[i-1]]+=1
  for j in range(5010):
    if 0<=j+B[i-1] and j+B[i-1]<=5009:
      dp[i][j+B[i-1]]+=dp[i-1][j]
ans=dp[n][2505]
print((ans+1)*2**c-1)

Measured memory_bytes: 5492
def Q2(x):
    N, K = x[0][0], x[0][1]
    lst = x[1][:]
    lst = sorted(lst)[::-1]
    return sum(lst[:K])

l = [int(i) for i in input().split()]
m = [int(i) for i in input().split()]
n = [l,m]
print(Q2(n))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int A, B, K;
  cin >> A >> B >> K;
  int l = min(A, B);
  int cnt = 0;
  int ans = 0;
  for(int i=l; i>=1; i--){
    if(cnt == K) {
      ans = i+1;
      break;
    }
    if(A%i == 0 && B%i == 0) cnt++;
  }
  if(ans == 0) ans = 1;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
#define INF 1000000007
#define MOD 1000000007

#define MAX_N 1005
#define MAX_M 10005

int tm[MAX_M][MAX_N];//tm[人数][時間]

int main(){

    int n,m;
    while(cin >> n >> m,n){//PC数、学生数

        REP(i,MAX_M){
            REP(j,MAX_N){
                tm[i][j] = 0;
            }
        }
        int r,t,pc,num,s,q;
        cin >> r;
        REP(i,r){
            cin >> t >> pc >> num >> s;
            num--;//配列の添え字に合わせる
            t-=540;//配列0スタートに合わせる
            if(s == 1){
                //ログイン
                tm[num][t+1]++;
            }else{
                //ログアウト
                tm[num][t+1]--;
            }
        }

        //累積和
        REP(i,m){
            REP(j,MAX_N-1){
                tm[i][j+1] += tm[i][j];//imos累積和
            }
            REP(j,MAX_N){
                if(tm[i][j] > 1){
                    tm[i][j] = 1;
                }
            }
            REP(j,MAX_N-1){
                tm[i][j+1] += tm[i][j];//累積和
            }
        }

        cin >> q;//クエリ

        int ts,tr;
        REP(i,q){
            cin >> ts >> tr >> num;//時刻tsから時刻trまでのnumの利用時間
            num--;
            ts-=540;
            tr-=540;
            cout << tm[num][tr] - tm[num][ts] << endl;
        }
    }


    return 0;
}



Measured memory_bytes: 42352
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

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

    vector<lint> pos(n+1);
    for(lint i=0; i<n; i++) {
        lint e;
        cin >> e;
        pos[e] = i;
    }

    multiset<lint> ms;
    ms.insert(-1);
    ms.insert(-1);
    ms.insert(n);
    ms.insert(n);

    lint ans = 0;
    for(lint i=n; i>=1; i--) {
        auto it = ms.insert(pos[i]);
        lint l = *(--it);
        lint ll = *(--it);
        it++; it++;
        lint r = *(++it);
        lint rr = *(++it);

        ans += (l - ll) * (r - pos[i]) * i;
        ans += (pos[i] - l) * (rr - r) * i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5760
while(True):
    s = input()
    t = s.split()
    a,b,op = int(t[0]),int(t[2]),t[1]
    if op == '?':
        break
    else:
        if op == '+':
            ans = a+b
        elif op == '-':
            ans = a-b
        elif op == '*':
            ans = a*b
        elif op =='/':
            ans = int(a/b)
        print(ans)
        


Measured memory_bytes: 5600
#include <iostream>
int main(void)
{
  long n, k, ans = 0;
  std::cin >> n >> k;
  if(k % 2 == 0){
    long t = (n + k / 2) / k;
    ans += t * t * t;
  }
  long t = n / k;
  ans += t * t * t;
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
int n, cnt, flag;
bool vis[100010];
struct NOOD{
	int pos, x;
}a[100010];
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)scanf("%d", &a[i].x);
	for(int i = 1; i <= n; i++)a[i].pos = i;
	int t = 1;
	while(t != 2){
		if(vis[t])flag = 1;
		if(flag)break;
		vis[t] = 1;
		t = a[t].x;
		cnt++;
	}
	if(flag)printf("-1\n");
	else printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 1024
def resolve():
    '''
    code here
    '''
    N, M = [int(item) for item in input().split()]

    edges = [[int(item) for item in input().split()] for _ in range(M)]
    links = [set() for _ in range(N+1)]


    for a, b in edges:
        links[a].add(a) 
        links[a].add(b)
        links[b].add(a)
        links[b].add(b)


    class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
        def __init__(self, n):
            self.n = n
            # root[x]<0ならそのノードが根かつその値が木の要素数
            # rootノードでその木の要素数を記録する
            self.root = [-1]*(n+1)
            # 木をくっつける時にアンバランスにならないように調整する
            self.rnk = [0]*(n+1)

        # ノードxのrootノードを見つける
        def Find_Root(self, x):
            if(self.root[x] < 0):
                return x
            else:
                # ここで代入しておくことで、後の繰り返しを避ける
                self.root[x] = self.Find_Root(self.root[x])
                return self.root[x]
        # 木の併合、入力は併合したい各ノード
        def Unite(self, x, y):
            # 入力ノードのrootノードを見つける
            x = self.Find_Root(x)
            y = self.Find_Root(y)
            # すでに同じ木に属していた場合
            if(x == y):
                return 
            # 違う木に属していた場合rnkを見てくっつける方を決める
            elif(self.rnk[x] > self.rnk[y]):
                self.root[x] += self.root[y]
                self.root[y] = x

            else:
                self.root[y] += self.root[x]
                self.root[x] = y
                # rnkが同じ（深さに差がない場合）は1増やす
                if(self.rnk[x] == self.rnk[y]):
                    self.rnk[y] += 1
        # xとyが同じグループに属するか判断
        def isSameGroup(self, x, y):
            return self.Find_Root(x) == self.Find_Root(y)

        # ノードxが属する木のサイズを返す
        def Count(self, x):
            return -self.root[self.Find_Root(x)]

    uf = UnionFind(N+1)
    for i, item in enumerate(links):
        for j in item:
            uf.Unite(i,j)

    res = 0
    for i in range(1, N+1):
        res = max(res, uf.Count(i))
        

    print(res)

        


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 98372
import math

def getDistance(n, x, y, p):
  temp = 0.0
  for i in xrange(n):
    temp += math.fabs(x[i] - y[i]) ** p
    # print "temp = " + str(temp)
  temp2 = 1.0 / p
  # print temp2
  return math.pow(temp, temp2)


n = int(raw_input())
x = map(float, raw_input().split(" "))
y = map(float, raw_input().split(" "))

for i in xrange(1, 4):
  print "{0:.6f}".format(getDistance(n, x, y, i))

max = 0.0
for i in xrange(n):
  d = math.fabs(x[i] - y[i])
  if d > max:
    max = d

print "{0:.6f}".format(max)

Measured memory_bytes: 6704
#include <iostream>
#include <algorithm>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int a,ans=0;
 	cin >> a;
 	int x[a];
 	for (int i = 0; i < a; i++) {
 		cin >> x[i];
 	}
 	sort(x,x+a);
 	reverse(x, x + sizeof(x) / sizeof(x[0]));
 	for (int i = 0; i < a; i=i+2) {
 		ans=ans+x[i]-x[i+1];
 	}
 	if(a%2==0){
 		cout << ans << endl;
 	}else{
 		cout << ans+x[a] << endl;
 	}
 }

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

int ham ( string s1 , string s2 )
{
    int a = 0 ;
    int n = s1.size() ;

    for ( int i=0 ; i < n ; i++ )
        a += ( s1[i] != s2[i] ) ;

    return a ;
}

void solve ( int test_case )
{
    string s ; cin >> s ;
    int n = s.size() ;

    string temp = "" ;
    for ( int i=0 ; i < n ; i++ )
    {
        if ( i % 2 ) temp += '0' ;
        else temp += '1' ;
    }


    int d1 = ham ( s , temp ) ;

    temp = "" ;
    for ( int i=0 ; i < n ; i++ )
    {
        if ( i % 2 == 0 ) temp += '0' ;
        else temp += '1' ;
    }


    int d2 = ham ( s , temp ) ;

    cout << min ( d1 , d2 ) ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <algorithm>
#define ll long long

using namespace std;

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

    long n, k;
    cin >> n;
    cin >> k;

    vector<long> h(n, 0);
    vector<long> dp(n, LONG_MAX);
    dp[0] = 0;

    for (auto &item: h)
        cin >> item;

    for (long i = 1; i < n; i++) {
        for (int j = 1; j <= k && i - j >= 0; j++)
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }

    cout << dp[n - 1] << endl;
}


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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
using str = string;

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

long int M = 1e+9+7;
int inf = 1e+9;

int n,m;
void solve(){
    int ans=0;
    vi k(m),p(m);
    vvi s(m,vi());
    rep(i,m){
        cin >> k[i];
        rep(j,k[i]){
            s[i].resize(k[i]);
            cin >> s[i][j];
        }
    }
    rep(i,m){
        cin >> p[i];
    }
    //cout << endl;
    rep(i, 1 << n){
        /*
        rep(j,n){
            cout << ((i>>j) & 1) << " ";
        }
        cout << endl;
        */
        bool flag=true;
        rep(j , m){
            int cnt=0;
            rep(a, k[j]){
                if((i >> s[j][a]-1) & 1) cnt++;
            }
            //cout << cnt << endl;
            if(cnt%2 != p[j]){
                flag=false;
                break;
            }
        }
        //cout << flag << endl << endl;
        if(flag){
            ans++;
        }
    }
    //cout << endl;
    cout << ans << endl;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    while(cin >> n >> m){
        //int ans = 0;
        solve();
        //cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3532
n = int(input())
s = list(input())
r = [i for i, x in enumerate(s) if x == "R"]
g = [i for i, x in enumerate(s) if x == "G"]
b = [i for i, x in enumerate(s) if x == "B"]
ans = len(r) * len(g) * len(b)

for i in r:
    for j in g:
        i_ = min(i, j)
        j_ = max(i, j)
        div = (j_ - i_)
        k_1 = i_ - div
        k_2 = div // 2 + i_
        k_3 = div + j_
        if k_1 >= 0 and s[k_1] == "B":
            ans -= 1
        if div % 2 == 0 and s[k_2] == "B":
            ans -= 1
        if k_3 < n and s[k_3] == "B":
            ans -= 1
print(ans)

Measured memory_bytes: 9300
#include <iostream>
#include <string>

using namespace std;

int main(){
    string S,copy ;
    int N , Q;
    int i = 0;
    cin >> N >> Q >> S ;
    int place[Q][2];
    while(i < Q){
        cin >> place[i][0] >> place[i][1] ;
        i++;
    } 

    copy = S;
    int count[N];
    count[0] = 0;

    if(copy[0] == 'A'){
        if (copy[1] == 'C') {
            copy[0] = 'a';
            count[0] = 1;
        }
    }


    for(i = 1; i < N ; i++){
        count[i] = count[i-1];
        if(copy[i] == 'A'){
            if (copy[i+1] == 'C') {
                copy[i] = 'a';
                count[i] = count[i-1] + 1;
            }
        }
    }

    // cout << copy << "\n" ;
    // i = 0;
    // while(i < N){
    // cout << count[i] << " ";
    // i++;
    // } 
    // cout << "\n";

    i = 0;
    while(i < Q){
        if (place[i][0] == 1 ) {
            cout << count[ place [i][1] - 2 ];
        }else{
            cout << count[ place[i][1] - 2 ] - count[ place[i][0] - 2 ] ;
        }
        cout << "\n";
        i++;
    }
    return 0;
}

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



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

Measured memory_bytes: 3636
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ');
            var data = Console.ReadLine().Split(' ');
            var sum = 0;
            foreach (string str in data)
            {
                sum += int.Parse(str);
            }
            sum = int.Parse(nm[0]) - sum;
            if (sum >= 0) {
                Console.WriteLine(sum);
            }
            else
            {
                Console.WriteLine("-1");
            }
        }
    }
}


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


template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for(T x:v)
    {
        os << x << " ";
    }
    os << endl;
    return os; 
}

auto solve(ll P, ll Q, ll R)
{
    return min({P+Q,Q+R,P+R});
}


int main()
{
    ll P;
    cin >> P;
    ll Q;
    cin >> Q;
    ll R;
    cin >> R;
    cout << solve(P, Q, R) << endl;
    return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "3 8", "3 30", "4 50", "5 60" ].parse.expand.solve == 90 );
	assert( [ "5 5", "1 1000000000", "1 1000000000", "1 1000000000", "1 1000000000", "1 1000000000" ].parse.expand.solve == 5000000000 );
	assert( [ "6 15", "6 5", "5 6", "6 4", "6 6", "3 5", "7 2" ].parse.expand.solve == 17 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nw = input.front.split.to!( long[] );
	auto wvs = new long[][]( nw[ 0 ], 2 );
	foreach( ref wv; wvs )
	{
		input.popFront;
		wv = input.front.split.to!( long[] );
	}
	return tuple( nw[ 1 ], wvs );
}

auto solve( long t, long[][] wvs )
{
	auto dp = new long[][]( wvs.length + 1, t + 1 );
	
	for( auto i = 1L; i < dp.length; i++ )
	{
		auto w = wvs[ i - 1 ][ 0 ];
		auto v = wvs[ i - 1 ][ 1 ];
		
		for( auto g = 1L; g < dp[ i ].length; g++ )
		{
			if( 0 <= g - w )
			{
				dp[ i ][ g ] = max(					// 価値の総和が大きくなるほうを選ぶ
					dp[ i - 1 ][ g ],				// 品物を入れない場合
					dp[ i - 1 ][ g - w ] + v		// 品物を入れる場合
				);
			}
			else
			{
				dp[ i ][ g ] = dp[ i - 1 ][ g ];
			}
		}
	}
	
	return dp[ $ - 1 ][ $ - 1 ];
}


Measured memory_bytes: 81020
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

#define REP(i,f,n) for(int i=(f); i < (n); ++i)
#define PER(i,f,n) for(int i=(n-1); i >= f; --i)

constexpr int evx[4] = { 1, 0, -1, 0 };
constexpr int evy[4] = { 0, 1, 0, -1 };

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

signed main()
{
    ios::sync_with_stdio(false);
        int k, t;
        vector<int> a;
        cin >> k >> t;
        for(int i = 0; i < t; i++)
        {
                int tmp;
                cin >> tmp;
                a.push_back(tmp);
        }

        int su = k / 2;
        int m = *max_element(a.begin(), a.end()) ;

        cout << (m > su ?  m-(k-m + 1) : 0) << '\n';
}



Measured memory_bytes: 256
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product

def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
a=list(map(int,input().split()))
# amari=[a[i]%k for i in range(n)]
rui=ruiseki(a)
# print(a)
# print(amari)
# print(rui)
dic=defaultdict(int)
ans=0
for i in range(n+1):
    if i>=k:
        dic[(rui[i-k]-(i-k))%k]-=1
    ans+=dic[(rui[i]-i)%k]
    dic[(rui[i]-i)%k]+=1
    # print(dic)
print(ans)

Measured memory_bytes: 111192
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
	string s;cin>>s;
	stack<int> stk;
	int ans=0;
	for(auto c:s){
	    if(c=='S'){
	        stk.push(1);
	    }else{
	        if(stk.empty()){
	            ans++;
	        }else stk.pop();
	    }
	}
	cout<<ans+stk.size()<<endl;
	return 0;
}


Measured memory_bytes: 900
import math
def main():

    N, D = map(int, input().split())
    ans = 0
    for _ in range(N):
        x, y = map(int, input().split())
        d2 = x*x + y*y
        if d2 <= D * D:
            ans += 1
    return ans

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


Measured memory_bytes: 69948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    vector<ll> t(n), a(n);
    rep(i,n) cin >> t[i];
    rep(i,n) cin >> a[i];

    vector<ll> minh(n), maxh(n);
    minh[0] = t[0], maxh[0] = t[0];
    minh[n-1] = a[n-1], maxh[n-1] = a[n-1];
    ll ht = t[0];
    for(int i = 1; i < n-1; i++){
        if (chmax(ht, t[i])){
            minh[i] = ht;
            maxh[i] = ht;
        }else{
            minh[i] = 1;
            maxh[i] = ht;
        }
    }

    ll ha = a[n-1];
    bool ok = ha >= ht;
    for(int j = n-2; j >= 0; j--){
        if (!ok){
            if (chmax(ha, a[j])){
                if (maxh[j] < ha){
                    cout << 0 << endl;
                    return 0;
                }else if (maxh[j] == ha){
                    ok = true;
                }
                minh[j] = ha;
            }
            maxh[j] = ha;
        }else{
            if (chmax(ha, a[j])){
                cout << 0 << endl;
                return 0;
            }
        }
    }

    if (ha != ht){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    const int mod = 1e9+7;
    rep(i, n){
        ans *= (maxh[i]-minh[i]+1);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6408