akhauriyash/Code-Regression huggingface dataset:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
d = Counter(a)
cnt = 0
for v in d.values():
    if v % 2 == 0:
        cnt += 1

if cnt % 2 != 0:
    print(len(d)- 1)
else:
    print(len(d))

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a >= b + c) {
    cout << 0 << endl;
  } else {
    cout << c - (a - b) << endl;
  }
};


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>

using namespace std;
typedef long long ll;

ll ans, mx, mn = 1e8, flag, sum, cnt;

int main(){
	ll n,a;
	cin>>n>>a;
	cout<<(n*n)-a<<endl;
}


Measured memory_bytes: 256
H, W = gets.split.map(&:to_i)
T = []
P = (1 .. H).map do |y| 
  line = gets.split.map(&:to_i)
  (1 .. W).each_cons(2) do |x1,x2|
    if line[x1 - 1].odd?
      line[x1] += 1
      T << "#{y} #{x1} #{y} #{x2}"
    end
  end
  line.last
end
(1 .. H).each_cons(2) do |y1,y2|
  if P[y1 - 1].odd?
    P[y1] += 1
    T << "#{y1} #{W} #{y2} #{W}"
  end
end
puts T.size
puts T

Measured memory_bytes: 15356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))

struct MQ{//平方分割 0-index
	int n,rn,bn;
	vector<ll> a,b;
	MQ(int n_){
		n = n_; rn = sqrt(n); bn = ceil((double)n/rn);
		a.resize(n,INF);
		b.resize(bn,INF);
	}
	ll value(ll s){
		if(a[s]>b[s/rn])a[s] = b[s/rn];
		return a[s];
	}
	void updete(int s,int t,ll x){
		for(int i=s;i<=t;i++){
			if(i%rn==0 && (i+rn-1)<=t){
				if(x<b[i/rn])b[i/rn]=x;
				i += rn-1;
			}else{
				if(a[i]>x)a[i]=x;
			}
		}
	}
};



int main(){
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	ll N,M;
	cin >> N >> M;
	vector< tuple<int,int,ll> > LRC(M);
	FOR(i,0,M){
		int l,r; ll c;
		cin >> l >> r >> c;
		l--;r--;
		LRC[i] = tie(l,r,c);
	}
	SORT(LRC);
	MQ minq(N);
	minq.updete(0,0,0);
	FOR(i,0,M){
		ll l,r,c;
		tie(l,r,c) = LRC[i];
		ll v = minq.value(l);
		if(v>=INF)continue;
		minq.updete(l+1,r,c+v);
	}
	ll ans = minq.value(N-1);
	if(ans==INF)ans=-1;
	cout << ans << endl;
}


