akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cstring>
#define MN 201000

char s[MN]; 
int n, a, b, c, d;

int main()
{
	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	scanf("%s", s + 1);
	
	bool ok = 0;
	for(int i = a; i <= std::max(c, d); i++)
		if(s[i] == '#' && s[i + 1] == '#') ok = 1;
	
	if(ok) return 0 * puts("No");
	
	if(c < d) return 0 * puts("Yes");
	
	ok = 0;
	for(int i = b; i <= d; i++)
		if(s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.') ok = 1;
	
	if(!ok) puts("No");
	else puts("Yes"); 
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(b-a == c-b){
        cout << "YES" << endl;
    }
    else cout << "NO" <<endl;
    return 0;
}

Measured memory_bytes: 256
# include <cstdio>

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

	int ans = 0x3f3f3f3f ;

	while ( n -- )  {
		int x, cnt = 0 ;
		scanf ( "%d", & x ) ;

		while ( x % 2 == 0 )  x /= 2, ++ cnt ;

		if ( cnt < ans )  ans = cnt ;
	}

	return ! printf ( "%d\n", ans ) ;
}


Measured memory_bytes: 128
let () = Scanf.scanf "%d %d %d %d\n" @@ fun n m v p ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  Array.sort (fun a a' -> compare a' a) as_;
  let acc = Array.make (n + 1) 0 in
  for i = 0 to n - 1 do
    acc.(i + 1) <- as_.(i) + acc.(i)
  done;
  Printf.printf "%d\n" @@
  Array.fold_left ( + ) 0 @@
  Array.init n @@ fun i ->
    if
      as_.(p - 1) <= as_.(i) ||
      as_.(p - 1) <= as_.(i) + m &&
      acc.(i) - acc.(p - 1)
        <= min (i - p + 1) (n - v) * m + as_.(i) * (i - p + 1)
    then 1
    else 0



Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	int ret=0;
	FOR(i,N) {
		cin>>x;
		if(i%2==0&&x%2) ret++;
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3596
n = gets.chomp.to_i

pos_x = 0
pos_y = 0
time = 0

n.times do
  t,x,y = gets.split(" ").map(&:to_i)

  dist = (x - pos_x).abs + (y - pos_y).abs

  if dist > t
    puts "No"
    exit
  elsif (dist - (t - time)) % 2 != 0
    puts "No"
    exit
  end

  pos_x = x
  pos_y = y
  time = t
end

puts "Yes"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define fi first
#define se second
#define ii pair<int, int>
#define int long long
using namespace std;

int a[200005], b[200005];

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

//    freopen("in.inp", "r", stdin);
//    freopen("out.out", "w", stdout);

    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i] >> b[i];
    sort(a+1, a+n+1);
    sort(b+1, b+n+1);
    if (n % 2 == 0)
    {
        int s1 = (a[n/2] + a[n/2 + 1]) ;
        int s2 = (b[n/2] + b[n/2 + 1]) ;
        cout << (s2 - s1) + 1;
    } else {
        cout << (b[(n+1)/2] - a[(n+1)/2]) + 1;
    }
}


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

const long long MOD = 1000000007;

int N, K;
vector<vector<int>> G;

long long dfs(int u, int parent) {
    int remaining;
    if (parent == -1) {
        remaining = K - 1;
    } else {
        remaining = K - 2;
    }

    if (K < G[u].size()) {
        return 0;
    } else {
        long long res = 1;
        for (int v : G[u]) {
            if (v == parent) continue;

            res *= remaining;
            res %= MOD;
            remaining--;
        }

        for (int v : G[u]) {
            if (v == parent) continue;

            res *= dfs(v, u);
            res %= MOD;
        }
        return res;
    }
}


int main() {
    cin >> N >> K;
    G.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    long long res = K * dfs(0, -1);
    res %= MOD;

    cout << res << endl;
    return 0;
}

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

//Common
using namespace std;using f64 = double;using i64=long long;using u64=unsigned long long;
template<typename T> using Arr=vector<T>;template<typename T> using Func=function<T>;template<typename T> using Str=basic_string<T>;
#define hfor(v, s, e) for(int v=(s);(s)<=v&&v<(e);++v)//half-opened range
#define hfori(v, s, e) for(int v=(e)-1;(s)<=v&&v<(e);--v)//inversion
#define hforo(v, s, e) int v=(s);for(;(s)<=v&&v<(e);++v)//out declaration
#define hforoi(v, s, e) int v=(e)-1; for(;(s)<=v&&v<(e);--v)
#define cfor(v, s, e) hfor(v,(s),(e)+1)//closed range
#define cfori(v, s, e) hfori(v,(s),(e)+1)
#define cforo(v, s, e) hforo(v,(s),(e)+1)
#define cforoi(v, s, e) hforoi(v,(s),(e)+1)
#define rep(v,x) hfor(v,0,(x))
#define repi(v,x) hfori(v,0,(x))
#define repo(v,x) hforo(v,0,(x))
#define all(x) (x).begin(),(x).end()
#define pushb push_back
#define pushf push_front
#define popb pop_back
#define popf pop_front
#define empl emplace
#define emplb emplace_back
#define emplf emplace_front
#define fi first
#define se second
#define cxp constexpr
#define PQ std::priority_queue

