akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int data[10][10010];
int r, c, i, j, res;
int cnt;
bool flag[15];

#define max(a, b) ((a < b) ? b : a)

void func(int now);

int main(void)
{
	while (cin >> r >> c, r && c){
		cnt = 1;
		for (i = 0; i < 15; i++) flag[i] = false;
		for (i = 0; i < r; i++){
			for (j = 0; j < c; j++){
				scanf("%d", &data[i][j]);
			}
		}
		
		res = 0;
		func(0);
		cout << res << endl;
	}
	
	return 0;
}

void func(int now)
{
	// r > ñ@c > s
	if (now == r){
		int sum = 0;
		for (i = 0; i < c; i++){
			int tmp = 0;
			for (j = 0; j < r; j++){
				if ((!flag[j] && (data[j][i] == 1)) || (flag[j] && (data[j][i] == 0))){
					tmp++;
				}
			}
			// tmp > iñÌ1ÌÐÁ­è©¦µÄ0ÉÈé©¸
			// c - tmp > iñÌ0ÌÐÁ­è©¦µÄ1ÉÈé©¸
			if (tmp < (r - tmp)){
				sum += (r - tmp);
			}
			else {
				sum += tmp;
			}
		}
		res = max(res, sum);
	}
	else if (r < now) return;
	
	flag[now] = true;
	func(now + 1);
	
	flag[now] = false;
	func(now + 1);
	
	return;
}

Measured memory_bytes: 1300
#include <stdio.h>

