akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;

const ll INF = 2000000000000000000;

vll cs;
vvi gf, bc;

void dfs(vi &vis, int n, int p) {
	vis[n] = 1;
	bc[p].push_back(n);
	for (int i = 0; i < (int)gf[n].size(); i++) {
		if (vis[gf[n][i]] == 0)
			dfs(vis, gf[n][i], p);
	}
}

int main() {FIN
	
	int n, i, j, k, p, m;
	ll K, mx = -INF, r, mm, sz;
	cin >> n >> K;
	cs = vll(n);
	gf = vvi(n);
	
	m = 0;
	for (i = 0; i < n; i++) {
		cin >> p;
		gf[i].push_back(--p);
	}
	for (i = 0; i < n; i++)
		cin >> cs[i];
	
	vi vis(n);
	bc = vvi(n/2);
	m = 0;
	for (i = 0; i < n; i++) {
		if (vis[i] == 0)
			dfs(vis, i, m++);
	}
	
	for (k = 0; k < m; k++) {
		sz = bc[k].size();
		vll sm(2*sz);
		for (j = 0; j < 2*sz-1; j++) 
			sm[j+1] = sm[j] + cs[bc[k][j%sz]];
		
		r = sm[sz+1] - sm[1];
			
		for (i = 0; i < sz; i++) {
			for (j = i+1; j <= min(sz, K)+i; j++) {
				mm = sm[j] - sm[i];
				if (r > 0)
					mx = max(mx, mm + ((K-(j-i))/sz) * r);
				else
					mx = max(mx, mm);
			}
		}
	}
	
	cout << mx << "\n";
	
	return 0;
}


Measured memory_bytes: 4452
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(void){
  int T;
  int X;
  double t;
  cin >> T >> X;
  t = (double)T/(double)X;
  printf("%lf\n", t);
  return 0;
}


Measured memory_bytes: 256
#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 - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll a, b, k;
  cin >> a >> b >> k;

  REP(i, k){
    if(i % 2 == 0){
      if(a % 2 == 1) a--;

      a /= 2;
      b += a;
    }
    else{
      if(b % 2 == 1) b--;
      b /= 2;
      a += b;
    }
  }

  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
N=int(input())
A=[0]*N
for i in range(N):
    X,L=map(int,input().split())
    A[i]=(X-L,X+L)

A.sort(key=lambda x:x[-1])

K=0
x=-float("inf")

for a,b in A:
    if x<=a:
        K+=1
        x=b

print(K)

Measured memory_bytes: 83316
#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)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    int x;
    cin >> x;
    if (x == 0) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3648
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N, K;
	std::cin >> N >> K;
	if (K == 1)
		std::cout << "0\n";
	else
		std::cout << (N-K) << "\n";
}


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

#define rep(i,n,m) for(int i=n; i<=m; i++)
#define per(i,n,m) for(int i=n; i>=m; i--)
#define print(x) printf("%d ", x);
#define println(x) printf("%d\n", x);
#define printarray(a,n) for(int i=0; i<n-1; i++){printf("%d ", a[i]);} printf("%d\n", a[n-1]);
#define scan(x) scanf("%d", &x);
#define scanarray(a,n) for(int i=0; i<n; i++){scanf("%d", &a[i]);}

void insertionsort(int *a, int n, int g);
void shellsort(int *a, int n);

int count = 0;

int main () {
    int n;
    scan(n);
    int a[n];
    scanarray(a,n);

    //printarray(a,n);

    shellsort(a,n);

    return 0;
}

void insertionsort(int *a, int n, int g) {
    int v;
    int j;
    rep(i,g,n-1) {
        v = a[i];
        j = i - g;
        while(j >= 0 && a[j] > v) {
            a[j+g] = a[j];
            j = j - g;
            count++;
        }
        a[j+g] = v;
    }
}

