akhauriyash/Code-Regression huggingface dataset:
n = int(input())
#n,m = map(int,input().split())
lst1 = list(map(int,input().split()))
ans = 0

leftmin = 10**9

for i in range(n):
    if leftmin >= lst1[i]:
        ans += 1
    leftmin = min(leftmin,lst1[i])

print(ans)




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

using namespace std;

int a,b,c,i;

int main(){
	scanf("%d%d%d", &a, &b, &c);
	
	for(i = 0; i < 20000000; i++){
		if(a & 1 || b & 1 || c & 1) return 0 * printf("%d\n", i);
		if(a == b && b == c) return 0 * printf("-1\n");
		
		int tmpa = b / 2 + c / 2;
		int tmpb = a / 2 + c / 2;
		int tmpc = a / 2 + b / 2;
		
		a = tmpa;
		b = tmpb;
		c = tmpc;
	}
	
	printf("-1\n");
}


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

int main(){
  string s;
  cin>>s;
  vector<char>vec;
  for(int i=0;i<s.length();i++){
    sort(vec.begin(),vec.end());
    if(!binary_search(vec.begin(),vec.end(),s[i])){
        vec.push_back(s[i]);
    }
  }
  if(vec.size()==2){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int a[n][m];
    int b[m];
    int c[n];
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        cin >> a[i][j];
      }
    }
    for(int k=0;k<m;k++){
      cin >> b[k];
    }
    for(int i=0;i<n;i++){
      // 初期化
      c[i] = 0;
      for(int j=0;j<m;j++){
        c[i] += a[i][j] * b[j];
      }
    }

    for(int l = 0;l<n;l++){
      cout << c[l] << "\n";
    }
    return 0;
}


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

#define int long long
#define pii pair<int, int>
#define pb push_back

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int a, b;
    cin >> a >> b;
    cout << (a * b)/ (__gcd(a, b));

    return 0;
}



Measured memory_bytes: 3596
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

int N, M;
string U[257];

int main() {
  char s[14];
  scanf("%d", &N);
  for (int i=0;i<N;i++) {
    scanf("%s", s);
    U[i] = s;
  }
  scanf("%d", &M);
  bool opened = false;
  for (int i=0;i<M;i++) {
    scanf("%s", s);
    const string* p = find(U, U+N, (string)s);
    if (p && !p->empty()) {
      opened = !opened;
      printf("%s by %s\n", (opened ? "Opened" : "Closed"), s);
    } else {
      printf("Unknown %s\n", s);
    }
  }
  return 0;
}

Measured memory_bytes: 2840
#include <iostream>
#include<cmath>
#include<stack>
#include<algorithm>
using namespace std;
int main(){
stack<int> S;
string s;
while(cin>>s){
    int a,b;
    if(s[0]=='+'){
        a=S.top();S.pop();
        b=S.top();S.pop();
        S.push(a+b);
        
    }else if(s[0]=='*'){
        a=S.top();S.pop();
        b=S.top();S.pop();
        S.push(a*b);
    }else if(s[0]=='-'){
        a=S.top();S.pop();
        b=S.top();S.pop();
        S.push(b-a);
    }else {
        S.push(atoi(s.c_str()));
    }
    
    
    
}
cout<<S.top()<<endl;
    
    
    
    
    
return 0;
}



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

int main() {
  double n,k; cin >> n >> k;
  double ans = 0;
  for (ll i = 1; i <= n; i++) {
    double c = max(ceil(log2(k/i)), (double)0);
    ans += (1 / n) * pow(0.5,c);
  }
  printf("%.12f\n",ans);
}

Measured memory_bytes: 4176
#include <bits/stdc++.h>
#define ll long long int
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)
#define sp(n) setprecision(n)
#define mp make_pair
#define mt make_tuple
#define pi 3.14159265358979323846264
#define MOD 1000000007

using namespace std;
/*
int primeFactors(ll n)  
{  ll f=0;
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        f++;
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            f++; 
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        f++;
        
 return f;        
}  
  
bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}
 
ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = ((C[i - 1][j - 1] + C[i - 1][j]))%MOD;}}}
    return C[n][k];
 }
 
ll gcd(ll a, ll b){if (b == 0)
        return a;return gcd(b, a % b);}
 
ll expmod(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}
//define temp-functions below
 
 
//some definitions and global variables
vector<ll> primes;
void storePrime(ll n){
    fori(n){
        if(isPrime(i+1)&&(n%(i+1)==0)){primes.push_back(i+1);}
    }
}*/


int main(){ //ake cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
string a;cin>>a;
if(a=="ABC") cout<<"ARC";
else cout<<"ABC";  


return 0;}


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