int main(void) {
	int a, b, c, i;
	int n = 0;
	
	scanf("%d %d %d", &a, &b, &c);
	
	for(i = a; i <= b; i++) {
		if(c % i == 0) {
			n++;
		}
	}
	
	printf("%d\n", n);
    
    return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<string.h>
#include<bitset>
#include<set>
using namespace std;
int day, N, ans;
int d[201], n[201][3];
int dp[201][201];
int main(){
	cin >> day >> N;
	for (int i = 1; i <= day; i++)
		cin >> d[i];
	for (int i = 1; i <= N; i++)
		cin >> n[i][0]>>n[i][1]>>n[i][2];
	for (int i = 0; i < 201; i++)
		fill(dp[i], dp[i] + 201, -1);
	for (int i = 1; i <= day; i++){
		for (int j = 1; j <= N; j++){
				if (d[i] >= n[j][0] && d[i] <= n[j][1]){
					if (i == 1){
						dp[1][j] = 0;
						continue;
					}
					for (int k = 1; k <= N; k++){
						if (dp[i - 1][k] != -1)
							dp[i][j] = max(dp[i][j], abs(n[j][2] - n[k][2]) + dp[i - 1][k]);
				}
			}
				if (i == day)
					ans = max(dp[i][j], ans);
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1320
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
ll A[5000001],bin[5000001];
vector<ll>v;
map<int,int>myMap;
set<int>mySet;
vector<pair<ll,ll> >vp;
/* Precode Start Here *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
 ll m,sum_of_digits=0,number_of_digits=0,d,c;
 cin>>m;
 for(int i=0;i<m;i++)
 {
     cin>>d>>c;
     number_of_digits+=c;
     sum_of_digits+=d*c;
 }
 cout<<number_of_digits-1+(sum_of_digits-1)/9<<endl;
return 0;
}



Measured memory_bytes: 256
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

A = None
B = None
N = None

def calc(x):
    return floor(A*x/B) - A * floor(x/B)

def main():
    global A,B,N
    A,B,N = map(int, input().split())
    if B > N:
        return calc(N)
    else:
        #mmax = 0
        #for x in range(N+1):
        #    mmax = max(mmax, calc(x))
        #print(mmax)
        return calc(B-1)

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 10520
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
#define inf 1000000001
using namespace std;
#define N 205
#define M 100005
int n,m,cnt=1,s,t,head[N],vis[N];char str[N];
struct edge{int to,nxt,c;}e[M<<1];
void adde(int x,int y,int z){e[++cnt].to=y;e[cnt].nxt=head[x];e[cnt].c=z;head[x]=cnt;}
void ins(int x,int y,int z){adde(x,y,z);adde(y,x,0);}
int dfs(int u,int flow){
	if (u==t) return flow;
	int w,used=0;
	for (int i=head[u],v;i;i=e[i].nxt){
		v=e[i].to;
		if (e[i].c&&vis[v]==vis[u]+1){
			w=dfs(v,min(flow-used,e[i].c));
			e[i].c-=w;e[i^1].c+=w;used+=w;
			if (flow==used) return used;
		}
	}
	if (!used) vis[u]=-1;
	return used;
}
bool bfs(){
	queue<int> q;q.push(s);rep (i,1,t) vis[i]=-1;vis[s]=1;
	while (!q.empty()){
		int u=q.front();q.pop();
		for (int i=head[u],v;i;i=e[i].nxt){
			v=e[i].to;
			if (e[i].c&&vis[v]==-1) vis[v]=vis[u]+1,q.push(v);
		}
	}
	return vis[t]!=-1;
}
int dinic(){int ret=0;while (bfs()) ret+=dfs(s,inf);return ret;}
int main(){
	scanf("%d%d",&n,&m);s=n+m+1,t=n+m+2;
	rep (i,1,n){
		scanf("%s",str+1);
		rep (j,1,m){
			if (str[j]=='o') ins(i,j+n,1),ins(j+n,i,1);
			if (str[j]=='S') ins(s,i,inf),ins(s,j+n,inf),ins(i,j+n,inf),ins(j+n,i,inf);
			if (str[j]=='T') ins(j+n,t,inf),ins(i,t,inf),ins(i,j+n,inf),ins(j+n,i,inf);
		}
	}
	int ans=dinic();
	if (ans>=inf) puts("-1");else cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 768
n=int(input())

if(n<10):
    ans=n
elif(9<n and n<100):
    ans=9
elif(99<n and n<1000):
    ans=9+n-100+1
elif(999<n and n<10000):
    ans=9+900
elif(9999<n and n<100000):
    ans=9+900+n-10000+1
elif(n==100000):
    ans=9+900+90000


print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define vvvel vector<vvel>
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
void sor(vel &v) { sort(v.begin(), v.end()); }
int zero() { return 0; }
signed main() {
	int n, k;
	cin >> n >> k;
	vel w(n); vel d(n);
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> d[i];
	}
	int upp = w[0] + d[0] * k;
	int low = 0;
	while (upp - low > 1) {
		int mid = (upp + low) / 2;
		int ko = 0;
		for (int i = 0; i < n; i++) {
			ko += max((mid - w[i]+d[i]), zero()) / d[i];
		}
		if (ko < k) low = mid;
		else upp = mid;
	}
	cout << upp << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll n,t;
    scanf("%lld%lld",&n,&t);
    fr time[n];
    // ll [n];
    rep(i,0,n){
        scanf("%lld%lld",&time[i].a,&time[i].b);
    }
    strsortup(time,n);
    rep(i,0,n){
        if(time[i].b<=t){
            printf("%lld\n",time[i].a);
            return 0;
        }
    }

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


Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n, q;
	cin >> n >> q;
	vector<int> sets(n);
	for (int i = 0; i < n; ++i) {
		sets[i] = i;
	}

	const int UNITE = 0;
	const int SAME = 1;

	int query, x, y;
	int set_num;
	while (q--) {
		cin >> query >> x >> y;
		switch(query) {
			case UNITE:
				if (sets[x] == sets[y]) break;

				set_num = sets[y];
				for (int i = 0; i < n; ++i) {
					if (sets[i] == set_num) sets[i] = sets[x];
				}
				break;
			case SAME:
				cout << (sets[x] == sets[y] ? 1 : 0) << endl;
				break;
			default:
				// nothing to do.
				break;
		}
	}
	return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  string s, t;
  cin >> s;
  t = s;
  reverse(all(t));
  int ans = 0;
  rep(i, s.size()) if (s[i] != t[i]) ans++;
  ans /= 2;
  cout << ans << endl;
}


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

namespace ITP2_6_A
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            Dictionary<int,int> line = ReadIntAr().Distinct().ToDictionary(x => x);
            int q = ReadInt();

            for (int i = 0 ; i < q ; i++)
            {
                Console.WriteLine(line.ContainsKey(ReadInt()) ? 1 : 0);
            }


        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 38016
#include<iostream>
#include<algorithm>
using namespace std;
#define reps(i,b,n) for(int i = b ; i < n ; ++i )
#define rep(i,n) reps(i,0,n)
#define INF (1 << 30)
#define MOD 100000
int dp[51][3001],N,M,S;
int main(){
  while(cin >> N >> M >> S , N){
    fill_n(dp[0],51*3001,0);
    dp[0][0] = 1;
    for(int i = 1 ; i <= M ; i++ ){
      for(int j = N * N ; j > 0 ; j-- ){
        for(int k = i ; k <= S ; k++ ){
          dp[j][k] = (dp[j][k] + dp[j-1][k-i]) % MOD;
        }
      }
    }
    cout << dp[N*N][S] << endl;
  }
}

Measured memory_bytes: 1756
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>


using namespace std;
int main() {
	int N, i;
	cin >> N;
	vector<int> a(N);
	for (i = 0; i < N; i++) { cin >> a[i]; }
	sort(a.begin(), a.end());
	cout << a[N-1] - a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INFLL (1ll<<60)
static const int MAX=200000;
int N;
ll a[MAX],sum;
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    
    cin>>N;
    cin>>a[0];
    for(int i=1;i<N;i++){
        cin>>a[i];
        a[i]+=a[i-1];
    }
    ll min_d=INFLL;
    
    for(int i=0;i<N-1;i++){
        if(min_d>abs(a[i]-(a[N-1]-a[i]))) min_d=abs(a[i]-(a[N-1]-a[i]));
    }
    
    cout<<min_d<<"\n";
    
    return 0;
}

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

int main() {
	int n,temp,ans=0;cin>>n;
  	vector<int> a(100000);
  	for(int i=0;i<n;i++){
    	cin>>temp;
      	a[temp]++;
    }
  	for(int i=2;i<=100000;i++){
     	 ans=max(ans,a[i-2]+a[i-1]+a[i]);
    }
  	cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX
bool cmp(int a, int b) {
	return a > b;
}
 
int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    long long ans=0;
    vector<int> h(n);
	for (int i = 0; i < n; ++i)
		cin >> h[i];
	sort(h.begin(), h.end(), cmp);
    for (int i=k; i<n; i++){
        ans+=h[i];
    }   
    cout<<ans<<endl;
    
 
}

Measured memory_bytes: 1024
import sys

def S(): return sys.stdin.readline().rstrip()

A,B = map(int,S().split())

def f(n):  # 0からnまでのxor
    res = 0
    for i in range(41):  # 2**iの位
        if i == 0:
            res += ((n+1)//2) % 2
        else:
            a = n - ((n >> (i+1)) << (i+1))
            if a < 2**i or a % 2 == 1:
                continue
            else:
                res += 1 << i
    return res

print(f(B) ^ f(A-1))

Measured memory_bytes: 61896
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define Pi 3.1415926535
#define MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}
void yes(){cout << "Yes" << endl;}
void no(){cout << "No" << endl;}

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

    rep(i,n-1){
        if(w[i].back() != w[i+1].front()){
            no();
            return 0;
        }
    }
    
    sort(all(w));

    rep(i,n-1){
        if(w[i] == w[i+1]){
            no();
            return 0;
        }
    }

    yes();

    return 0;
}

int main(){
    cin.tie(0);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll Inf = 1e18;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

class UnionFind {
    public:
        vector<int> rank, p, size;

        UnionFind() {}
        UnionFind(int s) {
            rank.resize(s, 0);
            p.resize(s, 0);
            size.resize(s, 0);
            rep (i, s) init(i);
        }

        void init(int x) {
            p[x] = x;
            rank[x] = 0;
            size[x] = 1;
        }

        bool isSame(int x, int y) {
            return root(x) == root(y);
        }

        void unite(int x, int y) {
            if (isSame(x, y)) return;
            link(root(x), root(y));
        }

        void link(int x, int y) {
            if (rank[x] > rank[y]) {
                p[y] = x;
                size[x] += size[y];
            } else {
                p[x] = y;
                size[y] += size[x];
                if (rank[x] == rank[y]) {
                    rank[y]++;
                }
            }
        }

        int root(int x) {
            if (x != p[x]) {
                p[x] = root(p[x]);
            }
            return p[x];
        }

        int getSize(int x) {
            return size[root(x)];
        }
};

struct edge {
    int source, target, cost;
    edge(int source = 0, int target = 0, int cost = 0): source(source), target(target), cost(cost) {}
    bool operator < (const edge &e) const {
        return cost < e.cost;
    } 
};

int kruskal(int N, vector<edge> edges) {
    int totalCost = 0;
    sort(edges.begin(), edges.end());

    UnionFind uf = UnionFind(N + 1);
    rep (i, N) uf.init(i);

    int source, target;
    rep (i, edges.size()) {
        edge e = edges[i];
        if (!uf.isSame(e.source, e.target)) {
            totalCost += e.cost;
            uf.unite(e.source, e.target);
        }
    }

    return totalCost;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int v, e;
    cin >> v >> e;
    vector<edge> g;
    rep (i, e) {
        int s, t, w;
        cin >> s >> t >> w;
        edge e;
        e.source = s, e.target = t, e.cost = w;
        g.push_back(e);
    }
    cout << kruskal(v, g) << endl;

    return 0;
}




Measured memory_bytes: 5176
#include <stdio.h>
#include <stdlib.h>
#include <math.h>



int main()
{
    int i,n;
    int result=0;
    int* arr;
    double p;
    double avg;
    int sum_all =0;
    
    scanf("%d",&n);
    arr = (int*)malloc(n*sizeof(int));
    
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
        sum_all+= arr[i];
    }
    
    avg = (double)sum_all/n;
    if( avg-(int)avg >= 0.5)
    {
        p = ceil(avg);
    }
    else
    {
        p = floor(avg);
    }
    
    for(i=0;i<n;i++)
    {
        result += (arr[i]-p)*(arr[i]-p);
    }
    printf("%d",result);

    return 0;
}


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

int main() {
	ll K,A,B;
	cin >> K >> A >> B;
	cout << max(K+1, max(0ll,(K+1-A)/2)*(B-A)+((K>A-2)?A:0)+(((K+1-A)/2>0)?((K+1-A)%2):0)) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int a,b,k;
    scanf("%d%d%d",&a,&b,&k);
    if(a<b){
        swap(a,b);
    }
    int h[1001],j=0;
    for(int i=1;i<=b;i++){
        if(a%i==0&&b%i==0){
            h[j++]=i;
        }
    }
    sort(h,h+j);
    printf("%d\n",h[j-k]);
    return 0;
}


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

int main(int argc, char *argv[]) {
        int a, b;
        scanf("%d", &a);
        scanf("%d", &b);
        if (a < b) {
                printf("a < b\n");
        } else if (a > b) {
                printf("a > b\n");
        } else {
                printf("a == b\n");
        }
        return 0;
}

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

using ll = long long;
using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(false)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x)         cout << ((x) ? "YES" : "NO") << endl
#define Yn(x)         cout << ((x) ? "Yes" : "No") << endl
#define yn(x)         cout << ((x) ? "yes" : "no") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;

ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return (a == 0 || b == 0) ? 0 : (a / __gcd(a, b) * b); }

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

	vector<ll> a(n, LLONG_MAX);
	vector<ll> b(n-1);

	rep(i, n-1) {
		cin >> b.at(i);
		a.at(i)   = min(a.at(i)  , b.at(i));
		a.at(i+1) = min(a.at(i+1), b.at(i));
	}

	ll ret = 0;
	rep(i, n) {
		ret += a.at(i);
	}

	cout << ret << endl;

	return 0;
}


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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int h, w, n, sx, sy;
	string s, t;
	cin >> h >> w >> n;
	cin >> sx >> sy;
	cin >> s >> t;
	bool ans = 0;
	for (int i=0, x=sx; i<n; i++) {
		if (s[i] == 'U') x --;
		if (x <= 0) ans = 1;
		 if (t[i] == 'D') x ++;
		 x = min(x, h);
	}
	for (int i=0, x=sx; i<n; i++) {
		if (s[i] == 'D') x ++;
		if (x > h) ans = 1;
		 if (t[i] == 'U') x --;
		 x = max(1, x);
	}
	for (int i=0, y=sy; i<n; i++) {
		if (s[i] == 'L') y --;
		if (y <= 0) ans = 1;
		 if (t[i] == 'R') y ++;
		 y = min(w, y);
	}
	for (int i=0, y=sy; i<n; i++) {
		if (s[i] == 'R') y ++;
		if (y > w) ans = 1;
		 if (t[i] == 'L') y --;
		 y = max(y, 1);
	}
	cout << (ans ? "NO" : "YES");
	return 0;
}


Measured memory_bytes: 920
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstring>

using namespace std;

const int MAX = 21;

struct Edge{int src, dst, cost;};

vector<int> E[MAX];
bool come[MAX];
int inEdge[MAX];

int main(){
  int m,n;
  cin >> m >> n;
  while(n--){
    int a, b;
    cin >> a >> b;
    a--;b--;
    E[a].push_back(b);
    inEdge[b]++;
  }
  
  memset(come,false,sizeof(come));
  queue<int> Q;

  for(int i = 0; i < m; i++){
    if(inEdge[i] == 0) Q.push(i);
  }

  vector<int> ans;
  while(!Q.empty()){
    int now = Q.front();
    Q.pop();

    if(come[now]) continue;

    come[now] = true;
    ans.push_back(now+1);
    for(int i = 0; i < (int)E[now].size(); i++) inEdge[E[now][i]]--;
    for(int i = 0; i < m; i++) if(inEdge[i] == 0 && !come[i]) Q.push(i);
  }

  for(int i = 0; i < (int)ans.size(); i++) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 1220
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int)(x).size())
#define MSG(a) cout << #a << " " << a << endl;

int main()
{
    ll N;
    int K;
    cin >> N >> K;
    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        int h;
        cin >> h;
        if (h >= K) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
def resolve():
    n, a, b = list(map(int, input().split()))
    MOD = 10**9+7
    ntoa = 1
    ato1 = 1
    ntob = 1
    bto1 = 1
    for i in range(a):
        ntoa *= (n-i)
        ntoa %= MOD
        ato1 *= (a-i)
        ato1 %= MOD
    for i in range(b):
        ntob *= (n-i)
        ntob %= MOD
        bto1 *= (b-i)
        bto1 %= MOD
    def pow(x, n, MOD=10**9+7):
        ret = 1
        while n > 0:
            if n & 1:
                ret = (ret*x)%MOD
            x = (x*x)%MOD
            n >>= 1
        return ret
    nca = ntoa*pow(ato1, MOD-2)%MOD
    ncb = ntob*pow(bto1, MOD-2)%MOD
    print((pow(2, n)%MOD-1-nca-ncb)%MOD)

if '__main__' == __name__:
    resolve()


Measured memory_bytes: 64056
n, l = (int(i) for i in input().split())
ap=[]
 
for i in range(n):
	ap.append(l+i)
 
mn=min(map(abs,ap))
 
if mn not in ap:
	mn=-mn
 
res=int((l-1)*n+(1+n)*n/2-mn)
print(res)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<int> Ls(N);
    for (int i = 0; i < N; ++i) cin >> Ls[i];
    sort(Ls.rbegin(), Ls.rend());
    LLONG count = 0;
    for (int i = 0; i < N - 2; ++i)
    {
        const int longest = Ls[i];
        for (int j = i + 1; j < N; ++j)
        {
            for (int k = j + 1; k < N; ++k)
            {
                if (Ls[j] + Ls[k] > longest)
                {
                    ++count;
                }
                else
                {
                    break;
                }
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    x, y, z = (int(i) for i in sys.stdin.read().split())
    n = 0
    while True:
        total = (n + 1) * z + n * y
        if total <= x: n += 1; continue
        else:
            if n == 0: print(0)
            else:print(n-1)
            exit()

if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 2940
def DFS(graph,root,parent):
  dist = [-1]*(n+1)
  dist[root] = 0
  stack = [root]
  while stack:
    x = stack.pop()
    for y in graph[x]:
      if dist[y] == -1:
        parent[y] = x
        dist[y] = dist[x]+1
        stack.append(y)
  return dist

#親のリスト、頂点v、kが与えられたときに「vのk個上の祖先」を見る
class Doubling:
  def __init__(self,graph,root):
    self.root = root
    n = len(graph)-1
    self.ancestor_ls = [[0]*(n+1)]
    self.distance = DFS(graph,root,self.ancestor_ls[0])
    self.bitn = n.bit_length()
    for i in range(1,self.bitn+1):
      ancestor_ls_app = [0]*(n+1)
      for j in range(1,n+1):
        ancestor_ls_app[j] = self.ancestor_ls[i-1][self.ancestor_ls[i-1][j]]
      self.ancestor_ls.append(ancestor_ls_app)
  
  def dist(self):
    return self.distance
  
  def parent(self):
    return self.ancestor_ls[0]

  def ancestor(self,v,depth):
    if depth == 1:
      return self.ancestor_ls[0][v]
    if depth == 2:
      return self.ancestor_ls[1][v]
    if depth == 0:
      return v
    if n<depth:
      return self.root
    ret = v
    for i in range(self.bitn):
      if depth&1<<i:
        ret = self.ancestor_ls[i][ret]
    return ret

import sys
input = sys.stdin.readline
from collections import deque
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
if a[0] != 1:
  ans += 1
graph = [[] for i in range(n+1)]
for i in range(1,n):
  graph[a[i]].append(i+1)
  graph[i+1].append(a[i])
if k > n:
  print(ans)
  exit()
sol = Doubling(graph,1)
dist = sol.dist()
if k == 1:
  print(n-dist.count(1)-dist.count(0)+ans)
  exit()
dls = []
for i in range(1,n+1):
  dls.append((dist[i],i))
vis = [0]*(n+1)
dls.sort()
dlsq = deque(dls)
parent = sol.parent()
while True:
  d,x = dlsq.pop()
  if d <= k:
    break
  if vis[x] == 1:
    continue
  ans += 1
  anc = sol.ancestor(x,k-1)
  stack = deque([anc])
  while stack:
    v = stack.pop()
    vis[v] = 1
    for u in graph[v]:
      if parent[u] == v and vis[u] != 1:
        stack.append(u)
print(ans)

Measured memory_bytes: 91040
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n,r;
    cin >> n >> r;
    if(n>=10) cout << r << endl;
    else cout << r + 100 * (10 - n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
int a=0,b=0,c,n;
vector<int> card;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	FOR(i,0,n){
		cin>>c;
		card.push_back(c);
	}
	sort(card.begin(),card.end());
	FOR(i,0,n){
		if(i%2)b+=card[card.size()-1-i];
		else a+=card[card.size()-1-i];
	}
	cout<<a-b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
long long bscore[100001];
long long lbound[100001];
long long rbound[100001];
pair <long long, long long> totalearn[100001];

long long rem(int i, int am) {
	if (am <= bscore[i])
		return lbound[i] * am;
	else return lbound[i] * bscore[i] + (am - bscore[i]) * rbound[i];
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	long long x;
	long long bwork = 0;
	cin >> n >> x;
	for (int i = 0; i < n; i++) {
		cin >> bscore[i] >> lbound[i] >> rbound[i];
		bwork += (bscore[i] * lbound[i]);
		totalearn[i] = make_pair(bscore[i] * lbound[i] + (x - bscore[i]) * rbound[i], i);
	}

	sort(totalearn, totalearn + n);
	for (int i = n - 2; i >= 0; i--) {
		totalearn[i].first += totalearn[i + 1].first;
		//cout << totalearn[i].first << ' ';
	}// cout << '\n';
	//cout << "TOTAL WORK: " << bwork << '\n';
	long long bestans = n * x;
	for (int i = 0; i < n; i++) {
		long long curbest = n * x; 
		int s = 0;
		int e = n - 1;
		while (s <= e) {
			int m = (s + e) / 2;
			long long totsum = totalearn[n - m].first;
			if (n - m <= i && m != n) {
				totsum = totalearn[n - m - 1].first - (totalearn[i].first - totalearn[i + 1].first);
			}
			if (totsum + totalearn[i].first - totalearn[i + 1].first >= bwork) {
				e = m - 1;
				long long lx = 0;
				long long rx = x;
				long long bestselect = x;
				while (lx <= rx) {
					int mx = (lx + rx) >> 1;
					if (rem(totalearn[i].second, mx) >= bwork - totsum) {
						rx = mx - 1;
						bestselect = mx;
					}
					else lx = mx + 1;
				}
				curbest = min(curbest, bestselect + m * x);
			}
			else s = m + 1;
			//cout << m << ' ' << totsum << '\n';
		}
		bestans = min(bestans, curbest);
	}
	cout << bestans << '\n';
}

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

using namespace std;

#define ll long long int

const int N = (int)1e5+15;
const ll inf = (ll)1e15+15;

ll dp[105][N];
ll wt[105];
ll val[105];
ll n,w;



int main() {
    
    scanf("%lld %lld",&n, &w);
    for (int i = 1; i <= n; i++) {
       scanf("%lld %lld",wt + i, val + i);
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= w; j++) {
            dp[i][j] = dp[i-1][j];
            if (j - wt[i] >= 0) {
                dp[i][j] = max(dp[i][j], dp[i-1][j-wt[i]] + val[i]);
            }
        }
    }

    printf("%lld\n",dp[n][w]);
    return 0;
}

Measured memory_bytes: 79360
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int h, w, n;
  map<P, int> mp;
  cin>>h>>w>>n;
  int a, b;
  LL ans[10]={};
  ans[0]=(LL)(h-2)*(w-2);

  REP(i, n){
    cin>>a>>b;
    for(int y=-1; y<=1; ++y){
      for(int x=-1; x<=+1; ++x){
        if(a+y<2||a+y>h-1) continue;
        if(b+x<2||b+x>w-1) continue;
        ++mp[make_pair(a+y, b+x)];
      }
    }
  }
  for(auto i=mp.begin(); i!=mp.end(); ++i){
    ++ans[i->second];
  }

  REP(i, 9){
    ans[0]-=ans[i+1];
  }
  REP(i, 10){
    cout<<ans[i]<<endl;
  }

  return 0;
}


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


int main() {
  char odd[] = {'R','U','D'};
  char even[] = {'L','U','D'};

  string s;
  cin >> s;
  int count = 0;
  for(int i=0;i<s.size();i++){
      if(i%2==0){
          for(char x:odd){
              if(s[i]==x){
                  count++;
                  break;
              }
          }
      }
      else{
          for(char y:even){
              if(s[i]==y){
                  count++;
                  break;
              }
          }
      }
  }
  if(count==s.size()) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
using namespace std;

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int x=c-a,y=d-b;

	rep(i,x){
		printf("R");
	}
	rep(i,y){
		printf("U");
	}
	rep(i,x){
		printf("L");
	}
	rep(i,y+1){
		printf("D");
	}
	rep(i,x+1){
		printf("R");
	}
	rep(i,y+1){
		printf("U");
	}
	printf("LU");
	rep(i,x+1){
		printf("L");
	}
	rep(i,y+1){
		printf("D");
	}
	printf("R\n");


}

Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //int a = int.Parse(Console.ReadLine());
            string str = Console.ReadLine();
            int len = str.Length;
            string ans = "Yes";
            for(int i = 0; i < len; i++)
            {
                if(i%2 == 0 && str[i] == 'L')
                {
                    ans = "No";
                    break;
                }
                if(i%2 == 1 && str[i] == 'R')
                {
                    ans = "No";
                    break;
                }
            }
            
            Console.WriteLine(ans);
        }
    }
}



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


#define ll long long int 
#define all(v) v.begin(),v.end()
#define MOD 1000000007
#define PB push_back
#define F first
#define S second

int happy(vector< vector< int >  > &v,int n,int index,int postaken,map< pair< int,int >,int > &dp){

    if(index==n) return 0;
    
    if(dp.count({index,postaken})) return dp[{index,postaken}];
    
    int one = INT_MIN,two= INT_MIN,three = INT_MIN;
    if(postaken !=0){
      one = v[index][0] + happy(v,n,index+1,0,dp);
    }
    if(postaken!=1){
    	two = v[index][1] + happy(v,n,index+1,1,dp);
    }
    if(postaken!=2){
    	three = v[index][2] + happy(v,n,index+1,2,dp);
    }

    dp[{index,postaken}] = max({one,two,three});
    return dp[{index,postaken}];

}


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

	 vector< vector< int > > v(n,vector< int >(3));

	 for(int i=0;i<n;i++){
	 	for(int j=0;j<3;j++){
	 		cin>>v[i][j];
	 	}
	 }
     map< pair< int,int > , int > dp;
	 int one = v[0][0] + happy(v,n,1,0,dp);
	 int two = v[0][1] + happy(v,n,1,1,dp);
	 int three = v[0][2] + happy(v,n,1,2,dp);

	 cout<<max({one,two,three})<<endl;

	return 0;
}

Measured memory_bytes: 41484
a = Array.new
3.times do
    a_row = gets.chomp.split
    a_row.length.times do |i|
        a_row[i] = a_row[i].to_i
    end
    a << a_row
end

n = gets.to_i
b = Array.new
n.times do
    input_b = gets.to_i
    b << input_b
end

3.times do |i|
    3.times do |j|
        9.times do |k|
            if a[i][j] == b[k]
                a[i][j] = 0
            end
        end
    end
end

result = false

if a[0][0] == 0 && a[1][0] == 0 && a[2][0] == 0
    result = true
end

if a[0][1] == 0 && a[1][1] == 0 && a[2][1] == 0
    result = true
end

if a[0][2] == 0 && a[1][2] == 0 && a[2][2] == 0
    result = true
end

if a[0][0] == 0 && a[0][1] == 0 && a[0][2] == 0
    result = true
end

if a[1][0] == 0 && a[1][1] == 0 && a[1][2] == 0
    result = true
end

if a[2][0] == 0 && a[2][1] == 0 && a[2][2] == 0
    result = true
end

if a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0
    result = true
end

if a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0
    result = true
end

if result
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
// In The Name of Almighty Allah
#include<bits/stdc++.h>
using namespace std;
#define             fastio              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define             ff                  first
#define             ss                  second
#define             int                 long long
#define             pb                  push_back
#define             pf                  push_front
#define             pii                 pair<int,int>
#define             print(x)            for(auto it : x) cout<<it<<' '; cout<<'\n';
#define             debug(x)            cout << #x << " --->> " << x << endl;
#define             mod                 1000000007
#define             inf                 1e18
#define             PI                  (acos(-1))
#define             eps                 (1e-8)
#define             clear(x)            memset(x,0,sizeof(x));

main()
{
	fastio;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int a, b, c, x, y, z, p, q, r, n, m;
	cin >> n;
	int sum = 0;
	for (int i = 1; i <= n; i++)
	{
		if (i % 3 == 0 || i % 5 == 0 || i % 15 == 0)
			continue;
		else sum += i;
	}
	cout << sum << endl;

}


Measured memory_bytes: 3640
import numpy as np
import math
A, B, h, m = map(int, input().split())
rad_l = 2 * math.pi / 60 * m
rad_s = 2 * math.pi / 12 * h + 2 * math.pi / (12 * 60) * m
a = np.array([B * math.cos(rad_l), B * math.sin(rad_l)])
b = np.array([A * math.cos(rad_s), A * math.sin(rad_s)])
print(np.linalg.norm(a - b))

Measured memory_bytes: 27268
#include <bits/stdc++.h>
 
using namespace std;
 
#define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int,int> PII;
const double eps=1e-8;
const double pi=acos(-1.0);
const int K=1e6+7;
const int mod=1e9+7;
 
 
char sa[200],sb[200];
int main(void)
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cin>>sa>>sb;
    int la=strlen(sa),lb=strlen(sb),ans;
    sa[la]=sb[lb]='\0';
    if(la<lb)   ans=-1;
    else if(la>lb)  ans=1;
    else    ans=strcmp(sa,sb);
    if(ans<0)
        cout<<"LESS\n";
    else if(ans==0)
        cout<<"EQUAL\n";
    else
        cout<<"GREATER\n";
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

is_ok = True

color_num = a[0]
unique = []
for i, a_i in enumerate(a[1:], 1):
    if a_i < len(unique):
        is_ok = False
        break
    if a_i == color_num - 1:
        unique.append(i)
    elif a_i != color_num:
        is_ok = False
        break
if len(unique) >= color_num:
    if len(unique) == color_num and len(unique) == N:
        is_ok = True
    else:
        is_ok = False
if N // color_num == 1:
    unique_num_min = color_num - (N % color_num)
    if len(unique) < unique_num_min:
        is_ok = False

color_num = a[0] + 1
unique = [0]
if not is_ok:
    is_ok = True
    for i, a_i in enumerate(a[1:], 1):
        if a_i < len(unique):
            is_ok = False
            break
        if a_i == color_num - 1:
            unique.append(i)
        elif a_i != color_num:
            is_ok = False
            break
    if len(unique) >= color_num:
        if len(unique) == color_num and len(unique) == N:
            is_ok = True
        else:
            is_ok = False
    if N // color_num == 1:
        unique_num_min = color_num - (N % color_num)
        if len(unique) < unique_num_min:
            is_ok = False

if is_ok:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14092
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

int main() {
   Int v, e;
   std::cin >> v >> e;
   std::vector<Int> vs[2], cs(e), fs(e);
   rep(i, 2) vs[i].resize(e);
   rep(i, e) {
      std::cin >> vs[0][i] >> vs[1][i] >> cs[i];
   }
   std::vector<std::vector<Int>> es[2];
   rep(i, 2) es[i].resize(v);
   rep(i, 2) rep(k, e) es[i][vs[i][k]].emplace_back(k);
   Int res = 0;
   Int source = 0, sink = v-1;
   for(;;) {
      std::queue<Int> q;
      std::vector<Int> xs(v), pes(v, -1);
      q.emplace(source);
      xs[source] = (Int)1 << 53;
      while( not q.empty() ) {
         Int s = q.front(); q.pop();
         rep(r, 2) {
            for(Int i : es[r][s]) {
               Int w = r ? fs[i] : cs[i] - fs[i];
               Int t = vs[1-r][i];
               guard( pes[t] == -1 and w > 0 );
               pes[t] = i;
               xs[t] = std::min(xs[s], w);
               q.emplace(t);
            }
         }
      }
      Int f = xs[sink];
      if( f == 0 ) break;
      for(Int i = sink, k = pes[i]; i != source; i=vs[0][k]+vs[1][k]-i, k=pes[i]) {
         fs[k] += (vs[1][k] == i ? +f : -f);
      }
      res += f;
   }
   printf("%ld\n", res);
}



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

int main()
{
    int i,j,a;
    for(i=1;i<=9;i++){
        for(j=1;j<=9;j++){
            a=0;
            a=i*j;
            printf("%dx%d=%d\n",i,j,a);
        }
    }
    return 0;
}



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

int main() {
  int N, K;
  cin >> N >> K;
  vector<long> Xp, Xm;
  long x;
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x < 0) Xm.push_back(abs(x));
    else if (0 < x) Xp.push_back(x);
    else K--;
  }
  if (Xm.size() == 0 && Xp.size() == 0) {
    cout << 0 << endl;
    return 0;
  }
  sort(Xm.begin(), Xm.end());
  sort(Xp.begin(), Xp.end());
  if (Xm.size() == 0) {
    cout << Xp[K-1] << endl;
    return 0;
  }
  if (Xp.size() == 0) {
    cout << Xm[K-1] << endl;
    return 0;
  }
  long ans = Xm.back() * 2 + Xp.back() * 2;
  for (int i = 0; i <= K; i++) {
    if (Xp.size() < i || Xm.size() < K-i) continue;
    long tmp1 = (i != 0) * Xp[i-1];
    long tmp2 = (K-i != 0) * Xm[K-i-1];
    ans = min({ans, tmp1*2 + tmp2, tmp1 + tmp2*2});
  }
  cout << ans << endl;
}

Measured memory_bytes: 1656
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
  int in;
  while(cin>>in){
    int number = 600/in;
    int sum = 0;
    for(int i=1; i<number; i++){
      sum += pow(i*in, 2) * in;
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import sys
from collections import Counter

n = int(sys.stdin.readline().rstrip())
s = sys.stdin.read().split()

def main():
    c = Counter(s)
    ma = max(c.values())
    res = []
    for l, v in c.items():
        if v == ma:
            res.append(l)
    return sorted(res)

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Measured memory_bytes: 38476
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	int ans=0;
	for(int i=1;i<=k;i++) ans+=a[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Hello
{
    private const long INF = 1000000007;
    private struct Pair { public long x, y; public Pair(long xx, long yy) { x = xx; y = yy; } }
    public static void Main()
    {
        int N = NextInt();
        int K = NextInt();
        long[] a = LineLong();

        long[] b = new long[N + 1];
        for (int i = 1; i <= N; i++) b[i] = b[i - 1] + a[i - 1];

        //N^2で全列挙
        List<long> next = new List<long>();
        for (int i = 0; i <= N; i++)
            for (int j = i + 1; j <= N; j++) next.Add(b[j] - b[i]);

        //各bitについて、立っているものが何個あるか数える
        //log_2(10^12) < 40
        for (int bit = 40; bit >= 0; bit--)
        {
            List<long> A = new List<long>();
            foreach (var C in next)
                if ((1 & C >> bit) == 1) A.Add(C);
            if (A.Count() >= K) next = A;
        }
        long ans = next[0];
        next.ForEach(v => ans &= v);
        Console.WriteLine(ans);
    }

}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  rep(i, n) {
    if(i >= n - 2) break;
    if(s.at(i) == 'A' && s.at(i+1) == 'B' && s.at(i+2) == 'C') cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3572