akhauriyash/Code-Regression huggingface dataset:
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) int __VA_ARGS__; in(__VA_ARGS__)
//オーバーフロー対策
#define INL(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

ll a[200000];
ll s[200020];

void solve()
{
    IN(n);
    rep (i, n)
    {
        cin >> a[i];
    }
    s[0] = a[0];
    reps(i, 1, n)
    {
        s[i] = s[i-1] + a[i];
    }
    ll m = 1LL<<60;
    rep(i, n-1)
    {
        chmin(m, abs(s[i]-(s[n-1]-s[i])));
    }
    cout << m << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int main() {
	int q;
	cin >> q;
	set<int>se;
	int a, b;
	for (int i = 0; i < q; i++) {
		cin >> a >> b;
		if (a == 0) {
			se.insert(b);
			cout << se.size() << endl;
		}
		else if (a == 1) {
			cout << se.count(b) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 12388
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define Sort(a) sort((a).begin(),(a).end())
#define Reverse(a) reverse((a).begin(),(a).end())
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;
void Debug(auto a);

signed main(){
    int h,w;
    cin >> h >> w;
    Vec(a,h);
    vector<string> b;
    REP(i,h){
        cin >> a[i];
    }
    bool er=false;
    REP(i,h){
        er=false;
        REP(j,w){
            if(a[i][j]=='#'){
                er = true;
            }
        }
        if(er){
            b.push_back(a[i]);
        }
        
    }
    h = b.size();
    Vec(c,h);
    copy(b.begin(),b.end(),c.begin());
    int tmp=0;
    REP(i,w){
        er=true;
        REP(j,h){
            if(b[j][i] == '#'){
                er=false;
            }
        }
        if(er){
            REP(j,h){
                c[j].erase(c[j].begin()+i-tmp);
                
            }
          tmp++;
        }
    }
    for(auto d: c){
        cout << d << endl;
    }
    
    
    return 0;
}
void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define N_ 201000
#define SZ 262144
using namespace std;
long long IT[SZ + SZ];
int n, H[N_], A[N_];
void Put(int a, long long b) {
	a += SZ;
	while (a) {
		IT[a] = max(IT[a], b);
		a >>= 1;
	}
}
long long Max(int b, int e) {
	long long r = 0;
	b += SZ, e += SZ;
	while (b <= e) {
		r = max(r, max(IT[b], IT[e]));
		b = (b + 1) >> 1, e = (e - 1) >> 1;
	}
	return r;
}
int main() {
	int i, a, b;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &H[i]);
	}
	for (i = 1; i <= n; i++) {
		scanf("%d", &A[i]);
	}
	for (i = 1; i <= n; i++) {
		Put(H[i], Max(0, H[i]) + A[i]);
	}
	printf("%lld\n", Max(0, n));
}

Measured memory_bytes: 5248
#include <iostream>
#include <cmath>

using namespace std;

typedef pair<int, int> Pii;

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

  int x, y;
  cin >> x >> y;

  int opCount = 0;
  if (abs(x) == abs(y)) {
    if (x == y) opCount = 0;
    else opCount = 1;
  }
  else if (abs(x) < abs(y)) {
    if (x < 0) opCount += 1;
    opCount += abs(y) - abs(x);
    if (y < 0) opCount += 1;
  }
  else { // abs(x) > abs(y)
    if (x > 0) opCount += 1;
    opCount += abs(x) - abs(y);
    if (y > 0) opCount += 1;
  }
  cout << opCount << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

struct UnionFind{
    vector<int> d;
    UnionFind(int n=0):d(n,-1){}
    int root(int x){
        if(d[x]<0)return x;
        return d[x]=root(d[x]);
    }
    bool unite(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return false;
        if(d[x]>d[y])swap(x,y);
        d[x]+=d[y];
        d[y]=x;
        return true;
    }
    bool same(int x,int y){return root(x)==root(y);}
    int usize(int x){return -d[root(x)];}
};

int main(){
    int n,m,k;cin >>n>>m>>k;
    V cnt(n,0);
    UnionFind uni(n);
    for (int i = 0; i < m; ++i) {
        int a,b;cin >>a>>b;
        a--;b--;
        cnt[a]++;
        cnt[b]++;
        uni.unite(a,b);
    }
    for (int i = 0; i < k; ++i) {
        int c,d;cin >>c>>d;
        c--;d--;
        if(uni.same(c,d)){
            cnt[c]++;
            cnt[d]++;
        }
    }
    for (int i = 0; i < n; ++i) {
        cout <<uni.usize(i)-cnt[i]-1<<endl;
    }
}


Measured memory_bytes: 4032
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int num,n,digit1,rev=0;
    cin>>num;
    n=num;
    while(num!=0){
        digit1=num%10;
        rev=(rev*10)+digit1;
        num=num/10;
    }
    if(n==rev)             cout<<"Yes"<<endl;
    else                   cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++) cin >> a[i];

    map<ll,ll> mp;

    ll now = 0;
    ll ans = 0;

    mp[0]++;

    for(ll i = 0; i < n; i++){
        now += a[i];
        ans += mp[now];
        mp[now]++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 17184
#include <stdio.h>
#include <string>
#include <algorithm>
#include <map>
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	int ans = K;
	for (int i = 1; i < N; i++)ans *= K-1;
	cout << ans << endl;
}


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

int main() {
    string S,T;
    cin >> S >> T;
    
    int64_t s,t;
    s = S.size();
    t = T.size();
    
    S = S + S;
    
    vector<vector<int64_t>> a(2*s+10,vector<int64_t>(26,2*s));
    for ( int64_t i = 2*s-1; i >= 0; --i){
        for ( int64_t j = 0; j < 26; ++j){
            a[i][j] = a[i+1][j];
        }
        a[i][S[i]-'a'] = i+1;
    }
    
    int64_t cur = 0;
    bool flg = false;
    for ( auto b: T ){
        int64_t c = b - 'a';
        int64_t pos = cur % s;
        if ( a[pos][c] == 2 * s ){
            flg = true;
            break;
        }
        cur = cur + a[pos][c] - pos;
    }
    
    if ( flg ){
        cout << -1 << endl;
    } else {
        cout << cur << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 52084
data = [
    [[0 for r in range(10)] for f in range(3)] for b in range(4)
]

count =int(input())
for c in range(count):
    b, f, r, v = [int(i) for i in input().split()]
    data[b-1][f-1][r-1] += v

for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')

        print()
    if bi < 3:
        print('#' * 20)

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

int main()
{
  string str;
  cin>>str;
  int n=str.size();
  
  if(str.at(n-1)=='2'||str.at(n-1)=='4'||str.at(n-1)=='5'||str.at(n-1)=='7'||str.at(n-1)=='9')
    cout<<"hon"<<endl;
  else if(str.at(n-1)=='0'||str.at(n-1)=='1'||str.at(n-1)=='6'||str.at(n-1)=='8')
    cout<<"pon"<<endl;
  else
    cout<<"bon"<<endl;
}

Measured memory_bytes: 3640
def sol(inputS):
  ans = 0
  prv_sub = ''
  tmp_sub = ''
  for s in inputS:
    tmp_sub += s
    if tmp_sub != prv_sub:
      ans += 1
      prv_sub = tmp_sub
      tmp_sub = ''
  return ans

S = input()
print(max(sol(S), sol(S[::-1])))

Measured memory_bytes: 43228
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <tchar.h>
//#include <intrin.h>

#define F first
#define S second
#define LL long long
#define MOD 1000000007
#define INF 2000000000
#define LINF 1000000000000000000

using namespace std;

string ans;
int n;

const int N = 4e5 + 10;
int main()
{
	LL n;
	scanf("%lld", &n);

	cout << (1000 - (n % 1000)) % 1000 << endl;
	cin >> n;
}

Measured memory_bytes: 3232
n=int(input())
a = list(map(int, input().split()))
count =0
flag = "true"
while flag=="true":
  for k in range(n):
    if a[k]%2==0:
      a[k] //= 2
    else:
      flag = "false"
      break
  count += 1
print(count-1)

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

int main() {
    int N, flag;
    std::string S;
    cin >> N;
    flag = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> S;
        if (S == "Y"){
            cout << "Four" << endl;
            flag++;
            break;
        };
    };
    if (flag == 0){
        cout << "Three" << endl;
    }
    
}


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

int main(void)
{
  char S[5], X[3], Y[3];
  int XisMM, YisMM;
  XisMM = 0;
  YisMM = 0;
  scanf("%s", S);
  X[0]=S[0];
  X[1]=S[1];
  X[2]=0x00;
  Y[0]=S[2];
  Y[1]=S[3];
  Y[2]=0x00;
  
  if (atoi(X)>=1 && atoi(X)<=12) XisMM = 1;
  if (atoi(Y)>=1 && atoi(Y)<=12) YisMM = 1;
  
  if (XisMM && !YisMM) {
    printf("MMYY\n");
  } else if (!XisMM && YisMM) {
    printf("YYMM\n");
  } else if (XisMM && YisMM) {
    printf("AMBIGUOUS\n");
  } else {
    printf("NA\n");
  }
}

Measured memory_bytes: 128
while True:
    s = input()
    if s == ".": break

    st = []
    is_valid = True
    for c in s:
        if c == "(": st.append(c)
        if c == "[": st.append(c)
        if c == ")":
            if (not st) or st[-1] != "(":
                is_valid = False
                break
            else:
                st.pop()
        if c == "]":
            if (not st) or st[-1] != "[":
                is_valid = False
                break
            else:
                st.pop()
    if st:
        is_valid = False

    print( "yes" if is_valid else "no" )



Measured memory_bytes: 5584
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int X,Y;
  cin >> X >> Y;
  if(X%Y==0){
    cout << -1 << endl;
    return 0;
  }
  int ans=X;
  while(ans%Y==0){
    ans+=X;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz(x) ((int)x.size())
#define pb push_back
#define ii pair<int,int>
#define ppb pop_back
#define orta ((bas+son)>>1)
#define st first
#define nd second
#define ll long long
#define N 2005
#define inf 100000000000000ll
#define MOD 998244353
#define LOG 31
#define EPS 0.000000001
#define M 305
#define PI 3.14159265359
using namespace std;

int n;
ll dp[2][N];
ll ans;
ii a[N];

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i].st;
		a[i].nd = i + 1;
	}
	sort(a, a + n, greater<ii>());
	for(int i = 0; i < n; i++) {
		int cur = i & 1;
		int nxt = !cur;
		fill(dp[nxt], dp[nxt] + n + 1, 0);
		for(int s = 0; s <= i; s++) {
			if(s + 1 <= a[i].nd) 
				dp[nxt][s + 1] = max(dp[nxt][s + 1], dp[cur][s] + (ll) a[i].st * (a[i].nd - (s + 1)));
			if(a[i].nd <= n - (i - s))
				dp[nxt][s] = max(dp[nxt][s], dp[cur][s] + (ll) a[i].st * ((n - (i - s)) - a[i].nd));
		}
		ans = max(ans, *max_element(dp[nxt], dp[nxt] + n + 1));
	}
	cout << ans;

}