Measured memory_bytes: 2560
main(){
	char b[110],s[110]={0},*q,*p;
	while(scanf("%[^\n]%*c",b),*b-'.'){
		q=s+1;
		for(p=b;*p-'.';p++){
			if(*p=='('||*p=='[') *q++=*p;
			if(*p==')'||*p==']'){
				q--;
				if(!((*q=='('&&*p==')')||(*q=='['&&*p==']'))){
					puts("no");
					break;
				}
			}
		}
		if(*p=='.')puts(q-s-1?"no":"yes");
	}
return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline

def unite(node_a, node_b):
    root_a = node_a.root()
    root_b = node_b.root()
    if root_a == root_b:
        return False
    if root_b.depth > root_a.depth:
        root_a, root_b = root_b, root_a
    root_b.is_root = False
    root_b.parent = root_a
    root_a.depth = max(root_a.depth, root_b.depth+1)
    return True

class Node:
    def __init__(self, id):
        self.id = id
        self.is_root = True
        self.parent = None
        self.depth = 1
    
    def root(self):
        # if self.is_root:
        #     return self
        # elif self.parent.is_root:
        #     return self.parent
        # else:
        #     self.parent = self.parent.root()
        #     return self.parent
        node = self
        while not node.is_root:
            node = node.parent
        return node

def main():
    N, K, L = map(int, input().split())
    
    trains = [Node(i) for i in range(N)]
    streets = [Node(i) for i in range(N)]

    for i in range(K):
        p, q = map(int, input().split())
        p -= 1; q -= 1
        unite(trains[p], trains[q])
    for i in range(L):
        r, s = map(int, input().split())
        r -= 1; s -= 1
        unite(streets[r], streets[s])
    dic = {}
    roots = []
    for i in range(N):
        tmp = (trains[i].root().id, streets[i].root().id)
        roots.append(tmp)
        if tmp in dic:
            dic[tmp] += 1
        else:
            dic[tmp] = 1
    
    for i in range(N-1):
        print(dic[roots[i]], end=" ")
    print(dic[roots[N-1]])

if __name__ == "__main__":
    main()

Measured memory_bytes: 150048
N = int(input())
c = [[0] * 10 for _ in range(10)]
for i in range(1, N+1):
	c[int(str(i)[0])][int(str(i)[-1])] += 1
ans = 0
for i in range(10):
	for j in range(10):
		ans += c[i][j] * c[j][i]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <numeric>// deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

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



int main() {

	int N;
	cin >> N;
	int counta=0;
	vector<int> vec(N);
	rep(i, N) {
		cin >> vec.at(i);
		while (vec.at(i) % 2 == 0) {
			counta++;
			vec.at(i) = vec.at(i) / 2;
	}
	}
	cout << counta << endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a)      cout<<a<<" "
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll minize(ll& a,ll b){return a=(a>b?b:a);}
inline ll maxize(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];
ll F(ll x,ll c,ll d){
	if(x==0)re 0;
	re x/c+x/d-x/(c*d/__gcd(c,d));
}
ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	sc2(n,m);
	sc2(x,y);
	ans=F(m,x,y)-F(n-1,x,y);
	pr(m-n+1-ans);
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cctype>

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef pair<int,int> PII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
int W,H;
vector<string> room;

int dfs(int y,int x){
	int res = 0;
	rep(i,4){
		if(y + DY[i] < 0 || y + DY[i] >= H || x + DX[i] < 0 || x + DX[i] >= W || room[y + DY[i]][x + DX[i]] == '#') continue;
		room[y + DY[i]][x + DX[i]] = '#';
		res++;
		res += dfs(y + DY[i],x + DX[i]);
	}
	return res;
}

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

	int sy,sx,ans;

	while(1){
		cin >> W >> H;
		if(W == 0 && H == 0) break;
		room.resize(H);

		rep(i,H){
			string s;
			cin >> s;
			room[i] = s;
		}

		rep(i,H){
			rep(j,W){
				if(room[i][j] == '@'){
					sy = i;
					sx = j;
					room[i][j] = '#';
				}
			}
		}

		ans = dfs(sy,sx);

		cout << ans + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <cstdio>

void output (int* v1, int* v2) {
   if (v1[0] - v2[0] > 0) {
    printf("10 %d\n", v1[0] - v2[0]);
   }
   if (v1[1] - v2[1] > 0) {
    printf("50 %d\n", v1[1] - v2[1]);
   }
   if (v1[2] - v2[2] > 0) {
    printf("100 %d\n", v1[2] - v2[2]);
   }
   if (v1[3] - v2[3] > 0) {
    printf("500 %d\n", v1[3] - v2[3]);
   }
   return;
}

int main(void) {
    int money;
    int have[4];
    int total_money;
    int notpay;
    int notpay_num[4];
    int cost[4] = {1, 5, 10, 50};

    scanf("%d", &money);
    while (1) {
        money /= 10;
        for (int i = 0; i < 4; i++) {
            scanf("%d", &have[i]);
        }

        total_money = have[0] + 5 * have[1] + 10 * have[2] + 50 * have[3];
        notpay = total_money - money;
        for (int i = 3; i >= 0; i--) {
           notpay_num[i] = notpay / cost[i];
           notpay -= cost[i] * notpay_num[i];
        }
        output(have, notpay_num);

        scanf("%d", &money);
        if (money == 0) {
            break;
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 3200
//ABC109B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include<stdio.h>
#include<climits>
#include<cfloat>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<string>s(n);
	for(int i=0;i<n;i++){
		cin >> s.at(i);
	}
	for(int i=0;i<n-1;i++){
		if(s.at(i)[s.at(i).size()-1] != s.at(i+1)[0]){
			cout << "No" << endl;
			return 0;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(s.at(i) == s.at(j)){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
count=0
sum=0
alist=[0]
for i in a:
    sum+=i
    alist.append(sum%m)
alist.sort()
k=-1
n=0
for j in alist:
    if k!=j:
        count+=(n*(n-1)/2)
        n=0
    n+=1
    k=j
count+=(n*(n-1)/2)
print(int(count))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int dp[101][4][4][4];
const int mod = 1000000007;
int main()
{
    int n;
    cin >> n;
    dp[0][3][3][3] = 1;
    rep(i,n)rep(a,4)rep(b,4)rep(c,4){
        rep(x,4){
            if(x == 2&&a == 1&&b == 0)continue;
            if(x == 1&&a == 2&&b == 0)continue;
            if(x == 2&&a == 0&&b == 1)continue;
            if(x == 2&&b == 1&&c == 0)continue;
            if(x == 2&&a == 1&&c == 0)continue;
            
            dp[i+1][x][a][b] += dp[i][a][b][c];
            dp[i+1][x][a][b] %= mod;


        }
    }
    int ans = 0;
    rep(a,4)rep(b,4)rep(c,4){
        ans+=dp[n][a][b][c];
        ans%= mod;
    }
    cout << ans << endl;

    return 0;
}

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

#define MAX_V 210
#define INF (1<<29)

using namespace std;

const double EPS=1e-10;

struct edge{int to,cap,rev;};

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,double cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,0,G[from].size()-1});
}

int dfs(int v,int t,int f){
  if(v==t)return f;
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    edge &e=G[v][i];
    if(!used[e.to] && e.cap>0){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
        e.cap-=d;
        G[e.to][e.rev].cap+=d;
        return d;
      }
    }
  }
  return 0;
}

vector<double>cost[MAX_V];
int n,m;

int max_flow(double lim){

  for(int i=0;i<MAX_V;i++)G[i].clear();

  int s=n+m,t=n+m+1;
  for(int i=0;i<n;i++)add_edge(s,i,1);
  for(int i=0;i<m;i++)add_edge(i+n,t,1);

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(cost[i][j]<lim+EPS){
        add_edge(i,j+n,1);
      }
    }
  }

  int flow=0;
  for(;;){
    fill(used,used+MAX_V,false);
    int f=dfs(s,t,INF);
    if(f==0)return flow;
    flow+=f;
  }
}

double dist(double x1,double y1,double x2,double y2){
  return sqrt(pow(x1-x2,2)+pow(y1-y2,2));
}

int main(void){

  while(cin >> n >> m,n|m){
    vector<double>nx(n),ny(n),nv(n),mx(m),my(m);

    for(int i=0;i<n;i++)
      cin >> nx[i] >> ny[i] >> nv[i];

    for(int i=0;i<m;i++)
      cin >> mx[i] >> my[i];

    for(int i=0;i<n;i++){
      cost[i].resize(m);
      for(int j=0;j<m;j++){
        cost[i][j]=dist(nx[i],ny[i],mx[j],my[j])/nv[i];
      }
    }

    double l=0,r=1e8;

    for(int i=0;i<100;i++){
      double mid=(l+r)/2;
      int res=max_flow(mid);
      if(res==m)r=mid;
      else l=mid;
    }

    printf("%.8f\n",r);
  }

  return 0;
}

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

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'R') {
            cnt++;
            ans = max(ans, cnt);
        } else {
            cnt = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
    if (a % b == 0) {
        return(b);
    }
    else {
        return(gcd(b, a % b));
    }
}

