akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    string s;cin>>s;
    while(s!="-"){
        ll n=s.size();
        ll m;cin>>m;
        ll sum=0;
        rep(i,m){
            ll h;cin>>h;
            sum+=h;
        }
        sum%=n;
        cout<<s.substr(sum)<<s.substr(0,sum)<<endl;
        cin>>s;
    }
}

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



Measured memory_bytes: 3224
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int 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;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}

ll calc(int x, int y, int h, int w) {
	int a = h - x, b = w - y;
	ll res = mult(fac[a + b], finv[a]);
	res = mult(res, finv[b]);
	return res;
}

void solve() {
	int H, W, A, B; cin >> H >> W >> A >> B;
	ll ans = 0;
	ll cum = 0;
	COMinit();
	for (int x = H - A - 1; x >= 0; x--) {
		int y = B;
		ll res = calc(0, 0, x, y);
		res = mult(res, sub(calc(x, y, H - 1, W - 1), cum));
		cum = calc(x, y, H - 1, W - 1);
		cum %= MOD;
		ans += res;
		ans %= MOD;
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 4992
//Date:06-01-17
 
#include<stdio.h>
#include<string.h>
#include<assert.h>
#include<stdlib.h>
#include<stdbool.h>
#include<float.h>
#include<math.h>
#include<ctype.h>
#include<limits.h>
#include<time.h>
#define ll long long
#define For(i,n)	for(i=0;i<n;i++)
#define rep(i ,a ,b)	for(i=(a);i<=(b);i++)
#define mset(a ,value)	memset(a ,value ,sizeof(a))
#define s(a)	scanf("%d" ,&a);
#define ls(a)	scanf("%ld" ,&a)
#define reg(i)	register int i
#define infinite INT_MAX
#define MAX 100005
#define NIL -1
int min(int a,int b){	return (a<b?a:b);	}
int max(int a,int b){	return (a>b?a:b);	}
main(){
	int sx ,sy ,tx ,ty;
	scanf("%d%d%d%d" ,&sx ,&sy ,&tx ,&ty);
	int x=sx ,y = sy;
	while(y!=ty){	printf("U");	y++;	}
	while(x!=tx){	printf("R");	x++;	}
	while(y!=sy){	printf("D");	y--;	}
	while(x!=sx){	printf("L");	x--;	}
	printf("L");	x--;
	while(y!=(ty+1)){	printf("U");	y++;	}
	while(x!=tx){	printf("R");	x++;	}
	printf("D");	y--;
	printf("R");	x++;
	while(y!=(sy-1)){	printf("D");	y--;}
	while(x!=sx){	printf("L");	x--;	}
	printf("U");	y++;
	assert((x==sx)&&(y==sy));
	return 0;
}

Measured memory_bytes: 128
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Tree = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];

	Vec pn;
	pn.pb(2);

	REP(num, 3, 1e4){
		bool flg = true;
		for(ll i : pn){
			if(num%i == 0){
				flg = false;
				break;
			}
			if(i*i > num) break;
		}
		if(flg) pn.pb(num);
	}

	unordered_map<ll, ll> ump;
 
	rep(i, n){
		ll b = a[i];
		for(ll j : pn){
			if(j*j > b){
				if(b != 1) chmax(ump[b], 1LL);
				break;
			}
			if(b%j) continue;
			ll cnt = 0;
			while(b%j == 0){
				cnt++;
				b /= j;
			}
			chmax(ump[j], cnt);
		}
	}

	ll ans = 0;
	rep(i, n){
		ll b = a[i], sum = 1;
		for(P j : ump){
			ll cnt = 0;
			while(b%j.fs == 0){
				cnt++;
				b /= j.fs;
			}
			rep(k, j.sc-cnt){
				sum *= j.fs;
				sum %= MOD;
			}
		}
		ans += sum;
		ans %= MOD;
	}
	co(ans);

	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];

    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    rep(i,n) {
        if(s[i] == "AC") ac++;
        if(s[i] == "WA") wa++;
        if(s[i] == "TLE") tle++;
        if(s[i] == "RE") re++;
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;


}

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