Measured memory_bytes: 3688
#include<iostream>
#include<vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main(){
	long long int n,k;
	cin>>n>>k;
	vector<int>a(n);
	rep(i,n)cin>>a[i];
	long long int left =0,right = 1000000000,mid;
	long long int sum;
	while(right-left>1){
		mid = (right+left)/2;
		sum=0;
		rep(i,n){
			sum+=(a[i]-1)/mid;
		}
		if(sum<=k){//mid is acceptable
			right = mid;
		}else{
			left = mid;
		}
	}
	cout<<right<<endl;


	return 0;
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

struct mint {
    const int mod = 998244353;
    long long x;
    
    mint (long long x = 0) : x((x % mod + mod) % mod) {
        
    }
    
    mint& operator=(const long long a) {
        x = a % mod;
        return *this;
    }
    
    mint& operator=(const mint a) {
        x = a.x % mod;
        return *this;
    }
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    
    mint& operator-=(const mint a) {
        if ((x += (mod - a.x)) >= mod) x -= mod;
        return *this;
    }
    
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    
    mint inv() const {
        return pow(mod - 2);
    }
    
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, s;
    cin >> n >> s;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<mint> dp(s + 1, 0);
    mint ans = 0;
    rep(i, n) {
        dp[0] += 1;
        rreps(j, a[i], s + 1) {
            if (j == s) ans += dp[j - a[i]] * (n - 1 - i);
            dp[j] += dp[j - a[i]];
        }
    }
    ans += dp[s];
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<fstream>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<sstream>

using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n); i++)
#define forsn(i,s,n) for(int i=(s);i<(int)(n); i++)
#define esta(x,v) (find((v).begin(),(v).end(),(x)) !=  (v).end())
#define index(x,v) (find((v).begin(),(v).end(),(x)) - (v).begin())
#define debug(x) cout << #x << " = "  << x << endl
#define pb push_back
#define mp make_pair