template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

int main(void) {
    ll  sum = 0;
    ll n;
    cin >> n;
    vector<ll>a(n);
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
        sum %= 1000000007;
    }
    ll ans = 0;
    for (ll t : a) {
        sum -= t;
        if (sum < 0)sum += 1000000007;
        ans += t * sum;
        ans %= 1000000007;
    }
    cout << ans;
}

/*
*/


Measured memory_bytes: 4828
k=int(input())
d=dict()
for i in range(k):
    x=input()
    d[x]=d.get(x,0)+1
q=list()
for k,v in d.items():
    q.append( (v,k) )
bigV=0
for (v,k) in sorted(q,reverse=True):
    if(v>bigV):
        bigV=v
for (v,k) in sorted(q):
    if(v==bigV):
        print(k)


Measured memory_bytes: 48284
#include <iostream>
#include <stack>
#include <stdio.h>

int main(){
    
	using namespace std;
	
	int a;
	int i,j;
	stack<int> s;
	
	while(scanf("%d",&a)!=-1){
		if(a==0){
			
			cout<<s.top()<<endl;
			s.pop();
		}
		else{
			
			s.push(a);
		}
	
	}
	return 0;
}
	

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	string s;
	std::cin >> s;
	std::vector<ll> v(s.size()+1, -1);
	if (s[0] == '<') {
		v[0] = 0;
	}
	if (s.back() == '>') {
		v[v.size()-1] = 0;
	}
	// ><になってるとこは0
	for (size_t i = 0; i < s.size()-1; i++) {
		if (s[i] == '>' && s[i+1] =='<') {
			v[i+1] = 0;
		}
	}

	// 左から見ていく
	// <だったら足していく
	for (size_t i = 0; i < s.size(); i++) {
		if (s[i] == '<') {
			v[i+1] = max(v[i+1],v[i]+1);
		}
	}
	// 右から見てく
	// >だったら足していく
	for (int i = s.size()-1; i > -1; i--) {
		if (s[i] == '>') {
			v[i] = max(v[i+1]+1, v[i]);
		}
	}

	std::cout << accumulate(v.begin(),v.end(),0LL) << '\n';

	// 表示用
	// for (size_t i = 0; i < v.size(); i++) {
	// 	std::cout << v[i] << ' ';
	// }
	// std::cout << '\n';
	return 0;
}


Measured memory_bytes: 4740
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define heap_min priority_queue<int,vector<int>,greater<int>>
#define heap_max priority_queue<int>
#define precision(x) cout << setprecision(x) << fixed;
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i] <<" "; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int vis[100001];
vector<vector<int>>adj;