void shellsort(int *a, int n) {
    int limit=1;
    int m=1;
    rep(i,1,100) {
        limit = 1 + 3*limit;
        if(limit > n) {
            m = i;
            break;
        }
    }
    int g[m];
    g[m-1] = 1;
    rep(i,1,m-1) {
        g[m-1 - i] = 1 + 3*g[m-1 - i + 1];
    }
    rep(i,0,m-1) {
        insertionsort(a,n,g[i]);
    }

    println(m);
    printarray(g,m);
    println(count);
    rep(i,0,n-1) cout << a[i] << endl;

}



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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[2005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K, Q;
    cin >> N >> K >> Q;
    vector<ll> v;
    REP(i, N) {
        cin >> A[i];
        v.push_back(A[i]);
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    ll ans = INF;
    REP(i, v.size()) {
        priority_queue<ll, vector<ll>, greater<ll>> q;
        vector<ll> u;
        REP(j, N) {
            if (A[j] < v[i]) {
                while (!q.empty()) {
                    ll t = q.top();
                    q.pop();
                    if (q.size() >= K - 1)
                        u.push_back(t);
                }
                continue;
            }
            q.push(A[j]);
        }
        while (q.size() >= K) {
            ll t = q.top();
            q.pop();
            u.push_back(t);
        }
        if (u.size() < Q)
            break;
        sort(u.begin(), u.end());

        ans = std::min(ans, u[Q - 1] - u[0]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

int main()
{
    std::string line;
    while (std::cin >> line) {
        if ("0" == line) {
            break;
        }
        int sum = 0;
        for (int i = 0; i < line.length(); ++i) {
            sum += (int)(line[i] & 0b00001111);
        }
        std::cout << sum << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>=10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int k,int mod){
	int res=1,bas=x;
	while(k){
		if(k&1) res=1ll*res*bas%mod;
		bas=1ll*bas*bas%mod,k>>=1;
	}
	return res;
}
int a,b;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(a),read(b);
	if(a>=13) print(b);
	if(a>=6&&a<13) print(b/2);
	if(a<6) print(0);
	return 0;
}

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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            Console.WriteLine((n - 1) * n / 2);
        }

    }
}

Measured memory_bytes: 27344
#include <stdio.h>

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long list[n];
  list[0] = a[0];
  long list_size = 1;
  long start,end,center;
  for (long i = 1; i < n; i++) {
    if (a[i] <= list[list_size-1]) {
      list[list_size] = a[i];
      list_size++;
    } else {
      if (a[i] > list[0]) {
        list[0] = a[i];
        continue;
      }
      start = 0;
      end = list_size-1;
      while (start+1 != end) {
        center = (start+end)/2;
        if (list[center] >= a[i]) {
          start = center;
        } else {
          end = center;
        }
      }
      list[end] = a[i];
    }
  }
  printf("%ld\n", list_size);

  return 0;
}

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

long long int attack(long long int a){
  if(a==1){
    return 1;
  }else if(a%2==0){
    return attack(a/2)*2+1;
  }else{
    return attack((a-1)/2)*2+1;
  }
}

int main(){
  long long int H;
  cin>>H;
  cout<<attack(H)<<endl;  
  
  
}

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

vector<P>E[400];
int d[400];
int main() {
	int n,m;scanf("%d%d",&n,&m);
	rep(i,m){
		int a,b,c;scanf("%d%d%d",&a,&b,&c);
		E[a].push_back(P(b,c));
	}
	priority_queue<P>que;
	que.push(P(0,0));
	while(!que.empty()){
		P p=que.top();que.pop();
		if(p.first<d[p.second])continue;
		for(P v:E[p.second]){
			if(d[v.first]<d[p.second]+v.second){
				d[v.first]=d[p.second]+v.second;
				que.push(P(d[v.first],v.first));
			}
		}
	}
	printf("%d\n",d[n-1]);
}

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

int main() {
  int n; cin >> n;
  set<int> st;
  for(int i = 0; i < n; ++i) {
    int x; cin >> x;
    st.insert(x);
  }
  int l = 0;
  for(int i : st) l++;
  cout << (l == n ? "YES" : "NO") << endl;
  return 0;
}

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

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

    if (x == 1) {
        cout << "0" << endl;
    } else if (x == 0) {
        cout << "1" << endl;
    }

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
int main() {
	ios_base::sync_with_stdio(false);
	string s; cin>>s;
	ll state=0;
	for (auto &w:s) {
		if (state==0&&w=='C') state++;
		if (state==1&&w=='F') state++;
	}
	if (state==2) {
		printf("Yes\n");
	}
	else printf("No\n");
}

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

const int maxn=10100;
const int maxm=1000100;

int n,m,pre[maxn],jl[maxn],f[maxn],a[maxn],b[maxn];
int xa[maxn],xb[maxn],ya[maxn],yb[maxn],ca[maxn],cb[maxn];
int tot,nex[maxm*2],las[maxm*2],tov[maxm*2],flow[maxm*2],val[maxm*2];
long long dis[maxn],maxflow,mincost;
bool vis[maxn];
queue <int> q;