typedef long long tint;
typedef unsigned long long utint;
typedef long double ldouble;

typedef vector<int> vint;

int toNumber (string s)
{
	int Number;
	if ( ! (istringstream(s) >> Number) ) Number = 0; // el string vacio lo manda al cero
	return Number;
}

string toString (int number)
{
    ostringstream ostr;
    ostr << number;
    return  ostr.str();
}

int main (){
	tint n;
	cin>>n;
	vector<tint> v;
	map<tint, tint> m;
	forn(i, n){
		tint a; cin>>a;
		m[a]=i;
		v.pb(a);
	}
	sort(v.begin(), v.end());
	tint res=0;
	forn(i, n){
		//cout<<i<<"  "<<v[i]<<"  "<<m[v[i]]<<endl;
		res+=(abs(m[v[i]]-i)%2);
	}
	cout<<res/2<<endl;
}


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

struct query {
	int t,s;
}e[N];
int n,m,sgn=-1,k=1;
int T[N];
ll mx,mn,h,X;

void cal(ll &k) {
	if (k>X) k=X;
	if (k<0) k=0;
}

int main()
{
	scanf("%lld%d",&X,&n);
	for (int i=1;i<=n;i++) scanf("%d",&T[i]);
	scanf("%d",&m);
	for (int i=1;i<=m;i++) scanf("%d%d",&e[i].t,&e[i].s);
	
	mn=0; mx=X;
	for (int i=1;i<=m;i++)
	{
		while (k<=n && T[k]<=e[i].t)
		{
			ll v=(T[k]-T[k-1])*sgn;
			mx+=v; mn+=v; h+=v;
			cal(mx); cal(mn);
			sgn*=-1; k++;
		}
		ll now=e[i].s+h,nowh=(e[i].t-T[k-1])*sgn;
		if (now>mx) now=mx;
		if (now<mn) now=mn;
		now+=nowh;
		cal(now);
		printf("%lld\n",now);
	}
	return 0;
}

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