int main(){
    std::string s;
    std::cin >> s;

    std::string ans = "No";
    if(0 != s.size() % 2){
        std::cout << ans << std::endl;
        return 0;
    }

    bool flg = true;
    int i = 0;
    while(flg && i < s.size()){
        if(0 == i % 2 && 'h' != s.at(i)){
            flg = false;
        }else if(1 == i % 2 && 'i' != s.at(i)){
            flg = false;
        }
        ++i;
    }

    if(flg){
        ans = "Yes";
    }

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

Measured memory_bytes: 888
from sys import stdin
import numpy as np
# import math
# import random
# import fractions
# import sys
# sys.setrecursionlimit(100000)
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]
N, M = [int(x) for x in stdin.readline().rstrip().split()]
K = []
S=[]
for i in range(M):
  A = [int(x) for x in stdin.readline().rstrip().split()]
  K.append(A[0])
  S.append(A[1:])
P = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
for i in range(2**N):
  bi = bin(1024+i)
  # print(bi)
  arr = [int(s=="1") for s in bi[13-N:]]
  # print(arr)
  Frag = True
  for j in range(M):
    sarr = S[j]
    on_sw = sum([arr[sidx-1] for sidx in sarr])
    if on_sw%2!=P[j]:
      Frag=False
      # print("x", sarr)
      break
  if Frag:
    # print(i, arr)
    ans+=1
print(ans)

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

using namespace std;

using Weight=int;
struct Edge{
    int src,dst;
    Weight weight;
    Edge(int src,int dst,Weight weight):
    src(src),dst(dst),weight(weight){}
};

auto operator < (const Edge &e,const Edge &f){
    if(e.weight!=f.weight)return e.weight>f.weight;
    else if(e.src!=f.src)return e.src<f.src;
    else return e.dst<f.dst;
}

using Edges=vector<Edge>;
using Graph=vector<Edges>;

template<typename T>
struct UnionFind{
    vector<T>data;
    UnionFind(T n):data(n,-1){}
    bool unite(T x,T y){
        x=root(x);y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];data[y]=x;
        }
        return x!=y;
    }
    T root(T x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    bool same(T x,T y){
        return root(x)==root(y);
    }
    T size(T x){
        return -data[root(x)];
    }
};

pair<Weight,Edges>kruskal(const Graph &g,int x,const vector<int>&h,UnionFind<int> &uf){
    int n=g.size();
    priority_queue<Edge>q;
    for(int i=0;i<n;++i){
        for(auto e:g[i]){
            if(i<e.dst && h[e.dst] > x && h[e.src] > x)q.push(e);
        }
    }
    Weight total=0;
    Edges forest;
    while(forest.size()<n-1 && !q.empty()){
        Edge e=q.top();q.pop();
        if(uf.unite(e.src,e.dst)){
            forest.push_back(e);
            total+=e.weight;
        }
    }
    return pair<Weight, Edges>(total,forest);
}

bool isrenketu(const Graph &g,int x,const vector<int>&h){
    int n=g.size();
    UnionFind<int> uf(n);
    for(int i=0;i<n;++i){
        if(h[i]<=x)continue;
        for(auto e:g[i]){
            if(h[e.dst]<=x)continue;
            uf.unite(i,e.dst);
        }
    }
    int k,flag=1;
    for(int i=0;i<n;++i){
        if(h[i]<=x)continue;
        if(flag){
            k=uf.root(i);
            flag=0;
        }
        if(k!=uf.root(i))return 0;
    }
    return 1;
}