void qsort(int l,int r)
{
	int i=l;int j=r;
	int m=a[(i+j)/2];
	while (i<=j)
	{
		while (a[i]>m) i++;
		while (a[j]<m) j--;
		if (i<=j)
		{
			swap(a[i],a[j]);
			swap(b[i],b[j]);
			i++;j--;
		}
	}
	if (l<j) qsort(l,j);
	if (r>i) qsort(i,r); 
}

void insert(int x,int y,int ff,int vv)
{
	tot++;
	tov[tot]=y;
	nex[tot]=las[x];
	las[x]=tot;
	flow[tot]=ff;
	val[tot]=vv;
	
	tot++;
	tov[tot]=x;
	nex[tot]=las[y];
	las[y]=tot;
	flow[tot]=0;
	val[tot]=-vv;
}

bool spfa(int s,int t)
{
	memset(dis,0x7f,sizeof(dis));
	memset(f,0x7f,sizeof(f));
	memset(vis,0,sizeof(vis));
	q.push(s); 
	vis[s]=1; 
	dis[s]=0; 
	pre[t]=-1;
	while (!q.empty())
	{
		int now=q.front();
		q.pop();
		vis[now]=0;
		for (int i=las[now];i;i=nex[i])
		{
			if (flow[i]>0 && dis[tov[i]]>dis[now]+val[i])
			{
				dis[tov[i]]=dis[now]+val[i];
				pre[tov[i]]=now;
				jl[tov[i]]=i;
				f[tov[i]]=min(f[now],flow[i]);
				if (!vis[tov[i]])
				{
					vis[tov[i]]=1;
					q.push(tov[i]);
				}
			}
		}
	}
	return pre[t]!=-1;
}

void MCMF()
{
	int t=2*n+6;
	while (spfa(1,t))
	{
		int now=t;
		maxflow+=f[t];
		mincost+=f[t]*dis[t];
		while (now!=1)
		{
			flow[jl[now]]-=f[t];
			flow[jl[now]^1]+=f[t];
			now=pre[now];
		}
	}
}

int main()
{
	tot=1;
	scanf("%d",&n);
	long long sum=0;
	for (int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&xa[i],&ya[i],&ca[i]);
		sum+=ca[i];
		insert(1,i+1,ca[i],0);
	}
	for (int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&xb[i],&yb[i],&cb[i]);
		insert(i+1+n+4,2*n+6,cb[i],0);
	}
	for (int i=1;i<=n;i++)
	{
		insert(i+1,n+1+1,ca[i],10000+xa[i]+ya[i]);
		insert(i+1,n+1+2,ca[i],10000-xa[i]+ya[i]);
		insert(i+1,n+1+3,ca[i],10000+xa[i]-ya[i]);
		insert(i+1,n+1+4,ca[i],10000-xa[i]-ya[i]);
		
		insert(n+1+1,i+1+n+4,cb[i],10000-xb[i]-yb[i]);
		insert(n+1+2,i+1+n+4,cb[i],10000+xb[i]-yb[i]);
		insert(n+1+3,i+1+n+4,cb[i],10000-xb[i]+yb[i]);
		insert(n+1+4,i+1+n+4,cb[i],10000+xb[i]+yb[i]);
	}
	MCMF();
	sum=sum*20000;
	printf("%lld\n",sum-mincost);
}

Measured memory_bytes: 4340
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define M 1000000007
#define ll long long
#define pb push_back
#define fo(i,N) for(int i = 0 ; i < N ; i++)
#define foo(i,x,N) for (int i = x; i < N ; i++)
#define fill(a,val) memset(a,val,sizeof(a))
#define fastio()  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define ff first
#define ss second
#define MAX 1234567
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(a) a.begin(),a.end()
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define inf 1e18
#define vi vector<int>
#define pii pair<int,int>
#define pqb priority_queue<pair<pair<ll,ll>,int>>
#define pqs priority_queue<pair<ll,ll>,vector <pair<ll,ll>>,greater<pair<ll,ll>>>
/// find_by_order() -- returns the iterator to the kth largest
/// order_of_key() -- number of elements strictly less than k
ll mpow(ll x, ll y, ll m) {if ( y == 0) return 1;  if ( y & 1) return (x % m * mpow(x, y - 1, m) % m) % m; else  {ll temp = mpow(x, y / 2, m) % m; return (temp * temp) % m;}}
ll power(ll x, ll y) {if ( y == 0) return 1;  if ( y & 1) return (x * power(x, y - 1)); else  {ll temp = power(x, y / 2); return (temp * temp);}}
typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag,
        tree_order_statistics_node_update>
        pbds;