//Math
template<typename T> cxp T inf() { return numeric_limits<T>::max() / 2; }
template<typename T> inline T sq(T x){return x*x;}
cxp int lgc(int x){return 64-__builtin_clzll(x-1);}
cxp int lgf(int x){return 63-__builtin_clzll(x);}
int rd(int lb, int ub){static mt19937 rng(time(0)^i64(new int)); return uniform_int_distribution<int>(lb, ub-1)(rng);}
int rd(int ub=inf<int>()){return rd(0,ub);}
const f64 pi=acosl(-1), eps=1e-10;

//IO
template<typename T>ostream& operator<<(ostream& s, const Arr<T>& a) {for(auto i:a) cout<<i<<' '; return s;}
int getint(){int x;cin>>x;return x;}
char getchr(){char x;cin>>x;return x;}
#ifndef DEBUG
	//#pragma GCC optimize ("Ofast") //somtimes it become more slower
	auto __PRE_RUN__=(ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),(cout<<fixed<<setprecision(11)), 0);
#endif

//Misc
int sz(const auto& x){return x.size();}
auto split(auto s, auto p){
	Arr<decltype(s)> ret;
	auto it1=s.begin();
	for(auto it2=it1; (it2 = find(it1,s.end(),p)) != s.end(); it1=it2+1)
		ret.pushb({it1, it2});
	ret.pushb({it1,s.end()});
	return ret;
}
template<typename T> T rev(const T& a){return {a.rbegin(),a.rend()};}
Arr<int> range(int n){ Arr<int> ret(n); rep(i,n)ret[i]=i; return ret; }
struct defer{ defer(auto f):f(f){} ~defer(){f();} function<void()> f; };
#define defer(x) auto _##__COUNTER__ = defer([&](){x;});
#define lam(expr, ...) [&](__VA_ARGS__){return expr;}
#define reduce accumulate

#define endl '\n'//not interactive?
#define int i64//MLE?
using pint = pair<int,int>;
using tint = tuple<int,int,int>;

signed main(){
	int a,v,b,w,t; cin>>a>>v>>b>>w>>t;
	if(w==v)
		cout<<(a==b?"YES":"NO")<<endl;
	else
		cout<<(v-w>0 and abs(a-b)<=t*(v-w)?"YES":"NO")<<endl;
	return 0;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
const int maxx = 1e5 + 7;
int n;
int ans, res;
int a1, a2;
int a[maxx];
map <int, int> c1;
map <int, int> c2;

int main() {
	while(scanf("%d", &n) != EOF) {
		c1.clear();
		c2.clear();
		ans = 0, res = 0;
		for(int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			if(i & 1) {
				c1[a[i]]++;
				if(ans < c1[a[i]]) {
					a1 = a[i];
					ans = c1[a[i]];
				}
			}
			else {
				c2[a[i]]++;
				if(res < c2[a[i]]) {
					a2 = a[i];
					res = c2[a[i]];
				}
			}
		}
		if(a1 == a2){
			if(ans == res) {
				int sum1 = 0, sum2 = 0;
				for(int i = 1; i <= n; i++) {
					if(a1 == a[i]) continue;
					if(i & 1) sum1 = max(sum1, c1[a[i]]);
					else sum2 = max(sum2, c2[a[i]]);
				}
				if(sum1 >= sum2) ans = sum1;
				else res = sum2;
			}
			else if(ans < res) {
				ans = 0;
				for(int i = 1; i <= n; i += 2){
					if(a[i] != a2) ans = max(ans, c1[a[i]]);
				}
			}
			else {
				res = 0;
				for(int i = 2; i <= n; i += 2){
					if(a[i] != a1) res = max(res, c2[a[i]]);
				}
			}
		}
		printf("%d\n", n - ans - res);
	}
}

Measured memory_bytes: 5376
#include<stdio.h>
int main(){
  
  int sum=0;
  int N=0,K=0;
  int i=0;
  int X=0,Y=0;
  scanf("%d %d %d %d", &N,&K,&X,&Y);
  
  for(i=1; i <= N; i++){
    if(i <= K){
      sum += X;
    }else{
      sum += Y;
    }
  }
  printf("%d",sum);
 return 0; 
}

Measured memory_bytes: 1704
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int H,W,i,j;
    while(1){
        cin>>H>>W;
        if(H==0&&W==0){
            break;
        }
        for(i=0;i<H;i++){
            for(j=0;j<W;j++){
                cout<<'#';
            }
            cout<<endl;
        }
        cout<<endl;
        
    }
}



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

using namespace std;

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

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

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

int n, q;
int A[100100];
bool dp[5000];

//bool solve(int i, int m) {
//	if (i == n) {
//		if(m == 0)return dp[m] = true;
//		else return false;
//	}
//	dp[m] |= solve(i + 1, m);
//	if (m - A[i] < 0)return dp[m];
//	dp[m - A[i]] |= solve(i + 1, m - A[i]);
//	return dp[m] || dp[m - A[i]];
//}

bool solve(int i, ll m) {
	if (m == 0)return true;
	if (i >= n)return false;
	bool res = solve(i + 1, m) || solve(i + 1, m - A[i]);
	return res;
}

