akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;



int main() {
	ll a[3];
	int k;
	for (int i = 0; i < 3; i++)cin >> a[i];
	cin >> k;
	sort(a, a + 3);

	ll t = 1;
	for (int i = 0; i < k; i++) {
		t *= 2;
	}

	ll ans = a[0] + a[1] + a[2] * t;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int search(int A[], int n, int key){
	int i = 0;
	A[n] = key;
	while( A[i] != key ) i++;
	return i != n;
}

int main(){
	int i,n,A[10000+1],q,key,sum = 0;
	scanf("%d", &n);
	for(i = 0; i < n; i++) scanf("%d", &A[i]);
	scanf("%d", &q);
	for(i = 0; i < q; i++){
		scanf("%d", &key);
		if( search(A,n,key) ) sum++;
	}
	printf("%d\n", sum);
	
	return 0;
}

Measured memory_bytes: 636
// C - One Quadrillion and One Dalmatians
#include <bits/stdc++.h>
using namespace std;

int main(){
	int64_t n; cin>>n;
	string a = "abcdefghijklmnopqrstuvwxyz";
	string ans = "";
	while(n > 0){
		int r = (n-1) % 26;
		n = (n-1) / 26;
		ans = a[r] + ans;
	}
	cout<< ans <<endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define Test(tt) cout << "Case #" << tt << ": "

using namespace std;



int main() {
#ifdef HOME
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int h1, m1, h2, m2, k;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

	cin >> h1 >> m1 >> h2 >> m2 >> k;    

	int start = h1 * 60 + m1;
	int end = h2 * 60 + m2;

	cout << max(0, (end - start - k));

    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
  string s;
  cin >> s;
  int i;
  if(s[2]==s[3]&&s[4]==s[5]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
 return 0;
}

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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(int size) {
        prime.resize(size + 1, 1);
        prime[0] = 0;
        prime[1] = 0;
        FOR(i, 2, size) {
            if (prime[i]) {
                for (int j = 2 * i; j <= size; j += i) {
                    prime[j] = 0;
                }
            }
        }
    }

};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

int N, M;
int v[101010];
vector<int> A[101010];

bool dfs(int x, int c) {
    c += A[x].size();
    c -= v[x];
    if (c % 2 == 1)return false;
    for (int to:A[x]) {
        if (!dfs(to, c))return false;
    }
    return true;
}

int main() {
    cin >> N >> M;
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        A[a].push_back(b);
        A[b].push_back(a);
    }
    REP(i, N) {
        if (A[i].size() % 2 == 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}



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

using namespace std;

struct Info {
	int time;
	int value;
};

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

	vector<Info> infoList(N);
	for(auto &x : infoList) {
		cin >> x.time >> x.value;
	}

	sort(infoList.begin(), infoList.end(), [](Info &a, Info &b) {
		return a.value > b.value;
	});
	
	// value[i][j]: i番目以降の料理で、j分以内に食べ終えられる満足度
	vector<vector<int>> value(N, vector<int>(T + 1, 0));
	// value2[i][j]: i番目以降の料理で、j分以内に注文できる満足度
	vector<vector<int>> value2(N, vector<int>(T + 1, 0));
	value[N - 1][0] = value2[N - 1][0] = 0;
	for(int t = 1; t <= T; t++) {
		const auto &info = infoList[N - 1];
		value2[N - 1][t] = info.value;
		if(info.time > t) {
			value[N - 1][t] = 0;
		} else {
			value[N - 1][t] = info.value;
		}
	}
	for(int i = N - 2; i >= 0; i--) {
		for(int t = 2; t <= T; t++) {
			const auto &info = infoList[i];

			{
				const auto noeat = value[i + 1][t];
				const auto eat = (t - info.time < 0) ? 0 : value[i + 1][t - info.time] + info.value;
				value[i][t] = max(noeat, eat);
			}

			{
				const auto noeat = value2[i + 1][t];
				const auto eatinlast = (t - 1 < 0) ? 0 : value[i + 1][t - 1] + info.value;
				const auto eat = (t - info.time < 0) ? 0 : value2[i + 1][t - info.time] + info.value;
				value2[i][t] = max({noeat, eatinlast, eat});
			}
		}
	}
	
	const auto result = value2[0][T];
	
	cout << result << endl;

	return 0;
}


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

int main (void) {
    int A=0,B=0,sum=0;
	cin >> A >> B;
	sum = A+B;
	if (sum%2==0){
	    cout << sum/2 <<endl;
	} else if (sum%2==1){
	    cout << "IMPOSSIBLE" << endl;
	}
	
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

template<class monoid>
struct LazySegmentTree
{
  using F=function<monoid(monoid,monoid)>;
private:
    int n;
    vector<ll> node, lazy;
    F f;
    monoid m1;


public:
    LazySegmentTree(int sz,F fun,monoid m1):f(fun),m1(m1)
    {
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1,m1);
        lazy.resize(2*n-1, 0);
    }
    void eval(int k, int l, int r)
    {
      if(lazy[k] != 0)
      {
        node[k] += lazy[k];//ここ
        if(r - l > 1)
        {
          lazy[2*k+1] += lazy[k];//ここ
          lazy[2*k+2] += lazy[k];//ここ
        }
        lazy[k] = 0;
      }
    }

    void add(int a, int b, monoid x, int k=0, int l=0, int r=-1)
    {
      if(r < 0) r = n;
      eval(k, l, r);
      if(b <= l || r <= a) return;
      if(a <= l && r <= b)
      {
          lazy[k] += x;//ここ
          eval(k, l, r);
      }
      else
      {
          add(a, b, x, 2*k+1, l, (l+r)/2);
          add(a, b, x, 2*k+2, (l+r)/2, r);
          node[k] = f(node[2*k+1],node[2*k+2]);
      }
    }

    monoid query(int a, int b, int k=0, int l=0, int r=-1)
    {
      if(r < 0) r = n;
      if(b <= l || r <= a) return 0;
      eval(k, l, r);
      if(a <= l && r <= b) return node[k];
      monoid vl = query(a, b, 2*k+1, l, (l+r)/2);
      monoid vr = query(a, b, 2*k+2, (l+r)/2, r);
      return f(vl,vr);
    }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  vector<vector<pair<int,int>>>sec(n+1);
  rep(i,m)
  {
    ll l,r,a;
    cin>>l>>r>>a;
    sec[r].push_back({l,a});
  }
  LazySegmentTree<ll> st(n+1,[](ll a,ll b){return max(a,b);},0);
  repi(i,1,n+1)
  {
    st.add(i,i+1,st.query(0,i));
    for(auto p:sec[i])
    {
      st.add(p.first,i+1,p.second);
    }
  }
  cout<<st.query(0,n+1)<<endl;


  return 0;

}


Measured memory_bytes: 19456
n = int(input())
xlt = []
for i in range(n):
    xi,li = map(int,input().split())
    xlt.append((xi+li,xi-li))
xlt.sort()
ans = 0
x = -float("INF")
for i in range(n):
    if x <= xlt[i][1]:
        ans += 1
        x = xlt[i][0]
print(ans)

Measured memory_bytes: 22760
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll x,y;cin>>x>>y;
    bitset<32>a(x),b(y);
    /*cout<<a<<endl;
    cout<<~a<<endl;
    cout<<(a<<1)<<endl;
    cout<<(a>>1)<<endl;*/
    cout<<(a&b)<<endl;
    cout<<(a|b)<<endl;
    cout<<(a^b)<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    vector<ll> v(n);
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
        sum+=v[i];
    }
    set<ll> s;
    for(ll i=1LL;i*i<=sum;i++){
        if(sum%i==0){
            s.insert(i);
            s.insert(sum/i);
        }
    }
    ll d[n];
    ll suma,sumi;
    set<ll>::iterator itr=s.end();
    itr--;
    for(;;itr--){
        suma=0,sumi=0;
        vector<ll> a=v;
        for(int i=0;i<n;i++){
            a[i]%=*itr;
        }
        sort(be(a));
        for(int i=0;i<n;i++){
            if(a[i])d[i]=*itr-a[i];
            else d[i]=0;
            suma+=d[i];
        }
        if(sumi==suma && sumi<=k){
            cout << *itr<<endl;
            return 0;
        }
        for(int i=0;i<n;i++){
            sumi+=a[i];
            suma-=d[i];
            if(sumi==suma && sumi<=k){
                cout << *itr<<endl;
                return 0;
            }
        }
        if(itr==s.begin()){
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	int A,B,C;
	cin >> A >> B >> C;

	string ans = "No";
	if(A==B || B==C || A==C){
		if(A!=B || B!=C || A!=C){
			ans="Yes";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    //float b= n;
    //int c=0;
    cin>>n;
    if(n%2==0)
    {
    	cout<<"0.5000000000"<<endl;
	}
	else
	{
		cout<<fixed<<setprecision(10)<<(long double)(n/2+1)/n<<endl;
	}
}

Measured memory_bytes: 3720
N,M=map(int,input().split())
total=1
mod=1000000007
if N==M:
    for i in range(1,N+1):
        total=total*i*i
        total=total%mod
    print((total*2)%mod)

elif N+1==M or M+1==N:
    total*=max(M,N)
    for i in range(1,min(M,N)+1):
        total=total*i*i
        total=total%mod
    print(total%mod)
else:
    print(0)

Measured memory_bytes: 39152
N, M = map(int, input().split())
Di = []
for i in range(N):
    d = list(map(int, input().split()))
    Di.append(d)
Di.sort(key=lambda x: x[0])

yen = 0
num = 0
for d in Di:
    if num + d[1] >= M:
        yen += (M - num) * d[0]
        break
    num += d[1]
    yen += d[0] * d[1]
print(yen)

Measured memory_bytes: 29024
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 100;

int N;

int A[MAX_N];

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

    cin >> N;

    int rn = 0;

    unordered_map<int, int> mp;

    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] >= 3200) {
            rn++;
        }
        for (int j = 0; j < 3200; j += 400) {
            if (j <= A[i] && A[i] < j + 400) {
                if (mp.count(j)) {
                    mp[j]++;
                } else {
                    mp.insert(make_pair(j, 1));
                }
            }
        }
    }

    int min = mp.size();
    if (mp.size() == 0) {
        min = 1;
    }
    int max = mp.size() + rn;

    cout << min << " " << max << "\n";

    return 0;
}

