akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    if (b==0) return (int)1;
    int x = p(a, b>>1);
    if (b & 1) return m(x*m(a*x));
    return m(x*x);
}
signed main(){
    fast();
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int sum = 0;
    if(k >= a){
        sum += a;
        k -= a;
        if(k > 0){
            k -= min(b, k);
        }
        if(k > 0){
            sum -= min(c, k);
        }
    }
    else{
        sum = k;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define PB push_back
#define in insert
#define MP make_pair
#define F first
#define S second
 void faster()
 {
 	ios_base::sync_with_stdio(false);
 	cin.tie(NULL);
 	cout.tie(NULL);
 }
 void inout()
 {
 	freopen("in.txt","r",stdin);
 	freopen("out.txt","w",stdout);
 }
 void solve()
 {
 	ll n;
 	cin>>n;
 	vector<char>v;
 	char ch[30]={'z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y'};
 	ll k=26;
 	while(n)
 	{
 		
 		ll a=n%k;
 		v.push_back(ch[a]);
 		n--;
  		n/=26;

 		

 	}
 	for(int i=v.size()-1;i>=0;i--)
 	{
 		cout<<v[i];
 	}
 }
 int main()
 {
 	faster();
 	//inout();
 	solve();
 	return 0;

 }

Measured memory_bytes: 3648
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <cstring>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <cassert>
#include <atcoder/segtree>
#include <cstdio>

using namespace std;
using namespace atcoder;

int op(int a, int b) { return max(a, b); }

int e() { return 0; }

int target;

bool f(int v) { return v < target; }

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

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (k == 0)
	{
		cout << n << '\n';
		return 0;
	}
	segtree<int, op, e> seg(300010);
		
	int res = 0;
	for (int i = 0; i < n; i++)
	{
		int l = max(0, a[i] - k);
		int r = min(300000, a[i] + k);
		int Max = seg.prod(l, r+1);
		//cout << Max << '\n';
		//cout << i << ' ' << l << ' ' << r<< ' ' <<  Max + 1 << '\n';
		res = max(Max + 1, res);
		seg.set(a[i], Max + 1);
	}
	
	cout << res << '\n';
	
	return 0;
}


Measured memory_bytes: 9800
#include<cstdio>
#include<string>
#include<iostream>
#include<cstring>

using namespace std;

int n;
int c[2][30];
int x[30];
bool used[30];
int sx,bx;

void dfs(int v,int nx){
	if(used[v])return;
	used[v]=true;
	x[v]=nx;
	sx=min(sx,nx);
	bx=max(bx,nx);
	if(c[0][v]!=-1)dfs(c[0][v],nx-1);
	if(c[1][v]!=-1)dfs(c[1][v],nx+1);
}

int main(void){
	scanf("%d",&n);
	for(int kkk=0;kkk<n;kkk++){
		memset(c,-1,sizeof(c));
		memset(used,false,sizeof(used));
		memset(x,0,sizeof(x));
		string s;
		cin >> s;
		int a,b,m=-1;
		for(int i=0;i<s.size();i++){
			if(s[i]>='a' && s[i]<='z'){
				a=b;
				b=s[i]-'a';
				if(m==1)c[0][b]=a,c[1][a]=b;
				if(m==0)c[1][b]=a,c[0][a]=b;
			}
			if(s[i]=='>')m=1;
			if(s[i]=='<')m=0;
		}
		sx=bx=0;
		dfs(s[0]-'a',0);
		for(int i=sx;i<=bx;i++){
			for(int j=0;j<=25;j++){
				if(x[j]==i && used[j])printf("%c",j+'a');
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
k = int(input())
ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for k in range(1,k+1):
            ans+=gcd(i,j,k)

print(ans)



Measured memory_bytes: 69856
=begin
N K Q
A1
A2
...
Aq
=end

n, k, q = gets.chomp.split(" ").map(&:to_i)
as = q.times.map do
  gets.chomp.to_i
end

ary = Array.new(n, 0)

as.each do |a|
  ary[a-1] += 1
end

n.times do |i|
  if (k - q + ary[i]) > 0
    puts "Yes"
  else
    puts "No"
  end
end


Measured memory_bytes: 4220
_ = gets.to_i
t, a = gets.split(" ").map(&:to_i)

puts gets.split(" ").map(&:to_i).each_with_index.min { |(h1, _), (h2, _)| (a - (t - (h1 * 0.006))).abs <=> (a - (t - (h2 * 0.006))).abs }[1] + 1


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

int main(){
    int K,A,B;
    cin >> K >> A >> B;
    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
        cout << "NG" << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int n,m,p,k,q,dp[64][2][3];
long long x[10010],y[10010];//dep,lim,mod
bool light(long long xx,long long yy){
	bool flag=0;
	for(int i=1;i<=n;i++){
		if(yy-y[i]<0||yy-y[i]>x[i]-xx) continue;
		flag^=(((x[i]-xx)|(yy-y[i]))==x[i]-xx);
	}
	return flag;
}
bool lres[3],rres[3],mres[3],res[3];
void calc(long long c,long long xx,long long yy,long long r){
	long long tmp=xx-c;r-=yy;
	if(r<0) return res[0]=res[1]=res[2]=0,void();
	memset(dp,0,sizeof(dp));
	dp[63][1][0]=1;
	for(int i=63;i>=1;i--){
		if(!((tmp>>(i-1))&1)){
			for(int j=0;j<3;j++){
				if(dp[i][0][j]) dp[i-1][0][(j*2)%3]^=1;
				if(dp[i][1][j]){
					if((r>>(i-1))&1) dp[i-1][0][(j*2)%3]^=1;
					else dp[i-1][1][(j*2)%3]^=1;
				}
			}
		}
		else{
			for(int j=0;j<3;j++){
				if(dp[i][0][j]) dp[i-1][0][(j*2)%3]^=1,dp[i-1][0][(j*2+1)%3]^=1;
				if(dp[i][1][j]){
					if((r>>(i-1))&1) dp[i-1][0][(j*2)%3]^=1,dp[i-1][1][(j*2+1)%3]^=1;
					else dp[i-1][1][(j*2)%3]^=1;
				}
			}
		}
	}
	yy=(yy%3+3)%3;
	res[yy]=dp[0][0][0]^dp[0][1][0];
	res[(yy+1)%3]=dp[0][0][1]^dp[0][1][1];
	res[(yy+2)%3]=dp[0][0][2]^dp[0][1][2];
}
long long work(long long c){
	long long l=-1e18,r=1e18,mid;
	for(int i=1;i<=n;i++){
		calc(c,x[i],y[i],r);
		rres[0]^=res[0],rres[1]^=res[1],rres[2]^=res[2];
	}
	int pos=0;
	for(int i=0;i<3;i++) if(rres[i]){
		pos=i;
		break;
	}
	while(l<r){
		mid=(l+r)>>1;memset(mres,0,sizeof(mres));
		for(int i=1;i<=n;i++){
			calc(c,x[i],y[i],mid);
			mres[0]^=res[0],mres[1]^=res[1],mres[2]^=res[2];
		}
		if(mres[pos]!=lres[pos]){
			r=mid;
			for(int i=0;i<3;i++) rres[i]=mres[i];
		}
		else{
			l=mid+1;
			for(int i=0;i<3;i++) lres[i]=mres[i];
		}
	}
	return l;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld%lld",&x[i],&y[i]);
	long long k=work(-1e17),lk=k,rk=k;
	for(int i=62;i>=0;i--) if(light(-1e17,lk-(1ll<<i))) lk-=1ll<<i;
	for(int i=62;i>=0;i--) if(light(-1e17,rk+(1ll<<i))) rk+=1ll<<i;
	printf("%lld %lld\n",(long long)(-1e17)+rk-lk,lk);
}


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

int main()
{
	int N, K, ans = 1;
	cin >> N >> K;

	for (int i = 0; i < N; i++) {

		if ((ans * 2) > ans + K) {
			ans += K;
			//cout << ans << endl;
		}

		else if ((ans * 2) < ans + K) {
			ans *= 2;
			//cout << ans << endl;
		}

		else {
			ans += K;
			//cout << ans << endl;
		}
	}

	cout << ans << endl;
}

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

int main()
{
	int N;
	string S;
	set<string> mySet;
	cin >> N;
	while(N--)
	{
		cin >> S;
		mySet.insert(S);
	}
	cout << mySet.size() << endl;
	return 0;
}

Measured memory_bytes: 19264
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, K, Q; cin >> n >> K >> Q;

    vi cnt(n);
    rep(_, Q){
        int v; cin >> v;
        v--;
        cnt[v]++;
    }

    for(auto& e : cnt){
        int x = K - (Q - e);
        bool ok = (x > 0);
        cout << (ok ? "Yes":"No") << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,c,d;cin>>a>>b>>c>>d;
    ll k=a/d;
    if(a%d)k++;
    ll l=c/b;
    if(c%b)l++;
    if(k>=l)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <unordered_map>
#include <cstdio>
#include <climits>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int par[100010], ran[100010];
ll cnt[100010];

void init(int n_) { for (int i = 1; i <= n_; i++)par[i] = i; };

int find(int x) {
	if (par[x] == x)return x;
	else return par[x] = find(par[x]);
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (ran[x] < ran[y]) {
		par[x] = y;
		cnt[y] += cnt[x];
	}
	else {
		if (ran[x] == ran[y])ran[x]++;
		par[y] = x;
		cnt[x] += cnt[y];
	}
}

int n, m, x[100010];
pair<int, pair<int, int>> y[100010];
vector<pair<int, int>> vec[100010];
vector<int> ve;
ll a[100010];
bool bl[100010];
bool bl2[100010];
int ans;

void dfs(int v, int k) {
	bl2[v] = true;
	ve.push_back(v);
	for (int i = 0; i < (int)vec[v].size(); i++) {
		if (k < vec[v][i].second)continue;
		bl[vec[v][i].second] = true;
		if (bl2[vec[v][i].first])continue;
		dfs(vec[v][i].first, k);
	}
}

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> n >> m;
	init(n);
	for (int i = 1; i <= n; i++)cin >> x[i], cnt[i] = x[i];
	for (int i = 0; i < m; i++)cin >> y[i].second.first >> y[i].second.second >> y[i].first;
	sort(y, y + m);
	for (int i = 0; i < m; i++) {
		vec[y[i].second.first].push_back(make_pair(y[i].second.second, i));
		vec[y[i].second.second].push_back(make_pair(y[i].second.first, i));
		unite(y[i].second.first, y[i].second.second);
		a[i] = cnt[find(y[i].second.first)];
	}
	for (int i = m - 1; i >= 0; i--) {
		if (bl[i])continue;
		if (a[i] < y[i].first)ans++;
		else {
			ve.clear();
			dfs(y[i].second.first, i);
			for (int j = 0; j < (int)ve.size(); j++)bl2[ve[j]] = false;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 19020
using System;
class program{
	static void Main(){
      	int n = int.Parse(Console.ReadLine());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, ulong.Parse);
      	Array.Sort(a);
      	ulong ans = a[n-1];
      	int i;
      	for(i=2;i<n/2+1;i++){
          //Console.WriteLine(ans);
          ans += a[n-i]*2;
        }
      	if(n%2== 1) ans += a[n-i];
 	    Console.WriteLine(ans);
	}
}

Measured memory_bytes: 46824
#include<bits/stdc++.h>
using namespace std;
float v[1010],t,ans;
int n,x,y;
bool cmp(int a,int b){
	return a>b;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>v[i];
	sort(v+1,v+n+1);
	//reverse(v+1,v+n+1);	
	for(int i=1;i<n;i++){
		t=(v[i]+v[i+1])/2;
		v[i+1]=t;
	}
	cout<<t;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long 
#define INF 1e9
#define LINF 1e18
 
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;
 
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
 
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int N, M, Q;
int sum[501][501];

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

    cin >> N >> M >> Q;
    for(int i = 0; i < M; ++i) {
        int r, l;
        cin >> l >> r;
        ++sum[l][r];
    }
    for(int i = 1; i <= N; ++i) for(int j = 1; j <= N; ++j) {
        sum[i][j] += sum[i][j - 1];
    }
    for(int i = 1; i <= N; ++i) for(int j = 1; j <= N; ++j) {
        sum[i][j] += sum[i - 1][j];
    }
    for(int i = 0; i < Q; ++i) {
        int l, r;
        cin >> l >> r;
        cout << sum[r][r] + sum[l - 1][l - 1] - sum[r][l - 1] - sum[l - 1][r] << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
import random
ans=0
last=[0]*26
d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
    List=list(map(int,input().split()))
    s.append(List)
for i in range(1,d+1):
    ans=min(enumerate(last), key = lambda x:x[1])[0]
    last[ans]=i
    print(ans+1)

Measured memory_bytes: 9880
#include<cstdio>
#include<iostream>
#include<cstring>
#include<stack>
using namespace std;
stack<char>s;
string a;
int main()
{
    cin>>a;
    int n=a.size();
    for(int i=0;i<n;i++)
        s.push(a[i]);
    bool fa=1;
    for(int i=0;i<n;i++){
        char front=s.top();
        if(front=='b') front='d';
        else if(front=='d') front='b';
        else if(front=='p') front='q';
        else if(front=='q') front='p';
        if(front==a[i]) fa=1,s.pop();
        else {fa=0;break;}
    }
    if(fa==0) printf("No");
    else printf("Yes");
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,d;
    cin>>a>>b>>c;
    d=a+b+c;
    cout<<((d%2==0&&(d/2==a||d/2==b||d/2==c))?"Yes":"No")<<endl;
}


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

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

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

  int res = 0;
  rep(i, 1000) {
    string ns = to_string(i);
    if (i == 0)
      ns = "000";
    else if (i < 10)
      ns = "00" + ns;
    else if (i < 100)
      ns = "0" + ns;
    int idx = 0;
    rep(j, N) {
      if (s[j] == ns[idx]) {
        idx++;
        if (idx == 3) break;
      }
    }
    if (idx == 3) res++;
  }

  cout << res << endl;
}

Measured memory_bytes: 256
n = int(input())
a = sorted(list(map(int, input().split())))
amax = a[-1]

ans = 0
tmp = 0
prev = 0
t = [False] * (amax + 1)
for i in a:
    if i != prev:
        ans += tmp
    tmp = 0
    if not t[i]:
        tmp += 1
        k = i
        while k <= amax:
            t[k] = True
            k += i
    prev = i
ans += tmp
print(ans)


Measured memory_bytes: 116772
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
int n;
long long d[60];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>d[i];
	long long res=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++)
			res+=d[i]*d[j];
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin>>s;
    int n=s.size();
    char ss=s[0];
    int ans=s.size();
    for(int i=1;i<s.size();i++){
        if(ss!=s[i]){
            int p=max(i,n-i);
            ans=min(ans,p);
            ss=s[i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define NewNode (ListNode *)malloc(sizeof(ListNode))
#define Mem(a,b) memset(a,b,sizeof(a))
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-10;
const unsigned long long mod = 998244353;
const double II = 3.1415926535;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int r;
    scanf("%d",&r);
    double sum = 2*r*II*1.0;
    printf("%lf\n",sum);
}


Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int h[n], dp[n] = {0};
  for(int i = 0; i < n; i ++) {
    cin >> h[i];
  }
  for(int i = 1; i < n; i ++) {
    int idx = max(0, i - k);
    for(int j = max(0, i - k) + 1; j < i; j ++) {
      if(dp[idx] + abs(h[i] - h[idx]) > dp[j] + abs(h[i] - h[j])){
        idx = j;
      }
    }
    dp[i] = dp[idx] + abs(h[i] - h[idx]);
  }
  cout << dp[n - 1];
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
from collections import deque

def bfs(adj_list, s):
    q = deque([s])
    visited = [False]*(n+2)
    visited[s] = True
    
    while q:
        v = q.popleft()
        
        for nv in adj_list[v]:
            if not visited[nv]:
                visited[nv] = True
                q.append(nv)

    return visited

while True:
    m = int(input())
    
    if m==0:
        break
    
    n = int(input())
    d = [int(input()) for _ in range(n)]
    adj_list = [[] for _ in range(n+2)]
    rev_adj_list = [[] for _ in range(n+2)]
    
    for i in range(n+1):
        for j in range(1, m+1):
            if i+j>n:
                adj_list[i].append(n+1)
                rev_adj_list[n+1].append(i)
            else:
                t = min(n+1, max(i+j+d[i+j-1], 0))
                adj_list[i].append(t)
                rev_adj_list[t].append(i)
    
    visited_1 = bfs(adj_list, 0)
    visited_2 = bfs(rev_adj_list, n+1)
    
    for i in range(n+2):
        if visited_1[i] and not visited_2[i]:
            print('NG')
            break
    else:
        print('OK')


Measured memory_bytes: 6120
#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 d;
	cin >> d;
	vector<int> c(30);
	vector<int> co(d+5);
	vector<int> ans(d + 5);
	int ans_c = 0;
 
	rep(i,26) {
		cin >> c[i];
	}
 
	vector<int> last(26);
 
	rep(i, 26) {
		last[i]=0;
	}
 
	vector<int> t(d + 5);
	int s[370][30];
 
	rep(j, d) {
		rep(i, 26) {
			cin >> s[j][i];
		}
	}
 
	int count = 0;
	
	rep(j, d) {
 
		int max=s[j][0];
		int max_d=0;
 
		rep(i, 26) {
			if (max <= s[j][i]) {
				max = s[j][i];
				max_d = i;
			}
		}
 
		last[max_d] = j+1;
		count += max;
 
		rep(i, 26) {
			count -= c[i] * (j+1-last[i]);
		}
 
		co[j] = max_d;
	}
 
	ans_c += count;
	count = 0;
//	cout << ans_c << endl;
 
	rep(k, 50000) {
		count = 0;
		rep(j, d) {
			ans[j] = co[j];
		}
 
		rep(i,((50000-k)/1000)+1) {
			ans[(rand() % d)] = rand()%26;
		}
		rep(i, 26) {
			last[i] = 0;
		}
 
		rep(j, d) {
 
			rep(i, 26) {
				if (ans[j] + 1 == i) {
					count += s[j][i];
				}
				else {
					count -= c[i] * (j + 1 - last[i]);
				}
			}
		}
	//	cout << count << endl;
 
		if (ans_c <= count) {
			ans_c = count;
			rep(j, d) {
				co[j] = ans[j];
			}
 
			rep(j, d) {
				cout << co[j] + 1 << endl;
			}
		}
 
	}
 
 
	rep(j, d) {
		cout << co[j]+1<<endl;
	}
 
	return 0;
}

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

int main (){
    int k, cont = 0;
    cin >> k;
    ll n = 7, m = 10, l = 7;

    if(k%2 == 0 || k%5 == 0){
        cout << -1 << endl;
        return 0;
    }

    while(n%k != 0){
        cont++;
        n = (n * m + l) % k;
    }

    cout << cont+1 << endl;

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
using namespace std;
signed main() {
	int h, w, s, t;
	cin >> h >> w >> s >> t;
	if (h*w % 2 == 0)cout << "Yes" << endl;
	else {
		if ((s + t) % 2 == 0)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


Measured memory_bytes: 3124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      String line = in.readLine();

      int[] seqA = new int[n/2];
      int[] seqB = new int[n/2];

      List<Integer> listA = new ArrayList<>();
      List<Integer> listB = new ArrayList<>();
      Map<Integer,Integer> mapA = new HashMap<>();
      Map<Integer,Integer> mapB = new HashMap<>();
      int offset=0,next=0;
      char regx = ' ';
      for(int i=0, j=0; i<n; i++, j= i >> 1) {
        if((next = line.indexOf(regx,offset)) == -1)
          next = line.length();
        Integer num = Integer.parseInt(line.substring(offset, next));
        offset = ++next;

        if((i & 1) == 0) {
          seqA[j] = num;
          if(mapA.containsKey(seqA[j])) {
            mapA.replace(seqA[j], mapA.get(seqA[j]) + 1);
          } else {
            mapA.put(seqA[j], 1);
            listA.add(seqA[j]);
          }
        }
        else {
          seqB[j] = num;
          if(mapB.containsKey(seqB[j])) {
            mapB.replace(seqB[j], mapB.get(seqB[j]) + 1);
          } else {
            mapB.put(seqB[j], 1);
            listB.add(seqB[j]);
          }
        }
      }

      int vma,vmb,xa,xb;
      vma = vmb = xa = xb =0;
      for (Integer var : listA) {
        int ma = mapA.get(var);
        if(vma < ma) {
          vma = ma;
          xa = var;
        }
      }
      for (Integer var : listB) {
        int mb = mapB.get(var);
        if(vmb < mb) {
          vmb = mb;
          xb = var;
        }
      }

      int cca,ccb;
      cca = ccb = 0;
      for (int i : seqA) {
        if(i != xa) cca++;
      }
      for (int i : seqB) {
        if(i != xb) ccb++;
      }

      int vma2,vmb2,xa2,xb2;
      vma2 = vmb2= xa2 = xb2 =0;
      int cca2,ccb2;
      cca2 = ccb2 = 0;
      int ans = 0;
      if(xa == xb) {
        for (Integer var : listA) {
          int ma = mapA.get(var);
          if(var != xa && vma2 < ma) {
            vma2 = ma;
            xa2 = var;
          }
        }
        for (Integer var : listB) {
          int mb = mapB.get(var);
          if(var != xb && vmb2 < mb) {
            vmb2 = mb;
            xb2 = var;
          }
        }
      
        for (int i : seqA) {
          if(i != xa2) cca2++;
        }
        for (int i : seqB) {
          if(i != xb2) ccb2++;
        }

        ans = cca2 > ccb2 ? cca + ccb2 : cca2 + ccb;
      }
      else {
        ans = cca + ccb;
      }

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 45836
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int par[100001], rnk[100001];

int fnd(int a) {
    if (par[a] == a) {
        return a;
    }

    par[a] = fnd(par[a]);
    return par[a];
}

void un(int a, int b) {
    if (fnd(a) == fnd(b)) {
        return;
    }

    if (rnk[fnd(a)] >= rnk[fnd(b)]) {
        par[fnd(b)] = fnd(a);
        rnk[fnd(a)] = rnk[fnd(a)] == rnk[fnd(b)] ? rnk[fnd(a)] + 1 : rnk[fnd(a)];
    }

    else {
        par[fnd(a)] = fnd(b);
    }
}



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

    int n, m;
    cin >> n >> m;
    memset(rnk, 0, sizeof rnk);
    for (int i = 1; i <= n; i++) {
        par[i] = i;
    }

    unordered_set<int> just;
    int x, y, z;
    while (m--) {
        cin >> x >> y >> z;
        un(x, y);
    }

    for (int i = 1; i <= n; i++) {
        just.insert(fnd(i));
    }

    cout << just.size();


}


Measured memory_bytes: 5156
n=gets.to_i
a=gets.split.map(&:to_i)
a.sort!
count=0
for i in 0..a.length-1
    for j in i+1..a.length-1
        if a[i]==a[j]
            next
        end
       v=a[j+1..-1]
       v.delete(a[j])
       #p v
        result=[]
         v.each do |n|
            if a[i]+a[j]>n
                result<<n
            end
        end
        
      #p result
        count+=result.length
    end
end
p count

Measured memory_bytes: 15208
#include <iostream>
#include <vector>
#include <math.h>
#include <climits>
using namespace std;


int main() {
	int n;
	cin >> n;
	int px=0, py=0,pt=0, x=0, y=0,t=0;
	for (int i = 0; i<n; i++) {
		cin>>t >> x >> y;

		int eu = abs(px - x) + abs(py - y);

		if (0 <= t - eu && (t - eu) % 2 == 0) {
			continue;
		}
		cout << "No";
      	return 0;
	}
	cout << "Yes";
	
	return 0;
}



Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

const ll MOD = 1000000007;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  bool ans = false;
  std::cin >> n;
  std::string s;
  std::cin >> s;
  std::vector<int> a(n);
  for (int i = 0; i < (1 << 2);i++){
    for (int j = 0; j < 2;j++){
      if((i>>j)&1){
        a[j] = 0;
      }else{
        a[j] = 1;
      }
    } 
    rep(j,2,n){
      if(s[j-1]=='o'){
        a[j] = a[j - 2] ^ a[j - 1] ^ 1;
      }else{
        a[j] = a[j - 2] ^ a[j - 1];
      }
    }
    bool isCollect = true;
    if(s[n-1]=='o'){
      if((a[n-2]^a[n-1]^a[0])==0){
        isCollect = false;
      }
    }else{
      if(a[n-2]^a[n-1]^a[0]){
        isCollect = false;
      }
    }
    if (s[0] == 'o') {
      if ((a[n - 1] ^ a[1] ^ a[0]) == 0) {
        isCollect = false;
      }
    } else {
      if (a[n - 1] ^ a[1] ^ a[0]) {
        isCollect = false;
      }
    }

    if(isCollect){
      ans = true;
      break;
    }
  }

  if(ans){
    rep(i, 0, n) {
      if (a[i]) {
        std::cout << "S";
      } else {
        std::cout << "W";
      }
    }
  }else{
    std::cout << -1;
  }
  return 0;
}

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

using namespace std;

int main()
{
    string a;
    string b;
    cin >> a;
    cin >>b;
    if(a == "H" && b == "H")
    {
        cout <<"H" <<endl;
    }
    else if(a == "D" && b == "H")
    {
        cout << "D" <<endl;
    }
    else if(a == "H" && b == "D")
    {
        cout << "D" <<endl;
    }
    else if(a == "D" && b == "D" )
    {
        cout << "H" <<endl;
    }
    return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int temp = m / n;
		if (n == 1) {
			System.out.println(m);
			return;
		}
		for (int i = temp; i >= 1; i--) {
			if (m % i == 0) {
				System.out.println(i);
				return;
			}
		}
	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;

int main(){
    ll P;
    cin >> P;
    ll Q;
    cin >> Q;
    ll R;
    cin >> R;
    ll ans=P+Q+R-max(P,max(Q,R));
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define REV(x) (reverse(x.begin(),x.end())) //reverse
const ll MOD=1e9+7;

int main(){
	string s;
	cin>>s;
	REV(s);
	ll dp[13]={};
	dp[0]=1;
	ll ten=1;
	for(char x:s){
		vector<ll> dp2(13,0);
		FOR(j,0,10){
			ll add = ten*j%13;
			if(x=='?'||(j==(x-'0')))
				FOR(i,0,13)
					(dp2[(add+i)%13]+=dp[i])%=MOD;
		}
		FOR(i,0,13)dp[i]=dp2[i];
		(ten*=10)%=13;
	}
	cout << dp[5] << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
  int a,b,c;
  scanf("%d\n",&a);
  while(scanf("%d %d %d\n",&a,&b,&c)!=EOF) {
    if(b>a){int s=b;b=a;a=s;}
    if(c>a){int s=c;c=a;a=s;}
    if(a*a==(b*b+c*c)) printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 584
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
from math import pi, ceil, floor
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
from bisect import bisect_left, bisect_right, insort_left, insort_right
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def total_check(sugar, water, lim):
    if sugar + water <= lim:
        return True
    else:
        return False


def concentration(sugar, water, lim_sugar):
    if sugar / (sugar + water) <= lim_sugar / (lim_sugar + 100):
        return True
    else:
        return False


def main():
    a, b, c, d, lim_sugar, lim = map(int, input().split())
    water_list = []
    for i in range(lim // (100 * a) + 1):
        for j in range(lim // (100 * b) + 1):
            if i == 0 and j == 0: continue
            w = 100 * i * a + 100 * j * b
            if w > lim: continue
            water_list.append(w)
    water_list = sorted(list(set(water_list)))

    sugar_list = []
    for i in range(lim // c + 1):
        for j in range(lim // d + 1):
            s = i * c + j * d
            if s > lim: continue
            sugar_list.append(s)
    sugar_list = sorted(list(set(sugar_list)))

    c = 0
    ans = (100 * a, 0)
    for w in water_list:
        for s in sugar_list:
            if total_check(s, w, lim) and concentration(s, w, lim_sugar):
                if c < s * 100 / (s + w):
                    c = s * 100 / (s + w)
                    ans = (s + w, s)
    print(*ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 21736
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n,x,t;
    cin >> n >> x >> t;
    int ans = 0;
    ans += n/x * t;
    if(n%x >0) ans += t;
    cout << ans << endl;

return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while( true ){
			int n = Integer.parseInt(scan.next());
			int r = Integer.parseInt(scan.next());
			int[] num = new int[n];
			for( int i = 0; i < n; i++ ){
				num[i] = n - i;
			}
			if( n == 0 && r == 0 ){
				break;
			}
			for( int i = 0; i < r; i++ ){
				int p = Integer.parseInt(scan.next());
				int c = Integer.parseInt(scan.next());
				Func(num, n, p, c);
			}
			for( int i = 0; i < n; i++ ){
			}
			System.out.println(num[0]);
		}
		return;
	}
	
	public static void Func(int[] num, int n, int p, int c){
		int[] n1 = new int[p-1];
		int[] n2 = new int[c];
		int[] n3 = new int[n-p+1-c];
		for( int i = 0; i < p - 1; i++ ){
			n1[i] = num[i];
		}
		for( int i = 0; i < c; i++ ){
			n2[i] = num[i+p-1];
		}
		for( int i = 0; i < n-p+1-c; i++ ){
			n3[i] = num[i+p-1+c];
		}
		
		for( int i = 0; i < c; i++ ){
			num[i] = n2[i];
		}
		for( int i = 0; i < p - 1; i++ ){
			num[i + c] = n1[i];
		}
		for( int i = 0; i < n-p+1-c; i++ ){
			num[c+p-1+i] = n3[i];
		}
		return;
	}
}

Measured memory_bytes: 26856
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;
const int MAX=20;

int N,K;
vector<int>A;
bool f(int x){
    int count=0;
    REP(i,N){
        if(0<=A[i]){
            int ok=-1;
            int ng=N;
            while(ng-ok>1){
                int mid=(ng+ok)/2;
                if(A[mid]*A[i]<x)ok=mid;
                else ng=mid;
            }
            count+=ng;
        }
        else{
            int ng=-1;
            int ok=N;
            while(ok-ng>1){
                int mid=(ng+ok)/2;
                if(A[mid]*A[i]<x)ok=mid;
                else ng=mid;
            }
            count+=N-ok;
        }
        if(A[i]*A[i]<x)count--;
    }
    count/=2;
    return  count<K;
}
void solve(){
    int ok=-INF;int ng=INF;
    while(ng-ok>1){
        int mid=(ok+ng)/2;
        if(f(mid))ok=mid;
        else ng=mid;
    }
    cout<<ok<<endl;
}

signed main(){
    cin>>N>>K;
    A.resize(N);
    REP(i,N)cin>>A[i];
    sort(A.begin(),A.end());
    solve();
}

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

using namespace std;

typedef long long LL;
const int mod = 1000000007;

unordered_map<LL, LL>m1;

LL f(LL n);

int main(){
  LL n;
  m1[1] = 2, m1[2] = 4, m1[3] = 5;
  scanf("%lld", &n);
  printf("%lld\n", f(n));
  return 0;
}
LL f(LL n){
  if(m1[n] != 0) return m1[n];
  LL n1 = n>>1;
  LL n2 = (n-(LL)1)>>1;
  LL n3 = (n-(LL)2)>>1;
  return m1[n] = (f(n1)%mod + f(n2)%mod + f(n3)%mod)%mod;
}


Measured memory_bytes: 256
from collections import deque
N = int(input())
A = list(map(int, input().split()))
#N=3
#A=[1,2,3]
q=deque(A)
#print(q)
ans=0
sums=sum(q)
#print(sums)
for i in range(N-1):
    qwe=q.popleft()
    ans+=qwe *(sums-qwe)
    sums-=qwe
print(ans%(10**9+7))

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

int n;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    vector<ll> a(n);
    for (auto& i : a) cin >> i;
    multiset<ll> groups;
    
    for (int i = n - 1; i >= 0; --i) {
        auto ub = groups.upper_bound(a[i]);
        if (ub != groups.end()) 
            groups.erase(ub);
        groups.insert(a[i]);
    }

    cout << groups.size();
}



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


int main() {
  int N;
  cin >> N;
  int S;
  S = 7;
  int count = 0;
  if(N == 1 || N == 7){
    cout << 1 << endl;
  }
  else if(N % 2 == 0 || N % 5 == 0){
    cout << -1 << endl;
  }
  else{
    for(int i = 0; i < N; i++){
      S = (S*10 + 7) % N;
      count++;
      if(S == 0){
        break;
      }
    }
    cout << count + 1 <<endl;
  }
}

Measured memory_bytes: 3604
N = int(input())
m = float("inf")
alist = []
blist = []

for i in range(1,N):
    a = i
    b = N - i
    while a > 0:
        alist.append( a % 10 )
        a //= 10
    alist.reverse()
    while b > 0:
        blist.append( b % 10 )
        b //= 10
    blist.reverse()
    A = sum(alist)
    B = sum(blist)
    if A + B < m:
        m = A + B
    alist.clear()
    blist.clear()

print(m)

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

ll f(ll x) {
    if (x < 0) return 0;
    else if (x % 4 == 0) {
        return x ^ 0;
    }
    else if (x % 4 == 1) {
        return 1;
    }
    else if (x % 4 == 2) {
        return x ^ 1;
    }
    else if (x % 4 == 3) {
        return 0;
    }
    return 0;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll ans = f(b) ^ f(a-1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    long long int n,x,y,o,e,i;
    scanf("%lld",&n);
    for(i=sqrt(n); i>=1; i--)
    {
        if(n%i==0)
        {
            x=i;
            y=n/i;
            printf("%lld\n",x+y-2);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <string>
#include <bitset>
#include <cassert>
#include <queue>
#include <memory>

//#pragma comment(linker, "/STACK:16777216")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")

using namespace std;

//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
//#define double long double
#define int ll
//#define int ull
//#define int short
//#define int unsigned short
//#define int unsigned int
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define hash hash228
const int SZ = 2e5 + 4;
const double EPS = 1e-7;
const int mod = 998244353;
const int hashpow = 2;
const int inf = 2e9;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int n;

void read() {
    cin >> n;
}

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

signed main() {

#ifdef __LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

//    int t;
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
        read();
        solve();
//    }

    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int H,W;
char F[101][101];
int A[101][101];
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

void dfs(int i, int j){
    A[i][j] = 1;
    for(int k=0; k<4; k++) {
        int nx = i + dx[k], ny = j + dy[k];
        if(nx >= 0 && nx < H && ny >= 0 && ny < W && F[nx][ny] == F[i][j]) {
            if(A[nx][ny] == 0) dfs(nx,ny);
        }
    }
}

int main() {
    while(1){
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        for(int i=0; i<H; i++) {
            for(int j=0; j<W; j++) cin >> F[i][j];
        }
        for(int i=0; i<H; i++) {
            for(int j=0; j<W; j++) A[i][j] = 0;
        }

        int res = 0;
        for(int i=0; i<H; i++) {
            for(int j=0; j<W; j++) {
                if(A[i][j] == 0) {
                    dfs(i,j);
                    res++;
                }
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3644
#pragma region include
    #include <iostream>
    #include <vector>
    #include <algorithm>
    #include <map>
    #include <string>
    #include <queue>
    #include <stack>
    #include <cmath>
    #include <set>
    #include <cstdio>
    #define ALL(obj) (obj).begin(),(obj).end()
    #define RALL(obj) (obj).rbegin(),(obj).rend()
    #define REP(i, n) for(int i = 0; i < n; i++)
    #define REPR(i, n) for(int i = n; i >= 0; i--)
    #define FOR(i, m, n) for(int i = m; i < n; i++)
    #define MOD 1000000007
    #define INF 1000000000
    #define LLINF 4000000000000000000
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> PII;
    typedef vector<int> VI;
    typedef vector<VI> VVI;
    #pragma endregion
     
    //#define __DEBUG__
    #ifdef  __DEBUG__
    #define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
    // vector出力
    template<typename T>
    ostream& operator << (ostream& os, vector<T>& v) {
        os << "{";
        REP(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
        os << "}";
        return os;
    }
    // pair出力
    template<typename T, typename U>
    ostream& operator << (ostream& os, pair<T, U>& p) {
        return os << "(" << p.first << ", " << p.second << ")";
    }
    // map出力
    template<typename T, typename U>
    ostream& operator << (ostream& os, map<T, U>& map_var) {
        os << "{";
        for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
            os << "(" << itr->first << ", " << itr->second << ")";
            itr++;
            if (itr != map_var.end()) os << ", ";
            itr--;
        }
        os << "}";
        return os;
    }
    // set 出力
    template<typename T>
    ostream& operator << (ostream& os, set<T>& set_var) {
        os << "{";
        for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
            os << *itr;
            ++itr;
            if (itr != set_var.end()) os << ", ";
            itr--;
        }
        os << "}";
        return os;
    }
    #endif
     
    int main() {
        cin.tie(0); ios::sync_with_stdio(false);
        int R, G, B, N;
        ll cnt = 0;
        cin >> R >> G >> B >> N;
        REP(r, N+1) {
            REP(g, N+1) {
                if (N - r * R - g * G >= 0 && (N - r * R - g * G) % B == 0) {
                    cnt++;
                }
            }
        }
        cout << cnt << endl;
        getchar(); getchar();
    }

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long N = long.Parse(str[0]);
		long A = long.Parse(str[1]);
		long B = long.Parse(str[2]);
		long K = long.Parse(str[3]);
		long mod = 998244353;
		long [] NA = new long[N+1];
		long [] INA = new long[N+1];
		NA[0] = 1;
		INA[0] = 1;
		for(var i=1;i<NA.Length;i++){
			NA[i] = NA[i-1] * i % mod;
			INA[i] = INA[i-1] * Mpow(i,mod-2,mod) % mod;
		}
		long ans = 0;
		for(var i=0;i<=N;i++){
			if(K-A*i < 0){
				break;
			}
			if((K-A*i)%B == 0){
				long j1 = (K-A*i)/B;
				if(j1<=N){
					long an1 = NA[N] * INA[N-i] % mod;
					an1 = an1 * INA[i] % mod;
					an1 = an1 * NA[N] % mod;
					an1 = an1 * INA[N-j1] % mod;
					an1 = an1 * INA[j1] % mod;
					ans = (ans + an1) % mod;
				}
			}
		}
		Console.WriteLine(ans);
	}

	public static long Mpow(long x,long n,long m)
	{
		long ans = 1;
		while(n > 0){
			if(n % 2 == 1){
				ans = ans * x % m;
				n -= 1;
			}
			x = x * x % m;
			n /= 2;
		}
		return ans;
	}
}

Measured memory_bytes: 15584
#include<stdio.h>
int main(){
  int a,b,c,min,max;
  scanf("%d%d",&a,&b);
  while(b!=0){
    if(a>b)
      min=b,max=a,c=b;
    else
      min=a,max=b,c=a;
    b=max%min;
    a=c;  
  } 
  printf("%d\n",min);
  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int maxx = 2e5 + 5;
//int a[101];
int main(){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
       ios_base::sync_with_stdio(false);
       cin.tie(0);
 string s;
 cin>>s;
 for (int i = 0; i < s.size(); ++i)  
 {
 	if(s[i] >= 'a' && s[i]<='z'){
 		s[i]='x';
 	}
 }
 cout<<s<<endl;
 return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, T;
    cin >> n >> T;
    ll ans = 0;
    int t[n];
    rep(i, 0, n) {
        cin >> t[i];
    }

    ans += T;
    rep(i, 1, n) {
        ans += min(T, t[i] - t[i - 1]);
    }

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


Measured memory_bytes: 1024
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    s = SR(n)
    print(len(set(s)))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 108992