int main() {
	cin >> n;
	rep(i, n)cin >> A[i];
	solve(0, 0);
	cin >> q;
	rep(i, q) {
		fill(dp, dp + 5000, false);
		int m;
		cin >> m;
		if (solve(0, m))cout << "yes" << endl;
		else cout << "no" << endl;
	}
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define mp          make_pair
#define ll          long long int
#define hmap        unordered_map
#define pii         pair<int,int>
#define pdd         pair<double, double> 
#define M           1000000007
#define MOD         998244353
#define fast        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test        ll t; cin>>t; while(t--)
#define inp(a,n)    int a[n]; for(int i=0;i<n;i++)  cin>>a[i];
#define inpl(a,n)   ll a[n];  for(ll i=0;i<n;i++)   cin>>a[i];
#define out(a,n)    for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define outl(a,n)   for(ll i=0;i<n;i++)  cout<<a[i]<<" "; cout<<endl;
#define outv(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";  cout<<endl;
#define all(s)      (s).begin(),(s).end()

struct pair_hash
{
    template <class T1, class T2>
    std::size_t operator () (const std::pair<T1,T2> &p) const {
        auto h1 = std::hash<T1>{}(p.first);
        auto h2 = std::hash<T2>{}(p.second);
        return h1 ^ h2;  
    }
};
using vote = pair<ll,ll>;
using Unordered_map = unordered_map<vote, ll, pair_hash>;
// int N = 1000002;
// hmap<ll,ll> h;
// void prime()
// {
//       ll dp[N]={};
//       for(ll i=3;i<N;i+=2)
//             dp[i]=1;
//       h[2]=1;
//       for(ll i=3;i<N;i+=2)
//       {
//             if(dp[i])
//             {
//                   for(ll j = i*i;j<N;j+=i)
//                         dp[j]=0;
//                   h[i]=1;
//             }
//       }
// }
// int base10(int n)
// {
//       int c=1;
//       while(n>9)
//       {
//             c++;
//             n = n/10;
//       }
//       return c;
// }
int main()
{
      fast
      //test
      {
            int n,m;
            cin>>n>>m;
            int dp[n][m];
            vector<string> v(n);
            for(int i=0;i<n;i++)
                  cin>>v[i];
            dp[0][0]=1;
            for(int i=1;i<n;i++)
            {
                  if(v[i][0]=='.')
                        dp[i][0] = dp[i-1][0];
                  else
                        dp[i][0]=0;
                  dp[i][0] = dp[i][0]%M;
            }
            
            for(int j=1;j<m;j++)
            {
                  if(v[0][j]=='.')
                        dp[0][j]=dp[0][j-1];
                  else
                        dp[0][j]=0;
                  dp[0][j] = dp[0][j]%M;
            }
            
            for(int i=1;i<n;i++)
            {
                  for(int j=1;j<m;j++)
                  {
                        dp[i][j] = dp[i-1][j] + dp[i][j-1];
                        if(v[i][j]=='#')
                              dp[i][j]=0;
                              dp[i][j] = dp[i][j]%M;
                      //  cout<<dp[i][j]<<" ";
                  }
                 // cout<<endl;
            }
            
            cout<<dp[n-1][m-1];
            
      }
}

Measured memory_bytes: 8568
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
const int N = 1e3+5;
const int M = 1e4;
const int INF = 0x3f3f3f3f;

int main(){
	ll n,m,x,sum = 0;
	scanf("%lld%lld",&n,&m);
	while(m--){
		scanf("%lld",&x);
		sum += x;
	}

	if(sum > n) printf("-1\n");
	else printf("%lld\n",n-sum);
    return 0;
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  int n,a,b;
  cin >> n >> a >> b;
  if(abs(a-b)%2) cout << "Borys" << endl;
  else           cout << "Alice" << endl;
  return 0;
}


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

typedef struct{
    char name[20];
    int exe_time;
    int fin_time;
}QueueData;

typedef struct _node
{
    QueueData data;
    struct _node *next;
}node;

typedef struct
{
    node *head, *tail;
}queue;

queue* init_queue()
{
    queue* qp = malloc(sizeof(queue));
    qp -> head = NULL;
    qp -> tail = NULL;
    return qp;
}

int empty(queue* q)
{
    return (q->head == NULL);
}

void enqueue(queue* q, QueueData d)
{
    node *np = malloc(sizeof(node));
    np->data = d;
    np->next = NULL;
    if(empty(q)){
        q -> head = np;
        q -> tail = np;
    }
    else{
        q -> tail -> next = np;
        q -> tail = np;
    }
}

QueueData dequeue(queue *q)
{
    if(empty(q)){
        printf("none\n");
        exit(1);
    }
    QueueData hold = q -> head -> data;
    node* temp = q -> head;
    q -> head = q -> head -> next;
    if(q->head == NULL) q->tail = NULL;
    free(temp);
    return hold;
}

int compare_find_time(const void* a, const void* b){
    QueueData *pa = (QueueData*) a;
    QueueData *pb = (QueueData*) b;

    return pa->fin_time - pb->fin_time;
}

int find_proc(char *s, QueueData *x, int total_proc){
    for(int i=0; i<total_proc; i++){
        if(strcmp(s,x[i].name)==0) return i;
    }
}

int main(){
    int proc_num, rr_time;
    queue *q = init_queue();
    scanf("%d %d", &proc_num, &rr_time);
    QueueData *proc = malloc(proc_num*sizeof(QueueData));
    for(int i=0; i<proc_num; i++){
        scanf("%s %d", proc[i].name, &proc[i].exe_time);
        enqueue(q, proc[i]);
    }

    
    int total_time = 0;
    while(q->head != NULL){
        if((q->head->data).exe_time > rr_time){
            (q->head->data).exe_time -= rr_time;
            total_time += rr_time;
            //enqueue
            enqueue(q, q->head->data);
            //pop from queue
            node *temp_x = q->head;
            q -> head = q->head->next;
            free(temp_x);
        }
        else if
            ((q->head->data).exe_time>0&&(q->head->data).exe_time<=rr_time){
            total_time += (q->head->data).exe_time;
            (q->head->data).exe_time = 0;
            (q->head->data).fin_time = total_time;
            printf("%s %d\n", 
                    (q->head->data).name, total_time);
            /*int proc_no = find_proc((q->head->data).name, proc, proc_num);
            proc[proc_no].fin_time = total_time;*/
            //pop from queue
            node *temp_x = q->head;
            q -> head = q->head->next;
            free(temp_x);
        }
    }
    
    /*qsort(proc, proc_num, sizeof(*proc), compare_find_time);

    for(int i=0; i<proc_num; i++){
        printf("%s %d\n", proc[i].name, proc[i].fin_time);
    }*/

    
    /*while(!empty(q)){
        printf("%s %d\n", dequeue(q).name, dequeue(q).num);
    }*/
    //printf("\n");
}



Measured memory_bytes: 5428
import sys
import collections as col
input=sys.stdin.readline

def mainA():
	N,R=map(int,input().split())
	#N=input().rstrip()
	#N=int(input())
	#vA=list(map(int,input().split()))
	
	if N >= 10:
		res = R
	else:
		res = R + 100*(10-N)
	
	print(res)

def mainB():
	N,K=map(int,input().split())
	#N=input().rstrip()
	#N=int(input())
	#vA=list(map(int,input().split()))
	
	res = 0
	while N:
		N //= K
		res += 1
	
	print(res)

def mainC():
	#N,K=map(int,input().split())
	N=input().rstrip()
	#N=int(input())
	vA=list(map(int,input().split()))
	
	res = float("inf")
	for i in range(1, 101):
		t = sum((x-i)**2 for x in vA)
		res = min(res, t)
	
	print(res)


mainA()
#mainB()
#mainC()


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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


ll dp[105][100005];

int main() {
    int N, K; cin >> N >> K;
    vi a(N + 1, 0);
    rep(i, N) cin >> a[i + 1];

    dp[0][0] = 1;
    for (int i = 1; i <= N; i++) {
        rep(j, K + 1) {
            dp[i][j] = dp[i - 1][j];
            if (j - 1 >= 0) dp[i][j] += dp[i][j - 1];
            if (j - 1 - a[i] >= 0) dp[i][j] -= dp[i - 1][j - 1 - a[i]];
            dp[i][j] = (dp[i][j] + MOD) % MOD;
        }
    }

    /*rep(i, N + 1) {
        rep(j, K + 1) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/

    cout << dp[N][K] << endl;

}

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

constexpr ll INF = ll(1e+18) + 1;

ll dist(ll a, ll b, ll c, ll d) {
    return abs(a-c) + abs(b-d);
}

int main() {
    int N;
    int ans = 0;
    int a;

    cin >> N;

    rep (i, N) {
        cin >> a;
        if ((i+1)%2 == 1 && a%2 == 1) {
            ans++;
        }
    }

    cout << ans <<endl;
}


Measured memory_bytes: 3628
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let mut itr = line.split_whitespace().map(|s| s.parse::<i32>().unwrap());
    let (a, b) = (itr.next().unwrap(), itr.next().unwrap());
    println!("{} {}", a*b, (a+b)*2);
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int h,w;
char s[51][51];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};


bool check(int i,int j){
    REP(a,4){
        int x=i+dy[a];
        int y=j+dx[a];
        if(x>=0&&x<h&&y>=0&&y<w){
            if(s[x][y]=='#')return true;
        }
    }
    return false;
}


int main(){
    cin >> h >> w;

    REP(i,h){
        REP(j,w){
            cin >> s[i][j];
        }
    }

    int flg=true;

    REP(i,h){
        REP(j,w){
            if(s[i][j]=='#'){
                if(check(i,j)==false){
                    flg=false;
                    break;
                }
            }
        }
        if(flg==false)break;
    }
    if(flg)YES;
    else NO;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int inf=1000001000;
ll INF=1e18;
ll mod=1000000007;
ll MOD=INF;


int main() {
  string s;
  cin >> s;
  int a=0;
  rep(i,s.size()){
      int u=s[i]-'0';
      a+=u;
  }
  if (a%9==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define all(collection) (collection).begin(), (collection).end()
#define loop(i, times) for(int i = 0; i < times; i++)
#define seloop(i, start_index, end_index) for(int i = start_index; i < end_index; i++)
#define eqseloop(i, start_index, end_index) for(int i = start_index; i <= end_index; i++)

int mp = 0;


int main()
{
	string s; cin >> s;
	string m = s.substr(5, 6);
	string d = s.substr(8, 9);

	if (1 <= stoi(m) && stoi(m) <= 4)
	{
		if (stoi(d) <= 30)
		{
			cout << "Heisei";
			return 0;
		}
	}

	cout << "TBD";

	return 0;
}

Measured memory_bytes: 256
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef double dd;
typedef pair <int, int> pii;
#define pb push_back
#define pf push_front
#define f first
#define s second
#define sz(x) (int)x.size()
#define smin(x , y) x = min(x , y)
#define smax(x , y) x = max(x , y)
#define mp make_pair
int32_t main(){		
	ios_base::sync_with_stdio(false);
    cin.tie(0);
	cout.tie(0);
	string s, t;
	cin >> s >> t;
	cout << t << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
const int MAXL = 1e5 + 10;
int Tree[MAXL];
int findRoot(int x) {
	if (Tree[x] == x) return x;
	else return Tree[x] = findRoot(Tree[x]);
}

int list[MAXL];
int belong[MAXL];

int main() {
	int n, m;
	while (scanf("%d%d", &n, &m) != EOF) {
		for (int i = 1; i <= n; i++) {
			scanf("%d", &list[i]);
			Tree[i] = i;
		}
		while (m--) {
			int a, b;
			scanf("%d%d", &a, &b);
			a = findRoot(a);
			b = findRoot(b);
			if (a != b) {
				Tree[a] = b;
			}
		}

		for (int i = 1; i <= n; i++) {
			belong[list[i]] = findRoot(i);
		}
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			if (belong[i] == findRoot(i))
				ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    ll X;
    cin>>X;
    ll max_i = 1;
    rep(i,2,X+1){
        ll i2 = 1;
        do{
            i2*=i;
        }while(i2 <= X);
        i2/=i;
        if(i2 == i)continue;
        max_i = max(max_i,i2);
    }
    cout<<max_i;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

signed main() {
	int n;
	cin >> n;
	cout << 3 * n * n << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigInteger;

import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	int MAX = (int)1e7 * 2;
	int[] num;
	boolean[] p;
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		BigInteger v = BigInteger.ONE;
		for(int i=2;i<=n+1;i++) v = v.multiply(BigInteger.valueOf(i));
		System.out.println(v.add(BigInteger.valueOf(2)));
		for(int i=2;i<=n+1;i++) System.out.println(i);
	}
	

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 26320
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#define fr first
#define sc second
using namespace std;
#define INF 10000000
typedef pair<int,int> iiP;
typedef pair<int,iiP> P;
struct edge{
  int to,cost;
  edge(){}
  edge(int to,int cost):to(to),cost(cost){};
};
int c,n,m;
int S,G;
int min_cost[101][10];
bool used[101][10];
vector< vector<edge> > info;
int solve();
int main(){
  while(cin >> c >> n >> m >> S >> G && (c||n||m||S||G)){
  for(int i=0;i<=n;i++){
    for(int j=0;j<=c;j++){
      min_cost[i][j] = INF;
      used[i][j] = false;
    }
  }
  info.resize(n + 1);
  for(int i=0,a,b,f;i<m;i++){
    cin >> a >> b >> f;
    info[a].push_back(edge(b,f));
    info[b].push_back(edge(a,f));
  }
  cout << solve() << endl;

  info.clear();
  }
}
int solve(){
  priority_queue< P,vector<P>,greater<P> > que;

  min_cost[S][c] = 0;
  que.push(P(0,iiP(S,c)));

  while(!que.empty()){
    P p = que.top();
    int cost = p.fr,now = p.sc.fr,KEN = p.sc.sc;
    que.pop();

    if( now == G) return cost;

    if( used[now][KEN] ) continue;
    used[now][KEN] = true;

    for(int i = 0,l = info[now].size();i < l;i++){
      edge e = info[now][i];
      if(cost + e.cost < min_cost[e.to][KEN]){
        min_cost[e.to][KEN] = cost + e.cost;
        que.push(P(min_cost[e.to][KEN],iiP(e.to,KEN)));
      }
      if(KEN != 0){
        if( cost + e.cost/2 < min_cost[e.to][KEN-1] ){
          min_cost[e.to][KEN-1] = cost + e.cost/2;
          que.push(P(min_cost[e.to][KEN-1],iiP(e.to,KEN-1)));
        }
      }
    }
  }
}

Measured memory_bytes: 1244
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

typedef long long LL;
const int N = 100005;

LL gcd(LL a, LL b) {
  return b ? gcd(b, a % b) : a;
}

int n;
LL k, a[N];

int main() {
  ios::sync_with_stdio(false);

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

  sort(a, a + n);

  LL g = 0;
  for (int i = 0; i < n; i++) {
    g = gcd(g, a[i]);
  }

  if (a[n - 1] < k || k % g != 0) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << "POSSIBLE" << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;
bool isSame(int n)
{
	int x =  n%10;
	while(n)
	{
		if((n%10)!=x)
			return false;
		n/=10;
	}
	return true;
}
void solve()
{
	int n;
	cin>>n;
	int i = n;
	while(i)
	{
		if(isSame(i))
		{
			cout<<i<<"\n";
			break;
		}
		i++;	
	}	
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

int main() {
	int n,k;
	cin>>n;
	int a[n][3];
	for(int i=0;i<n;i++)
	cin>>a[i][0]>>a[i][1]>>a[i][2];
	int dp[n][3];
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(int i=1;i<n;i++){
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a[i][2];
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
}

Measured memory_bytes: 2560
#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>;

struct L {
  int a, b, c;
  L(int a=0, int b=0, int c=0): a(a), b(b), c(c) {}
};

const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

int main() {
  int n, m;
  cin >> n >> m;
  map<int,int> mpX, mpY;
  mpX[0] = 0;
  mpY[0] = 0;

  vector<L> lh, lv;
  rep(i,n) {
    int a, b, c;
    cin >> a >> b >> c;
    mpX[a] = 0;
    mpX[b] = 0;
    mpY[c] = 0;
    lh.emplace_back(a,b,c);
  }
  rep(i,m) {
    int a, b, c;
    cin >> c >> a >> b;
    mpY[a] = 0;
    mpY[b] = 0;
    mpX[c] = 0;
    lv.emplace_back(a,b,c);
  }

  vector<int> xs, ys;
  for (auto& p : mpX) {
    p.second = xs.size();
    xs.push_back(p.first);
  }
  for (auto& p : mpY) {
    p.second = ys.size();
    ys.push_back(p.first);
  }

  int h = xs.size()*2;
  int w = ys.size()*2;

  vector<vector<int>> d(h, vector<int>(w));
  rep(i,n) {
    int a = mpX[lh[i].a]*2;
    int b = mpX[lh[i].b]*2;
    int c = mpY[lh[i].c]*2;
    for (int x = a; x <= b; ++x) d[x][c] = -1;
  }
  rep(i,m) {
    int a = mpY[lv[i].a]*2;
    int b = mpY[lv[i].b]*2;
    int c = mpX[lv[i].c]*2;
    for (int y = a; y <= b; ++y) d[c][y] = -1;
  }

  queue<P> q;
  int sx = mpX[0]*2, sy = mpY[0]*2;
  d[sx][sy] = 1;
  q.emplace(sx,sy);
  while (!q.empty()) {
    int x = q.front().first;
    int y = q.front().second;
    q.pop();
    rep(v,4) {
      int nx = x+dx[v], ny = y+dy[v];
      if (nx < 0 || nx >= h) continue;
      if (ny < 0 || ny >= w) continue;
      if (d[nx][ny] != 0) continue;
      d[nx][ny] = 1;
      q.emplace(nx,ny);
    }
  }

  ll ans = 0;
  rep(x,h)rep(y,w) {
    if (d[x][y] != 1) continue;
    if (x == 0 || x == h-1 || y == 0 || y == w-1) {
      cout << "INF" << endl;
      return 0;
    }
    if (x%2 == 0 || y%2 == 0) continue;
    ll ex = xs[x/2+1]-xs[x/2];
    ll ey = ys[y/2+1]-ys[y/2];
    ans += ex*ey;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 144512
#include<bits/stdc++.h>
#include<cstring>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back

unordered_map<int, bool> visited;
unordered_map<int, int> path_len;
vector<int> adjList[100005];
void dfs(int src)
{
	visited[src] = true;
	if (adjList[src].size() == 0)
	{
		path_len[src] = 0;
		return;
	}
	int x = 0;
	for (auto i : adjList[src])
	{
		if (!visited[i])
			dfs(i);

		x = max(x, path_len[i] + 1);
	}
	path_len[src] = x;
}




int main()
{


	ll n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++)
	{
		int x, y;
		cin >> x >> y;
		adjList[x].pb(y);
	}

	for (int i = 1; i <= n; i++)
		visited[i] = false;

	for (int i = 1; i <= n; i++)
	{
		if (!visited[i])
		{
			dfs(i);
		}
	}

	int ans = 0;
	for (int i = 1; i <= n; i++)
		ans = max(ans, path_len[i]);
	cout << ans << endl;

}





Measured memory_bytes: 16676
#include <iostream>
using namespace std;
#define debug(x) cout<<#x<<" : "<<x<<endl;
int n;
int fee[]={1150,125,140,160};
int phase[]={10,20,30,1000};
int main(){
  while(cin >> n,n+1){
    int pre=4280;
    int w=n;
    int money=fee[0];
    w-=phase[0];
    for(int i=1;w>0;i++){
      money+=min(phase[i]-phase[i-1],n-phase[i-1])*fee[i];
      w-=phase[i]-phase[i-1];
    }
    cout<<pre-money<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#![allow(unused_macros, unused_imports, dead_code, non_snake_case)]

use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
            assert!(_it.next().is_none());
        }
    };
}

macro_rules! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; input_inner ! {iter , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let mut s = {use std :: io :: Read ; let mut s = String :: new () ; std :: io :: stdin () . read_to_string (& mut s ) . unwrap () ; s } ; let mut iter = s . split_whitespace () ; input_inner ! {iter , $ ($ r ) * } } ; }
macro_rules! input_inner {($ iter : expr ) => {} ; ($ iter : expr , ) => {} ; ($ iter : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ iter , $ t ) ; input_inner ! {$ iter $ ($ r ) * } } ; ($ iter : expr , mut $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let mut $ var = read_value ! ($ iter , $ t ) ; input_inner ! {$ iter $ ($ r ) * } } ; }
macro_rules! read_value {($ iter : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ iter , $ t ) ) ,* ) } ; ($ iter : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ iter , $ t ) ) . collect ::< Vec < _ >> () } ; ($ iter : expr , chars ) => {read_value ! ($ iter , String ) . chars () . collect ::< Vec < char >> () } ; ($ iter : expr , usize1 ) => {read_value ! ($ iter , usize ) - 1 } ; ($ iter : expr , $ t : ty ) => {$ iter . next () . unwrap () . parse ::<$ t > () . expect ("Parse error" ) } ; }

fn main() {
    loop {
        from_line!(n:usize, m:usize);
        if n == 0 { break }
        let mut f = vec![0; n];
        let mut g = vec![0; m];
        let mut t = 0;
        let mut h = 0;
        let mut ans = (101, 101);
        for i in 0..n {
            from_line!(v:i32);
            f[i] = v;
            t += v;
        }
        for i in 0..m {
            from_line!(v:i32);
            g[i] = v;
            h += v;
        }
        if (h - t).abs() % 2 > 0 {
            println!("{}", -1);
            continue;
        }
        let h = (h - t) / 2;
        for &x in &f {
            if g.contains(&(x + h)) && ans.0 + ans.1 > x + x + h {
                ans = (x, x + h);
            }
        }
        if ans.0 > 100 {
            println!("{}", -1);
        } else {
            println!("{} {}", ans.0, ans.1);
        }

    }
}



Measured memory_bytes: 5040
n, m = map(int, input().split())
h = list(map(int, input().split()))

evaluation = list(True for _ in range(n))
for _ in range(m):
    frm, to = map(lambda x: int(x)-1, input().split())
    if h[frm] < h[to]:
        evaluation[frm] = False
    elif h[frm] > h[to]:
        evaluation[to] = False
    else:
        evaluation[frm] = False
        evaluation[to] = False
print(evaluation.count(True))


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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 4223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=1e5+5,mod=1e9+7,bit=61;

ll a[N],n,on[N];


signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        cin>>n;
        f(i,0,n)
        {
            cin>>a[i];
        }
        if(n>0 and a[0]!=0)
        {
            cout<<-1<<endl;
            continue;
        }
        on[0]=1;
        f(i,1,n)
        {
            on[i]=min((ll)llinf,2*(on[i-1]-a[i-1]));
        }
        ll bl=0,ans=0;
        rf(i,n,0)
        {
            ll l=(bl+1)/2;
            ll r=bl;
            l+=a[i];
            r+=a[i];
            ll my=min(on[i],r);
            if(my<l)
            {
                ans=-1;
                break;
            }
            bl=my;
            ans+=my;
        }
        cout<<ans<<endl;
    }
    return 0;
}


















Measured memory_bytes: 5228
function Main(arg)
{
  var N = arg.split("\n")[0].split(" ")[0] - 0;
  var R = arg.split("\n")[0].split(" ")[1] - 0;


  console.log(N >= 10 ? R : R + (100*(10-N)));
  return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

ll sum(int n) {
    return ll(n) * (n + 1) / 2;
}

int main(){
    int n;
    cin >> n;;
    ll ans = sum(n) - sum(n/3)*3 - sum(n/5)*5 + sum(n/15)*15;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int[] a= new int[n];
		int c=0;
		for(int i=0;i<n;i++)
		{
			a[i]=i+1;
			if(a[i]%2!=0) 
			{
				c++;
			}
		}
		double x=(double)c/n;
		System.out.println(x);

	}

}


Measured memory_bytes: 27088
n = int(input())
h = list(map(int, input().split()))
INF = 10**9
dp = [INF]*n
dp[0] = 0
for i in range(n-1):
    dp[i+1] = min(dp[i+1], dp[i]+abs(h[i]-h[i+1]))
    if i<n-2:
        dp[i+2] = min(dp[i+2], dp[i]+abs(h[i]-h[i+2]))
print(dp[-1])

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

int solve(){
  int n, y; cin >> n >> y;
  y/=1000;
  for(int a=0; a<=n; a++){
    for(int b=0; b<=n-a; b++){
      if((y-10*a-5*b)==(n-a-b)){
        cout << a << " " << b << " " << n-a-b << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}

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


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

using namespace std;

using ll = long long;

int main(void) {
    vector<int> arr(10);
    for (int i = 0; i < 10; i++)
        scanf("%d", &arr[i]);
    sort(arr.rbegin(), arr.rend());
    printf("%d\n%d\n%d\n", arr[0], arr[1], arr[2]);
    return 0;
}


Measured memory_bytes: 3232
K,N=map(int,input().split())
A=list(map(int,input().split()))
ans=K
B=[0]*N
for i in range(N):
    B[i]=min(abs(A[i]-A[i-1]),K-abs(A[i]-A[i-1]))
s=sum(B)    
for i in range(N):
    ans=min(ans,s-B[i])
    
print(ans)

Measured memory_bytes: 26444
N=int(input())
A=[]
Q={}
for i in range(N):
    B=input()
    A.append(B)
    Q[B]=0
    
for i in A:
    Q[i]+=1
    
a=max(Q.values())
ans=[]
for i in Q:
    if Q[i]==a:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 33416
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
 
typedef long long ll;
#define INF 1e9
 
 
int main(){
   int N;
   cin >> N;
   vector<int> a(3*N);
   REP(i, 3*N){
      cin >> a[i];
   }
   sort(a.begin(), a.end());
   ll ans = 0, cnt = 0;
   for(int i = 3*N-2; i >= N; i-=2){
      ans += a[i];
      cnt++;
   }
   ll sum = 0;
   for(int i = N; i < 2*N; i++){
      sum += a[i];
   }
   //cout << ans << " " << sum << " " << cnt << endl;
   ans = max(ans, sum);
   cout << ans << endl;


   return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int K, N;
    cin >> N >> K;
    int ans = 0;
    while (N > 0) {
        N /= K;
        ans++;
        }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
int main(){
    int n,K;std::cin>>n>>K;
    std::vector<std::complex<double>>P(n);
    std::vector<double>C(n),R(n);
    for(int i=0;i<n;i++){
        double x,y;std::cin>>x>>y;
        P[i]={x,y};
        std::cin>>C[i];
    }
    double eps=1e-12;
    double lwr=0,upr=200000;
    for(int ngtkana=0;ngtkana<70;ngtkana++){
        double T=(lwr+upr)/2;
        for(int i=0;i<n;i++)R[i]=T/C[i];
        auto covered_by_K=[&](std::complex<double>p, int i, int j){
            int counter=0;
            for(int k=0;k<n;k++){
                counter+=k==i||k==j||std::abs(p-P[k])<R[k];
            }
            return K<=counter;
        };
        for(int i=0;i<n;i++)if(covered_by_K(P[i],i,i))goto Upr;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                double d=std::abs(P[j]-P[i]);
                if(d<std::abs(R[j]-R[i])+eps||R[i]+R[j]-eps<d)continue;
                double t0=std::arg(P[j]-P[i]);
                double t1=std::acos((R[i]*R[i]+d*d-R[j]*R[j])/(2*R[i]*d));
                if(covered_by_K(P[i]+R[i]*std::exp(std::complex<double>(0,t0+t1)),i,j)
                    ||covered_by_K(P[i]+R[i]*std::exp(std::complex<double>(0,t0-t1)),i,j)){
                    goto Upr;
                }
            }
        }
        lwr=T;
        continue;
        Upr:upr=T;
    }
    std::cout<<std::setprecision(13)<<lwr<<std::endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int dp[5005][5005];
 
int main() {
  int n;
  string s;
  cin >> n >> s;
  for (int i = n-1; i >= 0; --i) {
    for (int j = n-1; j >= 0; --j) {
      if (s[i] != s[j]) dp[i][j] = 0;
      else dp[i][j] = dp[i+1][j+1]+1;
    }
  }
  int ans = 0;
  rep(i,n)rep(j,n) {
    if (i >= j) continue; // i < j;
    int now = min(dp[i][j], j-i);
    ans = max(ans, now);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std; 

int main (){

    long long n,  cont=0, a, b, d;

    cin >> n >> d;


    while(n--){

        cin >> a >> b; 

        if( ((a*a) + (b*b)) <= (d*d))
            cont++;
    }

    cout << cont << endl; 
    
}

Measured memory_bytes: 3600
def calc_allocatable_packet(packets, num_of_trucks, p_max):
    """ ?????????????????°?????????????????§?????????????±?????????????n??°??????????????????????????????????????°????±??????? """
    num_of_packets = len(packets)
    next_p = 0  # ?????°?????????????????° ??? ?¬????packet[i]?????????????????????
    for t in range(num_of_trucks):
        payload = 0  # ??????????????????????????????
        while next_p < num_of_packets:
            if payload + packets[next_p] <= p_max:  # ?¬?????????????????????§???????
                payload += packets[next_p]
                next_p += 1
            else:
                break  # ?¬???????????????????
    return next_p


def calc_minimum_payload(packets, num_of_trucks):
    num_of_packets = len(packets)
    lower_limit = packets[0]
    upper_limit = 10000 * num_of_packets

    while lower_limit < upper_limit:
        middle = (lower_limit + upper_limit) // 2
        result = calc_allocatable_packet(packets, num_of_trucks, middle)
        if result < num_of_packets:
            lower_limit = middle + 1
        else:
            upper_limit = middle

    return lower_limit


if __name__ == '__main__':
    # ??????????????\???
    num_of_packets, num_of_trucks = [int(x) for x in input().split(' ')]
    packets = [int(input()) for _ in range(num_of_packets)]
    # num_of_packets, num_of_trucks = 0, 0
    # packets = []
    # with open('ALDS1_4_D_in25.txt') as f:
    #    for line in f:
    #       if ' ' not in line:
    #           packets.append(int(line))
    #       else:
    #           num_of_packets, num_of_trucks = [int(x) for x in line.split(' ')]



    # ???????????????
    result = calc_minimum_payload(packets, num_of_trucks)

    # ???????????¨???
    print(result)

Measured memory_bytes: 11544
#include <iostream>
#include <queue>
#include <string>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n, q, t = 0;
  std::cin >> n >> q;
  std::queue<std::string> names;
  std::queue<int> times;

  rep(i, n) {
    std::string name;
    int time;
    std::cin >> name >> time;
    names.push(name);
    times.push(time);
  }

  while (!times.empty()) {
    int time = times.front();
    if (time <= q) {
      t += time;
      std::cout << names.front() << ' ' << t << '\n';
      times.pop();
      names.pop();
    } else {
      t += q;
      times.push(time - q);
      times.pop();
      names.push(names.front());
      names.pop();
    }
  }
  return 0;
}


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

const int MOD = 1000000007;

string a[1100];
long dp[1100][1100];

int main(){
    int h, w;
    cin >> h >> w;
    for(int i = 0; i < h; i++)
        cin >> a[i];
    for(int i = h - 1; i >= 0; i--){
        for(int j = w - 1; j >= 0; j--){
            dp[i][j] = (i == h - 1 && j == w - 1);
            if(i + 1 < h) dp[i][j] += dp[i+1][j];
            if(j + 1 < w) dp[i][j] += dp[i][j+1];
            dp[i][j] %= MOD;
            if(a[i][j] == '#') dp[i][j] = 0;
        }
    }
    cout << dp[0][0] << endl;
}

Measured memory_bytes: 9856
N, K = map(int, input().split())
X = list(map(int, input().split()))
ans = float("inf")
for i in range(N - K + 1):
    left, right = X[i], X[i + K - 1]
    if left * right <= 0:
        ans = min(ans, abs(left) + right + min(abs(left), right))
    elif left > 0:
        ans = min(ans, right)
    else:
        ans = min(ans, abs(left))
print(ans)


Measured memory_bytes: 14252