void dfs(int node){
  vis[node] = 1;
  for(auto p : adj[node]){
    if(vis[p] == 0){
      dfs(p);
    }
  }
}
int32_t main()
{
   fast;
   #ifndef ONLINE_JUDGE
   freopen("goodluckin.txt","r",stdin);
   freopen("goodluckout.txt","w",stdout);
   #endif

   int cnt = 0;
   int n,m;
   cin >> n >> m;
   adj.resize(n+1);
   int x,y;
   for(int i = 0 ; i < m ; i++){
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
   }
   for(int i = 1 ; i<=n ; i++){
    if(vis[i] == 0){
      dfs(i);
      cnt++;
    }
   }

   int ans = cnt-1;
   for(int i = 1; i <=n ; i++){
    if(vis[i] == 0){
        ans++;
      }
   }
   cout << ans;

}


Measured memory_bytes: 10576
n = int(input())
s = list(input())
ans = s.count('R')*s.count('G')*s.count('B')

for i in range(n):
  if s[i] == 'R':
    s[i] = 1
  elif s[i] == 'G':
    s[i] = 2
  elif s[i] == 'B':
    s[i] = 4
  
for i in range(n):
  for j in range(i+1, n):
    k = 2*j - i
    if k >= n:
      continue
    if s[i]+s[j]+s[k]==7:
      ans-=1

print(ans)


Measured memory_bytes: 9232
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b =	sc.nextInt();
	int c =	sc.nextInt();
	int d =	sc.nextInt();
	System.out.println((a-c)*(b-d));
    }
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i,n) for (ll i=(ll)n-1;i>=0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
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; }
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}//最大公約数
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}//最小公倍数
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
const int MOD = 1000000007;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

int main(){
   int n,k;cin>>n>>k;
   VI h(n);rep(i,n)cin>>h[i];
   VI dp(n+k+1,INFTY);

   dp[0]=0;
   rep(i,n){
      for(int j=1;j<=k;j++){
      chmin(dp[i+j],dp[i]+llabs(h[i+j]-h[i]));
      }
   }
   cout<<dp[n-1]<<endl;

}


Measured memory_bytes: 4820
//
//  main.cpp
//  CobaSemogaBisa
//
//  Created by Willy Putra on 19/12/19.
//  Copyright © 2019 Willy Putra. All rights reserved.
//

#include<stdio.h>
int main()
{
    int a,b,c,input;
    scanf("%d %d %d",&a,&b,&c);
    for(int x=0;x<3;x++)
    {
        if(a<b)
        {
            input=a;
            a=b;
            b=input;
        }
        if(b<c)
        {
            input=b;
            b=c;
            c=input;
        }
    }
    int hasil = a*10+b+c;
    printf("%d\n",hasil);
    
    
    
    return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(N) for (int i = 0; i < N; i++)

int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<char>> s(H, vector<char>(W));
    bool can_make = true;
    bool elem_can_make;
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cin >> s[i][j];
        }
    }

    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            if (s[i][j] == '#'){
                elem_can_make = false;
                if (j > 0){
                    if (s[i][j-1] == '#') elem_can_make = true;
                }
                if (j < W - 1){
                    if (s[i][j+1] == '#') elem_can_make = true;
                }
                if (i > 0){
                    if (s[i-1][j] == '#') elem_can_make = true;
                }
                if (i < H - 1){
                    if (s[i+1][j] == '#') elem_can_make = true;
                }
                if (elem_can_make == false) can_make = false;
            }
        }
    }

    if (can_make == true) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    ans = INF
    for x in range(-100, 101):
        tmp = 0
        for a in A:
            tmp += (x - a) ** 2
        if ans > tmp:
            ans = tmp

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;

 
int main(){
    int N; cin >> N;
    vector<vector<ll>> F(N, vector<ll>(10));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 10; j++) cin >> F[i][j];
    }

    vector<vector<ll>> P(N, vector<ll>(11));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 11; j++) cin >> P[i][j];
    }

    ll ans = -1e18;
    queue<string> Q;
    Q.push("");
    while(!Q.empty()){
        string S = Q.front(); Q.pop();
        if(S.size() == 10){
            if(S == "0000000000") continue;
            ll Max = 0;
            for(int i = 0; i < N; i++){
                int c = 0;
                for(int j = 0; j < 10; j++) if(F[i][j] ==1 && S[j] == '1') c++;
                Max += P[i][c];
            }
            ans = max(ans, Max);

        }
        else{
            string temp1 = S, temp2 = S;
            temp1+='0';
            temp2 += '1';
            Q.push(temp1); Q.push(temp2);
        }
    }
    cout << ans << endl;

    

}

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

using namespace std;

int main()
{
 
    int n;
    scanf("%d",&n);
    int a[n],i;
    for(i=0;i<n;++i)
        scanf("%d",&a[i]);
        
    sort(a,a+n,greater<int>());
    
    int cnt=0;
    for(i=0;i<n-1;++i)
      {
          if(a[i]==a[i+1])
             cnt++;
      }
      
      printf("%d",n-cnt);
  
}

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

