akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
const int N=1e5 + 5;

string s;

string substr(int i, int j)
{
	string str ="";
	int k;
	for(k=i;k<=j;k++)
	{
		str += s[k];
	}
	return str;
}

bool ok(string x){
    vector < ll > cnt(27, 0);
    for(ll i : x)
        cnt[i - 'a']++;
    for(ll i : x){
        if(cnt[i - 'a'] > (ll)x.size() / 2)
            return 1;
    }
    return 0;
}
 

int32_t main()
{
	IOS;
	cin >> s;
	int n=s.size();
	int cur=2;
	int i=0;
	int j=0;
	int k=0;
	for(cur=2;cur<=min(n,5ll);cur++)
	{
		for(j=cur-1;j<n;j++)
		{
			string str= substr(j-cur+1,j);
			if(ok(str)==1)
			{
				cout << j-cur+2 << " " << j+1 << endl;
				return 0;	
			}	
		}	
	}
	cout << "-1 -1 " << endl;
}


Measured memory_bytes: 512
class Union_Find():
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.siz = [1] * (n+1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            #親を検索
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def same_checker(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.siz[y] += self.siz[x]
        else:
            self.par[y] = x
            self.siz[x] += self.siz[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def size(self, x):
        return self.siz[self.find(x)]


N, M = map(int, input().split())
bridge = []
for i in range(M):
    bridge.append(list(map(int, input().split())))

bridge.reverse()
island = Union_Find(N)
confort = [0]
for i in range(M):
    if island.same_checker(bridge[i][0], bridge[i][1]):
        confort.append(confort[i])
    else:
        confort.append(confort[i]+island.size(bridge[i][0])*island.size(bridge[i][1]))
        island.union(bridge[i][0], bridge[i][1])
confort.reverse()
for i in range(M):
    print(confort[0] - confort[i+1])


Measured memory_bytes: 120024
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vi p(n);
    cin >> p;
    vi pl(n);
    rep(i,n) pl[--p[i]] = i;
    reverse(all(pl));
    set<int> se;
    se.insert(-1);
    se.insert(n);
    ll ans = 0;
    rep(i,n) {
        auto a = se.lower_bound(pl[i]);
        auto b = a;
        b--;
        auto c = a;
        c++;
        if(c != se.end()) {
            ans += ll(pl[i]-*b)*(*c-*a)*(n-i);
        }
        if(b != se.begin()) {
            auto d = b;
            d--;
            ans += ll(*b-*d)*(*a-pl[i])*(n-i);
        }
        se.insert(pl[i]);
    }
    cout << ans << endl;
}


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

int main(void){
  int N, K;
  cin >> N >> K;


  map<int, int> sunuke;
  int d, a;
  for(int i = 0; i < K; i++){
    cin >> d;
    for(int j = 0; j < d; j++){
      cin >> a;
      if(sunuke.count(a)){
	sunuke[a]++;
      }else{
	sunuke[a] = 1;
      }
    }
  }

  for(map<int, int>::const_iterator i = sunuke.begin();
      i != sunuke.end(); ++i){
    --N;
  }

  cout << N << endl;

  
  return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    long long int n, p;
    cin >> n >> p;
    long long int fixP = p;
    map<long long int, long long int> mp;
    int i = 2;
    if (n == 1)
    {
        cout << p << endl;
        return 0;
    }
    while (true)
    {
        if (p % i == 0)
        {
            mp[i]++;
            p = p / i;
        }
        else
        {
            i++;
        }
        if (p == 1 || sqrt(fixP + 100) < i)
            break;
    }
    long long int ans = 1;
    for (auto x : mp)
    {
        ans = ans * pow(x.first, x.second / n);
    }
    cout << ans << endl;
}


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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    ll z,w,a[n]; cin >> z >> w;
    rep(i,n) cin >> a[i];
    if(n == 1){
        cout << abs(a[0]-w) << endl;
        return 0;
    }
    cout << max(abs(a[n-1]-w), abs(a[n-2]-a[n-1])) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
struct Edge{
    int to, cost;
};
int color[100005]={0};
void dfs(int node, int c, const vector<vector<Edge>> &graph){
    if(color[node] >= 0)return;
    color[node] = c;
    for(auto e: graph[node]){
        if(e.cost % 2){
            dfs(e.to, c^1, graph);
        }else{
            dfs(e.to, c, graph);
        }
    }
}
int main(){
    i64 n;
    cin >> n;
    vector<vector<Edge>> graph(n+1, vector<Edge>());
    for(int i=0;i<n-1;++i){
        int u, v, w;
        cin >> u >> v >> w;
        graph[u].push_back({v, w});
        graph[v].push_back({u, w});
    }
    for(int i=1;i<=n;++i){
        color[i] = -1;
    }
    dfs(1, 0, graph);
    for(int i=1;i<=n;++i){
        cout << color[i] << endl;
    }
}

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

using namespace std;

//#define MULTITEST
//#define _DEBUG

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if (i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 200 * 1000 + 13;

int n, m;
vector<int> g[N];

bool read() {
	if (scanf("%d %d", &n, &m) != 2)
		return false;
	forn(i, m) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		g[x].pb(y);
		g[y].pb(x);
	}
	return true;
}

int col[N];

void dfs(int v, int c) {
	col[v] = c;

	for (int to : g[v]) {
		if (!col[to]) {
			dfs(to, c);
		}
	}
}

void solve() {
	int c = 1;
	forn(i, n) {
		if (!col[i]) {
			dfs(i, c);
			c++;
		}
	}

	vector<int> szs(n);
	forn(i, n) {
		szs[col[i]]++;
	}

	cout << *max_element(all(szs)) << endl;
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);

	int tt = clock();

#endif

	//ios::sync_with_stdio(false);
  	//cin.tie(0);
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef MULTITEST
	int tc;
	scanf("%d", &tc);
	while (tc--) {
		read();
#else
	while (read()) {
#endif
		solve();

#ifdef _DEBUG
		cerr << "TIME = " << clock() - tt << endl;
		tt = clock();
#endif

	}
	}

Measured memory_bytes: 25124
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
    cin>>a>>b;
    if(a>0)cout<<"Positive";
    else if(a==0||(a<0&&b>0))cout<<"Zero";
    else if((abs(b)-abs(a))%2!=0)cout<<"Positive";
    else cout<<"Negative";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> d(N);
  for (ll i = 0; i < N; ++i) {
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  cout << d.at(N / 2) - d.at(N / 2 - 1) << "\n";
}


Measured memory_bytes: 3928
#include <iostream>
#include <cstring>
#include <sstream>
#include <cctype>
#include <cmath>
#include <cstdio>
using namespace std;
#define MPI  3.14159265358979323846


int main(){
	while (true){
		int n, s[1001], sum = 0;
		double a=0,m;
		cin >> n;
		if (n == 0)break;
		for (int i = 0; i < n; i++){
			cin >> s[i];
			sum += s[i];
		}
		m = (double)sum / (double)n;
		for (int i = 0; i < n; i++){
			a += pow(s[i] - m, 2) / (double)n;
		}
		printf("%.8f\n", sqrt(a));
	}
	return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

int main(){
    ll a,b,c,d,e,k,l,m,n,o=0,p,q,x,y,z,max1=0,ans;
    string s,t,u;
    cin>>n>>s>>k;
    for (ll i=0; i<n; i++) {
        if (s[i]!=s[k-1]) {
            s[i]='*';
        }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
//===========================================================================
// review time code
use std::io::stdin;

fn main() {
    let mut input = String::new();
    stdin().read_line(&mut input);
    let mut vec = Vec::with_capacity(2);
    vec = input.split_whitespace().map(|x| x.parse::<i32>().unwrap()).collect();
    input.clear();
    stdin().read_line(&mut input);
    let mut sum = 0;
    for i in input.split_whitespace() {
        sum += i.parse::<i32>().unwrap();
    }
    if sum >= vec[0] {
        println!("Yes");
    } else {
        println!("No");
    }

}

Measured memory_bytes: 4476
#include<iostream>
#include<algorithm>
using namespace std;
int a[200000];
int main()
{
    int n, i = 0, f = 1;
    cin >> n;
    while(i < n)
    {
        cin >> a[i];
        i++;
    }
    sort(a, a + n);
    for(i = 0; i < n - 1; i++)
    {
        if(a[i] == a[i+1]){
            f = 0;
            break;
        }
    }
    if(f) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 1024
if __name__ == '__main__':
    n,m = list(map(int, input().split()))
    ks = []
    bitnums = []
    for i in range(m):
        ks.append(list(map(int, input().split())))
        bitnum = 0
        for j in range(1, ks[i][0]+1):
            bitnum += 1 << (ks[i][j]-1)
        bitnums.append(bitnum)
    p = list(map(int, input().split()))

    np = [1] * (2**n)

    for i in range(len(np)):
        for j in range(m):
            cnt = bin(i & bitnums[j]).count("1")
            if(cnt % 2 != p[j]):
                np[i] = 0
                break
    
    #for i in range(len(np)):
    #    print("{0} {1}".format(np[i], bin(i)))
        
    print(sum(np))


Measured memory_bytes: 3188
# abcde -> String
readline_() = readline() |> chomp
# a b c d e -> Array{SubString{String},1}
readline_array_string() = readline() |> chomp |> split
# 1 2 3 4 5 -> Array{Int64, 1}
readline_array_int() = [parse(Int, x) for x in readline() |> chomp |> split]

read_int() = parse(Int, readline() |> chomp)

n = read_int()
str = readline() |> chomp
k = read_int()

c = str[k]

val = ""
for (i, s) in enumerate(str)
    if s != c
        val *= "*"
    else
        val *= string(c)
    end
end

print(val)

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

int main(){
	int n,a,b,c=0;
	cin>>n>>a>>b;
	for(int i=1,t,s;i<=n;++i){
		s=0,t=i;
		while(t){
			s+=t%10;
			t/=10;
		}
		if(s>=a&&s<=b)c+=i;
	}
	cout<<c<<"\n"s;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll dp[100010];

int main()
{
    int n; cin >> n;
    int h[n];
    rep(i, n) cin >> h[i];
    rep(i, 100010) dp[i] = INF;
    dp[0] = 0;
    rep(i, n)
    {
        chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
        // if (i == 2)
        // {
        //     COUT(dp[i + 1]);
        //     COUT(h[i]);
        //     COUT(h[i + 1]);
        //     COUT(dp[i + 2]);
        //     COUT(h[i + 2]);
        // }
        // if (i == 3)
        // {
        //     COUT(dp[i + 1]);
        //     COUT(h[i]);
        //     COUT(h[i + 1]);
        //     COUT(dp[i + 2]);
        //     COUT(h[i + 2]);
        // }
    }
    //for (auto it : dp) COUT(it);
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define INF 1e9
#define MAX_V 10000
#define MAX_N 1000
using namespace std;

/*?????§?????¢?????´?????????(Ford_Fulerson????????¨)???O(F|E|)*/

//????????¨????§???????(???????????????????????????)
struct edge{int to, cap, rev;};

vector<edge> G[MAX_V]; //??°???????????£??\?????????
bool used[MAX_V];      //DFS??§?????§??????????????????????????°

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


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

//s??????t???????????§???????±???????
int max_flow(int s,int t){
  int flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(s, t, INF);
    if(f == 0)return flow;
    flow += f;
  }
}

int N,K;
bool can[MAX_N][MAX_N]; //can[i][j]:=???????????\??????i?????????j??????????????????
int Biparite_Matching(){
  //0??????N-1: ???????????\???????????????????????????
  //N??????N+K-1: ???????????????????????????
  int s = N+K, t = s+1;
  
  //s??¨???????????\??????????????¶
  for(int i=0; i<N; i++) add_edge(s,i,1);
  
  //????????¨t?????????
  for(int i=0; i<K; i++) add_edge(N+i,t,1);
  
  //???????????\????????¨??????????????¶
  for(int i=0;i<N;i++)
    for(int j=0;j<K;j++)
      if(can[i][j]) add_edge(i, N+j , 1);

  return max_flow(s,t);
}

int main(){
  while(1){
  int b,r,B[501],R[501];
  cin>>b>>r;
  if(!b&&!r)break;
  for(int i=0;i<b;i++) cin>>B[i];
  for(int i=0;i<r;i++) cin>>R[i];

  memset(can,0,sizeof(can));
  for(int i=0;i<MAX_V;i++) G[i].clear();
  N=b,K=r;
  for(int i=0;i<b;i++)
    for(int j=0;j<r;j++)
      if(__gcd(B[i],R[j])>1) can[i][j]=1;

  cout<<Biparite_Matching()<<endl;
  }
  
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S;
    ll count = 0;
    char prev;
    cin >> S;
    prev = S.front();
    iter(c, S) {
        if(c != prev) count++;
        prev = c;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define COUT(x) cout<<(x)<<"\n"
#define REP(i, n) for(int i=0;i<n;i++)
#define endl "\n"
using ll = long long;
const int MOD = 998244353;

int main() {
  int n,k; cin >> n >> k;
  vector<int> l(k),r(k);
  REP(i,k) cin >> l[i] >> r[i];
  vector<ll> dp(n+1), dpsum(n+1);

  dp[1] = 1; // マス1から始まるため dp[1] = 1 にする
  dpsum[1] = 1; // dpの累積和

  for (int i = 2; i <= n; i++) {
    REP(j,k) {
      int li = max(i-r[j], 1);
      int ri = i-l[j];
      if (ri < 0) continue; // 右端が範囲外

      dp[i] += dpsum[ri]-dpsum[li-1];
      dp[i] = dp[i] < 0 ? dp[i]+MOD : dp[i]%MOD; // MOD
    }
    dpsum[i] = (dpsum[i-1]+dp[i]) % MOD;
  }
  COUT(dp[n]);
  return 0;
}

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

int main(void) {
    int a, b, c;
    cin >> a >> c >> b;
    if (a <= b && b <= c || c <= b && b <= a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

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

   
 
  if (N%2 == 0) {
    cout << 0.5000000000
 << endl;
  }
  else {
    cout <<(double)(((N-1)/2)+1)/N << endl;
  }

}

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

using namespace std;
int main(){
    int k;cin>>k;
    string s;cin>>s;
    if(s.length() <= k){cout << s << endl;}
    else{
        for(int i=0;i<k;i++){
            cout << s[i] ;
        }
        cout << "..."<<endl;
    }

    return 0;
}

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

#define MAXN 212345
#define int long long
#define pb push_back
#define inf LLONG_MAX
#define mp make_pair
#define pii pair<int,int>
#define f first
#define s second

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

    int fa;
    int lz;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
    	if(s[i]=='A'){
    		fa=i;
    		break;
    	}
    }
    for(int i=s.size()-1;i>=0;i--){
    	if(s[i]=='Z'){
    		lz=i;
    		break;
    	}
    }
    cout<<lz-fa+1<<endl;

    return 0;
 
}











Measured memory_bytes: 720
#include<stdio.h>
int main(void){
  int A,B;
  scanf("%d %d",&A,&B);
  if(A<=5){
    printf("0\n");
  }else if(A>=13){
    printf("%d\n",B);
  }else{
    printf("%d\n",B/2);
  }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdlib>
#include<vector>
#include<queue>
#include<algorithm>

using namespace std;

typedef pair<int,int> PA;
typedef pair<long long,int> PAL;
typedef pair<PAL,int> PPA;

const long long INF = 1000010000100001;

int m,n,k;

vector<PA> vx[100010],vy[100010];
vector<PA> tate[200010],yoko[200010];
long long min_cost[2][200010];

void make_edge(){
    vx[n].push_back(PA(m,k+1));
    vy[1].push_back(PA(1,0));
    vy[m].push_back(PA(n,k+1));
    
    for(int i=1;i<=n;i++){
        if(vx[i].size() < 2) continue;
        sort(vx[i].begin(),vx[i].end());
        for(int j=0;j<vx[i].size()-1;j++){
            long long xcost = abs(vx[i][j].first-vx[i][j+1].first);
            yoko[ vx[i][j].second ].push_back( PAL(xcost,vx[i][j+1].second) );
            yoko[ vx[i][j+1].second ].push_back( PAL(xcost,vx[i][j].second) );
        }
    }
    
    for(int i=1;i<=m;i++){
        if(vy[i].size() < 2) continue;
        sort(vy[i].begin(),vy[i].end());
        for(int j=0;j<vy[i].size()-1;j++){
            long long ycost = abs(vy[i][j].first-vy[i][j+1].first);
            tate[ vy[i][j].second ].push_back( PAL(ycost,vy[i][j+1].second) );
            tate[ vy[i][j+1].second ].push_back( PAL(ycost,vy[i][j].second) );
        }
    }
    
}

int main(){
    
    int x,y;
    priority_queue<PPA,vector<PPA>,greater<PPA> > pq;
    
    cin >> m >> n >> k;
    for(int i=0;i<k;i++){
        cin >> x >> y;
        if(x==1 && y==1){
            vx[1].push_back(PA(1,0));
        }
        if(x==1 && y==1 || x==m && y==n) continue;
        vx[y].push_back(PA(x,i+1));
        vy[x].push_back(PA(y,i+1));
    }
    
    make_edge();
    
    for(int i=1;i<=k+1;i++){
        min_cost[0][i] = INF;
        min_cost[1][i] = INF;
    }
    min_cost[0][0] = 0;
    min_cost[1][0] = 0;
    
    pq.push( PPA(PA(0,0),0) );
    while(!pq.empty()){
        PPA pp = pq.top();
        pq.pop();
        PAL p = pp.first;
        
        for(int i=0;i<tate[p.second].size();i++){
            long long cost = p.first + tate[p.second][i].first;
            int to = tate[p.second][i].second;
            if(pp.second == 0 && min_cost[0][to] > cost){
                min_cost[0][to] = cost;
                pq.push( PPA(PAL(cost,to),0) );
            }
            if(pp.second == 1 && min_cost[0][to] > cost+1){
                min_cost[0][to] = cost+1;
                pq.push( PPA(PAL(cost+1,to),0) );
            }
        }
        
        for(int i=0;i<yoko[p.second].size();i++){
            long long cost = p.first + yoko[p.second][i].first;
            int to = yoko[p.second][i].second;
            if(pp.second == 0 && min_cost[1][to] > cost+1){
                min_cost[1][to] = cost+1;
                pq.push( PPA(PAL(cost+1,to),1) );
            }
            if(pp.second == 1 && min_cost[1][to] > cost){
                min_cost[1][to] = cost;
                pq.push( PPA(PAL(cost,to),1) );
            }
        }
        
    }
    
    long long ans = min(min_cost[0][k+1],min_cost[1][k+1]);
    cout << (ans==INF?-1:ans) << endl;
    
    return(0);
}


Measured memory_bytes: 40800
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int LL;
typedef LL ll;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
const ll M=1e3+5,LG=19,SM=4000+5,inf=1e9+1;
ll mod=1e9+7;

int main()
{
	ios::sync_with_stdio(0);
    ll a,b,c;
    cin >> a >> b >> c;
    if (!((a&1)&&(b&1)&&(c&1)))
        RET(0);
    ll x=min(a*b,b*c);
    smin(x,a*c);
    RET(x);       
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%s %s", $s, $t);
fscanf(STDIN, "%d %d", $a, $b);
fscanf(STDIN, "%s", $u);

$cnt = 0;
if(strcmp($u,$s)===0){
    $a--;
}else if(strcmp($u,$t)===0){
    $b--;
}
    echo($a);
    echo(" ");
    echo($b);
?>

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int M;
  cin >> M;
  ll D=0,S=0;
  for(int i=0; i<M; i++){
    ll d,c;
    cin >> d >> c;
    D += c;
    S += d*c;
  }
  cout << D-1 + (S-1)/9 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <iomanip> //cout << fixed << setprecision(12) << ans << endl;
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define loop(i, l, r) for(int i = l; i < r; i++)
#define rloop(i, l, r) for(int i = l; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vec_i;
typedef pair<int,int> pair_ii;
typedef pair<ull,ull> pair_ull;
 
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int INF = 1e9;
const int MOD = 1e9+7;
 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vec_i b(n-1);
	rep(i, n-1) cin >> b[i];
	int ans = 0;

	rep(i, n-2){
		ans += min(b[i], b[i+1]);
	}
	ans += b[0] + b[n-2];
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string a, b, c, d;
    cin >> a >> b;
    c = a;
    d = b;
    for(int i = 0; i < c[0] - '0' - 1; i++){
        b += d[0];
    }
    for(int i = 0; i < d[0] - '0' - 1; i++){
        a += c[0];
    }
    if(a < b){
        cout << a << endl;
        return 0;
    }
    cout << b << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<intmax_t> a(n), b(n);
  for (auto& ai: a) scanf("%jd", &ai);
  for (auto& bi: b) scanf("%jd", &bi);

  unsigned res = 0;
  for (intmax_t i = 1 << 29; i; i >>= 1) {
    std::sort(b.begin(), b.end());
    unsigned cur = 0;
    for (auto ai: a) {
      {
        intmax_t lb = i-ai;
        intmax_t ub = lb+i;
        auto il = std::lower_bound(b.begin(), b.end(), lb);
        auto iu = std::lower_bound(b.begin(), b.end(), ub);
        cur += iu-il;
      }
      {
        intmax_t lb = 3*i-ai;
        intmax_t ub = lb+i;
        auto il = std::lower_bound(b.begin(), b.end(), lb);
        auto iu = std::lower_bound(b.begin(), b.end(), ub);
        cur += iu-il;
      }
    }
    if (cur & 1) res |= i;

    for (auto& ai: a) ai &= i-1;
    for (auto& bi: b) bi &= i-1;
  }

  printf("%u\n", res);
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

struct Py {
  int id;
  int pref;
  int year;
  int cnt;
};

bool yearAsc(Py py1, Py py2) {
  return py1.year < py2.year;
}

bool idAsc(Py py1, Py py2) {
  return py1.id < py2.id;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<Py> py(m);
  rep(i, m) {
    int p, y;
    cin >> p >> y;
    py.at(i) = {i, p, y};
  }
  sort(py.begin(), py.end(), yearAsc);
  map<int, int> mp; // prefごとの数
  for (int i = 0; i < py.size(); i++) {
    Py &p = py.at(i);
    p.cnt = ++mp[p.pref];
  }
  sort(py.begin(), py.end(), idAsc);
  for (int i = 0; i < py.size(); i++) {
    Py v = py.at(i);
    cout << right << setw(6) << setfill('0') << v.pref;
    cout << right << setw(6) << setfill('0') << v.cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 7808
#include <iostream>
using namespace std;
int main(){
    int a,b;
    char op;
    while (true) {
		cin >> a >> op >> b;
		if (op == '?') {
			break;
		}
		switch (op) {
		case('+'):
			cout << a + b << endl;
			break;
		case('-'):
			cout << a - b << endl;
			break;
		case('*'):
			cout << a * b << endl;
			break;
		case('/'):
			cout << a / b << endl;
			break;
		}
	}
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  REP(i, n) {
    cin >> v[i];
  }
  sort(ALL(v), greater<int>());
  int ans = 0;
  REP(i, k) {
    ans += v[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;

	cin >>n;
	long long array[n];
	array[0]=2;
	array[1]=1;
	for(int i=2;i<=n;i++){
		array[i]=array[i-1]+array[i-2];
	}
	cout<<array[n]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <numeric>

using namespace std;

int main(){
    int n;
    int x;
    cin >> n;
    cin >> x;
    int y[n];
    int z[n];
    int gc[n];
    for(int i=0;i<n;i++){
        cin >> y[i];
    }
    for(int a=0;a<n;a++){
        z[a] = abs(x - y[a]);
        // printf("%d\n",z[a]);
    }
    int min_p = z[0]; //zから最小値を求める
    // int mp = z[0];
    for(int p=0;p<n;p++){
        if(min_p > z[p]){
            min_p = z[p];
        }
    }
    // min_p = z.min();
    for(int b=0;b<n;b++){
        // gc[b] = gcd(min_p, z[b]);
        int a = min_p;
        int c = z[b];
        int an;
        int r;
        if(a >= c){
            r = a % c;
            while(r != 0){
                a = c;
                c = r;
                r = a % c;
            }
            an = c;
        }
        else{
            r = c % a;
            while(r != 0){
                c = a;
                a = r;
                r = c % a;
            }
            an = a;
        }
        gc[b] = an;
    }
    // d = gc.min();
    int d = gc[0]; //zから最小値を求める
    // int mp = z[0];
    for(int q=0;q<n;q++){
        if(d > gc[q]){
            d = gc[q];
        }
    }

    printf("%d",d);

}


Measured memory_bytes: 1408
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ull i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;


int main() {
    #ifndef ONLINE_JUDGE
	// freopen("test.in", "r", stdin);
    #endif
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    deque<char> st;
    vector<char> e;
    int q; cin >> q;
    bool rev = false;
    for_(_, 0, q) {
        int c; cin >> c;
        if (c == 1) {
            rev = !rev;
        } else {
            int a; char b; cin >> a >> b;
            if (a == 1) {
                if (rev) {
                    e.push_back(b);
                } else {
                    st.push_front(b);
                }
            } else {
                if (rev) {
                    st.push_front(b);
                } else {
                    e.push_back(b);
                }
            }
        }
    }
    if (rev) {
        reverse(st.begin(), st.end());
        reverse(s.begin(), s.end());
        reverse(e.begin(), e.end());
        for (char c: e) cout << c;
        for (char c: s) cout << c;
        for (char c: st) cout << c;   
    } else {
        for (char c: st) cout << c;
        for (char c: s) cout << c;
        for (char c: e) cout << c;  
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 848
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    string s;
    cin>>s;
    int ans=0,rem=0;
    long long int i=0;
    while(i<s.length())
    {
        rem = (int(s[i] - '0') + ans)%9;
        ans = rem;
        i++;
    }
    if (ans == 0)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    
    
    
    return 0;
    
}

Measured memory_bytes: 3736
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int a,b;
  char str[100],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  a=atoi(p);
  p=strtok(NULL," \n");
  b=atoi(p);
  
  if(((a*b)/2)*2 == a*b){
    printf("Even\n");
  }else{
    printf("Odd\n");
    
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#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;
  cin >> n;
  vector<int> v(n);
  rep(i, n){
  	cin >> v.at(i);
  }
  int hight_price = *max_element(v.begin(), v.end());
  int sum = 0, cnt = 0;
  rep(i, n){
    if(v[i] == hight_price && cnt == 0){
    	v[i] /= 2;
      	cnt++;
    }
    sum += v[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

    int n,k;
    cin >> n >> k;
    priority_queue<int> pq;
    int c;
    for (int i=0;i<n;i++) {
        cin >> c;
        if (pq.size() < k) pq.push(c);
        else {
            if (pq.top() > c) {
                pq.pop();
                pq.push(c);
            }
        }
    }

    int res = 0;
    while (!pq.empty())
        res += pq.top(), pq.pop();
    cout << res << "\n";
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;
set<int> si;

int main() {
	cin >> n;
	rep(i, n) {
		int num;
		cin >> num;
		if (si.find(num) == si.end())si.insert(num);
		else si.erase(num);
	}
	cout << si.size() << endl;
}

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

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

const long long INF = 1LL << 60;

int n;
long long h[100010];

long long dp[100100];

int main(void){
    int n, k;
    std:: cin >> n >> k;

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

    for(int i = 0; i < 100100; i++){
        dp[i] = INF;
    }

    dp[0] = 0;

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


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main () {
  int n,l;
  cin >> n >> l;
  string x[101];
  for(int i = 0 ; i <n;i++){
	cin >> x[i];
  }
  sort(x,x+n);
  for(int i = 0 ; i < n;i++){
	cout << x[i];
  }
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    int x[110], y[110]; ll h[110];
    rep(i, N) cin >> x[i] >> y[i] >> h[i];
	rep(cx, 101) {
		rep(cy, 101) {
			int H;
			rep(i, N) {
				if(h[i] != 0) {
					H = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
					break;
				}
			}
			rep(i, N) {
				if(max(0, H - abs(x[i] - cx) - abs(y[i] - cy)) != h[i]) break;
				if(i == N - 1) {
					cout << cx << " " << cy << " " << H << endl;
				}
			}
		}
	}
    return 0;
}

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

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

  vector<bool> prime(10100, true);
  prime[0] = prime[1] = false;
  for(int i = 2; i * i < 10100; ++i) {
    if(prime[i]) {
      for(int j = i * i; j < 10100; j += i) {
        prime[j] = false;
      }
    }
  }

  vector<int> vec;
  for(int i = 2; i <= 10000; ++i) {
    if(prime[i]) vec.push_back(i);
  }

  int n;
  while(cin >> n, n != 0) {
    int ans = 0;
    for(int i = 0; i < vec.size(); ++i) {
      int sum = 0;
      for(int j = i; j < vec.size() && sum < n; ++j) sum += vec[j];
      if(sum == n) ans++;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int a, b, k;
  cin >> a >> b >> k;
  
  int s, t, u;
  s = min(a, b);
  t = 1;
  u = 0;
  
  while(u < k){
      if(((a%s) == 0) && ((b%s) == 0)){
        t = s;
        u++;
      }
      s--;
  }
  cout << t << endl;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,K,sub;
    cin>>A>>B>>K;
    vector<int>v;
    for(int i=1;true;i++){
        if(A%i==0&&B%i==0){v.push_back(i);}
        if(i>A||i>B){break;}
    }
    cout<<v[v.size()-K]<<endl;
}

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

using namespace std;
#define ll long long int

int main() {
    ll N,sum=0;
    cin>>N;
    for (ll i=1; i<=N;i++){
        if(!(i%3 == 0 || i%5 == 0)){
            sum=sum+i;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3636
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int R = sc.nextInt();

		if(N <= 10){
			System.out.println(100 * (10 - N) + R);
		}else
		System.out.println(R);
	}
}

Measured memory_bytes: 35260
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

i64 N;
vector<i64> a;

vector<vector<bool>> flag(3030, vector<bool>(3030, false));
vector<vector<i64>> dp(3030, vector<i64>(3030, 0));
i64 rec(i64 l, i64 r) {
  if(r < l) return 0;
  if(flag[l][r]) return dp[l][r];
  i64 turn = !!((N - (r - l + 1)) & 1);
  if(turn == 0) {
    dp[l][r] = max(rec(l + 1, r) + a[l], rec(l, r - 1) + a[r]);
  }
  else {
    dp[l][r] = min(rec(l + 1, r) - a[l], rec(l, r - 1) - a[r]);
  }
  flag[l][r] = true;
  return dp[l][r];
}

int main() {
  cin >> N;
  a.resize(N);
  for(int i = 0;i < N;i++) cin >> a[i];
  cout << rec(0, N - 1) << endl;
}


Measured memory_bytes: 73728
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
using namespace std;
int lst=0,lstx,lsty,n,f;
int read()
{
	int f=1,x=0;
	char ch=getchar();
	while(isdigit(ch)==0 && ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return x*f;
}
void write(int x)
{
	char ch[20];
	int f=0;
	if(!x){putchar('0');return;}
	if(x<0){putchar('-');x=-x;}
	while(x)ch[++f]=x%10+'0',x=x/10;
	while(f)putchar(ch[f--]);
	putchar('\n');
}
int main()
{
    int a=read(),b=read();int x=1;
    for(;x<=b;x*=10);
    a=a*x;
    if(((int)sqrt(a+b)) *((int)sqrt(a+b))==a+b)cout<<"Yes";
    else cout<<"No";
	return 0;
}


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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

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

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);
vector<ll> enum_div(ll);

// ================ Main Loop ================
int main() {
    ll n;
    cin >> n;
    vector<ll> tr1, tr2;
    set<ll> s;
    tr1 = enum_div(n);
    tr2 = enum_div(n - 1);
    for(auto v : tr1) {
        s.insert(v);
    }
    for(auto v : tr2) {
        s.insert(v);
    }

    s.erase(1);

    int ans = 0;
    for(auto v : s) {
        ll now = n;
        bool flg = false;
        while(now > 1) {
            // cout << now << endl;
            if(now % v == 0) {
                now = now / v;
            } else {
                flg = (now % v == 1);
                break;
            }
        }
        if(now == 1) flg = true;
        ans += flg;
    }

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

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

vector<ll> enum_div(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i != 1 && i * i != n) {
                ret.push_back(n / i);
            }
        }
    }
    ret.push_back(n);
    // n自身もくわえたければ

    // sort(ret.begin(), ret.end());
    // 最小順であることは保証されないので、必要に応じて。
    // この場合、O(sqrt(N)*(log(N)+1))
    return ret;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<long long>());

	long long ans = a[0];
	int idx = 1;

	for (int i = 2; i < n; i++)
	{
		ans += a[idx];
		if (i % 2 == 1) idx++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4752
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let h = Scanf.sscanf (read_line ()) "%d" (
        fun h -> 
                h
)

let i = ref 0

let rec f h =
        if h = 1 then
                1
        else
                2 * (f (h / 2)) + 1

let () =
        f h
        |> Printf.printf "%d\n"


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
   
/* brownsands :Arpit */		

void solve()
{  long double l,l1;
   cin>>l;
    l=l/3.0;
    l1=l*l*l;
   cout<<setprecision(10)<<l1;
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case #"<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
} 
               
			
 

				
		
		




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int N=500005;
long long fac[N],inv[N];
long long qpow(long long a,long long b);
int main()
{
	long long n,m,ans=0;
	cin>>n>>m;
	fac[0]=1;
	for (int i=1;i<=m;i++)
	{
		fac[i]=fac[i-1]*i%mod;
	}
	inv[m]=qpow(fac[m],mod-2);
	for (int i=m-1;i>=0;i--)
	{
		inv[i]=inv[i+1]*(i+1)%mod;
	}
	for(int i=0;i<=n;i++){
        ans=(ans+fac[n]*inv[i]%mod*inv[n-i]%mod*((i&1)?-1:1)*fac[m-i]%mod*inv[m-n]%mod)%mod;
    }
    for(int i=m-n+1;i<=m;i++)ans=ans*i%mod;
    cout<<(ans+mod)%mod<<endl;
	return 0;
}
long long qpow(long long a,long long b)
{
	long long ans=1ll;
	while (b)
	{
		if (b&1)   ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}

Measured memory_bytes: 11436