Measured memory_bytes: 3656
#include<cstdio>
#include<algorithm>
using namespace std;

const int MAXN=30;
const int MAXM=(1<<21)+5;
const int MOD=1e9+7;

int n,m,p,ans,now;
int dp[2][MAXN][MAXM],nxt[MAXM][MAXN];
int bz[MAXN][MAXN];

int main(){
    scanf("%d%d%d",&n,&m,&p); n--;
    for(int i=0;i<(1<<n);i++){
        int t=-1;
        for(int j=n-1;j>=0;j--){
            if((i&(1<<j))) t=j;
            nxt[i][j]=t;
        }
    }
    for(int i=1;i<=m;i++)
        for(int j=0;j<n;j++)
            bz[i][j]=-1;
    for(int i=1;i<=p;i++){
        int j,k,l;
        scanf("%d%d%d",&j,&k,&l);
        bz[j][k-1]=l;
    }
    dp[0][n][0]=1;
    now=1;
    for(int i=1;i<=m;i++){
        for(int s=0;s<(1<<n);s++) dp[now][0][s]=dp[now^1][n][s];
        for(int j=0;j<=n;j++)
            for(int s=0;s<(1<<n);s++)
                dp[now^1][j][s]=0;
        for(int j=0;j<n;j++)
            for(int s=0;s<(1<<n);s++)
                if(dp[now][j][s]){
                    for(int k=0;k<=1;k++){
                        if(bz[i][j]!=-1&&bz[i][j]!=k) continue;
                        int t=(s&(1<<j));
                        if(t) t=1;
                        if(!k&&t==1) continue;
                        if(k==t) (dp[now][j+1][s]+=dp[now][j][s])%=MOD;
                        else{
                            int r=nxt[s][j];
                            if(r==-1) (dp[now][j+1][s+(1<<j)]+=dp[now][j][s])%=MOD;
                            else (dp[now][j+1][s+(1<<j)-(1<<r)]+=dp[now][j][s])%=MOD;
                        }
                    }
                }
        now^=1;
    }
    for(int i=0;i<(1<<n);i++)
        (ans+=dp[now^1][n][i])%=MOD;
    printf("%d",(ans+MOD)%MOD);
}