int main(){
    int v,e;
    while (cin >> v >> e, v)
    {
        UnionFind<int> uf(v);
        vector<int> h(v);
        set<int> st;
        for (int i = 0; i < v; ++i)
        {
            cin >> h[i];
            st.insert(h[i]);
        }
        Graph g(v);
        for (int i = 0; i < e; ++i)
        {
            int s, t, w;
            cin >> s >> t >> w;
            --s;
            --t;
            g[s].emplace_back(s, t, w);
            g[t].emplace_back(t, s, w);
        }
        int end = 0;
        vector<int> ve;
        st.insert(0);
        for (auto x : st)
        {
            if (!isrenketu(g, x, h))
                break;
            ve.push_back(x);
        }
        int ans = 0;
        for (int i = ve.size() - 1; i >= 0; --i)
        {
            ans += kruskal(g, ve[i], h, uf).first;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4132
#!/usr/bin/env python3
from collections import Counter
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, a: "List[int]"):
    ctr = Counter(a)
    print(sum(nn if n > nn else nn - n for n, nn in ctr.items()))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24236
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
typedef long long ll;
const int N = 105 , Mod = 1e9 + 7 , G = 3 , INF = 0x3f3f3f3f;
double PI = acos(-1);

struct Virt{
    double x , y;
    Virt(double _x = 0.0 , double _y = 0.0):x(_x) , y(_y){}
};

Virt operator + (Virt x , Virt y){return Virt(x.x + y.x , x.y + y.y);}
Virt operator - (Virt x , Virt y){return Virt(x.x - y.x , x.y - y.y);}
Virt operator * (Virt x , Virt y){return Virt(x.x * y.x - x.y * y.y , x.x * y.y + x.y * y.x);}

int read(){
	int x = 0 , f = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-') f = -1 ; ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}

ll f[N][N] , c[N][N];

int main(){
	int n = read();
	for(int i = 0 ; i <= n ; i++){
		c[i][0] = 1;
		for(int j = 1 ; j <= i ; j++)
			c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % Mod;
	}
	f[1][n] = f[1][n - 1] = 1;
	for(int i = 1 ; i <= n ; i++)
		for(int j = -i ; j <= i ; j++)
			if(f[i][j + n])
				for(int s = max(1 , abs(j)) ; s <= n - i ; s++)
					if((j + s) % 2 == 0)
					for(int ss = 0 ; ss <= s ; ss++){
						int val = (j - s >> 1) + ss;
						if(val < -n || val > n) continue;
						f[i + s][val + n] = (f[i + s][val + n] + c[i + s][s] * f[i][j + n] % Mod * c[s][ss]) % Mod;
					}
	printf("%lld\n",f[n][n]);
	return 0;
}

Measured memory_bytes: 384
from itertools import accumulate
while 1:
    N = int(input())
    if N==0:
        break
    imos = [0]*24*60*60
    for _ in range(N):
        s, e = input().split()
        S = list(map(int, s.split(':')))
        E = list(map(int, e.split(':')))
        imos[S[0]*60*60+S[1]*60+S[2]] += 1
        imos[E[0]*60*60+E[1]*60+E[2]] -= 1
    IMOS = list(accumulate(imos))
    print(max(IMOS))



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

int main() {
    int num;
    int ans = 0;
    cin >> num;
    vector<int> list(num);
    for (int i = 0; i < num; i++) {
        cin >> list.at(i);
    }
    rep(i, num) {
        rep(j, num) {
            rep(k, num) {
                //重複無し
                if (i < j && j < k) {
                    if (list.at(i) == list.at(j)) continue;
                    if (list.at(i) == list.at(k)) continue;
                    if (list.at(j) == list.at(k)) continue;
                    if ((long long)list.at(i) + list.at(j) + list.at(k) <=
                        max({ list.at(i), list.at(j), list.at(k) }) * 2) {
                        continue;
                    }
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(){
    ll n,m,sk;
    cin >> n >> m;
    int k;
    vector<ll>p(m);
    vector<vector<int>>s(m);

    rep(i,m){
        cin >> k;
        rep(j,k){
            cin >> sk;
            s[i].push_back(sk-1);
        }
    }
    rep(i,m)cin >> p[i];

    int ans = 0;
    rep(bit,1<<n){
        bool ok = true;
        rep(i,m){
            int count = 0;
            for(int j:s[i]){
                if(bit&1<<j)count++;
            }
            if(count%2!=p[i]){
                ok = false;
                break;
            }
        }
        if(ok)ans++;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3644
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

signed main() {
   tezz
   
   int n,a,b;
   cin >> n >> a >> b;
   int x=(a+b);
   int ans=(n/x)*a;
   x=n%(a+b);
   ans+=min(x,a);
   cout << ans << endl;
  
   return 0;
}




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

string str;

bool solve()
{
	for(int i = 0; i < 3; i++)
	{
		if(str[i] == str[i+1]) return false;
	}
	return true;
}

int main()
{
	getline(cin, str);
	if(solve()) printf("Good\n");
	else printf("Bad\n");
}

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

void fnInput(vector<int>& rvnProblm)
{
  int nProblmSiz;
  cin >> nProblmSiz;
  rvnProblm.resize(nProblmSiz);

  for (int& rnProblm : rvnProblm)
    cin >> rnProblm;
}
  
int fnDevProblmCnt(const vector<int>& cnrvnProblm)
{
  vector<int> vnSrtProblm(cnrvnProblm);
  sort(begin(vnSrtProblm), end(vnSrtProblm));

  int n = vnSrtProblm.size() / 2;
  return (vnSrtProblm[n] - vnSrtProblm[n - 1]);
}
  
int main()
{
  vector<int> vnProblm;

  fnInput(vnProblm);
  cout << fnDevProblmCnt(vnProblm) << endl;

  return 0;
}

Measured memory_bytes: 1024
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    A=LI()
    A=tuple(sorted(A))
    if A==(5,5,7):
        print("YES")
    else:
        print("NO")
if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
/*author @sushil*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sushil ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test() long long t;cin>>t;while(t--)
using namespace std;
int main()
{
ll a,b,c;
cin>>a>>b>>c;
swap(a,b);
swap(a,c);
cout<<a<<" "<<b<<" "<<c;	

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int n, a, b, c, d;
    string s;
    cin >>  n >> a >> b >> c >> d >> s;
    //a--; b--; c--; d--;
    int i = a;
    s = '#' + s + '#';
    if(c < d) {
        for(int i = a; i <= d; i++) {
            if(s[i] == s[i-1] && s[i] == '#') {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    else {
        for(int i = a; i <= c; i++) {
            if(s[i] == s[i-1] && s[i] == '#') {
                cout << "No" << endl;
                return 0;  
            }
        }
        int flag = 0;
        for(int i = b; i <= d; i++) {
            if(s[i] == '.' && s[i-1] == '.' && s[i+1] == '.') {
                flag = 1;
                break;
            }
        }
        if(flag == 1) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;

}

Measured memory_bytes: 772
#include<stdio.h>
int main(){
	int low[30];
	int a,b,c,d,n,w;
	for(a=0;a<31;a++){
		low[a]=a+1;
	}
	scanf("%d",&w);
	scanf("%d",&n);
	for(a=0;a<n;a++){
		scanf("%d,%d",&b,&c);
		d=low[b-1];
		low[b-1]=low[c-1];
		low[c-1]=d;
	}
	for(a=0;a<w;a++){
		printf("%d\n",low[a]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int n , b[101] , a[101] = {};
    bool f = true;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> b[i];
        if(b[i] > i + 1){
            f = false;
        }
    }
    if(f){
        for(int i = 0; i < n; i++){
            for(int j = 99; j >= b[i] - 1; j--){
                a[j + 1] = a[j];
            }
 
            a[b[i] - 1] = b[i];
        }
 
        for(int i = 0; a[i] != 0; i++){
            cout << a[i] << endl;;
        }
    }
    else{
        cout << -1;
    }
    return (0);
}


Measured memory_bytes: 3604
#include <stdio.h>
#define RIGHT 0
#define DOWN 1
#define LEFT 2
#define UP 3

int main(void){
  char xy[9][6];
  int i, dir = RIGHT, px = 0, py = 0;

  for(i = 0; i < 9; i++){
    scanf("%s", xy[i]);
  }

  do{
    switch(dir){
    case RIGHT:
      if(py > 0 && xy[py*2-1][px] == '1'){
	dir = UP;
      }else if(px < 4 && xy[py*2][px] == '1'){
	dir = RIGHT;
      }else if(py < 4 && xy[py*2+1][px] == '1'){
	dir = DOWN;
      }else{
	dir = LEFT;
      }
      break;
    case DOWN:
      if(px < 4 && xy[py*2][px] == '1'){
	dir = RIGHT;
      }else if(py < 4 && xy[py*2+1][px] == '1'){
	dir = DOWN;
      }else if(px > 0 && xy[py*2][px-1] == '1'){
	dir = LEFT;
      }else{
	dir = UP;
      }
      break;
    case LEFT:
      if(py < 4 && xy[py*2+1][px] == '1'){
	dir = DOWN;
      }else if(px > 0 && xy[py*2][px-1] == '1'){
	dir = LEFT;
      }else if(py > 0 && xy[py*2-1][px] == '1'){
	dir = UP;
      }else{
	dir = RIGHT;
      }
      break;
    case UP:
      if(px > 0 && xy[py*2][px-1] == '1'){
	dir = LEFT;
      }else if(py > 0 && xy[py*2-1][px] == '1'){
	dir = UP;
      }else if(px < 4 && xy[py*2][px] == '1'){
	dir = RIGHT;
      }else{
	dir = DOWN;
      }
      break;
    }
    
    switch(dir){
    case RIGHT:
      px++;
      printf("R");
      break;
    case DOWN:
      py++;
      printf("D");
      break;
    case LEFT:
      px--;
      printf("L");
      break;
    case UP:
      py--;
      printf("U");
      break;
    }
  }while(!(px == 0 && py == 0));

  printf("\n");
  return 0;
}

Measured memory_bytes: 524
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        # 根への距離を管理
        self.weight = [0] * (n + 1)

    # 検索
    def find(self, x):  # xの親を返す
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            # 親の値を更新(アルゴリズムの高速化)
            self.par[x] = y
            return y  # 親

    # 併合
    # (xからyへの重みがw) = (y - x = W)
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # 既に同集合の場合
        if rx == ry:
            if self.diff(x, y) != w:
                print("No")
                exit()
        # 木の高さで処理を変えるのは高速化(木を低くする)のため
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w + self.weight[x] - self.weight[y]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]

    def show(self):
        for i in range(1, n + 1):
            print("node:{} par:{} w:{}".format(i, union.par[i], union.weight[i]))


n, m = [int(i) for i in input().split()]
l = [0 for i in range(m)]
r = [0 for i in range(m)]
d = [0 for i in range(m)]

union = WeightedUnionFind(n)
for i in range(m):
    l[i], r[i], d[i] = [int(i) for i in input().split()]
    union.union(l[i], r[i], d[i])
print("Yes")
#union.show()

Measured memory_bytes: 29816
#include<set>
#include<map>
#include<ctime>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>    
using namespace std;
#define LL long long
LL read(){
    LL f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define MAXN 1000
#define INF 0x3f3f3f3f
LL T[MAXN+5],A[MAXN+5];
int main(){
	LL n=read(),t1,t2,tmp,g;
	for(int i=1;i<=n;i++){
		T[i]=read(),A[i]=read();
		if(i==1){
			t1=T[i],t2=A[i];
			continue;
		}
		g=max((t2+A[i]-1)/A[i],(t1+T[i]-1)/T[i]);
		t2=g*A[i],t1=g*T[i];
	}
	printf("%lld\n",t1+t2);
	return 0;
}

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


//      DEEP


using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fwd(i,a,n) for(int i=a;i<=n;i++)
#define bak(i,a,n) for(int i=a;i>=n;i--)
#define all(v) v.begin(),v.end()
#define pb push_back
#define lop '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef set<int> si;
const ll mod = 1e9 + 7;
const ll mod1=998244353;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ull gcd(ull x,ull y){
   if(y==0)return x;
   return gcd(y,x%y);
}
//                                         EXTENDED_EUCLID
vector<ll>extended_Euclid(ll a,ll b){
    vector<ll>v(3);
    if(b==0){
        v[0]=a;v[1]=1;v[2]=0;
        return v;
    }
    else{
         vector<ll>v1 = extended_Euclid(b,a%b);    //recursive call
         v[0]=v1[0];
         v[1]=v1[2];
         v[2]=v1[1]-(a/b)*v1[2];
         return v;
    }
}
                                          // DFS ( number of connected components  )
//vector<vector<ll> >adj(200001);
//bool visited[200001];
/*ll dfs(int x,int c){                         // x - > node      c - > number of edges in the component
    if(visited[x])return c;
    else{
        visited[x]=true;
        int y=c;
        for(int i=0;i<adj[x].size();i++){
            if(!visited[adj[x][i]]){
                c+=1;
                int d=dfs(adj[x][i],y);
                c+=d;
            }
        }
        return c;
    }
}
*/
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/
                               // Binary Search
/*
ll bin_search(ll y){
  while(lo<hi){
    x=lo+(hi-lo)/2;
    if(condition){
            .....
    }
    else{
                  // increase lo or decrease hi suitably
            }
   }
}
*/

int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
       int a;
       cin>>a;
       cout<<a+a*a+a*a*a<<endl;
    }
}
/* Be careful about integer ranges;
   Check the corner cases before submitting.
*/






Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    string S; cin >> S;
    if (S[2] != S[3]) {
        cout << "No" << endl;
        return 0;
    }
    if (S[4] != S[5]) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int cnt(int c, int a, int n){
	int cnt = 0;
	while (true){
		if (c > 0 && a > 0 && n > 0){
			cnt++;
			c -= 1;
			a -= 1;
			n -= 1;
		}
		else if (c > 1 && a > 0){
			cnt++;
			c -= 2;
			a -= 1;
		}
		else if (c > 2){
			cnt++;
			c -= 3;
		}
		else{
			return cnt;
		}
	}
}
int main(){
	int Q;
	cin >> Q;
	int c[101], a[101], n[101];
	int team[101];
	for (int i = 0; i < 101; i++){
		team[i] = 0;
	}
	for (int i = 0; i < Q; i++){
		cin >> c[i] >> a[i] >> n[i];
		team[i] = cnt(c[i], a[i], n[i]);
	}
	for (int i = 0; i < Q; i++){
		cout << team[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

int main() {
  int n;
  cin>>n;
  deque<int>q;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    if(i%2==0){
      q.push_back(a);
    }else{
      q.push_front(a);
    }
  }
  if(n%2==1)reverse(q.begin(),q.end());
  for(int i=0;i<n;i++){
    if(i==n-1)cout<<q[i]<<endl;
    else cout<<q[i]<<" ";
  }
  return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
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-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n,m,out;
vvi G;
vi used;
void dfs(int a){
	bool h=true;
	rep(i,n)if(!used[i])h=false;
	if(h)out++;
	rep(i,G[a].size()){
		int to=G[a][i];
		if(used[to])continue;
		used[to]=true;
		dfs(to);
		used[to]=false;
	}
}
int main(){
	cin>>n>>m;
	G=vvi(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	used=vi(n);
	used[0]=true;
	out=0;
	dfs(0);
	cout<<out<<endl;
}






Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1000050;
//ここまでテンプレ
ll fact[SIZE]={};
void facto(ll N){
	for(ll i=2;i*i<=N;i++){
		while(N%i==0){
			fact[i]++;
			N/=i;
		}
	}
}
int main(){
	ll N,P;
	cin>>N>>P;
	facto(P);
	ll ans=1;
	if(N==1){
		cout<<P<<endl;
		return 0;
	}
	for(ll i=2;i*i<=P;i++){
		if(fact[i]>=N){
			for(int j=0;j<((fact[i]/N));j++)
				ans*=i;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
ll const INF = 1LL<<60;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int n,a[16][16];
ll dp1[1<<16],dp2[1<<16];

ll rec1(int s) {
    if (dp1[s] > -INF) return dp1[s];
    dp1[s] = 0;
    for (int i = 0;i < n;++i) if ((s>>i)&1) {
        dp1[s] += rec1(s^(1<<i));
        for (int j = i;j < n;++j) if ((s>>j)&1) dp1[s] += a[i][j];
        break;
    }
    return dp1[s];
}

ll rec2(int s) {
    if (dp2[s] > -INF) return dp2[s];
    dp2[s] = max(0LL,dp1[s]);
    for (int t = s;;t = (t-1)&s) {
        if (t == 0) break;
        dp2[s] = max(dp2[s],rec2(t)+rec2(s^t));
    }
    return dp2[s];
}


int main() {
    cin >> n;
    for (int i = 0;i < n;++i) for (int j = 0;j < n;++j) cin >> a[i][j];
    for (int i = 0;i < (1<<n);++i) dp1[i] = dp2[i] = -INF;
    for (int i = 0;i < (1<<n);++i) dp1[i] = rec1(i);
    cout << rec2((1<<n)-1) << endl;
    return 0;
}

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

int main()
{
  int N, A, B;
  cin >> N >> A >> B;

  if (A * N > B)
  {
    cout << B << endl;
  }
  if (A * N == B)
  {
    cout << B << endl;
  }
  if (A * N < B)
  {
    cout << A * N << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace testtesttest
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            Console.WriteLine(s.Insert(4, " "));
        }
    }
}


Measured memory_bytes: 2648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 2e9;
typedef pair<int, int> pi;
const int MOD = 100000000;
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    int ans = -1;
    ll nums = 0;
    for (int i = 1; i <= n; i++) {
        nums *= 10;
        nums += 7;
        if ((nums % n) == 0) {
            ans = i;
            break;
        }
        nums %= n;
    }
    cout << ans;
}


Measured memory_bytes: 3652
import std.stdio;
import std.regex;

void main(){
	auto io = new IO();
	
	auto S = io.line!string()[0];
	
	if ( S.have("N") ^ S.have("S") || S.have("W") ^ S.have("E") ){
		writeln("No");
	}else{
		writeln("Yes");
	}

	return;
}

import std.stdio,std.conv,std.string;
import std.algorithm,std.array,std.math;

class IO
{
	T[] line( T = size_t , string token = " " )( size_t m = 1 ){
		T[] arr = [];
		foreach( i ; 0..m ){
			arr ~= this.read!T();
		}
		return arr;
	}
	T[][] rect( T = size_t , string token = " " )( size_t m = 1 ){
		T[][] arr = new T[][](m);
		foreach( i ; 0..m ){
			arr[i] = this.read!T(token);
		}
		return arr;
	}
	private T[] read( T = size_t )( string token = " " ){
		T[] arr;
		foreach( elm ; readln().chomp().split(token) ){
			arr ~= elm.to!T();
		}
		return arr;
	}
}

// T -> T[]
pure T[] step( T = size_t )( in T begin , in T end , in T step = 1 ){
	T[] ret;
	for( T i = begin ; i < end ; i += step ){
		ret ~= i;
	}
	return ret;
}
unittest{
	assert( step(0,10,2) == [0,2,4,6,8] );
}

// T[] -> T[]
pure T[] fill( T )( T[] args , in T filling ){
	foreach( ref arg ; args ){
		arg = filling;
	}
	return args;
}
T[] map( T )( T[] args , T function(T) f ){
	foreach( ref arg ; args ){
		arg = f(arg);
	}
	return args;
}
unittest{
	assert( [true,false,true,false].fill(true) == [true,true,true,true] );
	assert( [1,-2,3,-4].map!int(x=>x*2) == [2,-4,6,-8] );
}
// T[] -> number
pure T sum( T )( in T[] args ){
	T ret = 0;
	foreach( i ; 0..args.length ){
		ret += args[i];
	}
	return ret;
}
pure T ave(T)( in T[] args ){
	return args.sum()/args.length;
}
pure real multi( in real[] args ){
	real ret = 1.0;
	foreach( i ; 0..args.length ){
		ret *= args[i];
	}
	return ret;
}

// T[] -> bool
pure bool any( T )( in T[] args , in T target ){
	foreach( arg ; args ){
		if( arg == target ){return true;}
	}
	return false;
}
pure bool all( T )( in T[] args , in T cond ){
	foreach( arg ; args ){
		if( arg != cond ){return false;}
	}
	return true;
}
pure bool have( T )( in T[] args , in T[] target ... ){
	bool[] found = new bool[](target.length);
	foreach( arg ; args ){
		foreach( i,t ; target ){
			if( arg == t ){
				found[i] = true;
			}
		}
	}
	foreach( f ; found ){
		if( f == false ){return false;}
	}
	return true;
}


unittest{
	assert( [1,2,3,4,5].sum() == 15 );
	assert( [1,2,3,4,5].ave() == 3 );
	assert( cmp( [0.3,0.3].multi() , 0.09 ) , "multi() test failed" );
	assert( cmp( [0.3,0.3,0.3].multi() , 0.027 ) , "multi() test failed" );
	
	assert( [1,1,1].all(1) == true );
	assert( [1,1,2].all(1) == false );
	assert( [1,1,2].any(2) == true );
	assert( [1,1,2].any(3) == false );
	
	assert( [1,2,3,4,5].have([1,3,5]) == true );
	assert( [1,2,3,4,5].have([1,3,5,7]) == false );
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int n;
    cin>>n;
    long long ans=0;
    for(int i=1;i<=n;i++){
        if(!(i%3==0 || i%5==0)){
            ans+=i;
        }
    }
    cout<<ans<<"\n";
}

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

    solve();
    return 0;
}

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

int main() {
  int n, k;
  string s;
  cin >> n >> s >> k;
  char key = s.at(k - 1);
  for (int i = 0; i < n; i++) {
    cout << (s.at(i) == key ? s.at(i) : '*');
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N = getN()
A = getList()
now = A[0]
ans = 0
for i in range(1, N):
    if now <= A[i]:
        now = A[i]
    ans += now - A[i]
print(ans)

Measured memory_bytes: 110472
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    return max(map(len, S.split('S')))


def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()


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

using namespace std;

#define all(a) a.begin(), a.end()
#define pi acos(-1)
#define eps 1e-6
#define inf 1e14

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

const int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy[8] = {-1, 0, 1, -1, 1, 0, 1, -1};
const int maxn = 2 * 1e5;
const int mod = 1e9 + 7;
const int maxa = 2 * 1e5;

int maxs(int &a, int b) { return a = max(a, b);}
int mins(int &a, int b) { return a = min(a, b);}
int mul(int a, int b) { return a * 1LL * b % mod;}
int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b;}
int sub(int a, int b) { return a >= b ? a - b : a - b + mod;}
int pow(int a, int k)
{
    int res = 1;
    while (k)
    {
        if (k % 2) res = mul(res, a);
        a = mul(a, a);
        k /= 2;
    }

    return res;
}

int inv(int a)
{
    return pow(a, mod - 2);
}

int n, m, V[maxn], res, dist[maxn];
vi G[maxn], P;

void dfs(int u)
{
    V[u] = 1;
    for (int v : G[u])
        if (!V[v])
            dfs(v);

    P.push_back(u);
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 0, u, v; i < m && cin >> u >> v; ++i)
        G[u - 1].push_back(v - 1);

    for (int i = 0; i < n; ++i)
        if (!V[i])
            dfs(i);

    reverse(all(P));
    for (int u : P)
        for (int v : G[u])
            res = max(res, maxs(dist[v], dist[u] + 1));

    cout << res;
}


Measured memory_bytes: 12284
<?php

fscanf(STDIN, "%d %d", $n, $x);
$x_arr = explode(' ', trim(fgets(STDIN)));

if ($n === 1) {
    echo abs($x_arr[0] - $x);
    return;
}


$diff_arr = [];
for ($i = 0; $i < $n; ++$i) {
    $diff_arr[] = abs($x - $x_arr[$i]);
}
sort($diff_arr);


$min_gcd = gcd($diff_arr[0], $diff_arr[1]);
for ($i = 1; $i < $n - 1; ++$i) {
    $min_gcd = min($min_gcd, gcd($diff_arr[$i], $diff_arr[$i + 1]));
}

echo $min_gcd;


function gcd($x, $y) {
    if ($y === 1) {
        return $y;
    }

    if ($x % $y === 0) {
        return $y;
    }

    return gcd($y, $x % $y);
}


Measured memory_bytes: 18932
#include<bits/stdc++.h>
#define llint long long
 
using namespace std;
typedef pair<llint, llint> P;
 
int n;
llint x[55], y[55];
set<P> S;
 
int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> x[i] >> y[i];
	
	if(n == 1){
		cout << 1 << endl;
		return 0;
	}
	
	llint ans = n+1;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(i == j) continue;
			if(x[i] == x[j] && y[i] == y[j]) continue;
			if(x[i] > x[j]) continue;
			llint p = x[j]-x[i], q = y[j]-y[i];
			
			S.clear();
			for(int i = 1; i <= n; i++) S.insert(make_pair(x[i], y[i]));
			llint tmp = 0;
			P pre; bool first = true;
			while(S.size()){
				P nx = make_pair(pre.first + p, pre.second + q);
				if(!first && S.count(nx)){
					pre = nx;
					S.erase(nx);
				}
				else{
					pre = *S.begin();
					S.erase(S.begin());
					tmp++;
				}
				first = false;
			}
			//cout << p << " " << q << " " << tmp << endl;
			ans = min(ans, tmp);
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const int MOD = (int)1e9+7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
int dy[4] = {-1, 0, 1, 1};
int dx[4] = {0, 1, 0, 1};

int n, m;
vi price;
vi unlock;

int cache[1000][1<<12];
int solve(int pos, int box) {
	if(pos == m) {
		if(box == (1<<n)-1) {
			return 0;
		} else {
			return INF;
		}
	}

	int& ret = cache[pos][box];
	if(ret != -1) return ret;
	ret = INF;
	ret = min(ret, solve(pos+1,box));
	int nbox = (box | unlock[pos]);
	ret = min(ret, price[pos] + solve(pos+1, nbox));
	return ret;
}

int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("in.txt", "r", stdin);
	memset(cache, -1, sizeof(cache));
	cin >> n >> m;
	price.resize(m);
	unlock.resize(m);
	rep(i,0,m) {
		int b;
		cin >> price[i] >> b;
		unlock[i] = 0;
		rep(j,0,b) {
			int c;
			cin >> c;
			unlock[i] |= (1 << (c-1));
		}
	}
	int ret = solve(0,0);
	if(ret == INF) {
		cout << -1 << '\n';
	} else {
		cout << ret << '\n';
	}
	return 0;
}


Measured memory_bytes: 16256