const long long inf = 1e18;
ll dp[101][100001];
ll wt[101];
ll val[101];


int main()
{
	ll n,W;
	cin>>n>>W;
	
	for(int i=0;i<n;i++){
		cin>>wt[i]>>val[i];
	}
	
	for(int i=0;i<101;i++){
		for(int j=0;j<100001;j++){
			dp[i][j] = inf;
		}
	}
	
	dp[0][0] = 0;
	dp[0][val[0]] = wt[0];
	
	for(int i=1;i<n;i++){
		dp[i][0] = 0;
		for(int j=1;j<100001;j++){
			if(val[i]<=j){
				dp[i][j] = min(dp[i-1][j],wt[i]+ dp[i-1][j-val[i]]);
			}
			else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	
	ll ans = 0;
	for(int val=100000;val>=0;val--){
		if(dp[n-1][val]<=W){
			ans = val;
			break;
		}
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 82380
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <iomanip>
#include <math.h>
using namespace std;
typedef long long ll;
 
int main() {
    ll n, m, v, p;
    cin >> n >> m >> v >> p;

    vector<ll> a(n), s(n + 1);
    for (int i = 0; i < n; i++) {
        int ai;
        cin >> ai;
        a[i] = ai;
    }
    sort(a.begin(), a.end());
    s[0] = 0;
    for (int i = 0; i < n; i++) {
        s[i + 1] = s[i] + a[i];
    }

    ll ans = p, b = a[n - p];
    for (ll i = n - p - 1; i >= 0; i--) {
        ll alr = (i + p) * m;
        //cout << alr << endl;
        if (a[i] + m >= b && m * v - alr <= 0) {
            ans++;
            continue;
        }
        else if (m * v - alr <= 0) break;
        else if (a[i] + m < b) break;

        ll rem = m * v - alr - ((a[i] + m) * (n - p - i) - (s[n - p + 1] - s[i + 1]));
        //cout << rem << " " << m * v - alr << " " << s[n - p + 1] - s[i + 1] << endl;
        if (rem > 0) break;
        else ans++;       

    }

    cout << ans << endl;

    

}

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

using namespace std;

typedef long long ll;

vector<ll> div(ll x) {
  vector<ll> res;
  res.push_back(x);
  for (ll i = 2; i * i <= x; i++)
    if (x % i == 0) {
      res.push_back(i);
      if (i * i != x)
        res.push_back(x / i);
    }
  return res; 
}

int main() {
  ll n; 
  cin >> n;
  if (n == 2) {
    cout << 1 << '\n';
    return 0;
  }
  ll ans = div(n - 1).size();
  vector<ll> a = div(n);
  for (int i = 0; i < a.size(); i++) {
    ll t = n; 
    while (t % a[i] == 0)
      t /= a[i];
    if (t % a[i] == 1)
      ans++;
  }
  cout << ans << '\n';
  return 0;
}


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

using namespace std;

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

    string word,command,x;
    int n,a,z;
    cin>>word>>n;

    for(int i=0; i<n; i++)
    {
        cin>>command;

        if(command =="replace")
        {
            cin>>a>>z>>x;
            for(int i=a;i<z+1;i++)
            {
                word[i]=x[i-a];
            }
            continue;
        }
        if(command == "reverse")
        {
            cin>>a>>z;
            for(int i=a,j=0;j<(z-a+1)/2;j++)
            {
                int temp = word[i+j];
                word[i+j]=word[z-j];
                word[z-j]=temp;
            }
            continue;
        }
        if(command == "print")
        {
            cin>>a>>z;
            for(int i=a;i<z+1;i++)
            {
               cout<<word[i];
            }
            cout<<'\n';
            continue;
        }
    }

    return 0;
}



Measured memory_bytes: 3268
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digitsum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
int getdigit(ll a) {
	return to_string(a).size();
}
int countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

int main() {
	IOS;
	int n, m;
	cin >> n >> m;
	vector<vector<bool>> v(n, vector<bool>(2,false));
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		if (a == 1)v[b][0] = true;
		if (b == n)v[a][1] = true;
	}
	bool ans = false;
	FOR(i, 1, n) {
		if (v[i][0] && v[i][1])ans = true;
	}
	cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}



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

pub fn read<T: FromStr>() -> T {
    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 is_prime(a: i64) -> bool {
    if a == 1 {
        return false;
    }
    for i in 2..a {
        if a % i == 0 {
            return false;
        }
    }
    return true;
}

const MOD: i64 = 1_000_000_007;

fn main() {
    let n: i64 = read();
    let mut prime: Vec<i64> = vec![];
    for i in 1..n + 1 {
        if is_prime(i) {
            prime.push(i);
        }
    }
    // println!("{:?}", prime);
    let mut a: Vec<i64> = vec![0; prime.len()];
    for i in 0..prime.len() {
        let pi = prime[i];
        let mut current = pi;
        while current <= n {
            a[i] += n / current;
            current *= pi;
        }
    }
    let mut sum = 1;
    for i in a {
        sum *= i + 1;
        sum %= MOD;
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
N = int(input())
S = input()

l_cnt = 0
for s in S[::-1]:
    if s == ')':
        l_cnt += 1
    elif s == '(':
        if l_cnt != 0:
            l_cnt -= 1

r_cnt = 0
for s in S:
    if s == '(':
        r_cnt += 1
    elif s == ')':
        if r_cnt != 0:
            r_cnt -= 1
            
print('(' * l_cnt + S + ')' * r_cnt)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

struct SP
{
  int number;
  std::string name;
  int point;
};

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

  std::vector<SP> sps(n);
  int number = 1;
  for (auto& sp : sps) {
    sp.number = number;
    ++number;
    std::cin >> sp.name >> sp.point;
  }

  std::sort(sps.begin(), sps.end(), [](const SP& lhs, const SP& rhs) {
    if (lhs.name == rhs.name) {
      return lhs.point > rhs.point;
    }
    return lhs.name < rhs.name;
  });

  for (const auto& sp : sps) {
    std::cout << sp.number << std::endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

const int INF = 1 << 25;

template <typename T, typename U>
T ipow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b;
    return n % 2 == 0 ? ipow(b * b, n / 2) : ipow(b, n - 1) * b;
}

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

    int A[3];
    for (int k = 0; k < 3; ++k) cin >> A[k];

    int L[N];
    for (int i = 0; i < N; ++i) cin >> L[i];

    int ans = INF;
    for (int t = 0; t < ipow(4, N); ++t) {
        int l[3] = {0, 0, 0};
        int cnt = 0, used = 0;

        for (int i = 0; i < N; ++i) {
            int k = t / ipow(4, i) % 4;
            if (k == 3) continue;

            ++used;
            if (l[k] == 0) ++cnt;
            l[k] += L[i];
        }

        if (cnt < 3) continue;

        int cost = 0;
        for (int k = 0; k < 3; ++k) {
            cost += abs(A[k] - l[k]);
        }
        ans = min(ans, cost + (used - 3) * 10);
    }

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


Measured memory_bytes: 256
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

A,B,C,D = list(map(int,input().split()))

#AまででCでもDでも割り切れない数の個数
A_C = A // C
A_D = A // D
A_CD = A //(C*D // gcd(C,D))
countA = A - A_C - A_D + A_CD
#print(countA,A_C,A_D,A_CD)

#BまででCでもDでも割り切れない数の個数
B_C = B // C
B_D = B // D
B_CD = B //(C*D // gcd(C,D))
countB = B - B_C - B_D + B_CD
#print(countB,B_C,B_D,B_CD)

if A % C != 0 and A % D != 0 and A % C != 0 and A % D != 0:
    print(countB - countA + 1)
else:
    print(countB - countA)

Measured memory_bytes: 3064
N = int(input())
CSF = [list(map(int,input().split())) for i in range(N-1)]


#かかる時間　＝　駅で待つ時間　＋　次の駅に向かうまでの時間
for i in range(N): #各駅について
    t = 0
    for j in range(i, N-1):
        if t < CSF[j][1]: #tがまだ最初の運行時刻でない場合
            t = CSF[j][1] #t = Si (始発を待たないといけないので)
        elif t % CSF[j][2] == 0:
            pass
        else:
            t += CSF[j][2] - t % CSF[j][2] 
        t += CSF[j][0] 
    print(t)     

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define pb                push_back
#define int               long long
#define M                 1000000007
#define MM                998244353
#define fr                first
#define sc                second
#define vc                vector
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define piii              pair<int,pii>

	signed main() {
	
		   int t=1;
		  //cin>>t;
		   while(t--)
		   {
		   		
		   	int n,k,w,mx=0,sum=0,xx=0;
		             string s;

		        cin>>s;
	int a[n],ii[n],b[n],c[n],p[n],q[n];
    for(int i=0;i<3;i++)
    	if(s[i]=='7'){cout<<"Yes"<<endl;return 0;}
    cout<<"No"<<endl;
}
 
	} 

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define fast ios::base_sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define M 1000000007
#define pie 3.141592653589793238
using namespace std;
 
bool Prime(int n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 

signed main(){
    int x;cin>>x;
    for(int i=x;;i++){
        bool y = Prime(i);
        if(y == true){
            cout<<i;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n; cin>>n;
  int i = 1;
  while(i <= n)
  {
    int x = i;
    if(x%3==0)
    {
      cout << " " << x;
    }
    else
    {
      int k = x;
      while(x>0)
      {
        if (x % 10 == 3)
        {
          cout << " " << k;
          break;
        }
        x/=10;
      }
    }
    i++;
  }
  cout << "\n";
}


Measured memory_bytes: 3092
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string.h>
#include<algorithm>
//#include<iostream>
//using namespace std;

int main() {
	
	char c[20],d[20];

	scanf("%s %s", c, d);

	for (int i = 0; i < 3; i++) {
		if (c[i] == d[2 - i]) {
		}
		else {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return(0);
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if((x+r)<=W&&(x-r)>=0&&(y+r)<=H&&(y-r)>=0)
{
printf("Yes\n");
}
else
{
printf("No\n");
}
return 0;
}


Measured memory_bytes: 2100
def main(): 

    n = int(input())
    p = list(map(int, input().split()))

    count = 0
    for i in range(1, n-1):
        if p[i-1] < p[i] < p[i+1]:
            count += 1
        elif p[i+1] < p[i] < p[i-1]:
            count += 1

    print(count)

if __name__ == "__main__":
    main() 

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> siz;
    UnionFind(int N) : par(N),siz(N,1) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        if(siz[rx] < siz[ry])swap(rx,ry);
        siz[rx] += siz[ry];
        par[ry] = rx; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

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

// TODO: write
int main() {   
  int n,m;cin>>n>>m;
  vector<int> p(n);rep(i,n)cin>>p[i];
  
  auto tree = UnionFind(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    tree.unite(a,b);
  }
  int ans = 0;
  rep(i,n){
    if(tree.same(i,p[i]-1))ans++;
  }
  print(ans);
  return 0;
}



Measured memory_bytes: 1408
import math
N,M=map(int,input().split())

if N<2:
  n=0
else:
  n=math.factorial(N)/(math.factorial(2)*math.factorial(N-2))
if M<2:
  m=0
else:
  m=math.factorial(M)/(math.factorial(2)*math.factorial(M-2))
  
print(int(n+m))

Measured memory_bytes: 3060
n = int(input())
l = sorted([int(x) for x in input().split()])
mid = int(len(l) / 2)
med = int((l[mid-1] + l[mid]) / 2)
if l[mid] != l[mid-1]:
    print(l[mid] - l[mid-1])
else:
    print(0)

Measured memory_bytes: 52780
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
#define MOD 1000000007
#define FormulaToConvertMicrosecondsToSeconds(duration) duration / 1e+6
#define _CRT_SECURE_NO_DEPRECATE
#define ll                    long long
#define nl                    '\n'                             // NL - sign of new line

#define upperString(str)      transform(str.begin(), str.end(), str.begin(), ::toupper); // make entire string uppercase
#define lowerString(str)      transform(str.begin(), str.end(), str.begin(), ::tolower); // make entire string lowercase

#define ps(x,y)               fixed << setprecision(y) << x     // usage: t=1.1234; cout << ps(t,4); // it means it will print 4 decimal places.

#define eb                    emplace_back
#define sortv(v)              sort(v.begin(), v.end());
#define rsortv(v)             sort(v.rbegin(), v.rend());
#define rev(v)		          reverse(v.begin(), v.end())       // reverse the vector

#define si                    set<int>

#define mii			          std::map <int,int>
#define multimii		      std::multimap <int,int>
#define mss			          map <string, string>
#define w(t)                  unsigned t; cin >> t; while(t--)
mt19937                       rng(chrono::steady_clock::now().time_since_epoch().count());

void solve();
//==================================

bool isPrime(int num) {
	if (num == 1) return false;
	for (int i = 2; i <= sqrt(num); i++) {
		if (num % i == 0) return false;
	}
	return true;
}

ll binarySearch(int a[], int l, int r, int x)
{
	while (l <= r)
	{
		int mid_index = l + (r - l) / 2;

		if (a[mid_index] == x)
			return mid_index;
		else if ( x > a[mid_index])
		{
			l = mid_index + 1;
		}
		else if ( x < a[mid_index])
		{
			r = mid_index - 1;
		}
	}
	return -1;
}

ll fast_power(ll base, ll power) {
	ll result = 1;
	while (power > 0) {

		// if( power % 2 == 1)
		if (power & 1) { // Can also use (power & 1) to make code even faster
			result = (result * base) % MOD;
		}
		base = (base * base) % MOD;

		// power /= 2
		power >>= 1; // Can also use power >>= 1; to make code even faster
	}
	return result;
}

//==================================
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//--------------------------------
	auto t1 = std::chrono::high_resolution_clock::now();

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

	solve();
	//}



	auto t2 = std::chrono::high_resolution_clock::now();
	auto duration = std::chrono::duration_cast<std::chrono::microseconds>( t2 - t1 ).count();

	cerr << "\n\nTime taken : " << FormulaToConvertMicrosecondsToSeconds(duration) << " secs" << nl;
	return 0;
}

void solve() //Task A. Double Cola!!! Two teams composing !
{

	int ac, wa, tle, re;
	ac = wa = tle = re = 0;

	w(t)
	{
		string s; cin >> s;
		if (s == "AC")
			++ac;
		else if ( s == "WA")
			++wa;
		else if ( s == "TLE")
			++tle;
		else if ( s ==  "RE")
			++re;
	}

	cout << "AC x " << ac << nl;
	cout << "WA x " << wa << nl;
	cout << "TLE x " << tle << nl;
	cout << "RE x " << re;

} // !solve


/* TESTS:


*/

Measured memory_bytes: 3800
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n;
		Converter c;
		String str;

		while(true){
			n = sc.nextInt();
			if(n == 0){
				break;
			}

			c = new Converter();
			for(int i=0;i<n;i++){
				c.setData(sc.next(),sc.next());
			}

			n = sc.nextInt();
			for(int i=0;i<n;i++){
				str = sc.next();
				System.out.print(c.convert(str));
			}
			System.out.println();
		}
	}
}

class Converter{
	int[] data;

	Converter(){
		data = new int[123];
	}

	public void setData(String before,String after){
		data[(int)before.charAt(0)] = (int)after.charAt(0);
	}

	public String convert(String str){
		if(data[(int)str.charAt(0)] != 0){
			return (char)data[(int)str.charAt(0)]+"";
		}else{
			return str;
		}
	}
}

Measured memory_bytes: 70284
#include<bits/stdc++.h>
using namespace std;
template <class T> inline bool chMax(T& a,T b){if(a<b){a=b;return true;}else{return false;}};
 
int main(){
    int N;
  	cin >>N;
  	int h[N+1][3];
  for (int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      cin >>h[i][j];
    }
  }
  int mem[N+1][3];
 fill (mem[0],mem[N+1],0);


  for (int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(j!=k){
        chMax(mem[i+1][j],mem[i][k]+h[i][k]);
      }
    }
    }
  }
 
  cout << max({mem[N][0],mem[N][1],mem[N][2]})<<endl;
  
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
using namespace std;
int main(){
	int n,t;
	cin>>n>>t;
	vector<int> a;
	int cnt=1;
	int mi = inf;
	int maxdif = 0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.pb(x);
	}
	for(int i=0;i<n;i++){
		if(a[i]-mi>maxdif){
			maxdif = a[i]-mi;
			cnt = 1;
		}
		else if(a[i]-mi == maxdif){
			cnt++;
		}
		if(a[i]<mi)mi=a[i];
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,cnt=0,cntE=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        if(a%2==0)
        {
            cntE++;
            if(a%3==0 || a%5==0)
                cnt++;
        }
    }
    if(cnt==cntE)
        cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
}


Measured memory_bytes: 256
import std.datetime, std.string, std.conv, std.algorithm, std.stdio;

enum Week = [
    "Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
];
void main()
{
    foreach(line;stdin.byLine)
    {
        auto input = line.split.map!(to!int);
        if(input[0] == 0 && input[1] == 0) break;
        Week[Date(2004, input[0], input[1]).dayOfWeek].writeln;
    }
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
    int M1,D1,M2,D2 = 0;
    cin >> M1 >> D1;
    cin >> M2 >> D2;

    if (M2 - M1 == 1 && D2 == 1){
        cout << "1" << endl;
    }else{
        cout << "0" << endl;
    }
}


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

bool func(int a){
  bool y=true;
  for(int i=2;i<= sqrt(a);i++){
    if(a%i == 0){
      y = false;
      break;
    }
  }
  
  return y;
}
  
int main(){
  int x,ans;
  cin >> x;
  for(int i=x;i>0;i++){
    if(func(i)){
      ans = i;
      break;
    }
  }
  
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define INF (1ll<<60)
#define mod 1000000007
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll mypow(ll a,ll b){
    ll ret=1;
    while(b--){
        ret*=a;
    }
    return ret;
}

int main(){
    ll n;cin>>n;
    vector<ll> ans;

    if(n==0){
        cout<<0<<endl;
        return 0;
    }

    ll num=0;
    while(n){
        ans.push_back(abs(n%2));
        n-=abs(n%2)*mypow(-1,num);
        n/=2;
        num++;

        //cout<<n<<endl;
        //if(num==10) break;
    }
    
    reverse(ans.begin(),ans.end());
    rep(i,ans.size()) cout<<ans[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3576
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
type Queue struct {
	arr []int
}

func (q *Queue) push(v int) {
	q.arr = append(q.arr, v)
}

func (q *Queue) pop() int {
	res := q.arr[0]
	q.arr = q.arr[1:]
	return res
}

func (q *Queue) isEmpty() bool {
	return len(q.arr) == 0
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	G := make([][]int, N)
	for i := 0; i < N; i++ {
		u, k := sc.nextInt()-1, sc.nextInt()
		for j := 0; j < k; j++ {
			G[u] = append(G[u], sc.nextInt()-1)
		}
	}
	var q Queue
	seen := make([]int, N)
	for i := 0; i < N; i++ {
		seen[i] = -1
	}
	var search func(cur int)
	search = func(cur int) {
		for i := 0; i < len(G[cur]); i++ {
			next := G[cur][i]
			if seen[next] == -1 {
				q.push(next)
				seen[next] = seen[cur] + 1
			}
		}
	}
	q.push(0)
	seen[0] = 0
	for !q.isEmpty() {
		search(q.pop())
	}

	for i := 0; i < N; i++ {
		fmt.Fprintln(wtr, i+1, seen[i])
	}
	wtr.Flush()
}



Measured memory_bytes: 1116
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

const int MAX_N = 110;
const int SHICHIGO = 75;

map<int, int> prime_factor(int n){
  map<int, int> res;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}

int main(int argc, char const *argv[])
{
	int n;
	map<int, int> primes;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		map<int, int> mp = prime_factor(i);
		for(auto x : mp) {
		    int p = x.first, c = x.second;
		    primes[p]+=c;
		}
	}
	ll ans = 0;
	map<int, int> cnt;
	for (auto x : primes){
		if (x.first==1) continue;
		if (x.second>=2) cnt[2]++;
		if (x.second>=4) cnt[4]++;
		if (x.second>=14) cnt[14]++;
		if (x.second>=24) cnt[24]++;
		if (x.second>=74) cnt[74]++;
	}

	ans += cnt[74];
	ans += cnt[4]*(max(0,cnt[4]-1))*(max(0,(cnt[2]-2)))/2;
	ans += cnt[24]*(max(0, (cnt[2]-1)));
	ans += cnt[14]*(max(0, cnt[4]-1));

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

Measured memory_bytes: 256
n, y = map(int, input().split())


ans = [-1, -1, -1]

for i in range(n+1) :
    y2 = y - i*10000
    i2 = n - i
    no = y2 - i2*1000
    if no % 4000 == 0 and 0 <= no // 4000 <= i2 :
        ans = [i, no//4000, n-i-no//4000]

print("{} {} {}".format(ans[0],ans[1],ans[2]))


Measured memory_bytes: 3060