akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll l, r, d; cin >> l >> r >> d;

  ll ans = 0;
  ans += r/d;
  ans -= (l-1)/d;

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
int main(){
vector<int> v(3);
for(int i=0;i<3;i++)cin>>v[i];
sort(v.begin(),v.end());
if(v[0]==5&&v[1]==5&&v[2]==7)cout<<"YES";
else cout<<"NO";
    
}

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

int main(){
  
  int L, R, d, i, cnt=0;
  cin >> L >> R >> d;
  for(i=max(L,d); i<=R; i++){
    
    if(i%d==0)cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(b/a>c) co(c);
  else co(b/a);
  
  return 0;
}


Measured memory_bytes: 256
import scala.io.Source.stdin

object Main extends App {
  def isLeapYear(y:Int) = {
    if(y%4 != 0) false
    else if(y%100 != 0) true
    else if(y%400 != 0) false
    else true
  }

  println {
    stdin.getLines.filter( _.trim != "0 0").map { s=>
      val y = s.split(" ").map(_.toInt)
      val leapYear = for(i<-y(0) to y(1);if isLeapYear(i)) yield i
      if(leapYear.length==0) "NA"
      else leapYear.mkString("\n")
    }.mkString("\n\n")
  }
}

Measured memory_bytes: 44724
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

Node treeMinimum(Node u){
  while(u->left != NIL) {
      u = u->left;
    }
    return u;

}

/*Node treeMaximum(Node u){


}*/

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key) return u;
  if (k<u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);

}

Node treeSuccessor(Node u){
  Node y = NIL;
    if( u->right != NIL ) return treeMinimum(u->right);
    y = u->parent;
    while(y != NIL && u == y->right) {
      u = y;
      y = y->parent;
    }
    return y;

}

void treeDelete(Node u){
  Node y; // node to be deleted
  Node x; // child of y

  if( u->left == NIL || u->right == NIL ) y = u;
    else y = treeSuccessor(u);
    
    if( y->left != NIL ) x = y->left;
    else x = y->right;
    
    if( x != NIL ) x->parent = y->parent;
    
    if( y->parent == NIL) root = x;
    else if( y == y->parent->left ) y->parent->left = x;
    else y->parent->right = x;
    
    if( y != u ) {
      u->key = y->key;
    }


}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;

  if(y==NIL) root=z;
  else if(z->key < y->key) y->left=z;
  else y->right=z;

}

void inorder(Node u){
  if(u==NIL) return ;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL) return ;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

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

int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	
	int prime[1000001];
	for(int i=0;i<1000001;++i){
		prime[i]=1;
	}
	prime[1000000]=1;
	prime[0]=prime[1]=0;
	for(ll i=2;i<=1000000;++i){
		if(prime[i]){
			for(ll j = i*i;j<=1000000;j+=i){
				prime[j]=0;
			}
		}
	}

		
	for(int i=0;i<n;++i){
		cin>>a[i];
		for(int j=2;j*j<=a[i];++j){
			if(a[i]%j==0){
				while(a[i]%j==0){
					a[i]/=j;
				}
				prime[j]-=1;
			}
		}
		if(a[i]!=1) prime[a[i]]-=1;
	}
	int set=1,pair=1;
	for(int i=0;i<=1000000;++i){
		if(prime[i]!=0&&prime[i]!=1){
			pair=0;
		}
		if(prime[i]==1-n) set=0;
	}
	
	if(pair){
		cout<<"pairwise coprime";
	}else if(set){
		cout<<"setwise coprime";
	}else cout<<"not coprime";
	return 0;
}




Measured memory_bytes: 11364
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c1 = Counter(A[::2])
c2 = Counter(A[1::2])
c1m = max(c1.items(), key=lambda x:x[1])
c2m = max(c2.items(), key=lambda x:x[1])
if len(set(A)) == 1:
    print(N // 2)
    exit()
c1c2 = max(c for k,c in c2.items() if c1m[0]!=k)
c2c1 = max(c for k,c in c1.items() if c2m[0]!=k)
print(min(N - c1m[1] - c1c2, N - c2m[1] - c2c1))

Measured memory_bytes: 22328
#関数リスト
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def ruiseki(mydata):
    res = [0]*(len(mydata)+1)
    for i in range(len(mydata)):
        res[i+1] = res[i] + mydata[i]
    return res

n, k , m = MI()
a = tuple(ruiseki(LI()))
b = tuple(ruiseki(LI()))

result = 0
index = k
for i, ii in enumerate(a):
    if ii > m:
        break
    while b[index] + ii > m:
        index -= 1
    result = max(result, i+index)
print(result)

Measured memory_bytes: 114972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);


		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a == b && b== 5 && c == 7 || b == c && c== 5 && a == 7|| c == a && a== 5 && b == 7){

				System.out.println("YES");

		}
			else {
				System.out.println("NO");
			}
	}
}