Measured memory_bytes: 227456
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if  (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n;
    cin >> n;
    vector<double> v(n);
    rep(i,n) cin >> v[i];
    rep(i,n-1){
        sort(all(v));
        double tmp=v[0]+v[1];
        v.erase(v.begin(),v.begin()+2);
        v.pb(tmp/2);
    }
    cout << v[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    long long n = 0;
    int temp;
    
    while((temp = getchar()) != '\n'){
        n += temp - '0';
    }

    if((n % 9) == 0){
        printf("Yes");
    } else {
        printf("No");
    }

    
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll int, null_type,less<ll int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,m,n;
        cin>>n;
        ll a[100005][3];
        for(i=1;i<=n;i++)
            cin>>a[i][0]>>a[i][1]>>a[i][2];
        ll dp[100005][3];
        clr(dp,peak);
        dp[0][0]=0;dp[0][1]=0;dp[0][2]=0;
        for(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][0],max(dp[n][1],dp[n][2]));
    }
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int m,n;
vector<int> graph[100001];
vector<int> length;
int dfs(int i);
int main()
{
    int x,y,i,j;
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
        cin>>x>>y;
        graph[x].push_back(y);
    }
    for(i=0;i<=n;i++)
    {
        length.push_back(0);
    }
    int maxx=0;
    for(i=1;i<=n;i++)
    {
        int d=dfs(i);
        if(d>maxx)
            maxx=d;
    }
    cout<<maxx<<endl;
    return 0;
}
int dfs(int i)
{
    //cout<<i<< " "<<length[i]<<endl;
    if(!graph[i].size())
        return 0;
    if(length[i]!=0)
        return length[i];
    for(int j=0;j<graph[i].size();j++)
    {
        int d=dfs(graph[i][j])+1;
        if(length[i]<d)
            length[i]=d;
    }
    return length[i];


}