#define pb push_back
#define mp make_pair

using namespace std;

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

int main() {
  vi a;
  int n;
  cin >> n;
  
  while (n--) {
    int k;
    cin >> k;
    
    a.pb(k);
  }
  
  int count = 0;
  
  for (int i = 0; i < a.size(); ++i) {
    if (a[a[i]-1] == i+1) {
      count++;
    }
  }
  
  cout << count/2 << endl;
  return 0;
}

Measured memory_bytes: 3940
read N Y
(( Y /= 1000 ))
for (( z = Y % 5; z <= N; z += 5 )); do
    x5=$(( Y + 4 * z - N * 5 ))
    x=$(( x5 / 5 )) y=$(( N - x - z ))
    (( x >= 0 && y >= 0 )) && echo $x $y $z && exit
done
echo -1 -1 -1


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

using namespace std;

#define int				long long
#define pb 				push_back
#define endl 			'\n'
#define F				first
#define S				second
#define mod				(ll)998244353
#define mp              make_pair
#define lb				lower_bound
#define ub				upper_bound
#define ios 			ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inf				1e18
#define mem(a,x)		for(int i=0;i<(int)(sizeof(a)/sizeof(a[0]));i++) a[i] = x;
#define trace(a)		cout<<(#a)<<" --> "<<a<<endl
#define trace2(a,b)		{trace(a);trace(b);}
#define trace3(a,b,c)	{trace(a);trace(b);trace(c);}
#define trace4(a,b,c,d) {trace(a);trace(b);trace(c);trace(d);}
#define M_PI           	3.14159265358979323846

signed main(){
	ios;
	int n;
	cin>>n;
	int c = 0;
	for(int i=1;i<=n;i++){
		int x = i;
		int p = 0;
		while(x>0){
			p++;
			x/=10;
		}
		if(p%2)
			c++;
	}
	cout<<c;
	return 0;
}






Measured memory_bytes: 256
from typing import List


def selection_sort(A: List[int]) -> int:
    cnt = 0
    for i in range(len(A)):
        min_j = i
        for j in range(i, len(A)):
            if A[j] < A[min_j]:
                min_j = j
        if min_j != i:
            cnt += 1
        A[i], A[min_j] = A[min_j], A[i]
    return cnt


N = int(input())
A = [int(i) for i in input().split()]
cnt = selection_sort(A)
print(' '.join(map(str, A)))
print(cnt)


Measured memory_bytes: 7156
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  long long N;
  cin >> N;
  long long ans = 0;
  for (long long A = 1; A < N; A++) {
    long long Bmax = (N - 1) / A;
    ans += Bmax;
  }
  cout << ans << '\n';
  return 0;
}


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