Measured memory_bytes: 21972
#include<iostream>

using namespace std;

int main(void)
{
	char a;
	cin>>a;
	
	switch(a)
	{
		case 'a':cout<<"vowel\n";return 0;
		case 'e':cout<<"vowel\n";return 0;
		case 'i':cout<<"vowel\n";return 0;
		case 'o':cout<<"vowel\n";return 0;
		case 'u':cout<<"vowel\n";return 0;
	}
	
	cout<<"consonant\n";
	
	return 0;
}

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

int main(void){
int n;
string moji [100];
string result ="Yes";
cin >> n;

cin>>moji[0];

for (int i =1;i<n;i++){
cin >> moji [i];
if(moji[i-1][moji[i-1].length()-1] != moji[i][0]){
result = "No";
}
for(int j=0;j<i;j++){
if(moji[j]==moji[i]){
result = "No";
}
}
}

cout <<  result<< endl;
return 0;
}


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

#define rep(i,f,n) for (int i = (f); i < (n); ++i)
#define repr(i,f,n) for (int i = (n); i < (f); --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  int outlet = 1;
  while (outlet < b)
  {
    --outlet;
    outlet += a;
    ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long int
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e7;
const ll MOD=998244353;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
int main() 
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    cout.tie(0);
    int n , m;
    cin>>n>>m;
    int f=0;
    for(int i=0;i<=n;i++){
      if((i*4+(n-i)*2)==m)
        f=1;
    }
    if(f)
      cout<<"Yes";
    else
      cout<<"No";
}

Measured memory_bytes: 3608
N=int(input())
d=[[0]*10 for i in range(10)]
for i in range(1,N+1):
    n=str(i)
    d[int(n[0])][int(n[-1])]+=1
r=0
for i in range(9):
    for j in range(9):
        r+=d[i+1][j+1]*d[j+1][i+1]