Measured memory_bytes: 8312
#include <cstdio>
#include <climits>
#include <cstdlib>

using namespace std;
 
int main(void){
  int N,A;

  scanf("%d %d", &N, &A);
 
  int L=A;
  int R=A+N-1;

  int eat;
  if (R <= 0) {
      eat = R;
  } else if ( L >= 0) {
      eat = L;
  } else {
      eat = 0;
  }

  int ringo_result=(R+L)*(R-L+1)/2-eat;

  printf("%d", ringo_result);
 
  return 0;
}


Measured memory_bytes: 128
import sys

N,K=map(int, sys.stdin.readline().split())
P=map(int, sys.stdin.readline().split())

A=[]
for p in P:
    A.append(float(1+p)*p/2/p)

RUISEKI_A=[0]
for a in A:
    RUISEKI_A.append(RUISEKI_A[-1]+a)

ans=float("-inf")
for i in range(N-K+1):
    ans=max(ans,RUISEKI_A[i+K]-RUISEKI_A[i])

print ans


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

using namespace std;
using ll = long long;

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  vector<ll> P;
  P.push_back(0);
  for(int i = 0; i < N; i++) {
    ll p;
    cin >> p;
    P.push_back(p);
  }
  P.push_back(N + 1);
  N = P.size();
  vector<ll> dp(N, 1LL << 62);
  dp[0] = 0;
  for(int i = 0; i < N; i++) {
    ll acc = 0;
    for(int j = i - 1; j >= 0; j--) {
      if (P[j] < P[i]) {
        dp[i] = min(dp[i], dp[j] + acc);
        acc += B;
      } else {
        acc += A;
      }
    }
  }
  cout << dp.back() << endl;
  return 0;
}


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