int keta(ll n) {
  int count = 0;
  while (n > 0) {
    n /= 10;
    count++;
  }
  return count;
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  ll n;
  cin >> n;
  int ans = 1000;
  for (ll i = 1; i*i <= n; ++i) {
    if (n % i != 0) continue;
    int temp = max(keta(i), keta(n/i));
    ans = min(temp, ans);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    int W, H, N;
    std::cin >> W >> H >> N;
    
    int x_min = 0;
    int x_max = W;
    int y_min = 0;
    int y_max = H;

    int x, y, a;
    for (int i = 0; i < N; ++i) {
        std::cin >> x >> y >> a;
        if (a == 1) {
            x_min = std::max(x_min, x);
        } else if (a == 2) {
            x_max = std::min(x_max, x);
        } else if (a == 3) {
            y_min = std::max(y_min, y);
        } else {
            y_max = std::min(y_max, y);
        }
    }

    const auto ret = std::max(x_max - x_min, 0) * std::max(y_max - y_min, 0);

    std::cout << ret << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N ,A[210]={},ans=0;
int main(){
  cin >> N;
  int tmp=0;
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  while(1){
    tmp=0;
    for(int i=0;i<N;i++){
      //cin >> A[i];
      if(A[i]%2==0){
        A[i]/=2;
        tmp++;
      }
    }
    if(tmp==N) ans++;
    else{
      cout << ans << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main( void )
{
	int APoint;
	int BPoint;
	int ABuf;
	int BBuf;
	int i;
	int j;
	
	while( 1 )
	{
		APoint = 0;
		BPoint = 0;
		
		scanf( "%d", &j );
		if( j == 0 )break;
		for( i = 0; i < j; i++ )
		{
			scanf("%d%d", &ABuf, &BBuf );
			if( ABuf > BBuf )
			{
				APoint += ABuf + BBuf;
			}
			else if( ABuf < BBuf )
			{
				BPoint += ABuf + BBuf;
			}
			else
			{
				APoint += ABuf;
				BPoint += BBuf;
			}
		}
		printf("%d %d\n", APoint, BPoint );
	}
	
	return (0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;
typedef pair<mp,ll> mmp;


int main(){
 while(1){
  ll r,n;
  cin>>r>>n;
  if(r==0 &&n == 0 )break;
  vector<mmp> x(n),y(n);
  for(ll i=0;i<n;i++){
   ll xl,xr,h;
   cin>>xl>>xr>>h;
   x[i] = mmp( mp(xl,xr) , h );
   y[i] = mmp( mp(-xr,-xl) , h);
  }
  sort( x.begin() , x.end() );
  sort( y.begin() , y.end() );

  vector<ll> left(21,0),right(21,0);
  for(ll i=0;i<n;i++){
   for(ll j=0;j<x[i].second;j++){
    if( x[i].first.first <= left[j] ){
     left[j] = max( left[j] , x[i].first.second );
    }
   }
   for(ll j=0;j<y[i].second;j++){
    if( y[i].first.first <= right[j] ){
     right[j] = max( right[j] , y[i].first.second );
    }
   }
  }

  double res = 20;
  for(ll i=0;i<21;i++){
   ll lr = min( r, min( right[i] , left[i] ) );
   double rr = i+  r-sqrt( r*r - lr*lr ) ;
   if( lr == r ) rr = 20;
   res = min( res , rr );
   if( lr == 0 ) break;
 //  cout<<lr<<' '<<rr <<endl;
  }

  printf("%0.10lf\n",res);

 }
    return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, d; cin >> n >> d;
    int k = 2 * d + 1;
    if (n % k == 0) cout << n/k << endl;
    else cout << n/k + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys

N,M,K = map(int,sys.stdin.readline().split())
a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
b = tuple(map(int,sys.stdin.readline().split())) # single line with multi param

cum_a = [0]*(N+1)
for i in range(N):
    cum_a[i+1] = cum_a[i]+a[i]

cum_b = [0]*(M+1)
for i in range(M):
    cum_b[i+1] = cum_b[i]+b[i]

ok = 0
ng = N+M+1

def isOK(mid):
    for i in range(N+1):
        if 0 <= mid-i and mid-i <=M and cum_a[i]+cum_b[mid-i]<=K:
            return True
    return False

while ng-ok > 1:
    mid = (ok+ng)//2
    if isOK(mid):
        ok = mid
    else:
        ng = mid
print(ok)


Measured memory_bytes: 48948
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
ans = 0
prev = -100
for i in range(n):
  ans += b[a[i]-1]

  if a[i] == (prev + 1):
    ans += c[prev-1]

  prev = a[i]
  
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.Deque;
 
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double sum = 0.0;
        for(int i = 1; i <= n; i++){
            if(i % 2 == 1)
                sum += 1.0;
        }
        System.out.println(sum / n);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef vector<ll> Vec;
typedef vector<pair<ll, ll>> Pair;
#define rep(i, n) for(ll i=0;i<n;i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//static const ll MOD = 1000000007;
//static const ll INF = 100000000;
//#define PI 3.14159265359


int main() {
    // input
    string S, T;
    cin >> S >> T;

    // process
    if (S.length() + 1 != T.length()) {
        cout << "No";
        return 0;
    }

    rep(i, S.length()) {
        if (S[i] != T[i]) {
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";

    return 0;
}



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

int main(){

    string a , b , c;
    cin>>a>>b>>c;

    bool isRight = (a[a.length()-1]==b[0] and b[b.length()-1]==c[0]);

    if (isRight)
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define pb push_back
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ll long long
using namespace std;
int main(){
  ll n, m;
  cin >> n >> m;
  unordered_map<ll, ll> b;
  ll c = 0;
  b[0]++;
  REP(i, n){
    ll a;
    cin >> a;
    c += a;
    c %= m;
    b[c]++;
  }
  ll ans = 0;
  for(auto pair: b){
    if(pair.second > 1)ans += pair.second * (pair.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;
class Main{
	public static void main(String[]args) {
	Scanner scan=new Scanner(System.in);
	String a=scan.next();
	//int c=scan.nextInt();
	int ans=0;
	if(a.charAt(6)<'5') {
		ans=1;
	}
	else{
	}
	if(a.charAt(5)=='1') {
		ans=0;
	}
	System.out.println(ans==1?"Heisei":"TBD");
	}
}

Measured memory_bytes: 21460
#include <iostream>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> red, blue;
map<ll, bool> mp;
ll n, x, y, res;
int main(void){
    // Your code here!
    cin >> n;
    for (ll i = 0; i < n; i++) {
        cin >> x >> y;
        red.push(P(x, y));
    }
    for (ll i = 0; i < n; i++) {
        cin >> x >> y;
        blue.push(P(x, y));
    }
    while (blue.size()) {
        P p1 = blue.top(); blue.pop();
        while (red.size()) {
            P p2 = red.top();
            if (p2.first > p1.first) break;
            red.pop();
            mp[p2.second] = true;
        }
        auto itr = mp.lower_bound(p1.second);
        if (itr == mp.begin()) continue;
        res++; itr--; mp.erase(itr);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
ll power(ll x,ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 
// Returns sum of bitwise OR 
// of all pairs 
vector<ll>arr;
ll sumXOR(ll n) 
{ 
    ll sum = 0; 
    for (ll i = 0; i < 64; i++)  
    { 
        ll zc = 0, oc = 0;  
        ll idsum = 0;  
        for (ll j = 0; j < n; j++) 
        { 
            if (arr[j] % 2 == 0) 
                zc++; 
            else
                oc++; 
            arr[j] /= 2; 
        } 
        ll dol = power(2,i,MOD);
        idsum = ((oc * zc)%MOD*dol)%MOD;  
        sum = (sum%MOD+idsum%MOD)%MOD; 
        //debug(i); 
    } 
    return sum%MOD; 
}
int main()
{
  //flash;
  ll n;
  cin>>n;
  for (ll i = 0; i < n; ++i)
  {
   ll yo;
   cin>>yo;
   arr.pb(yo);
  }
  cout<<sumXOR(n);
  return 0;
}
//code the AC sol !
// BS/queue/map


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

int main(){
    long long n;
    cin >> n;
    long long l3, l5, l15;
    l3 = n/3;
    l5 = n/5;
    l15 = n/15;
    long long sum = n*(n+1)/2;
    long long sum_l3 = 3*l3*(l3+1)/2;
    long long sum_l5 = 5*l5*(l5+1)/2;
    long long sum_l15 = 15*l15*(l15+1)/2;
    long long ans = sum - sum_l3 - sum_l5 + sum_l15;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
/* ****TCIITB**** */
                     
#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          int long long
#define pb          push_back
#define endl        '\n'
#define piil         pair<ll ,ll >
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
                    
                   
using namespace std;
 
ll expo(ll base, ll exponent, ll mod) {                //return base^exponent modulo modulus
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            
        }
        base = base*base;
       
        exponent>>= 1;
    }
    return ans;
}
int main()
{
   ll t;
   t=1;
   while(t--)
   { 
    string x;
    cin>>x;
    ll k;
    cin>>k;
    std::vector<string> a;
    std::map<string,ll> aa;
    rep(i,0,x.length())
    {
       string z="";
       for(ll j=i;j<x.length() && j<=i+k+1;j++)
       {
        z+=x[j];
         if(aa.find(z)!=aa.end())
      {
         continue;
      }
      else
      {
         aa[z]=1;
         a.push_back(z);
      }
 
 
       }
    }
    
   
    sort(a.begin(), a.end());
    cout<<a[k-1];

     

 
     
 
   }
 
  
} 


Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<=y;++i)
#define rf(i,x,y) for(int i=x;i>=y;--i)
#define LL long long
using namespace std;
const int N=1010;
struct data{
	LL x,y;
}a[N];
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};
char ch[4]={'R','D','L','U'};
vector<LL>v;

int main(){
	int n;scanf("%d",&n);
	fr(i,1,n) scanf("%lld%lld",&a[i].x,&a[i].y);
	int flg=0;
	fr(i,1,n){
		if(i==1) flg=(a[i].x+a[i].y)&1;
		else if(flg!=((a[i].x+a[i].y)&1)) return printf("-1\n"),0;
	}
	rf(i,30,0) v.push_back(1LL<<i);
	if(!flg) v.push_back(1);
	int len=v.size();
	printf("%d\n",len);
	fr(i,0,len-1) printf("%lld ",v[i]);
	puts("");
	fr(i,1,n){
		LL xx=a[i].x,yy=a[i].y;
		fr(j,0,len-1){
			LL minn=1e18,res=-1;
			fr(o,0,3){
				LL nx=xx-v[j]*dx[o],ny=yy-v[j]*dy[o];
				if(minn>abs(nx)+abs(ny)) minn=abs(nx)+abs(ny),res=o;
			}
			xx-=v[j]*dx[res],yy-=v[j]*dy[res];
			printf("%c",ch[res]);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		while ((line = br.readLine()) != null) {
			String[] s = line.split(" ");
			if(s.length<8)break;
			double[] x = new double[4];
			double[] y = new double[4];
			for (int i = 0; i < 4; i++) {
				x[i] = Double.parseDouble(s[2 * i]);
				y[i] = Double.parseDouble(s[2 * i + 1]);
			}
			double c = 0.0;
			for (int i = 0; i < 3; i++) {
				c = ((x[0] - x[1]) * (y[2] - y[0]) + (y[0] - y[1]) * (x[0] - x[2])) * ((x[0] - x[1]) * (y[3] - y[0]) + (y[0] - y[1]) * (x[0] - x[3]));
				if (c < 0.0)
					break;
				double t = x[0];
				x[0] = x[1];
				x[1] = x[2];
				x[2] = t;
				t = y[0];
				y[0] = y[1];
				y[1] = y[2];
				y[2] = t;
			}
			System.out.println(c < 0.0 ? "NO" : "YES");
		}
	}
}

Measured memory_bytes: 9736
#include <bits/stdc++.h>
#define ll int
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define inf 1000000007
#define fi first
#define se second
using namespace std;
 
const ll n6=1e6+10;
const ll n5=1e5+10;


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll i,j,k,t,x,y,n,p,q,m,f,tt,l,r;
	string s,ls,rs;
	cin>>s;
	n=s.length();
	s=" "+s;
	f=0;
	FOR(i,1,n/2-1) {
		ls=s.substr(1,i);
		rs=s.substr(i+1,i);
		if(ls==rs) f=i;
	}
	cout<<2*f<<endl;
 	return 0;
}  

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int M; cin >> M;

	cout << 48 - M << endl;


	return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define MaxN 200000+100
typedef long long LL;
using namespace std;
LL sum[MaxN];
LL p[10];
LL my_min(LL a,LL b)
{
    return a<b? a:b;
}
int main()
{
    int N;
    LL min=100000000000000007;
    scanf("%d",&N);
    for(int i=1;i<=N;i++)
    {
        scanf("%lld",&sum[i]);
        sum[i]+=sum[i-1];
    }
    for(int i=2;i<=N-1;i++)
    {
        LL p1=sum[i];
        int star=1;
        int end=i-1;
        while(star<=end)
        {
            int mid=(star+end)/2;
            if(sum[mid]<=p1/2)
                star=mid+1;
            else
                end=mid-1;
        }
        p[0]=sum[star];
        p[1]=sum[i]-sum[star];
        p[2]=sum[end];
        p[3]=sum[i]-sum[end];
  //      printf("%lld %lld %lld %lld\n",p[0],p[1],p[2],p[3]);
        sort(p,p+4);
        p[0]=p[1];
        p[1]=p[2];
        star=i+1;
        end=N-1;
        p1=sum[N]-sum[i];
        while(star<=end)
        {
            int mid=(star+end)/2;
            if(sum[N]-sum[mid]<=p1/2)
                end=mid-1;
            else
                star=mid+1;
        }
        p[4]=sum[N]-sum[star];
        p[5]=p1-p[4];
        p[6]=sum[N]-sum[end];
        p[7]=p1-p[6];
    //    printf("%lld %lld %lld %lld\n",p[4],p[5],p[6],p[7]);
   //     printf("\n");
        sort(p+4,p+8);
        p[2]=p[5];
        p[3]=p[6];
        sort(p,p+4);
        min=my_min(min, p[3]-p[0]);
    }
    printf("%lld\n",min);
    return 0;
}


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

long long int N, h, a[100001], s, t, i;

int main(){
    scanf("%lld%lld", &N, a);
    h = N * 1000000000LL;
    a[N] = *a;
    s = *a;
    for(; ++i < N;){
        scanf("%lld", a + i);
        s += a[i];
    }
    if(s % (N * (N + 1) / 2))return 0 & puts("NO");
    s /= (N * (N + 1) / 2);
    for(i = 0; i < N; ++i){
        t += (a[i] - a[i + 1] + s) / N;
        if((a[i] - a[i + 1] + s) < 0 || (a[i] - a[i + 1] + s) % N != 0)return 0 & puts("NO");
    }
    puts(((t + h) % N != (s + h) % N) ? "NO" : "YES");
    return 0;
}


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

int main() {
  string str;
  cin >> str;
  
  if(str.at(0) == 'a'){
  	cout << "vowel" << endl;
  }
  else if(str.at(0) == 'i'){
  	cout << "vowel" << endl;
  }
  else if(str.at(0) == 'u'){
  	cout << "vowel" << endl;
  }
  else if(str.at(0) == 'e'){
  	cout << "vowel" << endl;
  }
  else if(str.at(0) == 'o'){
  	cout << "vowel" << endl;
  }
  else{
  	cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    long long N, a[3001], i, ans=0;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> a[i];
        ans += a[i]-1;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

void solve()
{
	int N;
	cin >> N;
	while(N--)
	{
		int n, m;
		cin >> n >> m;
		
		vector<int> Vec(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> Vec[i];
		}
		if(n <= m)
		{
			cout << 0 << endl;
			continue;
		}
		priority_queue<int> PQue;
		for(int i = 1; i < n; ++i)
		{
			PQue.push(Vec[i] - Vec[i - 1]);
		}
		int length = Vec[n - 1] - Vec[0];
		--m;
		for(int i = 0; i < m; ++i)
		{
			length -= PQue.top();
			PQue.pop();
		}
		cout << length << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0