print(r)

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  int i,n;

  scanf("%d",&n);
  int b[100],m=0;
  for(i=0;i<n-1;i++){
    scanf("%d",&b[i]);
    if(i==0){
      m += 2*b[i];
    }
    else{
      if(b[i-1] > b[i]){
        m += 2*b[i]-b[i-1];
      }
      else{
        m += b[i];
      }
    }
  }
  printf("%d",m);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	int c=0;
	cin>>s>>t;
	for(int i=0;i<t.size();i++){
		if(s[i]!=t[i])
			c++;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3916
#include <stdio.h>
#include <stdlib.h>

int cmp(const void *n1, const void *n2)
{
    return *(int *)n1 - *(int *)n2;
}

int main(void)
{
    int inputN, inputQ, *inputA, *flag, answerCount = 1;
    long int inputK;
    scanf("%d%ld%d", &inputN, &inputK, &inputQ);
    inputA = (int *)malloc(sizeof(int) * inputQ);
    flag = (int *)malloc(sizeof(int) * inputN);
    if (inputK - inputQ > 0)
    {
        for (int index = 0; index < inputN; index++)
        {
            flag[index] = 1;
        }
    }
    else
    {
        for (int index = 0; index < inputN; index++)
        {
            flag[index] = 0;
        }
    }
    for (int count = 0; count < inputQ; count++)
    {
        scanf("%d", &inputA[count]);
    }
    qsort(inputA, inputQ, sizeof(int), cmp);
    for (int count = 0; count < inputQ; count++)
    {
        if (count == inputQ - 1)
        {
            if (inputK - (inputQ - answerCount) > 0)
            {
                flag[inputA[count] - 1] = 1;
                break;
            }
        }
        if (inputA[count] != inputA[count + 1])
        {
            if (inputK - (inputQ - answerCount) > 0)
            {
                flag[inputA[count] - 1] = 1;
            }
            answerCount = 1;
        }
        else
        {
            answerCount++;
        }
    }
    for (int index = 0; index < inputN; index++)
    {
        if (flag[index])
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }

    free(inputA);
    free(flag);

    return 0;
}

Measured memory_bytes: 1404
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,k;
  cin>>n>>k;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  sort(ALL(v));
  if(n<=k){
    cout<<0<<endl;
    return 0;
  }
  ll ans=0;
  rep(i,n-k){
    ans+=v[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int A[1000000], n;

int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1; 
    if(key > A[mid]) left = mid + 1;
    else if(key < A[mid]) right = mid; 
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2100
// Created by Sharat Sachin
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(ll i=0;i<(n);++i)
#define repA(i,a,n) for(ll i=a;i<=(n);++i)
#define repD(i,a,n) for(ll i=a;i>=(n);--i)
using namespace std;
using ll = long long;

int main()
{   ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string a,b;
    cin>>a>>b;
    int n=a.length(), m=b.length();
    int lcs[n+1][m+1];
    rep(i,n+1) rep(j,m+1) lcs[i][j]=0;
    repA(i,1,n) repA(j,1,m) lcs[i][j] = ((a[i-1]==b[j-1])? lcs[i-1][j-1]+1 : max(lcs[i-1][j],lcs[i][j-1]));
    
    // rep(i,n+1) rep(j,m+1) cout<<lcs[i][j]<<" \n"[j==m];
    string sol;
    int i=n, j=m;
    while(i>0 && j>0){
    	if(a[i-1]==b[j-1]) sol+=a[i-1], i--, j--;
    	else {
    		if(lcs[i][j]==lcs[i][j-1]) j--;
    		else i--;
    	}
    	// db3(i,j,sol);
    }
    reverse(sol.begin(), sol.end());
    cout<<sol;
    return 0;
}

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

int main() {
  int A,B,K;
  string ans;

  cin >> A >> B;

  if ( A >= B ) {
    int num = (A-B)/2;
    if ( (A-B)%2 == 0 ) {
      K = A-num;
    } else {
      K = 0;
    }
  } else {
    int num = (B-A)/2;
    if ( (B-A)%2 == 0 ) {
      K = B-num;
    } else {
      K = 0;
    }
  }
  
  if( K == 0 ) {
    ans = "IMPOSSIBLE";
    cout << ans << endl;
  } else {
    cout << K << endl;
  }
}

Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007ll
using namespace std;
int n,a[40],b[40];
ll ans;
map<ll,int> m[20];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n*2;++i){
        char c;
        scanf(" %c",&c);
        a[i]=c-96;
    }
    for(int _=(1<<n)-1;_>=0;--_){
        for(int i=0;i<n;++i)b[i+1]=(_>>i)&1;
        ll o=0,p=0;
        int cnt=0;
        for(int i=1;i<=n;++i)if(!b[i])o=(o*31ll+a[i])%orz,p=(p*47ll+a[i])%orz,++cnt;
        for(int i=n;i;--i)if(b[i])o=(o*31ll+a[i])%orz,p=(p*47ll+a[i])%orz;
        ++m[cnt][o*(orz+1)+p];
    }
    for(int _=(1<<n)-1;_>=0;--_){
        for(int i=0;i<n;++i)b[i+n+1]=(_>>i)&1;
        ll o=0,p=0;
        int cnt=0;
        for(int i=n*2;i>n;--i)if(b[i])o=(o*31ll+a[i])%orz,p=(p*47ll+a[i])%orz,++cnt;
        for(int i=n+1;i<=n*2;++i)if(!b[i])o=(o*31ll+a[i])%orz,p=(p*47ll+a[i])%orz;
        ans+=m[cnt][o*(orz+1)+p]*1ll;
    }
    cout<<ans<<endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 33024
#include<iostream>
#include<vector>
#include<algorithm>
#define ll long long
using namespace std;
vector <ll> vec;
ll n, s;
bool cmp(ll x, ll y)
{
	return x > y;
}
ll f(ll b, ll n)
{
	if (n < b) return n;
	return f(b, n / b) + n % b;
}
bool check(ll x)
{
	ll a0, a1;
	a1 = n / x;
	a0 = n % x;
	if (a1 < x && x >= 2 && a0 + a1 == s)
		return true;
	return false;
}
int main()
{
	cin >> n >> s;
	if (n < s)
	{
		cout << -1 << endl;
		return 0;
	}
	if (n == s)
	{
		cout << n + 1 << endl;
		return 0;
	}
	ll i;
	for (i = 2; i * i <= n; i++)
	{
		if(f(i,n) == s)
		{
			cout << i << endl;
			return 0;
		}
	}
	ll y = n - s;
	for (ll j = 1; j * j <= y; j++)
		if (y % j == 0)
			vec.push_back(j), vec.push_back(y / j);
	sort(vec.begin(), vec.end(), cmp);
	for (ll j = 0; j < vec.size(); j++)
	{
		ll b = y / vec[j] + 1;
		if (f(b, n) == s)
		{
			cout << b << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define F first
#define S second
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
using namespace std;
//<<>>
vector<pair<int,int>> v[29][2];
int nb[29][2];
signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	int a[n+1]; for(int i=1; i<=n; ++i) cin>>a[i];
	int b[n+1]; for(int i=1; i<=n; ++i) cin>>b[i];
	
	for(int bit=0; bit<=28; ++bit){
		map<int,int> map[2];
		for(int i=1; i<=n; ++i){
			int x = b[i]&((1<<bit)-1);
			bool bb = b[i]&(1<<bit);
			++map[bb][x];
			++nb[bit][bb];
		}

		for(int bb=0; bb<2; ++bb){
			for(const auto &p: map[bb]) v[bit][bb].push_back(p);
			for(int i=1; i<sz(v[bit][bb]); ++i) v[bit][bb][i].S += v[bit][bb][i-1].S;
		}
	}

	int ans=0;
	for(int bit=0; bit<=28; ++bit){
		LL t = 0;
		for(int i=1; i<=n; ++i){
			bool bb = a[i]&(1<<bit);
			int y = a[i]&((1<<bit)-1);
            
            auto it = lower_bound(all(v[bit][bb]), make_pair((1<<bit)-y , 0));
			if(it != v[bit][bb].begin()) t += nb[bit][bb] - (--it)->S;
			else t += nb[bit][bb];
            
			it = lower_bound(all(v[bit][1-bb]), make_pair((1<<bit)-y , 0));
			if(it != v[bit][1-bb].begin()) t += (--it)->S;
		}

		if(t%2 == 1) ans += (1<<bit);
	}
	
	cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 31476
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

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

template< typename T >
vector< T > bellman_ford(Edges< T > &edges, int V, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(V, INF);
  dist[s] = 0;
  for(int i = 0; i < V - 1; i++) {
    for(auto &e : edges) {
      if(dist[e.src] == INF) continue;
      dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
    }
  }
  bool flag = 0;
  for(int i = 0; i < V+1; i++){
    for(auto &e : edges) {
        if(dist[e.src] == INF) continue;
        if(dist[e.src] + e.cost < dist[e.to])
        {
            dist[e.to] = dist[e.src] + e.cost;
            negative[e.to] = 1;
        }
    }
  }
  return dist;
}

void propagate(Edges<LL> &edges){
    REP(i,3000){
    for(auto &e : edges){
        if(negative[e.src] == 1) negative[e.to] = 1;
    }
    }
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    LL N,M,P; cin >>N>>M>>P;
    Edges<LL> es;
    REP(i,2510) negative[i] = 0;
    REP(i,M)
    {
        LL a,b,c; cin>>a>>b>>c;
        a--; b--;
        //c *= -1;
        c -= P;
        c *= -1;
        es.emplace_back(a,b,c);
    }
    auto dists = bellman_ford(es,N,0);
    propagate(es);

    if(negative[N-1] == 1)
    {
        cout << -1 << endl;
        return 0;
    }
    else
    {
        cout << max(dists[N-1] * -1,0LL) << endl;
    }

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vs = vector<string>;
using vvs = vector<vs>;
using pli = pair<long long, int>;
using vpli = vector<pli>;

int main() {
  ll N;
  double dist, ans = 0.0;
  cin >> N;
  vll Xs(N);
  vll Ys(N);
  vector<double> Ds(N, 0.0);
  
  for (int i = 0; i < N; i++) {
    cin >> Xs.at(i) >> Ys.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      else {
        Ds.at(i) += sqrt((Xs.at(i) - Xs.at(j)) * (Xs.at(i) - Xs.at(j)) + 
                        (Ys.at(i) - Ys.at(j)) * (Ys.at(i) - Ys.at(j)));
      }
    }
    Ds.at(i) /= N;
  }
  
  for (int i = 0; i < N; i++) {
    ans += Ds.at(i);
  }
  
  printf("%.10lf\n", ans);
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	int g;
	long long I, O, J, L;
	cin >> I >> O >> g >> J >> L >> g >> g;

	long long a = I / 2 + J / 2 + L / 2;
	a = a * 2 + O;

	long long b = 0;
	if(I >= 1 and J >= 1 and L >= 1){
		b += 3;
		I--;
		J--;
		L--;
	}
	b += (I / 2 + J / 2 + L / 2) * 2 + O;

	cout << max(a,b) << endl;

}


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

 int main() {
   int N;
   cin >> N;

   vector<int> a(N + 1), b(N + 1, 0);
   rep(i, 1, N + 1) cin >> a.at(i);

   for (int i = N; i >= 1; i--) {
     int cnt = 0;
     if (N / i == 1) b.at(i) = a.at(i);
     else {
       for (int j = 2; j <= N / i; j++) cnt += b.at(j * i);
       if (cnt % 2 == a.at(i)) b.at(i) = 0;
       else b.at(i) = 1;
     }
   }

   vector<int> ans;
   rep(i, 1, N + 1) {
     if (b.at(i) == 1) ans.push_back(i);
   }

   cout << ans.size() << endl;

   if (ans.size() > 0) {
     rep(i, 0, ans.size() - 1) cout << ans.at(i) << " ";
     cout << ans.at(ans.size() - 1) << endl;
   }
 }


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

const ll sch = 200000;

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





int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n,q,sum=0;
    cin >> n;
    map<ll,ll> a;
    set<ll> conf;
    rep(i,n){
        int k;
        cin >> k;
        if(conf.count(k)){
            a[k]++;
        }else{
            a[k] = 1;
        }
        conf.insert(k);
        sum += k;
    }
    cin >> q;
    vector<ll> b(q),c(q);
    rep(i,q){
        cin >> b[i] >> c[i];
        
    }
    rep(i,q){
        if(conf.count(b[i])){
            sum += (c[i]-b[i])*a[b[i]];
            if(conf.count(c[i])){
                a[c[i]] += a[b[i]];
            }else{
                a[c[i]] = a[b[i]];
            }
            a.erase(b[i]);
            conf.erase(b[i]);
            conf.insert(c[i]);
        }
        cout << sum << endl;
    }

    

    


    return 0;
}


Measured memory_bytes: 11620
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)

template<typename T>
void remove(vector<T>& vector, unsigned int index){
vector.erase(vector.begin() + index);
}

typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int n;
	cin >> n;
	double general = 100000.0;
	rep(i, n){
		general *= 1.05;
		general/=1000;
		general = ceil(general);
		general*=1000;
	}
	int x = general;
	cout << x << endl;
	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1168
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
long long mod=1e9+7;
//
int main(){
	string s,t;
	cin>>s>>t;
	s=s+t[t.size()-1];
	if(s==t){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
int main()
{
  
  std::string enter;
  std::cin>>enter;
  if(enter=="Sunny")
     std::cout<<"Cloudy";
  else
    if(enter=="Cloudy")
      std::cout<<"Rainy";
  else
    if(enter=="Rainy")
      std::cout<<"Sunny";
  
  return 0;
  
}

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

using namespace std;

#define ll long long
#define ld long double

ll ans;
string s;
map<char, ll> charCnt;

int main() {
	cin >> s;

	ans = s.size()*(s.size()-1)/2 + 1;

	for(int i = 0; i < s.size(); i++) charCnt[s[i]]++;

	for(auto x: charCnt) ans -= x.second*(x.second-1)/2;

	cout << ans << endl;
}

Measured memory_bytes: 640
n,x,y = map(int, input().split())
max_dis = 0
ans = [0]*n
for i in range(1, n):
    for j in range(i+1,n+1):
        ans[min(abs(i-j), (abs(x-i)+1 +abs(y-j)))] +=1
print(*ans[1:], sep="\n")

Measured memory_bytes: 3444
n, k = map(int, input().split())

ans = 0
for b in range(k+1, n+1):
    p = n // b
    q = n % b
    ans += (b-k)*p
    if q >= k and k > 0:
        ans += q-k+1
    elif q >= k and k == 0:
        ans += q

print(ans)

Measured memory_bytes: 3060
N, Q = map(int, input().split())
S = input()
cum_sum = [0]*(N+1)
for i in range(2, N+1):
    if S[i-2:i] == 'AC':
        cum_sum[i] = cum_sum[i-1] + 1
    else:
        cum_sum[i] = cum_sum[i-1]

for _ in range(Q):
    l, r = map(int, input().split())
    ans = cum_sum[r] - cum_sum[l]
    print(ans)

Measured memory_bytes: 6060
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<tuple>
using namespace std;

int main() {
	long long N;
	cin >> N; tuple<long long, long long, long long>G = make_tuple(-1, -1, -1);
	vector<long long> x; x.resize(N + 1);
	vector<long long> y; y.resize(N + 1);
	vector<long long> h; h.resize(N + 1);
	vector<tuple<long long, long long, long long>>vec;

	for(int i = 1; i <= N; ++i) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] >= 1) G = make_tuple(x[i], y[i], h[i]);
	}
	for (int i = 0; i <= 100; ++i) {
		for (int j = 0; j <= 100; ++j) {
			bool flags = true;
			long long H1 = get<2>(G) + abs(get<0>(G) - i) + abs(get<1>(G) - j); H1 = max(H1 , 0LL);
			for (int k = 1; k <= N; ++k) {
				long long H = H1 - abs(x[k] - i) - abs(y[k] - j); H = max(H , 0LL);
				if (h[k] != H) flags = false;
			}
			if (flags)vec.push_back(make_tuple(i, j, H1));
		}
	}
	if (vec.size() == 1) {
		cout << get<0>(vec[0]) << " " << get<1>(vec[0]) << " " << get<2>(vec[0]) << endl;
	}
	else {
		cout << vec.size() << endl; 
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int x,y;

int main(){
	ios::sync_with_stdio(false);
	cin>>x>>y;
	if(2*x<=y&&y<=4*x&&y%2==0)
		cout<<"Yes";
	else
		cout<<"No";
	
	
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

int main() {
    std::vector<long long> prices, max_cand;
    int n;

    std::cin >> n;
    for (int i = 0; i < n; i++) {
        long long in;
        std::cin >> in;
        prices.push_back(in);
    }
    long long min = 1e9+1;
    for (int i = 0; i < n - 1; i++) {
        if (min > prices[i]) {
            min = prices[i];
            long long max = prices[i+1];
            for (int j = i+2; j < n; j++) {
                if (prices[j] > max) {
                    max = prices[j];
                }
            }
            max_cand.push_back(max-prices[i]);
        }
    }
    std::cout << *std::max_element(max_cand.begin(), max_cand.end()) << std::endl;

    return 0;
}


Measured memory_bytes: 4892
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

void topsort(vector<vector<ll> > &adj,vector<bool> &visited,stack<ll> &order,ll src)
{
    visited[src]=1;
    for(auto x:adj[src])
        if(!visited[x])
            topsort(adj,visited,order,x);
    order.push(src);
}

void dfs(vector< vector<ll> > &adj,vector< vector<ll> > &radj,vector<ll> &visited,ll src)
{
    visited[src] = 0;
    foi(0,adj[src].size())
    {
        if (visited[adj[src][i]]==-1)
            dfs(adj,radj,visited,adj[src][i]);
    }
    foi(0,radj[src].size())
    {
        if(visited[radj[src][i]]!=-1)
            visited[src] = max(visited[src],visited[radj[src][i]]+1);
    }
}

int main()
{
    f_io;
    ll n,m;
    cin >> n >> m;
    vector<string> arr(n);
    foi(0,n)
        cin >> arr[i];
    vector<vector<ll> > dp(n,vector<ll> (m));
    dp[0][0] = 1;
    foi(1,m)
    {
        if(arr[0][i]=='.')
            dp[0][i] = 1;
        else
            break;
    }
    foi(1,n)
    {
        if(arr[i][0]=='.')
            dp[i][0] = 1;
        else
            break;
    }
    foi(1,n)
    {
        foj(1,m)
        {
            if(arr[i][j]=='.')
            {
               dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
            }
        }
    }
    cout << dp[n-1][m-1];
    return 0;
}


Measured memory_bytes: 12172
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define int long long
using namespace std;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int MOD = 1e9 + 7;

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

signed main() {
  int N, M; cin >> N >> M;
  string S, T; cin >> S >> T;
  int g = gcd(N, M);
  int i = 0, j = 0;
  while (i < N && j < M) {
    if (S[i] != T[j]) {
      cout << -1 << endl; return 0;
    }
    i += N / g;
    j += M / g;
  }
  cout << N * M / g << endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

bool f(string s) {
	if (s == "ABC")return true;
	if (s.size() <= 3)return false;
	string A = "", B = "", C = "";
	int a = 0, b = 0, c = 0;
	string t = s + "$$";
	rep(i, 0, s.size()) {
		if (t[i] == 'A'&&t[i + 1] == 'B'&&t[i + 2] == 'C') {
			A += "A";
			B += "B";
			C += "C";
			i += 2;
		}
		else {
			A += t[i];
			B += t[i];
			C += t[i];
			if (t[i] == 'A')a++;
			else if (t[i] == 'B')b++;
			else if (t[i] == 'C')c++;
		}
	}
	bool ret = false;
	if (s == A&&s == B&&s == C)return false;
	if (a == 0)ret |= f(A);
	if (b == 0)ret |= f(B);
	if (c == 0)ret |= f(C);
	return ret;
}

signed main() {
	string S; cin >> S;
	if (f(S))cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 46404
B=input()
A=[]
for i in B:
    A.append(i)



for i in ["+","-"]:
    for j in ["+","-"]:
        for k in ["+","-"]:
            if(eval(A[0]+i+A[1]+j+A[2]+k+A[3])==7):
                print(A[0]+i+A[1]+j+A[2]+k+A[3]+"=7")
                exit()

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

#define endl "\n"
#define ll long long int
#define f(i,n) for(ll i=0;i<n;i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define MOD 1000000007

void yes(){
    cout << "YES" << endl;
}

void no(){
    cout << "NO" << endl;
}

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

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


    if(a>=k)
        cout << k << endl;
    else if(a+b>=k)
        cout << a << endl;
    else if(a+b+c>=k)
    {
        ll x = a+b;
        ll y = k-x;

        cout << a-y << endl;
    }

        /*
           ll arr[n];

           f(i,n)
           cin >> arr[i];
        */

    return 0;
}



Measured memory_bytes: 3660
/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
#define endl '\n'
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef queue<int> qii;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
#define all(x) x.begin(),x.end()
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;

void solve(){
    int n;
    cin>>n;
    ll sum=0;
    rep(i,1,n+1){
        if(i%3!=0 and i%5!=0) sum+=i;
    }
    cout<<sum;
}

int main(){ 
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
	 ios::sync_with_stdio(false);
	 int N, K;
	 int ret;
	 while(cin>>N>>K)
	 {
	 	 ret=N%K;
	 	 if(ret!=0) 
			ret=1;
		 cout<<ret<<endl; 
	 }
	 return 0;
}


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

typedef long long ll;

const ll MOD = 1e9+7;

int main() {
    int n; cin >> n;
    vector<ll> t(n), a(n);
    for (int i=0; i<n; ++i) {
        cin >> t[i];
    }
    for (int i=0; i<n; ++i) {
        cin >> a[i];
    }
    vector<bool> ft(n);
    ll cur=t[0];
    ft[0]=true;
    for (int i=1; i<n; ++i) {
        if (t[i]!=cur) {
            ft[i]=true;
            cur=t[i];
        }
    }
    vector<bool> fa(n);
    cur=a[n-1];
    fa[n-1]=true;
    for (int i=n-1; i>=0; --i) {
        if (a[i]!=cur) {
            fa[i]=true;
            cur=a[i];
        }
    }
    ll ans=1;
    for (int i=0; i<n; ++i) {
        if (fa[i] && ft[i]) {
            ans*=(a[i]==t[i]);
        } else if (fa[i]) {
            ans*=(a[i]<=t[i]);
        } else if (ft[i]) {
            ans*=(t[i]<=a[i]);
        } else {
            ans*=min(a[i], t[i]);
            ans%=MOD;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1920
from collections import defaultdict, deque
import sys
import math

sys.setrecursionlimit(100000)

MIN = -10 ** 9
MAX = 10 ** 9 + 7


def main():
    # N = int(input())
    N, M = [int(a) for a in input().split()]
    AB = [
        [int(a) for a in input().split()]
        for _ in range(N)
    ]

    AB = sorted(AB, key=lambda it: it[1])

    ARR = [[] for _ in range(M + 1)]
    for a, b in AB:
        if a > M:
            continue
        ARR[a].append(b)
    # print("ARR", ARR)

    res = 0
    q = []
    for i in range(1, M + 1):
        current = ARR[i]
        if len(current) != 0:
            if len(q) != 0:
                if current[-1] > q[-1]:
                    res += current.pop()
                else:
                    res += q.pop()
            else:
                res += current.pop()
            q = sorted(q + current)
            q = q[-(M - i):]
        else:
            if len(q) != 0:
                res += q.pop()
            else:
                pass
        # q += current
        # q = sorted(q)
        # # print(q)
        # if len(q) != 0:
        #     mm = q.pop()
        #     res += mm
        # q = q[-(M - i):]
    print(res)


if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
    int n, k, i, j, tg, h[100000], s[100000];
    cin>>n>>k;
    for(i=1; i<=n; i++) cin>>h[i];
    s[1]=0; s[2]=abs(h[2]-h[1]);
    s[3]=min(abs(h[1]-h[3]), s[2]+abs(h[2]-h[3]));
    for(i=3; i<=n; i++)
    {
        tg=s[i-1]+abs(h[i-1]-h[i]);
        for(j=i-2; j>=(max(1,i-k)); j--)
        {
            tg=min(s[j]+abs(h[j]-h[i]), tg);
        }
        s[i]=tg;
    }
    cout<<s[n];
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,t;
  cin>>n>>x>>t;
  int sum=x;
  if(sum>=n){
      cout<<t;
      return 0;
  }
  
  for(int i=2;i<=1000;i++){
    int r=x+sum;
    if(r>=n){
      	cout<<(i*t);
      	return 0;
    }
    else{
      sum+=x;
    }
 }
    return 0;
}
  

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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}

long long D, t[41], ans, k;

int main(){
    D = read();
    t[0] = 1;
    for (int i = 1; i < 30; i++)
        t[i] = t[i-1] * 10LL;
    for (int i = 2; i <= 20; i++){
        k = i / 2;
        for (int s = 0; s < (1 << k); s++){
            long long way = (i%2==1 ? 10 : 1), z = D;
            for (int j = 0; j < k; j++){
                long long d = (long long)abs(z)%10LL;
                if (z < 0)
                    d = 10 - d, d %= 10;
                if (s >> j & 1){
                    long long n = 10LL - d;
                    if (j == 0) n--;
                    way *= n;
                    z += d * t[i-2*j-1];
                    z -= d;
                }
                else{
                    long long n = d;
                    if (j == 0) n--;
                    if (n < 0){
                        way = 0;
                        break;
                    }
                    way *= n;
                    z -= (10LL-d) * t[i-2*j-1];
                    z += (10LL-d);
                }
                z /= 10LL;
            }
            if (z == 0) ans += way;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main() {
  int n, w, t, p = 0, s = 0;
  cin >> n >> w;
  for (int i = 0; i < n; ++i) {
    cin >> t;
    if (p + w <= t) {
      s += w;
      p = t;
    } else {
      s += t - p;
      p = t;
    }
  }
  s += w;
  cout << s << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;

const int Amax=1000010;
ll mod=998244353, A[200010], num[Amax]={}, sum[Amax]={};

void fillNum(){
	for(int i=1; i<Amax; ++i){
		num[i]=(num[i]+1)%mod;
		for(int j=1; i*j<Amax; ++j){
			if(j>1){
				(num[i*j] += mod-(num[i]*j)%mod) %= mod;
			}
		}
	}
}

int main() {
	fillNum();
	int N;
	cin >> N;
	for(int i=0; i<N; ++i){
		cin >> A[i];
		++sum[A[i]];
	}
	ll ans=0;
	for(int i=1; i<Amax; ++i){
		ll tsum=0, now=0;
		for(int j=1; i*j<Amax; ++j){
			(now += (tsum*(sum[i*j]*j%mod))%mod) %= mod;
			(now += (((sum[i*j]*(sum[i*j]-1)/2)*j)%mod)*(i*j)%mod) %= mod;
			(tsum += (sum[i*j]*i*j)%mod) %= mod;
		}
		(now *= num[i]) %= mod;
		(ans += now) %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 17408
import itertools
n = int(input())
name = [0]*5
s = []
for i in range(n):
    st = input()
    if st[0] == 'M':
        name[0] += 1
    elif st[0] == 'A':
        name[1] += 1
    elif st[0] == 'R':
        name[2] += 1
    elif st[0] == 'C':
        name[3] += 1
    elif st[0] == 'H':
        name[4] += 1
    s.append(st)

ans = 0
for v in itertools.combinations(name, 3):
    # print(v)
    ans += v[0]*v[1]*v[2]

print(ans)

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

int b[100];
int a[101];

int main(int argc, char const* argv[]) {
  int n;
  cin >> n;

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

  a[1] = b[1];
  a[n] = b[n - 1];
  for (int i = 2; i < n; i++) {
    a[i] = min(b[i - 1], b[i]);
  }

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

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


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

using namespace std;

int main()
{
 	int a,b;
  cin>>a>>b;
  int ret=1;
  int cnt=0;
  while(ret<b)
  {
   	ret+=a-1;
    cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int X;

bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2){
    if (num % i == 0)return false;
  }
  return true;
}

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

  cin >> X;
  while(true) {
    bool flag = IsPrime(X);
    if (flag) {
      cout << X << "\n";
      return 0;
    }
    X++;
  }
  return 0;
}

Measured memory_bytes: 896
S = input()
N = len(S)
left = S[:int((N-1)/2)]
right = S[int((N+3)/2)-1:]

if S != S[::-1]:
  print("No")
  exit()
if left != left[::-1]:
  print("No")
  exit()
if right != right[::-1]:
  print("No")
  exit()
print("Yes")

Measured memory_bytes: 38256