int main() {
	int n, k; cin >> n >> k;
	vector<int>a(n, 0);

	for (int i = 0; i < n; i++) {
		int tmp; cin >> tmp;
		a[tmp-1]++;
	}
	int cnt = 0;
	for (auto&& x : a) {
		if (x)cnt++;
	}

	if (cnt <= k)cout << 0 << endl;
	else {
		int ans = 0;
		sort(a.begin(), a.end());
		for (auto&& x : a) {
			if (x) {
				ans += x;
				cnt--;
			}
			if (cnt == k) {
				cout << ans << endl;
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 4036
#include <iostream>
#include <cmath>
#define ROPE 50.0
#define NEXTD -30

using namespace std;
double dist(int,int);
int inv_in(int,int);

int index_[1000],x[1000],y[1000];
double dst[1000][1000];
int next[1000][1000];

int main(){
  int b_num,root_num;
  int s_index[1000],g_index[1000];
  while(cin >> b_num && b_num!=0){
    for(int i=0;i<b_num;i++){  
      cin >> index_[i] >> x[i] >> y[i];
      for(int j=0;j<=i;j++){
	dst[i][j]= (dist(i,j) > ROPE) ? 10000000.0 : 100000+dist(i,j);
	//ÀÍÍKEEE
	dst[j][i]= dst[i][j];
	next[i][j] = (dist(i,j) > ROPE) ? NEXTD : j;
	next[j][i] = (dist(i,j) > ROPE) ? NEXTD : i;
      }
    }
    
    for(int k=0; k<b_num;k++){
      for(int i =0; i<b_num; i++){
	for(int j =0; j<b_num; j++){
	  if(dst[i][j] > dst[i][k] + dst[k][j]){
	    dst[i][j] = dst[i][k] + dst[k][j];
	    next[i][j] = next[i][k];
	  }
	}
      }
    }
    
    cin >> root_num;
    for(int i=0;i < root_num;i++){
      cin >> s_index[i] >> g_index[i];
      int S=inv_in(b_num,s_index[i]);
      int G=inv_in(b_num,g_index[i]);
      if(next[S][G]!=NEXTD){
	for(int j=S;j!=G;j=next[j][G]){
	  cout << index_[j] << ' ' ;
	}
	cout << index_[G] << endl;
      }
      else{
	cout << "NA" << endl;
      }    
    }
  }
}

double dist(int i,int j){
  double dis;
  dis = pow(pow(double(x[i]-x[j]),2.0)+pow(double(y[i]-y[j]),2.0),0.5);
  return dis;
}

int inv_in(int b_num,int b_ind){
  int inv;
  for(int j=0;j<b_num;j++){
    if(index_[j]==b_ind){
      inv = j;
      break;
    }
  }
  return inv;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int H, W;
  cin >> H >> W;
  if ( H == 1 || W == 1 ) {
  cout << 1 << endl;
  }
  else {cout << (H*W+1)/2 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <math.h>

using namespace std;
#define li long long int
#define FOR(i, a, b) for (int i = a ; i < b ; ++i)
#define REP(i, n) for (int i = 0 ; i < n ; ++i)

li gcd(li a,li b) {
    return a % b == 0 ? b : gcd(b, a % b);
}

int main(void) {
    li N;
    cin >> N;
    N++; // 初期位置も入れる
    li t[N], x[N], y[N];
    FOR(i, 0, N) {
        if (i == 0) {
            t[i] = 0, x[i] = 0, y[i] = 0;
            continue; // 初期値
        }
        cin >> t [i] >> x[i] >> y[i];
    }

    bool canGoal = true;

    FOR(i, 0, N - 1) {
        // diffを取る
        li diffX = x[i + 1] - x[i];
        li diffY = y[i + 1] - y[i];
        li diffT = t[i + 1] - t[i]; 
        
        li total = diffX + diffY;
        li step = diffT - total;
        if (step < 0) {
            // 時間が足りない
            canGoal = false;
            break;
        } else {
            if (step % 2 == 1) {
                // 奇数の場合はちょうど到達することができない
                canGoal = false;
                break;
            } else {
                // 偶数 or 0 の場合は到達できる
                continue;
            }
        }
    }

    cout << (canGoal ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

int main() {

    string N;
    cin >> N;

    int length = N.length();

    if (N[length - 1] == '2') {
        cout << "hon" << endl;
    }

    if (N[length - 1] == '4') {
        cout << "hon" << endl;
    }

    if (N[length - 1] == '5') {
        cout << "hon" << endl;
    }

    if (N[length - 1] == '7') {
        cout << "hon" << endl;
    }

    if (N[length - 1] == '9') {
        cout << "hon" << endl;
    }

    if (N[length - 1] == '0') {
        cout << "pon" << endl;
    }

    if (N[length - 1] == '1') {
        cout << "pon" << endl;
    }

    if (N[length - 1] == '6') {
        cout << "pon" << endl;
    }

    if (N[length - 1] == '8') {
        cout << "pon" << endl;
    }

    if (N[length - 1] == '3') {
        cout << "bon" << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main() 
{
    int n;
    string str,ans="No";
    cin >> n;
    cin >> str;

    if( !(n&1) && str.substr(0,n/2) == str.substr(n/2 , n/2))   ans = "Yes";
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    N, M = map(int, input().split())

    def make_divisors(n):
        divisors = []
        cnt = 0
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n // i)

        divisors.sort()
        return divisors

    divisor = make_divisors(M)
    cnt = len(divisor)
    for i in range(cnt):
        if M // divisor[cnt - i - 1] >= N:
            print(divisor[cnt - i - 1])
            return


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, ans;
    cin >> n >> m;
    for (int i = m / n; i > 0; --i)
    {
        if (m % i == 0)
        {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

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

a_new = []
for _a in a:
    a_new.append(-1 * _a)

a = sorted(a_new)
import heapq
heapq.heapify(a)

# print(a)

for i in range(k):
    tmp = heapq.heappop(a)
    # print(tmp)
    tmp = tmp / 2
    heapq.heappush(a, tmp)
    # print(a)

ans = 0
for i in range(n):
    ans += int(a[i] * -1)
print(ans)


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

int main(){
  int N,g1,g2;
  long long ans=0;
  cin>>N;
  for(int i=1;i<=N;i++){for(int j=1;j<=N;j++){
    g1=__gcd(i,j);
    for(int k=1;k<=N;k++){
      g2=__gcd(g1,k);
      ans+=g2;
    }
  }}
  
  cout<<ans;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int A, B, C; cin >> A >> B >> C;
  set<int> s = {A, B, C};
  auto ans = s.size();
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;

int main(){
    ll n;cin>>n;
    ll ans =INFL;
    rep(i,sqrt(n)+3){
        if(i==0)continue;
        if(n%i==0){
            ll a =i;
            ll b= n/i;
            if(b<a)continue;
            ans=min(ans,a+b-2);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,d,s=0;
    cin>>n;
    d=n;
    while(d>0)
    {
        s+=(d%10);
        d/=10;
    }
    if(n%s==0)
      Yes
    else
      No
}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];\
void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}\
void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 1234567
int n,X,Y,c[SZ],w[SZ]; pii ps[SZ];
vector<int> vs[SZ]; Edg
bool vis[SZ];
map<int,int> sz;
void dfs(int x)
{
	vis[x]=1; ++sz[c[x]];
	for esb(x,e,b) if(!vis[b]) dfs(b);
}
const int MOD=1e9+7;
ll fac[SZ],rfac[SZ];
ll qp(ll a,ll b)
{
	ll x=1; a%=MOD;
	while(b)
	{
		if(b&1) x=x*a%MOD;
		a=a*a%MOD; b>>=1;
	}
	return x;
}
ll C(int a,int b)
{
	return fac[a]*rfac[a-b]%MOD*rfac[b]%MOD;
}
int main()
{
	fac[0]=rfac[0]=1;
	for(int i=1;i<SZ;++i) fac[i]=fac[i-1]*i%MOD;
	rfac[SZ-1]=qp(fac[SZ-1],MOD-2);
	for(int i=SZ-1;i>=1;--i)
		rfac[i-1]=rfac[i]*i%MOD;
	memset(ps,120,sizeof ps);
	scanf("%d%d%d",&n,&X,&Y);
	for(int i=1;i<=n;++i)
	{
		scanf("%d%d",c+i,w+i); vs[c[i]].pb(i);
		ps[c[i]]=min(ps[c[i]],pii(w[i],i));
	}
	for(int i=1;i<=n;++i)
	{
		int x=ps[i].se,y=ps[i].fi;
		for(auto g:vs[i])
			if(y+w[g]<=X) adde(g,x);
	}
	sort(ps+1,ps+1+n);
	int a=ps[1].se,b=ps[2].se;
	for(int i=1;i<=n;++i)
	{
		if(1<=a&&a<=n)
		{
			if(c[i]!=c[a]&&w[i]+w[a]<=Y) adde(i,a);
		}
		if(1<=b&&b<=n)
		{
			if(c[i]!=c[b]&&w[i]+w[b]<=Y) adde(i,b);
		}
	}
	ll cp=1;
	for(int i=1;i<=n;++i) if(!vis[i])
	{
		sz.clear(); dfs(i);
		int s=0;
		for(auto g:sz)
		{
			int p=g.se;
			cp=cp*C(s+=p,p)%MOD;
		}
	}
	printf("%d\n",int(cp));
}


Measured memory_bytes: 86144
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5;

int main(){
	int N;
	cin>>N;
	lli a[3*MAX+1];
	rep1(i,3*N)cin>>a[i];
	
	lli c[MAX+1];
	c[0]=0;
	rep1(i,N)c[0]+=a[i];
	priority_queue<lli> pqx;
	rep1(i,N)pqx.push((-1)*a[i]);
	rep1(i,N){
		c[i]=c[i-1]+a[N+i];
		pqx.push((-1)*a[N+i]);
		lli mn=(-1)*pqx.top();
		pqx.pop();
		c[i]-=mn;
	}
	lli d[MAX+1];
	d[N]=0;
	rep1(i,N)d[N]+=a[2*N+i];
	priority_queue<lli> pqn;
	rep1(i,N)pqn.push(a[2*N+i]);
	for(int i=N-1;i>=0;i--){
		d[i]=d[i+1]+a[N+i+1];
		pqn.push(a[N+i+1]);
		lli mx=pqn.top();
		pqn.pop();
		d[i]-=mx;
	}
	lli ans=c[0]-d[0];
	rep1(i,N)ans=max(c[i]-d[i],ans);
	cout<<ans<<endl;
}

Measured memory_bytes: 6516
def slove():
    import sys
    input = sys.stdin.readline
    k, s = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    for i in range(k + 1):
        for j in range(k + 1):
            if i + j > s:
                break
            else:
                n = s - i - j
                if 0 <= n <= k:
                    cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 40540
package main

import (
	"fmt"
	//"math"
	//"strings"
)

func main() {
	var d int
	fmt.Scan(&d)
	var str string
	switch d{
	case 22: str = "Christmas Eve Eve Eve"
	case 23: str = "Christmas Eve Eve"
	case 24: str = "Christmas Eve"
	case 25: str = "Christmas"
	}
	fmt.Println(str)
}


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

// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

#define St first
#define Nd second
#define Pb push_back
#define Mp make_pair
#define print_pair(p) cout<<p.St<<" "<<p.Nd
#define endl "\n"

#define REP(i,a,b) for(int i = a; i <= b; i++)
#define REV(i,a,b) for(int i = a; i >= b; i--)

#define AritSum(a,d,n) ((n)*(2*(a)+((n)-1)*(d)))/2
#define Log(base, num) log2(num)/log2(base)


// ************* MAIN *******************

double R;
const double PI = 3.141592653589793;
void solve() {
    cin>>R;
    cout << setprecision(18) << fixed << 2*PI*R << endl;
}
/*
g++ -std=c++14 -Wall -Wextra -O2 Test.cpp -o Test
*/
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T=1;
    // cin>>T;
    for (int t = 1; t <= T; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


ll dp[444][444];
ll a[444];
ll cum[444];
int flg[444][444];

ll memo(int l, int r){
    if(r - l == 1) return 0;
    if(flg[l][r]) return dp[l][r];
    flg[l][r] = 1;
    ll ans = LINF;
    for(int k=l+1;k<r;k++){
        ll tmp = memo(l,k) + memo(k,r) + cum[r] - cum[l];
        ans = min(ans, tmp);
    }
    return dp[l][r] = ans;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    REP(i,N) cin >> a[i];
    REP(i,N) cum[i+1] = cum[i] + a[i];
    ll ans = memo(0,N);
    cout << ans << endl;
}


Measured memory_bytes: 2432
N=int(input())
FizzBuzz=0
for i in range(1,N+1):
    if i%3==0 and i%5==0:
        #print("FizzBuzz")
        FizzBuzz=FizzBuzz+0
    elif i%3==0:
        #print("Fizz")
        FizzBuzz=FizzBuzz+0
    elif i%5==0:
        #print("Buzz")
        FizzBuzz=FizzBuzz+0
    else:
        #print(i)
        FizzBuzz=FizzBuzz+i
print(FizzBuzz)

Measured memory_bytes: 9188
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
plus=0
for i in range(N):
  if A[i]>=B[i]+plus:
    ans+=B[i]+plus
    plus=0
  else:
    ans+=A[i]
    if A[i]>=plus:
      plus=B[i]+plus-A[i]
    else:
      plus=B[i]
if A[N]>=plus:
  ans+=plus
else:
  ans+=A[N]
print(ans)

Measured memory_bytes: 18476
#include <bits/stdc++.h>
#include <unordered_map> 
using namespace std; 
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI1 3.14159265358979311599796346854418516159057617187500

typedef long long int ll;  
ll MOD = 1e9 + 7;

ll power(ll a , ll n)
{
    unsigned long long int result=1,x=a;
    while(n>0)
    {
        if(n % 2 ==1)
            result = (result * x)%MOD;
        x = (x * x)%MOD;
        n=n/2;
    }
    return result;
}

ll GCD(ll a , ll b)
{
    if(b==0)
        return a;
    else
        return GCD(b,a%b);
}


int main() 
{ 
    FIO
    int t;
    t=1;
    while(t--)
    {   
        int n;
        cin >> n;
        
        int a[n];
        map<int,int> mp;
        for(int i=0;i<n;i++)
        {
            cin >> a[i];
            mp[a[i]]++;
        }
            
        sort(a,a+n);
        int cnt = 0;
        for(int i=0;i<n;i++)
        {
            if(mp[a[i]]==1)
                cnt++;
            for(int j=2*a[i];j<=a[n-1];j+=a[i])
                mp[j]++;
        }
        
        cout << cnt << endl;

    }
    return 0; 
}


Measured memory_bytes: 51136
l = dict()
t, f = 0, 0
n, m = map(int, input().split(" "))
for _ in range(m):
  p, s = input().split(" ")
  if not p in l:
    l[p] = [None, 0]
  if s == "WA":
    if l[p][0] != True:
      l[p][1] += 1
  elif s == "AC":
    if l[p][0] != True:
      l[p][0] = True
      t += 1

for _, v in l.items():
  if v[0]:
    f += v[1]
print(t, f)

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

int main() {
  int N;
  cin >> N;
  if(N == 1){
    int A;
    cin >> A;
    cout << 1 << endl;
    return 0;
  }
  if(N == 2){
    int A,B;
    cin >> A >> B;
    if(abs(A-B) < 2){
      cout << 2 << endl;
      return 0;
    }
    cout << 1 << endl;
    return 0;
  }
  vector<int>vec(N,0);
  for(int i=0; i<N; i++){
    int M;
    cin >> M;
    if(M-1 >= 0 && M-1 <= N){
      vec[M-1]++;
    }
    vec[M]++;
    if(M+1 <= N){
      vec[M+1]++;
    }
  }
  sort(vec.begin(),vec.end());
  cout << vec[N-1] << endl;
}


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

int func(int x, int y, int z) {
  return x*x + y*y + z*z + x*y + y*z + z*x;
}

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

  for(int i = 1; i < n+1; i++) {
    int sum = 0;
    for(int x = 1; func(x, 1, 1) <= i; x ++) {
      for(int y = 1; func(x, y, 1) <= i; y ++) {
        for(int z = 1; func(x, y, z) <= i; z ++) {
          if (func(x, y, z) == i) sum++;
        }
      }
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 3588
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	@SuppressWarnings("unchecked")
	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			n = scanner.nextInt();
			if (n == 0)
				break;
			lists = new ArrayList[n];
			for (int i = 0; i < n; i++)
				lists[i] = new ArrayList<Edge>();
			for (int i = 0; i < n - 1; i++) {
				int from = scanner.nextInt() - 1;
				int to = scanner.nextInt() - 1;
				int cost = scanner.nextInt();
				lists[from].add(new Edge(to, cost));
				lists[to].add(new Edge(from, cost));
			}
			for (int i = 0; i < n; i++) {
				if (lists[i].size() == 1 && i != 0) {
					lists[i].get(0).cost = INF;
				}
			}
			int sum = 0;
			for (int i = 0; i < n; i++) {
				if (lists[i].size() == 1 && i != 0)
					continue;
				for (Edge edge : lists[i]) {
					if (lists[edge.to].get(0).cost == INF)
						continue;
					sum += edge.cost;
				}
			}
			PriorityQueue<Edge> pq = new PriorityQueue<Edge>();
			pq.offer(new Edge(0, 0));
			int[] costs = new int[n];
			Arrays.fill(costs, 1 << 24);
			costs[0] = 0;
			while (!pq.isEmpty()) {
				Edge edge = pq.poll();
				for (Edge e : lists[edge.to]) {
					if(lists[e.to].get(0).cost==INF)
						continue;
					if (costs[e.to] > e.cost + edge.cost) {
						costs[e.to] = e.cost + edge.cost;
						pq.offer(new Edge(e.to, costs[e.to]));
					}
				}
			}
			int max = 0;
			for (int ans : costs) {
				if (ans == INF)
					continue;
				max = Math.max(max, ans);
			}
			System.out.println(sum - max);
		}
	}

	int n;
	List<Edge>[] lists;
	int INF = 1 << 24;

	class Edge implements Comparable<Edge> {
		int to, cost;

		Edge() {
		}

		public Edge(int to, int cost) {
			super();
			this.to = to;
			this.cost = cost;
		}

		@Override
		public String toString() {
			return "Edge [to=" + to + ", cost=" + cost + "]";
		}

		@Override
		public int compareTo(Edge o) {
			return this.cost - o.cost;
		}

	}
}

Measured memory_bytes: 23492
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int k; cin >> k;
	--k;
	vector<int>vec = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	cout << vec[k] << "\n";

	return 0;
}

Measured memory_bytes: 256