void wandan23() {
    fastio()
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int n, m;
char arr[1001][1001];
int dp[1001][1001];

int solve(int i, int j)
{
    if ( i >= n || j >= m || arr[i][j] == '#')
        return 0;

    if ( dp[i][j] != (-1))
        return dp[i][j];

    if ( (i == n - 1) && (j == m - 1))
        return dp[i][j] = 1;

    return dp[i][j] = (solve(i + 1, j) % M + solve(i, j + 1) % M) % M;
}

int main() {

    cin >> n >> m;
    fo(i, n)
    {   fo(j, m)
        cin >> arr[i][j];
    }
    fill(dp, -1);

    cout << solve(0, 0) << endl;


}






















Measured memory_bytes: 8596
#include<cstdio>
int u[128],d[128],tt,n,an,k;
char s[1000000];
int main(){
 scanf("%d%d",&n,&k);
 for(int i=0;i<n;i++){
  scanf("%s",s);
  d[s[0]]++;
 }
 while(1){
  int ma=0,id;
  tt++;
  for(int i=0;i<k;i++){
    ma=0;
    for(int j='A';j<='Z';j++){
     if(d[j]>ma&&u[j]!=tt)ma=d[j],id=j;
    }
    if(ma==0)return 0*printf("%d\n",an);
    d[id]--;
    u[id]=tt;
  }
  an++;
 }
 return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

int main(void) {

    int N; cin >> N;
    vector<ll> a(3*N);
    for (int i = 0; i < 3*N; i++) cin >> a[i];

    ll ans = 0;
    sort(a.begin(), a.end());
    for (int i = 0; i < N; i++) {
        int idx = (3*N-2) - i*2;
        ans += a[idx];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
class Pro
  attr_accessor :name, :time
  def initialize(name, time)
    @name = name
    @time = time
  end
end

n, q = gets.split.map(&:to_i)
queue = []
n.times do
  p, t = gets.chomp.split
  pro = Pro.new(p, t.to_i)
  queue << pro
end
time = 0
while !queue.empty? do
  p = queue.shift
  t = [q, p.time].min
  time += t
  p.time -= t
  if p.time <= 0
    puts "#{p.name} #{time}"
  else
    queue << p
  end
end


Measured memory_bytes: 11444
#include<stdio.h>
#define MAX 250

int main(){
    int key[MAX];
    int i,n;

    scanf("%d",&n);

    for(i=1;i<=n;i++) scanf("%d",&key[i]);

    for(i=1;i<=n;i++) {
        printf("node %d: ",i);
        printf("key = %d, ",key[i]);
        if(((i)/2)>0) printf("parent key = %d, ",key[(i)/2]);
        if((2*(i))<=n) printf("left key = %d, ",key[2*(i)]);
        if(((2*i)+1)<=n) printf("right key = %d, ",key[(2*i)+1]);
        printf("\n");
    }

        return 0;
}

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

using namespace std;

int main()
{
    //system("chcp 65001");

    char n[3];
    int i;
    cin >> n;

    for(i = 0;i <= 2;i++)
    {
        if(n[i] == '1')
        {
            n[i] = '9';
        }
        else
        {
            n[i] = '1';
        }
    }

    cout << n;

    //cout << N;

    return 0;
}

Measured memory_bytes: 256
t = int(input())
for i in range(t):
    n, a, b, c, d = map(int, input().split())
    e = {}
    def coin(n):
        if n == 0:
            return 0
        if n == 1:
            return d
        if n in e:
            return e[n]
        f = min(
            d*n,
            d*abs(n-n//5*5)+c+coin(n//5),
            d*abs(n-(n+4)//5*5)+c+coin((n+4)//5),
            d*abs(n-n//3*3)+b+coin(n//3),
            d*abs(n-(n+2)//3*3)+b+coin((n+2)//3),
            d*abs(n-n//2*2)+a+coin(n//2),
            d*abs(n-(n+1)//2*2)+a+coin((n+1)//2)
        )
        e[n] = f
        return f
    print(coin(n))

Measured memory_bytes: 10768
#include <bits/stdc++.h>
using namespace std;
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

#define INF 1e+9




int main(){

ios::sync_with_stdio(false);
cin.tie(0);

double n;
cin>>n;
cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;

}


Measured memory_bytes: 3748
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		long[] A = nextLongArray(N);

		String res = "Yes";

		A[0]--;
		for(int i=1;i<N;i++) {
			if(A[i-1]<A[i]) {
				A[i]--;
			}
		}

		for(int i=1;i<N;i++) {
			if(A[i-1]>A[i]) {
				res = "No";
				break;
			}
		}
		out.println(res);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}


}

Measured memory_bytes: 49320
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np

import bisect

def main():
	N,W=map(int,input().split())
	
	li=[list(map(int,input().split())) for _ in range(N)]
	V=sum(v for w,v in li)
	
	dp=[[10**15]*(V+2) for _ in [0]*(N+1)]
	
	for i in range(N):
		w = li[i][0]
		v = li[i][1]
		dp[i + 1][v] = min(dp[i + 1][v], w)
		for j in range(V+1)[::-1]:
			if j-v>=0:
				dp[i+1][j]=min(dp[i+1][j],dp[i+1][j+1],dp[i][j],dp[i][j-v]+w)
			else:
				dp[i + 1][j] = min(dp[i + 1][j], dp[i + 1][j + 1], dp[i][j])
#	for i in range(N+1):
#		print(dp[i])
	
	print(bisect.bisect_right(dp[-1],W)-1)
	
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 119024
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
struct nd{
    int to, w;
    nd(int t, int ww) : to(t), w(ww) {}
};
std::vector<nd> vec[100005];
int drg[100005];
bool vis[100005];
bool col[100005];
int main(){
    int n;
    std::cin >> n;
    int u,v,w;
    for(int i = 1; i < n; ++ i){
        std::cin >> u >> v >> w;
        vec[u].push_back(nd(v,w));
        vec[v].push_back(nd(u,w));
        drg[u] ++;
        drg[v] ++;
    }
    std::queue<int> que;
    vis[1] = true;
    que.push(1);
    while(!que.empty()){
        int it = que.front();
        que.pop();
        for(auto &ir : vec[it]){
            if (!vis[ir.to]) {
                if (ir.w & 1) col[ir.to] = !col[it];
                else col[ir.to] = col[it];
                que.push(ir.to);
                vis[ir.to] = true;
            }
        }
    }
    for(int i =1 ; i<= n; ++ i){
        std::cout << col[i] << std::endl;
    }
}

Measured memory_bytes: 7040
#include <stdio.h>
int main ( void ) {
    int a[5];
    int n,i,work;
    int max[5]={0};
    scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4]);
    for(i=0;i<5;i++){
        for(n=i+1;n<5;n++){
            if(a[i]<a[n]){
                work=a[i];
                a[i]=a[n];
                a[n]=work;
            }
        }
    }
    for(i=0;i<4;i++){
        printf("%d ",a[i]);
    }
    printf("%d",a[4]);
    puts("");
    return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  string s;
  set<string> se;
  rep(i,n) {
    R s;
    se.in(s);
  }
  pr(se.size());

}

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


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

#define pb  push_back
#define ll  long long
#define INF 0x3f3f3f3f
#define pii pair<int, int>
#define ull unsigned long long int

const int t = 105;
int p[t], v[t];
ll ans[2][100005];
int n, w;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n >> w;
    for (int i = 0; i < n; i++) 
        cin >> p[i] >> v[i];
    
    for (int i = n; i >= 0; i--) {
        for (int j = 1; j <= w; j++) {
            ll passa = ans[(i + 1) & 1][j];
            if (j - p[i] < 0) {
                ans[i & 1][j] = passa;
                continue;
            }
            ll pega = ans[(i + 1) & 1][j - p[i]] + v[i];
            ans[i & 1][j] = max(pega, passa);
        }
    }
    cout << ans[0][w] << "\n";
    
    //cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}

Measured memory_bytes: 1792
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second


ll N, K, A, B, C;
ll arr[100005];
vector<ll> V;
string S;
ll cntA = 0;
ll cntB = 0;

int main() {
	cin >> S;
	for(int i = 0; i < S.size(); i++) {
		if(S[i] == 'A') {
			cntA++;
		}
		else {
			cntB++;
		}
	}
	if(!cntA || !cntB) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <cstdio>
#define LIMIT 2000000

void CountingSort(int A[], int B[], int n) {
    int C[LIMIT];
    for (int i = 0; i < LIMIT; i++) {
        C[i] = 0;
    }
    for (int j = 0; j < n; j++) {
        C[A[j]]++;
    }
    for (int i = 1; i < LIMIT; i++) {
        C[i] = C[i] + C[i-1];
    }
    for (int j = n - 1; j >= 0; j--) {
        B[C[A[j]]-1] = A[j];
        C[A[j]]--;
    }
}

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

    int A[n], B[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    CountingSort(A, B, n);
    
    for (int i = 0; i < n; i++) {
        if (i) printf(" ");
        printf("%d", B[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 26144
#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair 
#define pb push_back 
#define F first 
#define S second 
#define f(i,n) for(int i=0;i<n;i++) 
#define fr(i,a,b) for(int i=a;i<b;i++) 

using namespace std;

ll fact[200002],ifact[200002];
	

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1LL; 
    x = x % p;
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
}

ll gcdExtended(ll a, ll b, ll *x, ll *y); 

ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
    ll res = (x%m + m) % m; 
    return res;
}  
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{  
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1);  
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 

void test(){
	ll n,k;
	cin>>n>>k;
	ll mod = 1e9+7;
	
	ll sum = 0;
	for(ll i=k;i<=n+1;i++){
		// we will select k ele ,
		ll mini = (i-1)*(i);
		mini = mini/2;
		ll maxa = n*(n+1);
		maxa = maxa/2;
//		cout<<(i-1)<<" "<<n<<"\n";
//		cout<<maxa<<" "<<mini<<"\n";
		ll m2 = (n-i)*(n-i+1);
		m2 = m2/2;
		maxa = maxa-m2;
		
		sum = sum + (maxa-mini+1);
		sum%=mod;
	}
	cout<<sum<<"\n";
}

int main(){
	int t=1;
//	cin>>t;
	while(t--){
		test();
	}
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m;

	if(!(n & 1)  ||  !(m & 1)) cout<<"Even"<<endl;
	else cout<<"Odd"<<endl;



}


Measured memory_bytes: 256
// 08/06/20 // 10:39 PM //

#include <bits/stdc++.h>

using namespace std;

#define int long long

const int MAXN = (int)(2e5) + 10;
const int INF = 0x3f3f3f3f;

int n, h[MAXN], a[MAXN], dp[MAXN];

int query(int i){
    int qmax = 0;

    while(i>0){
        qmax = max(qmax, dp[i]);
        i -= (i&-i);
    }

    return qmax;
}

void update(int i, int val){
    while(i<=n){
        dp[i] = max(dp[i], val);
        i += (i&-i);
    }
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;

    for(int i=1; i<=n; i++) cin >> h[i];
    for(int i=1; i<=n; i++) cin >> a[i];

    for(int i=1; i<=n; i++){
        update(h[i], max(query(h[i]-1) + a[i], query(h[i])));
    }

    cout << query(n) << endl;

    return 0;
}


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
  
  
  
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
  
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 7772
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/operators.hpp>
#include <boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	std::int64_t X;
	std::cin >> X;
	auto max = (X / 500) * 1000;
	X %= 500;
	max += (X / 5) * 5;
	std::cout << max << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if (a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
using namespace std;
int main(){
    int r,c,A[101][101];
    cin>>r>>c;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            cin>>A[i][j];
        }
    }
    for(int i=0;i<=r;i++) A[i][c]=0;
    for(int j=0;j<=c;j++) A[r][j]=0;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            A[i][c]+=A[i][j];
            A[r][j]+=A[i][j];
            A[r][c]+=A[i][j];
        }
    }
    for(int i=0;i<=r;i++){
        for(int j=0;j<=c;j++){
            if(j>0){
                cout<<" ";
                cout<<A[i][j];
            } 
            else{
                cout<<A[i][j];
            }
        }cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 7/13/2018
 
 16:35-17:00, 18:10-18:30 give up
 18:30-19:05 read editorials
 19:05-19:47 1WA
 
 Editorials:
  -
 
 Key:
  - K is cyclic => modular arithmetic
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
// 16:35-17:00, 18:10-18:30 give up
const int MAX_K=1e3+1;
int N,K;
int G[2][2*MAX_K][2*MAX_K]={};
int cum[2][2*MAX_K][2*MAX_K]={};
int f(int i1, int j1, int i2, int j2, int c) {
  int res=cum[c][i2][j2]-cum[c][i2][j1]-cum[c][i1][j2]+cum[c][i1][j1];
  if(res<0) {
    dump4(i1,j1,i2,j2);
    dump4(cum[c][i2][j2],cum[c][i2][j1],cum[c][i1][j2],cum[c][i1][j1]);
    dump2(c,res);
  }
  assert(res>=0);
  return res;
}

void solve() {
  int KK=2*K;
//  REP(i,KK)REP(j,KK) dump3(i,j,G[1][i][j]);
  REP(c,2)REP(i,KK)REP(j,KK) {
    cum[c][i+1][j+1]=cum[c][i+1][j]+cum[c][i][j+1]+G[c][i][j]-cum[c][i][j];
//    dump4(i,j,c,cum[c][i+1][j+1]);
  }
  int res=0;
  REP(i,K)REP(j,K) REP(c,2) {
    int c1=c,c2=c^1;
    int w=f(0,0,i,j,c1)+f(i,j,i+K,j+K,c1)+f(i+K,j+K,KK,KK,c1)+f(i+K,0,KK,j,c1)+f(0,j+K,i,KK,c1);
    int b=f(0,j,i,j+K,c2)+f(i,0,i+K,j,c2)+f(i,j+K,i+K,KK,c2)+f(i+K,j,KK,j+K,c2);
//    dump4(i,j,w,b);
    SMAX(res,w+b);
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ZERO(G),ZERO(cum);
  cin>>N>>K;
  REP(i,N) {
    int x,y; char c;
    cin>>x>>y>>c;
    G[c=='B'][x%(2*K)][y%(2*K)]++;
  }
  solve();
  return 0;
}


Measured memory_bytes: 63480
use std::io::*;
use std::str::FromStr;


fn read<T: FromStr>() -> T {
// taken from https://qiita.com/tubo28/items/e6076e9040da57368845 (2020/07/03)
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let a: u32 = read();
    println!("{}", a + a*a + a*a*a);
}


Measured memory_bytes: 2120
#include<iostream>
#define MAX_V 100000
#define MAX_E 500000
#define INF 1e9
using namespace std;

int V;//頂点の数
int E;//辺の数

struct edge {
	int from, to, cost;
};
edge es[MAX_E];

int dist[MAX_V];

int find_negative_loop(int s) {
	dist[s] = 0;
	int count = 0;

	while (true) {
		count++;
		bool update = false;
		for (int i = 0; i < E; i++) {
			if (es[i].from != INF && dist[es[i].to] > dist[es[i].from] + es[i].cost) {
				if (count == V) {
					return true;
				}
				dist[es[i].to] = dist[es[i].from] + es[i].cost;
				update = true;
			}
			
		}
		if (update == false) {
			return false;
		}
	}
	
}

int main() {
	int r;
	cin >> V >> E >> r;
	for (int i = 0; i < V; i++) {
		dist[i] = INF;
	}
	for (int i = 0; i < E; i++) {
		cin >> es[i].from >> es[i].to >> es[i].cost;
	}
	if (find_negative_loop(r)) {
		cout << "NEGATIVE CYCLE" << endl;
	}
	else {
		for (int i = 0; i < V; i++) {
			if (dist[i] == INF) {
				cout << "INF" << endl;
			}
			else {
				cout << dist[i] << endl;
			}
		}
	}
	return 0;


}


Measured memory_bytes: 9116
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

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

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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s[k - 1] = tolower(s[k - 1]);
  cout << s << '\n';
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/list"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := readInt()
	qu := list.New()
	for i := 0; i < n; i++ {
		a := readInt()
		if i%2 == 0 {
			qu.PushBack(a)
		} else {
			qu.PushFront(a)
		}
	}

	var wr = bufio.NewWriter(os.Stdout)
	for qu.Len() > 0 {
		var x int
		if n%2 == 0 {
			x = qu.Remove(qu.Front()).(int)
		} else {
			x = qu.Remove(qu.Back()).(int)
		}
		if qu.Len() > 0 {
			wr.WriteString(strconv.Itoa(x) + " ")
		} else {
			wr.WriteString(strconv.Itoa(x) + "\n")
		}
	}
	wr.Flush()
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0)return a;
    return gcd(b, a % b);
}

// 素因数分解
map<ll, ll> prime_factorize(ll N) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= N; ++i) {
        while (N % i == 0) {
            res[i]++;
            N /= i;
        }
    }
    if (N != 1) res[N] = 1;
    return res;
}

void Main() {
    ll A, B;
    cin >> A >> B;
    ll g = gcd(A, B);
    map<ll, ll> pf = prime_factorize(g);
    cout << pf.size() + 1 << '\n';;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	size := len(s)
	var win int
	for _, c := range s {
		if c == 'o' {
			win++
		}
	}

	if win+15-size >= 8 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
a,v = gets.split.map(&:to_i)
b,w = gets.split.map(&:to_i)
t = gets.to_i
if v <= w then
    puts "NO"
    exit
end
d = (a-b).abs.to_f
d_v = (v-w).abs
num = (d/d_v).ceil
puts num <= t ? "YES" : "NO"

Measured memory_bytes: 14312
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
   input! {
       l: u64,
       r: u64,
   } 

   if r - l > 2018 {
       println!("{}", 0);
       return;
   }

   let tmpl = l  / 2019;
   
   let newl = l -tmpl*2019;
   let newr = r - tmpl*2019;

    //println!("newl {} newr {}", newl, newr);
    let mut min = 1<<60;
    if newr >= 2019 {
        println!("{}", 0);
    } else {
        for i in newl..newr+1 {
            for j in i+1..newr+1 {
                if min > (i*j)%2019 {
                    min = (i*j)%2019;
                }
            }
        }
        println!("{}", min);
    }
}   



Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]){
		cout<<"YES"<<endl;
		return 0;
	}
	cout<<"NO"<<endl;
	return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

int x,y;

int gcd(int a,int b) {
	int r;
	if(a<b) swap(a,b);
	while(a%b!=0) {
		r=b;b=a%b;a=r;
	}
	return b;
}

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

	cin>>x>>y;
	cout<<x+y+2-gcd(x,y)-1<<endl;

	return 0;
}



Measured memory_bytes: 3164
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    H, W, Q = map(int, input().split())
    grid = []
    for _ in range(H):
        grid.append(input().rstrip('\n'))

    V = [[0] * (W+1) for _ in range(H+1)]
    for h in range(H):
        for w in range(W):
            V[h+1][w+1] = V[h+1][w] + V[h][w+1] - V[h][w] + int(grid[h][w])
    EH = [[0] * (W+1) for _ in range(H)]
    for h in range(H-1):
        for w in range(W):
            if grid[h][w] == grid[h+1][w] == "1":
                add = 1
            else:
                add = 0
            EH[h+1][w+1] = EH[h+1][w] + EH[h][w+1] - EH[h][w] + add
    EW = [[0] * (W + 1) for _ in range(H + 1)]
    for h in range(H):
        for w in range(W-1):
            if grid[h][w] == grid[h][w+1] == "1":
                add = 1
            else:
                add = 0
            EW[h + 1][w + 1] = EW[h + 1][w] + EW[h][w + 1] - EW[h][w] + add
    for _ in range(Q):
        h1, w1, h2, w2 = map(int, input().split())
        v = V[h2][w2] - V[h2][w1-1] - V[h1-1][w2] + V[h1-1][w1-1]
        eh = EH[h2-1][w2] - EH[h2-1][w1-1] - EH[h1-1][w2] + EH[h1-1][w1-1]
        ew = EW[h2][w2-1] - EW[h2][w1-1] - EW[h1 - 1][w2-1] + EW[h1 - 1][w1-1]
        print(v - eh - ew)


if __name__ == '__main__':
    main()


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> city(N);
  vector<int> road(2 * M);
  
  for (int i = 0; i < N; i++) {
    city.at(i) = i + 1;
  }
  
  for (int i = 0; i < 2 * M; i++) {
    cin >> road.at(i);
  }
  
  vector<int> result(N);
  for (int i = 0; i < 2 * M; i++) {
    for (int j = 0; j < N; j++) {
      if (road.at(i) == city.at(j)) {
        result.at(j)++;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    cout << result.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

int N;
int cnt[100001];

int main(){
    cin>>N;
    rep(i,N){
        int a;
        cin>>a;
        cnt[a]++;
    }
    repn(i,100000) cnt[i]=max(0,cnt[i]-1);

    int ans=N;
    int sum=0;
    repn(i,100000){
        sum+=cnt[i];
    }
    ans-=sum;
    if(sum%2==1) ans--;

    cout<<ans<<endl;
}

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


 int main(){
  string N;
  string a, b, c;

  cin >> N;

  a = N.substr(0,1);
  c = N.substr(2,1);
 

  if(a == c) cout << "Yes" << endl;
   else cout << "No" << endl;

 return 0;
}



Measured memory_bytes: 256