typedef long long ll;
typedef long double ld;
#define double ld
typedef complex<ld> point;
#define F first
#define S second
#define ii pair<int,int>
#define iii pair<int,ii>



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

    int n;
    cin>>n;
    vector<ii> v;
    vector<string> w;
    for(int i=0; i<n; i++)
    {
        int x, y;
        string s;
        cin>>x>>y>>s;
        v.push_back(ii(x, y));
        w.push_back(s);
    }

    auto val = [&](ld x)
    {
        ld lx = 1e9, rx = -1e9, ly = 1e9, ry = -1e9;
        for(int i=0; i<n; i++)
        {
            ld x1 = v[i].F, y1 = v[i].S;
            if(w[i] == "U")
                y1 += x;
            if(w[i] == "D")
                y1 -= x;
            if(w[i] == "R")
                x1 += x;
            if(w[i] == "L")
                x1 -= x;
            lx = min(lx, x1);
            rx = max(rx, x1);
            ly = min(ly, y1);
            ry = max(ry, y1);
        }
        return (rx - lx) * (ry - ly);
    };

    ld l = 0, r = 2e8, ans = 1e18;
    for(int i=0; i<200; i++)
    {
        ld mid1 = l + (r - l) / 3;
        ld val1 = val(mid1);

        ld mid2 = l + 2.0 * (r - l) / 3;
        ld val2 = val(mid2);

        if(val1 < val2)
            r = mid2;
        else
            l = mid1;

        ans = min(ans, min(val1, val2));
    }

    cout<<setprecision(10)<<fixed;
    cout<<ans<<'\n';



    return 0;
}


Measured memory_bytes: 8552
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstring>/*The header <string> and
<string.h> does not contain the useful
function 'memset' and 'memcpy'.*/
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<utility>
#include<algorithm>
#include<functional>
#include<ctime>
#include<cmath>
#include<cstdlib>
#include<cstdio>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	cout<<min(min(a+b,a+c),b+c)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e6+1;
double s[N];
int n,m;ll k;
int a[N],p[N],u[N],tmp[N];
int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
    return x*f;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	m=read();scanf("%lld",&k);
	for(int i=1;i<=n;i++) p[i]=i,u[i]=i;
	for(int i=1;i<=m;i++){
		int x=read();
		swap(p[x],p[x+1]);
	}
	while(k){
		if(k&1){
			for(int i=1;i<=n;i++) tmp[i]=u[p[i]];
			for(int i=1;i<=n;i++) u[i]=tmp[i];
		}	
		for(int i=1;i<=n;i++) tmp[i]=p[p[i]];
		for(int i=1;i<=n;i++) p[i]=tmp[i];
		k>>=1;
	}
	for(int i=1;i<=n;i++) s[i]=a[u[i]]-a[u[i]-1]+s[i-1];
	for(int i=1;i<=n;i++) printf("%.1lf\n",s[i]);
	return 0;
}

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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    string S, T;
    ist >> S >> T;

    /* ------- 計算 ------- */

    bool ans = true;

    if (S.length() + 1 != T.length())
    {
        ans = false;
    }

    for (int i = 0; i < S.length(); i++)
    {
        if (S[i] != T[i])
        {
            ans = false;
        }
    }

    if (ans)
    {
        ost << "Yes" << endl;
        return;
    }
    ost << "No" << endl;
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;
typedef long double ld;
typedef pair<ld, ld> pdd;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = (int)1e5 + 9;
vector<int> T[N];
int dp[N];

void dfs(int u, int par){
  bool can = true;
  for(auto x : T[u]){
    if(x == par) continue;
    dfs(x, u);
    if(dp[x] == 0){
      if(can) can = false;
      else dp[u] ++ ;
    }
    dp[u] += dp[x];
  }
}

int main(){
  fastIO;
  int n;
  cin >> n;
  int u, v;
  for(int i = 1; i < n; i ++ ){
    cin >> u >> v;
    T[u].push_back(v);
    T[v].push_back(u);
  }
  int r = -1;
  for(int i = 0; i < n; i ++ )
    if(T[i].size() >= 3) r = i;
  if(r == -1){
    cout << "1\n";
    return 0;
  }
  dfs(r,-1);
  cout << dp[r] << "\n";
  return 0; 
}

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

