akhauriyash/Code-Regression huggingface dataset:
import math
import bisect
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []
    time = 0
    
    while True:
        prime = min(A)
        
        if prime > math.sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P
n = int(input())
P = eratosthenes(100100)
insert_index = bisect.bisect_left(P,n)
print(P[insert_index])

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

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

	for(int i = a; i <= b; i++) {
		if(i % k == 0) {
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
    return 0;
}

Measured memory_bytes: 3620
def main():

    while True:
        m, f, r = tuple(map(int, input().split()))
        if m == f == r == -1:
            break
        elif m == -1 or f == -1:
            print('F')
        elif m + f >= 80:
            print('A')
        elif m + f >= 65:
            print('B')
        elif m + f >= 50:
            print('C')
        elif m + f >= 30:
            if r >= 50:
                print('C')
            else:
                print('D')
        else:
            print('F')

if __name__ == '__main__':
    main()
    


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    vector<int> arr(n);
    for (auto &v : arr)
        cin >> v;
    sort(arr.begin(), arr.end());
    reverse(arr.begin(), arr.end());
    LL ans = arr[0];
    for (int i = 2 ; i < n ; i++) {
        ans += arr[i / 2];
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3992
N, M = map(int, input().split())

all_results = []

for i in range(N):
    survey = list(map(int, input().split()))
    all_results.append(survey)

counters = {}
for i in range(M):
    counters[i+1] = 0


for i in range(N):
    for j in range(1, len(all_results[i])):
        counters[all_results[i][j]] += 1

counters_list = list(counters.values())
ans = 0
for i in range(len(counters)):
    if counters_list[i] == N:
        ans += 1


print(ans)


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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define ll long long
#define in freopen(".in", "r", stdin)
#define out freopen(".out", "r", stdout)

using namespace std;

const long long INF = (int)1e17 + 7;

int a[100009], ar[100009];
int ans;

int main()
{
    int n;

    cin >> n;

    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        if (a[i] == i)
        {
            ar[i]++;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        if (ar[i] > 0 && ar[i + 1] > 0)
        {
            ans++;
            i ++;
        }
        else if (ar[i] > 0)
        {
            ans++;
        }
    }

    cout << ans;

}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,c=0;
   cin>>n;
   long long int a[n];
   for(i=0;i<n;i++)
    cin>>a[i];
   sort(a,a+n);
   for(i=1;i<n;i++)
   {
       if(a[i]==a[i-1])
       {
            c=1;break;
      }

   }
   if(c==0)
    cout<<"YES"<<endl;
   else
    cout<<"NO"<<endl;



    return 0;
}


Measured memory_bytes: 1792
#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> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
int n = 42;
vector<int> a(n),b(n);
vector<vector<int>> tree(n,vector<int>());
vector<int> ans;

void maketree(int top,int L,int R,int par=-1){
    if(L==R) return;

    if(par!=-1) tree[par].push_back(a[top]);

    if(L+1==R){
        return;
    }

    int idx = 0;
    for(int i=L;i<R;i++){
        if(b[i]==a[top]){
            idx = i;
            break;
        }
    }


    int top1 = top+1;
    int top2 = top+idx-L+1;
    maketree(top1,L,idx,a[top]);
    maketree(top2,idx+1,R,a[top]);

    return;
}

void dfs(int i){

    for(int c:tree[i]){
        dfs(c);
    }

    ans.push_back(i);
    return;
}

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

    maketree(0,0,n);
    /*
    rep(i,n){
        rep(j,tree[i].size()) cout << tree[i][j] <<"  ";
        cout <<endl;
    }
    */

    dfs(a[0]);

    rep(i,n){
        cout << ans[i] << (i==n-1?'\n':' ');
    }

    return 0;
}


Measured memory_bytes: 3164
#include <stdio.h>
#include <string.h>

int map[14][14];

void put(int x,int y,int size){
	int i,j;
	switch(size){
		case 1:
			map[y][x-1]++;
			map[y][x+1]++;
			map[y-1][x]++;
			map[y+1][x]++;
			map[y][x]++;
			break;
		case 2:
			for(i = -1;i < 2;i++){
				for(j = -1;j < 2;j++){
					map[y+i][x+j]++;
				}
			}
			break;
		case 3:
			for(i = -1;i < 2;i++){
				for(j = -1;j < 2;j++){
					map[y+i][x+j]++;
				}
			}
			map[y][x-2]++;
			map[y][x+2]++;
			map[y-2][x]++;
			map[y+2][x]++;
			break;
		default:
			break;
	}
}