int main() {
  int a,b;

  cin >> a >> b;

  int ans = 0;

  for(int i=0; i < 2; i++) {
    if(a>=b) {
      ans += a;
      a--;
    } else {
      ans += b;
      b--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// agc006_a
#include <algorithm>
#include <bitset>
#include <complex>
#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>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  int N, index=0;
  string S,T;
  cin>>N>>S>>T;
  rep (i, N) {
    if (S.substr(N-1-i) == T.substr(0, i+1)) {
      index = i+1;
    }
  }
  cout<<2*N-index<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <unordered_map>
#include <utility>
#include <map>
#include <set>
#include <numeric>
using namespace std;

int main(){
    string s;
    cin >> s;
    int len = s.size();
    
    if(len == 2){
        cout << s << endl;
    }else{
        cout << s[2] << s[1] << s[0] << endl;
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <set>
using namespace std;
multiset<int, greater<int> > a;
long long n, m, b, k, i;
signed main()
{
    cin >> n >> m;
    for (i = 0; i < n; i++) cin >> k, a.insert(k);
    for (i = 0; i < m; i++) a.insert((*a.begin()) / 2), a.erase(a.begin());
    for (auto c : a) b += c;
    cout << b;
}

Measured memory_bytes: 4992
//author Eterna King
#define Hello the_cruel_world!
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<numeric>
#define max(x,y) ((x) > (y) ? (x) : (y))
#define min(x,y) ((x) < (y) ? (x) : (y))
#define lowbit(x) ((x) & (-(x)))
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\1.in", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\1.out", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define outd(x) printf("%d\n", x)
#define outld(x) printf("%lld\n", x)
#define memset0(arr) memset(arr, 0, sizeof(arr))
#define il inline
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 2e5;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
const double eps = 1e-7;
const double Pi = acos(-1.0);
il int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
il ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
il ll quick_pow(ll base, ll index) {
	ll res = 1;
	while (index) {
		if (index & 1)res = res * base % mod;
		base = base * base % mod;
		index >>= 1;
	}
	return res;
}
int n, m, k, tot;
ll f[maxn + 5], coe, res;
int main()
{
	n = read_int(), m = read_int(), k = read_int();
	tot = n * m;
	f[0] = f[1] = 1;
	for (int i = 2; i <= tot; ++i)f[i] = f[i - 1] * i % mod;
	coe = f[tot - 1] * quick_pow(f[k - 1], mod - 2) % mod * quick_pow(f[tot - k], mod - 2) % mod * quick_pow(tot - 1, mod - 2) % mod;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j) {
			ll sum = 0;
			ll a = 1ll * (i - 1) * m, b = 1ll * (n - i) * m;
			sum += a * i - 1ll * m * i * (i - 1) / 2;
			sum %= mod;
			sum += 1ll * (n - i) * (n + i + 1) / 2 % mod * m - b * i;
			sum %= mod;
			res = (res + sum) % mod;
			a = 1ll * (j - 1) * n, b = 1ll * (m - j) * n;
			sum = 0;
			sum += a * j - 1ll * n * j * (j - 1) / 2;
			sum %= mod;
			sum += 1ll * (m - j) * (m + j + 1) / 2 % mod * n - b * j;
			sum %= mod;
			res = (res + sum) % mod;
		}
	res = res * quick_pow(2, mod - 2) % mod;
	res = res * coe % mod;
	res = res * (k - 1) % mod;
	cout << res << endl;
	//system("pause");
	return 0;
}

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

int main() {
  
  string a,b,c;
  cin >> a >> b >> c;
  
  cout << char(a.at(0) - 32) << char(b.at(0) - 32) << char(c.at(0)- 32 ) << endl;
  
  
}



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

using namespace std;



int main(){
    string a,b,c;
    cin>>a>>b>>c;
    if(a.at(a.size()-1)==b.at(0)&&b.at(b.size()-1)==c.at(0)){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }


}


Measured memory_bytes: 256
from bisect import bisect_left
import numpy


def main():
    def isOK(score):
        count = 0
        for a in reversed(A):
            border_score = score - a
            index = bleft(A, border_score)
            count += N - index
            if count >= M:
                return True
        return False

    N, M = map(int, input().split())
    A = sorted(map(int, input().split()))
    ans = 0

    ng = A[-1] + A[-1] + 1
    ok = A[0] + A[0]
    bleft = bisect_left

    while(abs(ok-ng) > 1):
        #print(ok, ng)
        mid = (ok+ng) // 2
        f = isOK(mid)
        if f:
            ok = mid
        else:
            ng = mid
        #print(f)
        #print(ok, ng)
    C = [0,] + A
    C = numpy.cumsum(C[::-1])
    #print(C)
    min_score = float('inf')
    count = 0
    for a in reversed(A):
        index = bleft(A, ok-a)
        if index < N:
            min_score = min(a+A[index], min_score)
            ans += C[N-index-1] + (N-index) * a
            count += N-index

    ans -= min_score * (count-M)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23364
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


fn abs(x: i64) -> i64 {
    if x < 0  {
        return -x;
    } else {
        return x;
    }
}

fn main() {
    let n: usize = read();
    let a: Vec<i64> = read_vec();
    let mut minus: u64 = 0;

    for i in 0..n {
        if a[i] < 0 {
            minus += 1;
        }
    }
    let mut ans: i64 = 0;

    if minus % 2 == 0 {
        for i in 0..n {
            ans += abs(a[i]);
        }
    } else {
        let mut minabs = 10000000000;
        for i in 0..n {
            if abs(a[i]) < minabs {
                minabs = abs(a[i]);
            }

            ans += abs(a[i]);
        }
        ans += -2*minabs;
    }

    println!("{}", ans);

}


Measured memory_bytes: 8444
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

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

    vector<pair<int, int>> pre_suf(N);

    for (int i = 1; i <= N; i++) {
        string si = to_string(i);
        pre_suf[i - 1].first = int(si[0] - '0');
        pre_suf[i - 1].second = int(si[si.length() - 1] - '0');
    }

    int ans = 0;
    map<pair<int, int>, int> c;
    rep(i, N) { c[pre_suf[i]]++; }

    rep(j, 10){
        rep(i, 10){
            ans+=c[{i,j}]*c[{j,i}];
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<pair<int,int>> edge(M);
  
  for(int i=0; i< M; i++){
    cin >> edge.at(i).first >> edge.at(i).second;
  }
  
  vector<int> node(N);
  for(int i=0; i<N; i++){
    node.at(i) = i+1; 
  }
  
  sort(node.begin(), node.end());
  
  int count = 0;
  do{
    bool complete = false;
    for(int i =0; i<N-1; i++){
      int a, b;
      bool exist = false;
      if(node.at(i) < node.at(i+1)){
        a = node.at(i);
        b = node.at(i+1);
      }else{
        a = node.at(i+1);
        b = node.at(i);
      }
      exist = false; //reset
      for(int j = 0; j < M; j++){
        if(edge.at(j).first == a && edge.at(j).second == b){
          exist = true;
        }
      }
      if(!exist) break;
      if(i == N -2) complete = true;
    }
    if(complete) count++;
  }while(next_permutation(node.begin()+1,node.end()));
  cout << count << endl;
}


Measured memory_bytes: 3616
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 5000000;
const int K = 350;
int z[N], dp[N], used[N], in[N];
vector < int > g[N];
void zcalc(vector < int > a){
    int l = 0;
    int r = 0;
    int n = a.size();
    for (int i = 1; i < n; i++){
        if (i <= r){
            z[i] = min(z[i - l], r - i + 1);
        }
        while(i + z[i] < n && a[i + z[i]] == a[z[i]]){
                z[i]++;
            }
        if (i + z[i] - 1 > r){
            l = i;
            r = i + z[i] - 1;
        }
    }
}
void dfs(int v){
    in[v] = 1;
    used[v] = 1;
    for (auto u: g[v]){
        if (used[u]){
            if (in[u]){
                cout << -1;
                exit(0);
            }
            dp[v] = max(dp[v], dp[u] + 1);
        }
        dfs(u);
        dp[v] = max(dp[v], dp[u] + 1);
    }
    in[v] = 0;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    string s;
    string t;
    cin >> s;
    cin >> t;
    string q = s;
    while(s.length() < t.length()){
        s += q;
    }
    int n = s.length();
    int m = t.length();
    vector < int > a;
    for (int i = 0; i < m; i++){
        a.pb(t[i] - 'a');
    }
    a.pb(50);
    for (int i = 0; i < n + n; i++){
        a.pb(s[i % n] - 'a');
    }
    zcalc(a);
    for (int i = m + 1; i < m + n + n + 1; i++){
        if (z[i] == m){
            int u = i - (m + 1);
            int v = i + m - (m + 1);
            if (v >= n) v -=n;
            g[u].pb(v);
        }
    }
    for (int i = 0; i < n; i++){
        if (!used[i]) dfs(i);
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        ans = max(ans, dp[i]);
    }
    cout << ans;
}


Measured memory_bytes: 240824
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let s = read_as_string();

    print!("{}", s);
    if s.chars().last().unwrap() == 's' {
        println!("es");
    } else {
        println!("s");
    }
}


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

using namespace std;
 
int main(){
	
	ios::sync_with_stdio(false);
	
	long long dp[100005];
	
	int a[100005];
	
	int n, i;
	
	cin>>n;
	
	for(i = 1; i <= n; i++){
        
        cin>>a[i];
	}
	for(i = 2; i <= n; i++){
		
		dp[i] = dp[i-1] + abs(a[i] - a[i - 1]);
		
		if(i>2){
			
			dp[i] = min(dp[i], dp[i-2] + abs(a[i] - a[i - 2]));
		}
	}
	cout << dp[n];
	
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
int main(){
	int a,b,x,y,r;
	scanf("%d %d %d %d %d",&a,&b,&x,&y,&r);
	if(a<(x+r) || b<(y+r)){
		printf("No\n");
	}
	else{
		if(r>x || x>a-r){
			printf("No\n");
		}
		else if(r>y || y>b-r){
			printf("No\n");
		}
		else{
			printf("Yes\n");
		}
	}
	return 0 ;
}

Measured memory_bytes: 2696
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=1e5+10;
uli a[mx];
uli lft[mx],rht[mx];
int main(){
  int n,k;
  scanf("%d %d",&n,&k);
  for(int i=0;i<n;i++)
    scanf("%lld",a+i);
  uli sm=0;
  for(int i=n-1;i>=0;i--){
    if(a[i]>0)sm+=a[i];
    rht[i]=sm;
  }
  sm=0;
  for(int i=0;i<n;i++){
    if(a[i]>0)sm+=a[i];
    lft[i]=sm;
  }
  sm=0;
  uli ans=0;
  for(int i=0;i<n;i++){
    sm+=a[i];
    if(i>=k)sm-=a[i-k];
    if(i>=k-1){
      uli bet=max(sm,0ll);
      if(i+1<n)bet+=rht[i+1];
      if(i-k>=0)bet+=lft[i-k];
      ans=max(ans,bet);
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;
ll GCD(ll x, ll y) {if (x % y == 0) return y;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x * y / GCD(x, y);}

int main(){
  string s; cin>>s; ll k; cin>>k;
  rep(i,k){
  if(s[i]!='1'){
  cout<<s[i]<<endl;
    return 0;
  }
  }
   cout<<'1'<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <ext/pb_ds/assoc_container.hpp> 	// Common file
#include <ext/pb_ds/tree_policy.hpp> 		// Including tree_order_statistics_node_update
#include<bits/stdc++.h>
#define int            		long long
#define x              		first
#define y              		second
#define all(aaa)       		(aaa).begin(),(aaa).end()
#define REP(i,sss,eee) 		for(int i=sss;i<=eee;++i)
#define pb             		push_back
#define pii            		pair<int,int>
#define vi             		vector<int>
#define speed          		ios_base::sync_with_stdio(0);cin.tie(0);
#define N              		1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

inline int ex(int a, int b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	int tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
inline int inv(int k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
std::vector<pii> inp;
std::vector<std::vector<int>> g;
std::vector<bool> vis;
std::vector<int> topo;
std::vector<int> fact;
bool path(int a, int b)
{
	if(a==b){return 0;}
	return (((inp[a].x)<=(inp[b].x))&&((inp[a].y)<=(inp[b].y)));
}
int tsrt(int a)
{
	vis[a]=1;
	for(auto it:g[a])
	{
		if(!vis[it]){tsrt(it);}
	}
	topo.pb(a);
	return 0;
}
inline int ways(int l1, int l2)
{
	if(l1<0||l2<0){return 0;}
	return ((fact[l1+l2]*inv(((fact[l1]*fact[l2])%N)))%N);
}
int solve()
{
	int h,w,n;cin>>h>>w>>n;
	g.resize(n);vis.resize(n,0);
	REP(i,0,n-1)
	{
		int r,c;cin>>r>>c;inp.pb({r,c});
	}
	REP(i,0,n-1)
	{
		REP(j,0,n-1)
		{
			if(path(i,j)){g[i].pb(j);}
		}
	}
	for(int i=0;i<n;++i)
	{
		if(!vis[i]){tsrt(i);}
	}
	std::vector<int> f(n,0);
	REP(ix,0,n-1)
	{
		int i=topo[ix];
		f[i]=ways((h-(inp[i].x)),(w-(inp[i].y)));
		REP(p,0,ix-1)
		{
			int j=topo[p];
			f[i]-=(f[j]*ways(inp[j].x-inp[i].x,inp[j].y-inp[i].y));
			f[i]%=N;f[i]+=N;f[i]%=N;
		}
		//cout<<inp[i].x<<" "<<inp[i].y<<" "<<f[i]<<"\n";
	}
	int ans=ways(h-1,w-1);
	REP(i,0,n-1)
	{
		ans-=(f[i]*ways(inp[i].x-1,inp[i].y-1));
		ans%=N;ans+=N;ans%=N;
	}
	cout<<ans<<"\n";
}
signed main(){
	speed
	int tt=1;
	fact.resize(300002,1);
	fact[0]=1;
	REP(i,1,200000)
	{
		fact[i]=(fact[i-1]*i)%N;
	}
	//cin>>tt;
	while(tt--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 49476
#include<bits/stdc++.h>
#define N 1123
#define endl '\n'

using namespace std;

int v[N], ans, n, k;

int main() {
    ios_base::sync_with_stdio(0);

    cin >> n >> k;

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

    sort(v, v + n);

    for(int i=0; i < k; ++i) {
        ans += v[i];
    }
    cout << ans << endl;

    return 0;

}


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

#define REP(i,n) for(long long i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(long long i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9


int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if(abs(x-a) < abs(x-b)){
    cout << "A" << endl;
  }
  else{
    cout << "B" << endl;
  }

  

  return 0;
}


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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

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

const int INF = 1000000007;
const ll MOD = 1000000007;

ll dist(pll a, pll b)
{
    return abs(a.f - b.f) + abs(a.s - b.s);
}

void solve_test()
{
    int n;
    cin >> n;
    ll mx = -2e9, mn = 2e9;
    ll mx2 = -2e9, mn2 = 2e9;
    vector<pll> pts;

    for(int i=0; i<n; i++)
    {
        ll x, y;
        cin >> x >> y;
        mx = max(mx, x+y);
        mn = min(mn, x+y);
        mx2 = max(mx2, x-y);
        mn2 = min(mn2, x-y);
        pts.PB({x, y});
    }
    pll p[4];
    for(int i=0; i<n; i++)
    {
        if(pts[i].f + pts[i].s == mx)
        {
            p[0] = pts[i];
        }
        if(pts[i].f + pts[i].s == mn)
        {
            p[1] = pts[i];
        }
        if(pts[i].f - pts[i].s == mx2)
        {
            p[2] = pts[i];
        }
        if(pts[i].f - pts[i].s == mn2)
        {
            p[3] = pts[i];
        }
    }
//    what_is(p[0].f);
//    what_is(p[0].s);
//    what_is(p[1].f);
//    what_is(p[1].s);
//    what_is(p[2].f);
//    what_is(p[2].s);
//    what_is(p[3].f);
//    what_is(p[3].s);

    cout << max(dist(p[0], p[1]), dist(p[2], p[3]));
}

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int tests;
    tests = 1;
    //cin >> tests;
    while(tests--)
    {
        solve_test();
    }
    return 0;
}


Measured memory_bytes: 7388
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-6
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 110000;

string st;
int cnt;

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> st;
	for (int i = 0; i < st.size(); i++)
	{
		if (i == 0 || st[i] != st[i - 1])
			++cnt;
	}
	cout << cnt - 1<< endl;

	cin.get(); cin.get();
	return 0;
}

Measured memory_bytes: 1020
use std::collections::HashMap;
fn main() {
    let mut buf = String::new();
    let _ = std::io::stdin().read_line(&mut buf).ok();
    let n:usize = buf.trim().parse().unwrap();
    let mut map = HashMap::new();
    for _ in 0..n {
        let mut buf = String::new();
        let _ = std::io::stdin().read_line(&mut buf).ok();
        let mut buf = buf.split_whitespace();
        let inst: &str = buf.next().unwrap();
        let op  = buf.next().unwrap().to_string();
        if inst == "insert" {
            map.insert(op, 0);
        } else if inst == "find" {
            if map.contains_key(&op) {
                println!("yes");
            } else {
                println!("no");
            }
        }
    }
}



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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

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

int main(){
  ll A, B;
  cin >> A >> B;
  ll G = gcd(A, B);
  if(G == 1){
    cout << 1 << endl;
    return 0;
  }
  // cout << "hello" << endl;
  // vector<bool> sosu(G+2, false);
  // cout << "good bye" << endl;
  ll cnt = 1;
  // for(ll i = 2; i <= G+1; i++){
  //   if(sosu[i]) continue;
  //   if(G % i == 0) cnt++;
  //   for(ll j = 2; j*i <= G; j++){
  //     sosu[i*j] = true;
  //   }
  // }
  ll g = G, x = 2;
  while(g != 1 && x*x <= G){
    if(g % x == 0){
      cnt++;
    }
    while(g % x == 0){
      g /= x;
    }
    x++;
  }
  if(g != 1){
    cnt++;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define l(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5]) cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

const int INF = 1e9;

struct edge {
	int A, B, D, E;
};

struct node {
	int v;
	int used;
	int cost;
	bool operator<(const node& that) const {
		return cost > that.cost;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N, M, L;
	while (cin >> N >> M >> L, N | M | L) {
		vector<vector<edge>> G(N);
		for (int i = 0; i < M; i++) {
			int A, B, D, E;
			cin >> A >> B >> D >> E; A--, B--;
			G[A].push_back((edge){ A, B, D, E });
			G[B].push_back((edge){ B, A, D, E });
		}
		vector<vector<int>> dp(N, vector<int>(L + 1, INF));
		priority_queue<node> pq;
		pq.push((node) { 0, 0, 0 });
		while (!pq.empty()) {
			auto p = pq.top(); pq.pop();
			int v = p.v, use = p.used, cost = p.cost;
			if (dp[v][use] != INF) continue;
			dp[v][use] = cost;
			for (auto& e : G[v]) {
				if (dp[e.B][use] == INF) {
					pq.push((node) { e.B, use, cost + e.E });
				}
				if (use + e.D <= L && dp[e.B][use + e.D] == INF) {
					pq.push((node) { e.B, use + e.D, cost });
				}
			}
		}
		cout << *min_element(dp[N - 1].begin(), dp[N - 1].end()) << endl;
	}
	return 0;
}



Measured memory_bytes: 7744
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < (up); ++i)
#define repp(i, up) for (ll i = 0; i <= (up); ++i)
#define rrep(i, lo, up) for (ll i = (lo); i < (up); ++i)
#define rrepp(i, lo, up) for (ll i = (lo); i <= (up); ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))
#define feach(it, vec) for (auto it = (vec).begin(); it != (vec).end(); ++it)


ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


#define VEC_MAX(v) max(max((v)[0], (v)[1]), max((v)[2], (v)[3]))

int main()
{
    ll r, c, k;
    cin >> r >> c >> k;
    vector<vector<ll>> m(r);
    rep(i, r) {
        m[i].resize(c, 0);
    }
    rep(i, k) {
        ll rr, cc, vv;
        cin >> rr >> cc >> vv; --rr; --cc;
        m[rr][cc] = vv;
    }
    vector<vector<vector<ll>>> work(r);
    rep(i, r) {
        work[i].resize(c);
        rep(j, c) {
            work[i][j].resize(4, 0);
        }
    }
    if (m[0][0] > 0) {
        work[0][0][1] = m[0][0];
    }
    rrep(j, 1, c) {
        work[0][j][0] = work[0][j - 1][0];
        rrep(l, 1, 4) {
            if (m[0][j] > 0) {
                work[0][j][l] = max(work[0][j - 1][l], work[0][j - 1][l - 1] + m[0][j]);
            } else {
                work[0][j][l] = work[0][j - 1][l];
            }
        }
    }
    rrep(i, 1, r) {
        if (m[i][0] > 0) {
            work[i][0][1] = m[i][0] + VEC_MAX(work[i - 1][0]);
        }
        work[i][0][0] = VEC_MAX(work[i - 1][0]);
        rrep(j, 1, c) {
            work[i][j][0] = max(work[i][j - 1][0], VEC_MAX(work[i - 1][j]));
            rrep(l, 1, 4) {
                if (m[i][j] > 0) {
                    work[i][j][l] = max(work[i][j - 1][l], work[i][j - 1][l - 1] + m[i][j]);
                } else {
                    work[i][j][l] = work[i][j - 1][l];
                }
            }
            if (m[i][j] > 0) {
                work[i][j][1] = max(work[i][j][1], VEC_MAX(work[i - 1][j]) + m[i][j]);
            }
        }
    }
    cout << VEC_MAX(work[r - 1][c - 1]) << endl;
    return 0;
}


Measured memory_bytes: 706348
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
  
int n,k;
vector<int> d;
vector<vector<int>> a;

void input(){
  cin >> n >>k;
  d.resize(k);
  a.resize(k , vector<int>());
  for(int i=0;i<k;i++){
     cin >> d[i];
     a[i].resize(d[i]);
     for(int j=0;j<d[i];j++){
       cin >> a[i][j];
     }
  }
}

void solve(){
  int ans=0;
  for(int i=1;i<=n;i++){
    bool have = false;
    for(auto v:a){
      for(auto p:v){
        if(p==i) have = true;
      }
    }
    if(!have) ans++;
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 3656
#include <stdio.h>
int main(){
    // Your code here!
    int S = 0;
    int h = 0;
    int m = 0;
    int s = 0;
    scanf("%d",&S);
    h = S/3600;
    m = (S - 3600*h)/60;
    s = S - 3600*h - 60*m;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


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

string s,t="CODEFESTIVAL2016";
int countx=0;

int main()
{
    cin>>s;
    for (int i=0; i<s.length(); i++)
        if(s[i]!=t[i])
            countx++;
    printf("%d\n",countx);        
    return 0;
}

Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    ll res = 0;
    FOR(i,1,n)
        if (i % 3 == 0 || i % 5 == 0) continue;
        else res += i;
    cout << res;
    return 0;
}


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

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a,b) << " " << max(0, a+b-n) << endl;
}


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

int main(){
  int N,K;cin>>N>>K;
  string S;cin>>S;
  char f=S.at(K-1);
  if(f=='A') S.at(K-1)='a';
  else if(f=='B') S.at(K-1)='b';
  else S.at(K-1)='c';
  cout<<S<<endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	ll Q;
	cin >> Q;
	ll sumb = 0;
	ll gradl = 0;
	ll gradr = 0;
	priority_queue<ll> pql;
	priority_queue<ll, vector<ll>, greater<ll>> pqr;


	REP(i, Q) {
		ll kind;
		cin >> kind;
		if (kind == 1) {
			ll a, b;
			cin >> a >> b;

			// add
			if (pqr.empty() || a < pqr.top()) {
				pql.push(a);
				gradl += a;
			}
			else {
				pqr.push(a);
				gradr += a;
			}
			// save
			while (pql.size() >= pqr.size() + 2) {
				ll now = pql.top(); pql.pop();
				gradl -= now;

				pqr.push(now);
				gradr += now;
			}
			while (pql.size() + 2 <= pqr.size()) {
				ll now = pqr.top(); pqr.pop();
				gradr -= now;

				pql.push(now);
				gradl += now;
			}

			sumb += b;
		}
		else {
			ll res1, res2;
			if (pql.size() == pqr.size()) {
				res1 = pql.top();
			}
			else if (pql.size() == pqr.size() + 1) {
				res1 = pql.top();
			}
			else {
				res1 = pqr.top();
			}
			res2 = res1 * pql.size() - gradl;
			res2 += gradr - res1 * pqr.size();
			cout << res1 << " " << res2 + sumb << endl;
		}
	}
	return 0;
}


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

#include <math.h>
#include <stdlib.h>


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

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<int> a(100050, 0);
    for(int i = 0; i < n; i++){
        int x; cin >> x;
        if(x!=0) a[x-1]++; 
        a[x]++; 
        a[x+1]++;
    }
    int ans = 0;
    for(int i =0; i < 100050; i++) ans = max(ans, a[i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int a[10000];
	int b[10000];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int p, m, x;
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> p >> x;
		int cnt = 0;
		for (int i2 = 0; i2 < n; i2++) {
			if (i2+1 != p) {
				cnt += a[i2];
			}
			else {
				cnt += x;
			}
		}
		cout << cnt << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> f,b;
int n,k,c;
string s;
int main()
{
	cin>>n>>k>>c>>s;
	int last=-1e9;
	for(int i=1;i<=n;i++)
	{
		if(s[i-1]=='o'&&last+c<i)
		{
			last=i;
			f.push_back(i);
		}
		if(f.size()==k)
			break;
	}
	int stock=1e9;
	for(int i=n;i>=1;i--)
	{
		if(s[i-1]=='o'&&stock>=c)
		{
			b.push_back(i);
			stock=0; 
		}	
		else
			stock++;
		if(b.size()==k)
			break;
	}
	reverse(b.begin(),b.end());
	for(int i=0;i<k;i++)
		if(b[i]==f[i])
			cout<<f[i]<<endl;
	return 0;
}

Measured memory_bytes: 3448
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
const int mo = 1e9 + 7;
int isnp[1005], p[1005], num, n;

ll calc(int n, ll d) {
	ll res = 0;
	for (; n; n /= d) res += n / d;
	return res;
}

int main() {
	scanf("%d", &n);
	for (int  i = 2; i <= n; ++i) {
		if (!isnp[i]) p[++num] = i;
		for (int j = i + i; j <= n; j += i) isnp[j] = 1;
	} ll ans = 1;
	for (int i = 1; i <= num && p[i] <= n; ++i) (ans *= (calc(n, p[i]) + 1)) %= mo;
	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;

int main(){
	int n,m,a,b,x,breakflag;
	cin >> n >>m;
	int flag[100001]={};
	vector<int> root,root2;
	vector<int> v[100001];
	for(int i=0;i<m;i++){
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for(int i=0;i<100001;i++){
		v[i].push_back(-1);
	}
	flag[1]=1;
	x=1;
	breakflag=0;
	root.push_back(1);
	while(1){
		for(int i=0;i<v[x].size();i++){
			if(v[x][i]==-1){
				breakflag=1;
				break;
			}
			if(flag[v[x][i]]!=1){
				flag[v[x][i]]=1;
				root.push_back(v[x][i]);
				x = v[x][i];
				break;
			}
		}
		if(breakflag==1)break;
	}
	x=1;
	breakflag=0;
	while(1){
		for(int i=0;i<v[x].size();i++){
			if(v[x][i]==-1){
				breakflag=1;
				break;
			}
			if(flag[v[x][i]]!=1){
				flag[v[x][i]]=1;
				root2.push_back(v[x][i]);
				x = v[x][i];
				break;
			}
		}
		if(breakflag==1)break;
	}
	cout << root.size() + root2.size() << endl;
	for(int i=0;i<root2.size();i++){
		cout << root2[root2.size()-1-i] <<" ";
	}
	for(int i=0;i<root.size();i++){
		cout << root[i] <<" ";
	}
	cout <<endl;
	return 0;
}

Measured memory_bytes: 7160
package main

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

const MAX_ELEM = 10000

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	elems, err := nextInts(n, sc)
	if err != nil {
		panic(err)
	}
	sorted := countingSort(elems)
	printlnInts(sorted)
}

func countingSort(as []int) []int {
	cs := make([]int, MAX_ELEM+1)
	for _, v := range as {
		cs[v] = cs[v] + 1
	}
	for i := 1; i < len(cs); i++ {
		cs[i] = cs[i] + cs[i-1]
	}
	bs := make([]int, len(as))
	for i := 0; i < len(as); i++ {
		bs[cs[as[i]]-1] = as[i]
		cs[as[i]] = cs[as[i]] - 1
	}
	return bs
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

func nextInts(n int, sc *bufio.Scanner) ([]int, error) {
	rs := make([]int, n)
	for i, _ := range rs {
		x, err := nextInt(sc)
		if err != nil {
			return nil, err
		}
		rs[i] = x
	}
	return rs, nil
}

func printlnInts(xs []int) {
	rs := make([]string, len(xs))
	for i, _ := range rs {
		rs[i] = strconv.Itoa(xs[i])
	}
	fmt.Println(strings.Join(rs, " "))
}



Measured memory_bytes: 83996
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#define INF (int)1e9
using namespace std;

int main(void){
  int n,m;
  int a[55],b[55],c[55],d[55];

  cin>>n>>m;
  int i,j;
  for(i=1;i<=n;i++){
    cin>>a[i]>>b[i];
  }
  for(i=1;i<=m;i++){
    cin>>c[i]>>d[i];
  }

  int t,maxd;
  for(i=1;i<=n;i++){
    t=1;
    maxd=INF;
    for(j=1;j<=m;j++){
      if(abs(a[i]-c[j])+abs(b[i]-d[j])<maxd){
        t=j;
        maxd=abs(a[i]-c[j])+abs(b[i]-d[j]);
      }
    }
    cout<<t<<endl;
  }
  return 0;
}

Measured memory_bytes: 256