int main(){
	int x,y,size,i,j,cnt,max;

	memset(map,0,sizeof(map));

	while(scanf("%d,%d,%d",&x,&y,&size) != EOF){
		put(x+2,y+2,size);

		cnt = 0;
		max = 0;
		for(i = 2;i < 12;i++){
			for(j = 2;j < 12;j++){
				if(map[i][j] == 0){
					cnt++;
				}else if(max < map[i][j]){
					max = map[i][j];
				}
			}
		}
	}

	printf("%d\n%d\n",cnt,max);

	return 0;
}

Measured memory_bytes: 600
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define IN4(P1,P2,P3,P4) cin>>(P1)>>(P2)>>(P3)>>(P4)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int A,B,C,D,lower,upper;
inline void solve(){
  IN4(A,B,C,D);
  lower=max(A,C);
  upper=min(B,D);
  OUT(max(0,upper-lower));
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#pragma GCC optimize("trapv")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
const int maxn = 1<<17;
ll n, m, k;
vector<ll> a, d, p;
void apply(vector<ll> a, vector<ll> &b) {
	vector<ll> res(a.size());
	for(int i = 0; i < a.size(); i++) res[i] = b[a[i]];
	b = res;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	a.resize(n);
	for(auto &i : a) cin >> i;
	for(int i = 1; i < n; i++) d.push_back(a[i]-a[i-1]);
	cin >> m >> k;
	p.resize(n-1);
	iota(all(p), 0);
	auto r = p;
	for(int t, i = 0; i < m; i++) {
		cin >> t;
		swap(p[t-1], p[t-2]);
	}
	while(k) {
		if(k&1) apply(p, r);
		apply(p, p), k>>=1;
	}
	apply(r, d);
	cout << a[0] << '\n';
	for(auto i : d) cout << (a[0] += i) << "\n";
}


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

/*int shorter(int N, int M, int p, int d[]){
 int money=0;
 for(int i=0; i<M+1; i++){
  if((d[i]-p) < (N-d[i]+p)){
   money = money + d[i] - p;
  }else{
   money = money + N - d[i]+p;
  }
  p = d[i];
 }
 return money*100; 
} */

int main(){
 int N,M,p = 0;
 cin >> N >> M >> p;

 int d[M+1];
 d[0] = p;

 for(int i=1; i<=M; i++){
  cin >> d[i];
 }

 sort(d, d+M+1);

// cout << shorter(N, M, p, d) << endl;

 int money = N-1;
 for(int i=0; i<M+1; i++){
  int q = d[i];
  int r1 = d[(i-1+M+1)%(M+1)];
  int r2 = d[(i+1)%(M+1)];
  int c1 = ((p-q+N)%N)*2+(r1-p+N)%N;
  int c2 = ((q-p+N)%N)*2+(p-r2+N)%N;
  money = min(money, min(c1,c2));
 }
 cout << money*100 << endl;
 return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ull;
ull gcd(ull a, ull b)
{
    if (b==0)
        return a;
    return gcd(b, a%b);
}
ull findlcm(ull arr[], ull n)
{
    ull ans = arr[0];
    for (ull i=1; i<n; i++)
        ans = ( ((arr[i] /
                (gcd(arr[i], ans)) )*ans));
    return ans;
}
int main()
{
   ull n;
   cin>>n;
   ull i,a[n];
   for(i=0;i<n;i++)
    cin>>a[i];
   cout<<findlcm(a,n)<<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

long long dp[51][51][2501] = {0};

int main(){
  long long n,a;
  cin >> n >> a;
  int x[n+1];
  for(int i = 1;i <= n;i++)
    cin >> x[i];
  dp[0][0][0] = 1;
  for(int i = 1; i < n+1;i++){
    for(int j = 0;j < n+1;j++){
      for(int k = 0; k < 2501;k++){
	dp[i][j][k] = dp[i-1][j][k];
	if(j > 0 && k >= x[i])
	  dp[i][j][k] += dp[i-1][j-1][k-x[i]];
      }
    }

  }

  long long res = 0;
  for(int i = 1;i<n+1;i++){
    res += dp[n][i][i*a];
  }

  cout << res << endl;

}


Measured memory_bytes: 50048
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
using namespace std;
typedef long long LL;

int read()
{
    int x=0,flag=1;
    char c=getchar ();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

int main()
{
    //freopen("input.txt","r",stdin);
    int a=read(),b=read();
    int now=1,t=0;
    while(now<b)
    {
        now--;
        now+=a;
        t++;
    }
    cout<<t;

	return 0;
}


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

int n;

int main()
{
    cin >> n;
    vector<float> v(n);
    for (int i = 0; i < n; ++i)
        cin >> v[i];
    sort(v.begin(), v.end());

    float ans = 0;
    for (int i = 0; i < n; ++i)
    {
        if (ans == 0)
            ans += v[i];
        else
            ans = (ans + v[i]) / 2.0;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int cnt[40];
char s[100];
int main() {
  scanf("%s", s);
  for (int i = 0; s[i]; ++i) {
    cnt[s[i] - 'a']++;
  }
  bool found = false;
  for (int k = 0; k < 26; ++k) {
    if (cnt[k] > 1) found = true;
  }
  puts(found ? "no" : "yes");
  return 0;
}


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

int main() {
	int a,b;
	cin>>a>>b ;
	if(a==b)
    {
        cout<< a ;
    }
    else if(a>b)
    {
        cout << a-1 ;
    }
    else if(a<b)
    {
        cout<< a ;
    }
	return 0;
}


Measured memory_bytes: 256
def nasu(x):
  L = []
  cnt = 0
  while x:
    if x & 1:
      L.append(cnt)
    x >>= 1
    cnt += 1
  ans = 0
  for i in range(len(L) - 1):
    for j in range(i + 1, len(L)):
      ans += a[L[i]][L[j]]
  return ans

N = int(input())
a = [list(map(int, input().split())) for _ in range(N)]
DP = [0] * (1 << N)
for m in range(1, N + 1):
  x = (1 << m) - 1
  while x < (1 << N):
    DP[x] = nasu(x)
    b = x
    while b:
      d = x ^ b
      DP[x] = max(DP[x], DP[d] + DP[b])
      b = (b - 1) & x

    y = x & -x;
    z = x + y
    x = (((x & ~ z) // y) >> 1) | z

print(DP[-1])

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

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

    map<int, int64_t> a;
    int64_t sum_a = 0;
    for (auto i = 0; i < n; i++) {
        int tmp; cin >> tmp;
        a[tmp]++;
        sum_a += tmp;
    }

    cin >> q;
    for (auto i = 0; i < q; i++) {
        int64_t b, c; cin >> b >> c;
        sum_a = sum_a - a[b] * b + a[b] * c;
        a[c] += a[b]; a[b] = 0;
        cout << sum_a << endl;
    }

    return 0;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { 1,  0, -1,  0,  1, -1,  1, -1};
static const int dy[8] = { 0,  1,  0, -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;
const int mod = 1e9+7;

string s;

int main()
{
    cin >> s;
    int sz = s.size();
    int ok = 1;
    _for(i,1,sz){
        if(s[i-1] == s[i]) ok = 0;
    }
    if(ok) cout << "Good"<<endl;
    else cout << "Bad" << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"math/rand"
	"time"
	"os"
	"bufio"
	"fmt"
	"strconv"
)

var(
	inf = 10000000071000000
	stdin = bufio.NewReader(os.Stdin)
	mod = 1000000007
	mod9 = 1000000009
	//////////////////////////////////
	stack []byte
)

func init()  {
	rand.Seed(time.Now().UnixNano())
}


func main() {
	n,k,l := goint(),goint(),goint()
	road := &UnionFind{}
	rail := &UnionFind{}
	road.uniInit(n)
	rail.uniInit(n)
	for i:=0;i<k;i++{
		s,t := goint()-1,goint()-1
		road.connect(s,t)
	}
	for i:=0;i<l;i++{
		s,t := goint()-1,goint()-1
		rail.connect(s,t)
	}
	ls := make([]int,n)
	for i:=0;i<n;i++{
		ls[i] = road.root(i) + rail.root(i) * 1000000
	}
	c := countInt(ls)
	for _,v:= range ls{
		fmt.Print(c[v]," ")
	}
	fmt.Println("")
}

//要素の個数を数える
func countInt(ls []int) map[int]int {
	counter := make(map[int]int)
	for _,v := range ls{
		if _, ok := counter[v]; ok {
			counter[v] ++
		} else {
			counter[v] = 1
		}
	}
	return counter
}

//Union-Find
type UnionFind struct {
	par []int
}

func (u *UnionFind) uniInit(n int)  {
	u.par = make([]int,n)
	for i:=0;i<n;i++{
		u.par[i] = -1
	}
}

//aがどのグループに属しているか
func (u *UnionFind) root (a int) int {
	if u.par[a] < 0{
		return a
	}
	u.par[a] = u.root(u.par[a])
	return u.par[a]
}

//自分のグループの頂点数
func (u *UnionFind) size (a int) int {
	return -u.par[u.root(a)]
}

//つなげる
func (u *UnionFind) connect(a,b int) bool {
	a = u.root(a)
	b = u.root(b)
	if a == b {
		return false
	}
	if u.size(a) < u.size(b) {a,b = b,a}
	u.par[a] += u.par[b]
	u.par[b] = a
	return true
}

func solv(s []byte) {

}

//||||||||||||||||||||||||||入力|||||||||||||||||||||||||||||||||||||||

//次のスペースか改行まで読み込む
func gostring() string {
	byte_ls := make([]byte,0)
	for  {
		b, _ := stdin.ReadByte()
		if b == 32 || b == 10 || b == 0{
			return string(byte_ls)
		} else if b == 13 {
			continue
		} else {
			byte_ls = append(byte_ls,b)
		}
	}
}

//上の関数のintバージョン
func goint() int {
	n,_ := strconv.Atoi(gostring())
	return n
}

//数字一行
func intLine(n ,a int) []int {
	ls := make([]int,n)
	for i,_ := range ls{
		ls[i] = goint() + a
	}
	return ls
}

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

func sum(a ...int) int {
	ans := 0
	for i:=0;i<len(a);i++{
		ans += a[i]
	}
	return ans
}

func min(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans > a[i]{
			ans = a[i]
		}
	}
	return ans
}

func abs(n int) int {
	if n >= 0{
		return n
	} else {
		return -n
	}
}

func max(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans < a[i]{
			ans = a[i]
		}
	}
	return ans
}

func intList(n,k int) []int {
	ls := make([]int,n)
	for i:=0;i<n;i++{
		ls[i] = k
	}
	return ls
}

Measured memory_bytes: 18944
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
const int w=5e5+5;
const ll mod=998244353;
int n,m;
int main()
{
    int i,j;
    ll x,y,z;
    cin>>x>>y>>z;
    if(x>=z)
    {
        x-=z,z=0;
        cout<<x<<" "<<y<<endl;
    }
    else
    {
        z-=x;
        x=0;
        y-=z;
        if(y<0)
            y=0;
        cout<<x<<" "<<y<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap as M
import Data.List
import Data.Char

main :: IO ()
main = do
    [_, m] <- readInts
    as <- readInts
    print $ solve m as

readInts :: IO [Int]
readInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine

solve :: Int -> [Int] -> Int
solve m =  M.foldl' (+) 0
     . fmap (\x -> x * (x - 1) `div` 2)
     . foldr (\k mp -> M.insertWith (+) k 1 mp)  M.empty
     . map (`mod` m)
     . scanl' (+) 0


Measured memory_bytes: 17788
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;

immutable MAX = 1300000;
bool p[MAX];
int res[MAX];

void main()
{
	
	p[] = 1;
	p[0..2] = 0;
	foreach (i; 2..sqrt(MAX*1.0).ceil.to!int) {
		if (p[i]) {
			foreach (j; iota(i*2, MAX, i))
				p[j] = 0;
		}
	}

	int pre = 3, cnt;
	foreach (i; 4..MAX) {
		if (p[i]) {
			res[pre+1..i] = cnt + 1;
			cnt = 0;
			pre = i;
		} else {
			cnt++;
		}
	}

	while (1) {
		auto x = readln.chomp.to!int;
		if (!x) break;
		res[x].writeln;
	}
}

Measured memory_bytes: 7400
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())

TTL = (1+N)*N//2

fb = N//15
f = N//3
b = N//5
FB_t = (fb*15+15)*fb//2
F_t = (f*3+3)*f//2
B_t = (b*5+5)*b//2

print(TTL-F_t-B_t+FB_t)

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

long long abs(long long n){
  return (n > 0) ? n : -n;
}

int main(){
  int n;
  long long a;
  long long snuke[200000], arai[200000];
  long long sum = 0, mindiff, temp;

  std::cin >> n;
  for(int i = 0; i < n; i++){
    std::cin >> a;
    sum += a;
    snuke[i] = sum;
  }

  for(int i = 0; i < n; i++) arai[i] = sum - snuke[i];

  mindiff = LLONG_MAX;
  for(int i = 0; i < n-1; i++)
    if(mindiff > (temp = abs(snuke[i]-arai[i])))
      mindiff = temp;

  std::cout << mindiff;

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>

using namespace std;

int main() {
    string s;
    cin >> s;
    for (size_t i = 0; i < s.length(); i++)
    {
        if (s[i] != ',')
        {
            cout << s[i];
        }
        else
        {
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n; cin >> n;
    vii abc(n, vi(3));
    rep(i,n) cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
    vii dp(n+1, vi(3, 0));
    for(int i = 1; i <= n; i++){
        rep(j,3){
            rep(k,3){
                if(j == k) continue;
                else{
                    dp[i][j] = max(dp[i][j], dp[i-1][k]+ abc[i-1][k]);
                }
            }
        }
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << '\n';
}

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

int a[100005];
int cnt[100005];

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (!a[i]) {
            cnt[0]++; cnt[1]++;
        } else {
            cnt[a[i] - 1]++;
            cnt[a[i]]++;
            cnt[a[i] + 1]++;
        }
    }

    int ans = 0;
    for (int i = 0; i <= 100001; i++) {
        ans = max(ans, cnt[i]);
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
bool use[10000];
int main()
{
  int s;
  cin >> s;
  for (int i = 0; i < 10000; i++) use[i] = false;
  
  int ans = 1;
  use[s] = true;
  for (;;) {
    int next = s%2==0?s/2:3*s+1;
    ans++;
    if (use[next]) {
      cout << ans << endl;
      return 0;
    }
    use[next] = true;
    s = next;
  }
}

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

int tw[201], md = 998244353;

struct V{
	int x, y;
	V(){}
	V(int a, int b):x(a), y(b) {}
	int operator |(V const o)const { return x * o.y - o.x * y; }
	bool operator <(V const o)const { return (*this | o) < 0; }
	void N() { if (x < 0 || x == 0 && y < 0)x = -x, y = -y; }
	V operator -(V o) { return V(x - o.x, y - o.y); }
}p[200];

int main(){
	tw[0] = 1;
	f(i, 1, 201)if ((tw[i] = tw[i - 1] << 1) >= md)tw[i] -= md;
	int n;
	scanf("%d", &n);
	f(i, 0, n)scanf("%d%d", &p[i].x, &p[i].y);
	int an = tw[n] - 1 - n;
	if (an < 0)an += md;
	f(i, 0, n){
		map<V, int> mp;
		f(j, i + 1, n){
			V v = p[j] - p[i];
			v.N();
			++mp[v];
		}
		for (map<V, int>::iterator it = mp.begin(); it != mp.end(); ++it)if ((an -= tw[it->second] - 1) < 0)an += md;
	}
	printf("%d\n", an);
}

Measured memory_bytes: 256
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <iostream> 
#include <iomanip>  
#include <string>
#include <sstream>  
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <cstring>
#include <cmath>
#include <cassert>


#define INF              (int)1000000007
#define EPS              1e-9
#define pb               push_back
#define mp               make_pair
#define all(c)           c.begin(), c.end()
#define forall(i,a,b)    for(int i=a;i<(b);++i)
#define trav(a,x)        for(auto & a: x)
#define in(a,b)          ((b).find(a) != (b).end())
#define sz(c)            (int)(c).size()
#define input(a)         for(auto & x : a) cin >> x;

using namespace std;

typedef vector<int>      vi;
typedef pair<int,int>    ii;
typedef vector<vi>       vvi;
typedef vector<ii>       vii;
typedef long long        ll;

#ifdef DEBUG
#define trace(...)       __f(#__VA_ARGS__, __VA_ARGS__)
#define debug(args...)   {dbg,args; clog<<endl;}
#define print_( a )      for( auto & x : a ) clog << x << ' '; clog << '\n';
#define printPair_( a )  for( auto & x : a ) clog << '(' << x.first << ',' << x.second << ')' << ' '; clog << '\n';
#else
#define trace(...)       
#define debug(args...)            
#define print_( a )               
#define printPair_( a )           
#endif

struct debugger {
  template<typename T> debugger& operator , (const T& x) {    
    clog << x << " ";    return *this;    
  }
}dbg;

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " | ";
    __f(comma + 1, args...);
}

auto ____ =[]() { std::ios::sync_with_stdio(0); cin.tie(0); return nullptr; }();

int main( int argc, char * argv[] ){
  int n; cin >> n; 
  vvi v(n, vi(3));
  forall(i,0,n) cin >> v[i][0] >> v[i][1] >> v[i][2];

  vvi dp(n, vi(3, 0));
  dp[0] = v[0];
  forall(i,1,n){
    forall(j,0,3){
      forall(k,0,3){
        if( j == k ) continue;
        dp[i][j] = max(dp[i][j], dp[i-1][k] + v[i][j]);
      }
    }
  }
  cout << *max_element(all(dp.back())) << endl;

  return 0;
}


Measured memory_bytes: 11264
// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define rep(i, x, n) for(ll i = x; i < n; i++)
#define rrep(i, x, n) for(ll i = x; i >= n; i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define e emplace
#define mp make_pair
#define debug(this) cout<<"> "<<#this<<" : "<<this<<"\n"
typedef long long int ll;
typedef long double ld;
typedef pair< ll, ll > pii;
typedef vector< ll > vi;
typedef vector< vi > vvi;
const ll MOD = 1e9+7;
ld PI=3.1415926535897932384626;
ld EPS = 1e-9;
#define endl '\n'

bool square(ll n) {
	return ((ll)sqrt(n) * (ll)sqrt(n)) == n;
}

ll dist(vi &a, vi &b) {
	ll ans = 0;
	rep(i, 0, (ll)a.size()) ans += (a[i] - b[i]) * (a[i] - b[i]);
	return ans;
}

int main() {
	boost
	ll n, d;
	cin >> n >> d;
	vvi pts(n, vi(d));
	for(vi &pt : pts) for(ll &cord : pt) cin >> cord;
	ll ans = 0;
	rep(i, 0, (n-1)) rep(j, (i+1), n) if(square(dist(pts[i], pts[j]))) ans++;
	cout << ans << endl;
}




























Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int N = in.i();
        int K = in.i();
        int M = 1_000_000_007;
        long max = 0;
        long min = 0;
        for (int i = 0; i < K; i++) {
            max = (max + N - i) % M;
            min = (min + i) % M;
        }
        long ans = 0;
        for (int i = K; i <= N + 1; i++) {
            ans = (M + ans + max - min + 1) % M;
            max = (max + N - i) % M;
            min = (min + i) % M;
        }
        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = read(cbuf, 0, cbuf.length);
            } catch (IOException e) {}
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (c != ' ' && c != '\n' && c != '\r') {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (true) {
            char c = next();
            if (c != ' ' && c != '\n' && c != '\r') {
                back();
                break;
            }
        }
    }

    char[] s(final int N) {
        skip();
        char[] s = new char[N];
        for (int i = 0; i < s.length; i++) {
            s[i] = next();
        }
        return s;
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int n;
  cin >> n;
  vector<int> sum(n);
  REP(i,n-1){
    int x;cin >> x;
    x--;
    sum[x]++;
  }
  REP(i,n){
    cout << sum[i] << endl;
  }

  


  

  return 0;
}


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

int main(){
    char c;
    cin >> c;
    vector<char> alph = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    for(int i=0;i<26;i++){
        if(c == alph[i]){
            cout << alph[i+1] << endl;
            return 0;
        }
    }
}


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

int main() {
  long long N;
  cin >> N;
  long long NN = N;
  map<long long, int> m;
  for (long long i = 2; i * i <= N; ++i) {
    while (NN % i == 0) {
      NN /= i;
      ++m[i];
    }
  }

  if (NN != 1) {
    ++m[NN];
  }

  int ans = 0;
  for (auto i : m) {
    int e = 1;
    while (i.second - e >= 0) {
      ++ans, i.second -= e, ++e;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

using dat = pair<int, int>;
int main() {
    init();

    int k; cin >> k;

    VI dis(k, INF); dis[1] = 1;
    PQ<dat> dik; dik.emplace(1, 1);

    while (!dik.empty()) {
        int d, now;
        tie(d, now) = dik.top();
        dik.pop();
        if (dis[now] < d)continue;

        if (chmin(dis[(now + 1) % k], d + 1)) {
            dik.emplace(d + 1, (now + 1) % k);
        }
        if (chmin(dis[now * 10 % k], d)) {
            dik.emplace(d, now * 10 % k);
        }
    }

    cout << dis[0] << "\n";
}


Measured memory_bytes: 1276
#include<stdio.h>

int main(){
  int H,W,y,x;

  while(1){
    scanf("%d %d",&H,&W);
    
    if(H+W == 0) break;
    
    for(y=0;y<H;++y){
      for(x=0;x<W;++x){
	if(y % 2 == 0 && x % 2 == 0){
	  printf("#");
	}else if(y % 2 == 0 && x % 2 == 1){
	  printf(".");
	}else if(y % 2 == 1 && x % 2 == 0){
	  printf(".");
	}else{
	  printf("#");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2108
n,m = map(int,input().split())
a = list(map(int,input().split()))
bc =  [list(map(int,input().split())) for _ in range(m)]
bc.sort(key=lambda x:x[1],reverse = True)
cnt = 0
j = 0
while cnt < n and j < m:
  a += [bc[j][1]]*(min(n-cnt,bc[j][0]))
  cnt += min(n-cnt,bc[j][0])
  j += 1
a.sort(reverse=True)
print(sum(a[:n]))

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

int main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
  	cout << "vowel" << endl;
  }
  else{
  	cout << "consonant" << endl;
  }
  
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#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 debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  VI p(m), y(m);
  vector<vector<P>> c(n);
  rep(i, m) {
    cin >> p[i] >> y[i];
    c[p[i]-1].emplace_back(y[i], i);
  }
  VI ans(m, 0);
  rep(i, n) {
    sort(all(c[i]));
    rep(j, c[i].size()) {
      ans[c[i][j].second] = j + 1;
    }
  }
  rep(i, m) {
    printf("%06d%06d\n", p[i], ans[i]);
  }

  return 0;
}


Measured memory_bytes: 8192
#include<iostream>
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<deque>

using namespace std;
typedef long long ll;

int main(void){
    int n, k;
    cin>>n>>k;
    vector<int> v(n+2);
    rep(i, n){
        cin>>v[i+1];
    }
    v[n+1]=0;
    int all=min(k, n);
    ll ans=0;
    rep(i, n+2){
        
    }
    for(int a=0;a<=all;a++){
        for(int b=0;b<=(all-a);b++){
        
        int sum=0;
        vector<int>minus(n);
        for(int i=0;i<=a;i++){
            sum+=v[i];
            
            if (v[i]<0){   
                minus.push_back(v[i]);
            }

        }
        for(int j=0;j<=b-1;j++){
            sum+=v[n+1-j-1];
            
            if (v[n+1-j-1]<0){                
                minus.push_back(v[n+1-j-1]);
            }
        }
        sort(minus.begin(), minus.end());
        
        rep(i, k-(a+b)){
            if (i>=minus.size()) break;
            sum-=minus[i];                   
        }
        if (sum>ans){
            ans=sum;
        }
        }
    }
    cout<<ans<<endl;



}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

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

inline bool inside(ll y, ll x, ll H, ll W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

char G[405][405];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll h,w; cin>>h>>w;
  rep(i,h) rep(j,w) cin>>G[i][j];
  map<char, int> ctoi;
  ctoi['.']=0, ctoi['#']=1;
  
  ll ans=0;
  
  
  vvi visited(h+1, vi(w+1));
  
  rep(i,h){
    rep(j,w){
      if(visited[i][j]) continue;
      visited[i][j]=1;
      
      char st=ctoi[G[i][j]];
      
      ll cnt0=0, cnt1=0;
      if(st) cnt1++;
      else cnt0++;
      
      queue<pair<pii,int>> q;
      q.emplace(pii(i,j), st);
      
      ll tmp=0;
      
      while(!q.empty()){
        auto p=q.front(); q.pop();
        int y=p.first.first, x=p.first.second, from=p.second;
        rep(ki,4){
          int ny=y+dy[ki], nx=x+dx[ki];
          if(inside(ny,nx,h,w)){
            if(visited[ny][nx]) continue;
            ll now=ctoi[G[ny][nx]];
            if(from==now) continue;
            visited[ny][nx]=1;
            q.emplace(pii(ny,nx), now);
            if(now) cnt1++;
            else cnt0++;
          }
        }
      }
      
      ans+=cnt1*cnt0;
    }
  }
  
  cout<<ans<<endl;
  
}

Measured memory_bytes: 4368
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main(){
	fast;
	ll a,b,c;
	cin>>a>>b>>c;
	if(a==b)
		cout<<c;
	else if(b==c)
		cout<<a;
	else
		cout<<b;
	return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define ld long double
#define pb push_back
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000003
#define pll pair<ll, ll>
#define vl vector<ll>
#define vll vector< vector<ll> >

ll mulmod(ll, ll);
ll fastpower(ll, ll);
void getprime(vector<bool>&);
void getfact(vector<ll>&, vector<ll>&);
ll ncr(ll, ll, vector<ll>&, vector<ll>&);

ll calcAngle(ll h, ll m)  
{
    ll hour_angle = 0.5 * (h * 60 + m);  
    ll minute_angle = 6 * m;  

    ll angle = abs(hour_angle - minute_angle);  

    angle = min(360 - angle, angle);  
    return (angle);  
}
void solve()
{
    ll h, m, a, b;
    cin>>a>>b>>h>>m;
    
    //ll angle = calcAngle(h, m);
    ld rad = M_PI * 2 * (h/ 12.0 + (m/ 60.0) / 12.0 - m/ 60.0);
    ld res = sqrt(a*a + b*b - 2*a*b*cos(rad));
    cout<<setprecision(20)<<res;
}

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

ll mulmod(ll a, ll b)
{
    ll res = 0; 
    a = a % MOD;
    while(b > 0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
 
        a = (a * 2) % MOD; 
        b /= 2;
    } 
    return res % MOD; 
}

ll  fastpower(ll a, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n % 2 != 0)
        {
            res = (res * a) % MOD;
        }
        n /= 2;
        a = (a * a) % MOD;
    }
    return res;
}

void getprime(vector<bool>&prime)
{
    prime[0] = false;
    prime[1] = false;
    
    for(ll i = 2;i <= MAX; i++)
    {
        if(prime[i])
        {
            for(ll j = i*i; j <= MAX; j += i)
                prime[j] = false;
        }
    }
}

void getfact(vector<ll> &fact, vector<ll> &ifact)
{
    fact[0] = 1;
    ifact[0] = 1;
    
    for(ll i = 1; i <= MAX; i++)
    {
        fact[i] = (fact[i-1] * i)%MOD;
        ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
    }
}

ll ncr(ll n, ll r, vector<ll>&fact, vector<ll>&ifact)
{
    ll res;
    res = (((fact[n] * ifact[r]) % MOD) * ifact[n-r]) % MOD;
    return res;
}


Measured memory_bytes: 4104
import std.stdio, std.string, std.algorithm;
import std.conv, std.array;
import std.typecons;
import std.functional;

const int M = 1003;
alias Tuple!(int, int) pair;

int[M][M] F;
pair[M * M + 1] T;
int[4] dx = [1, 0, -1, 0];
int[4] dy = [0, -1, 0, 1];

bool[] prime;
void init_prime() {
    prime = new bool[M * M + 1];
    prime.fill(true);
    prime[0] = prime[1] = false;
    for (int i = 2; i <= M * M; i++) {
        if (prime[i]) {
            for (int j = i + i; j <= M * M; j += i) {
                prime[j] = false;
            }
        }
    }
}

void P() {
    foreach (xs; F) {
        foreach (x; xs) {
            writef("%3d ", x);
        }
        writeln;
    }
}

void init_F() {
    int y = M / 2, x = M / 2;
    int d = 0;
    int c = 1;
    int clim = 1;
    int used = 0;
    bool f = false;
    while (c <= M * M) {
        //stderr.writeln(y, " " , x);
        F[y][x] = c;
        T[c] = pair(y, x);
        c++;
        y += dy[d];
        x += dx[d];
        used++;
        if (used == clim) {
            d = (d + 1) % 4;
            if (f) {
                clim++;
                f = false;
            } else {
                f = true;
            }
            used = 0;
        }
    }
}

void main() {
    init_prime;
    init_F;
    int m, n;
    while (true) {
        readf("%d %d\n", &m, &n);
        if (m == 0 && n == 0) break;
        solve(m, n);
    }
}

void solve(int m, int n) {
    int y = T[n][0], x = T[n][1];
    pair ans = count(m, y, x);
    writef("%d %d\n", ans[0], ans[1]);
}

pair count(int m, int y, int x) {
    if (F[y][x] > m) return pair(0, 0);
    alias memoize!count mcount;
    pair ans =  max(mcount(m, y + 1, x - 1),
                    mcount(m, y + 1, x),
                    mcount(m, y + 1, x + 1));
    if (prime[F[y][x]]) {
        if (ans[0] == 0) {
            ans[1] = F[y][x];
        }
        ans[0]++;
    }
    return ans;
}

Measured memory_bytes: 68140
#include<iostream>
 
using namespace std;
 
int main()
{
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  
  if ((e-a)>k)
    cout << ":(" << endl;
  else
    cout << "Yay!" << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    string s;
    cin >> s;
    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 200002;
ll n;
string in;
vector<char> s;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>in;
	FOR(i,0,in.size()){
		if(in[i]=='B'){
			if(s.size()>0)s.pop_back();
		}else{
			s.pb(in[i]);
		}
	}
	FOR(i,0,s.size()){
		cout<<s[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256