akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
          if(n/i==i)
            c++;
          else
            c+=2;
        }

    }

    
    return  c;
}
int func(int n)
{
    return (n*(n+1))/2;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   
    int n;
    cin>>n;
    set<char>s;
    while(n--)
    {   char c;
        cin>>c;
        s.insert(c);
    }
    if(s.size()==3)
        cout<<"Three";
    else
        cout<<"Four";


 return 0;
}








Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define frw(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpii vector<pii>
#define vpiii vector<piii>
#define vpll vector<pll>
#define vplll vector<plll>
#define mod 1000000007

int modInverse(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
    return x; 
} 
int n,m,k;
vector<ll>a[100005];
ll pr[100005];
ll s[100005];
ll vis[100005];

void dfs(int u,int p)
{
	pr[u]=p;
	s[p]++;
	vis[u]=1;
	for(int i=0;i<a[u].size();i++)
	{
		if(vis[a[u][i]]==0)
		{
			
			dfs(a[u][i],p);
		}
	}
}
int main()
{
	//int n,m,k;
	cin>>n>>m>>k;
	//ll a[n+1][n+1];
	ll b[n+1][n+1];
	ll de[n+1];
for(int i=0;i<=n;i++)
{
	s[i]=0;
	de[i]=0;
}
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		a[x].push_back(y);
		a[y].push_back(x);
		de[x]++;
		de[y]++;

	}
// for(int i=0;i<n;i++)
// cout<<de[i+1]<<" ";
// cout<<endl;
	
	for(int i=0;i<=n;i++)
		vis[i]=0;
	for(int i=0;i<n;i++)
	{
		if(vis[i+1]==0)
		dfs(i+1,i+1);	

	}
	for(int i=0;i<k;i++)
	{
		int x,y;
		cin>>x>>y;
		if(pr[x]==pr[y])
		{
			de[x]++;
			de[y]++;
		}

	}
	for(int i=0;i<n;i++)
	{
		int t=pr[i+1];
		cout<<s[t]-de[i+1]-1<<" ";
//	cout<<t<<" "<<s[t]<<" "<<de[i+1]<<endl;

	}
	
	
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

// mergeの応用
ll merge (int a[], int n, int left, int mid, int right) {
    int n1 = mid - left, n2 = right - mid;
    ll cnt = 0;
    int l[n1 + 1], r[n2 + 1];
    rep (i, 0, n1) l[i] = a[left + i];
    rep (i, 0, n2) r[i] = a[i + mid];
    l[n1] = inf, r[n2] = inf;
    int i = 0, j = 0;
    rep (k, left, right) {
        if (l[i] < r[j]) {
            a[k] = l[i++];
        } else {
            a[k] = r[j++];
            cnt += n1 - i;
        }
    }
    return cnt;
}

ll mergesort (int a[], int n, int left, int right) {
    if (right - left > 1) {
        int mid = (left + right) / 2;
        ll v1 = mergesort (a, n, left, mid);
        ll v2 = mergesort (a, n, mid, right);
        ll v3 = merge (a, n, left, mid, right);
        return v1 + v2 + v3;
    } else
        return 0;
}

int main() {
    int n;
    cin >> n;
    int a[n];
    rep (i, 0, n) cin >> a[i];
    cout << mergesort (a, n, 0, n) << "\n";
}


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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector<vector<int> > c(n);
  int d[200001] = {};

  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    c[a].pb(b);
    c[b].pb(a);
  }
  int ans = false;
  rep(i, 0, c[0].size()) {
    d[c[0][i]] = 1;
  }
  rep(i, 0, c[n - 1].size()) {
    if(d[c[n - 1][i]]) {
      ans = true;
      break;
    }
  }
  cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


Measured memory_bytes: 12784
N = int(input())
A = [0]*(N)

def solution(N,A):
    for i in range(1,N+1):
        A[i-1] = i
    
        if A[i-1]%3==0 or A[i-1]%5==0:
            A[i-1] =0
    print(sum(A))

solution(N,A)

Measured memory_bytes: 33696
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<int, int>;
LL INF = 1e18;
LL d[201][201];
LL N, M, R;
map<int, int>  used;
vector<LL> r;

LL dfs(int v){
    for(auto i : r){
        if(!used[i])    break;
        if(i == r[R-1])    return 0;
    }
    LL res = INF;
    for(auto i : r){
        if(!used[i]){
            used[i] = 1;
            res = min(res, dfs(i)+d[v][i]);
            used[i] = 0;
        }
    }
    return res;
}
int main(){
    cin >> N >> M >> R;
    for(int i = 0;i < R;i++){
        int ri;
        cin >> ri;
        r.emplace_back(ri);
        used.emplace(r[i], 0);
    }
    for(int i = 0;i < 201;i++)for(int j = 0;j < 201;j++)    d[i][j] = INF;
    for(int i = 0;i < 201;i++)  d[i][i] = 0;
    for(int i = 0;i < M;i++){
        LL ai, bi, ci;
        cin >> ai >> bi >> ci;
        d[ai][bi] = ci;
        d[bi][ai] = ci;
    }
    for(int k = 1;k <= N;k++){
        for(int i = 1;i <= N;i++){
            for(int j = 1;j <= N;j++){
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
    LL ans = INF;
    for(auto i : r){
        used[i] = 1;
        ans = min(ans, dfs(i));
        used[i] = 0;
    }
    cout << ans << endl;
}


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

typedef long long ll;
#define MOD = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) { s >> x; } return s;}
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
#define ANS(a) cout<<a<<endl
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin >>N;
    vector<int> a(N); cin >> a;

    int ans = -1;
    int on = 1;
    rep(i, N) {
        if ((on = a[on-1]) == 2) {
            ans = i + 1;
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define pb push_back
#define mp make_pair
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;



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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	char a, b;
	cin >> a >> b;
	string aa(b-'0', a);
	string bb(a-'0', b);
	
	if (aa < bb) {
		cout << aa << endl;
	}
	else {
		cout << bb << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define umap unordered_map
#define mp make_pair
#define pb push_back
#define ll long long
#define int long long
#define ld long double
#define f(i, x, n) for(int i = x; i < n; i++)
#define fd(i, n, x) for(int i = n; i >= x; i--)
#define mod 1000000007


int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int k;
    string s;
    cin >> k >> s;
    int l = s.size();
    if(l > k)
        s = s.substr(0, k) + "...";
    cout << s << '\n';
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
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;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
int main(){
    string s,t,ans;
    ans="";
    bool find=false;
    int st;
    cin >>s>>t;
    //int now;
    int at=s.size()-t.size();
    clog<<at<<endl;
    while(1){
        for(int now=0;now<t.size();now++){
            if(s[at+now]==t[now] or s[at+now]=='?'){
                if(now==t.size()-1){
                    st=at;
                    find = true;
                    break;
                }
            }else{
                at--;
                break;
            }
        }
        if(at<0 or find){
            break;
        }
    }
    clog<<at<<endl;
    if(at<0){
        cout << "UNRESTORABLE" << endl;
    }else{
        for(int i=0;i<s.size();i++){
            clog << i << " " << s[i] <<" --> ";
            if((i<st+t.size()) and (i >=st)){
                s[i]=t[i-st];
            }else{
                if(s[i]=='?'){
                    s[i]='a';
                }
            }
            clog<< s[i]<<endl;
            
        }
    cout<<s<<endl;
    }
    //
}
// bool result2 = std::equal(std::begin(v), std::end(v), std::begin(v2), std::end(v2),[](int x, int y) {
    

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;

void read(VI tree[], int &root) {
    REP (i, N) {
	int x;
	scanf("%d", &x);
	if (x == -1) {
	    root = i;
	} else {
	    x--;
	    tree[x].push_back(i);
	}
    }
}

VI G[100011];
int par[100011];
int R[100011];
void bfs(VI tree[], int root) {
    VI ord;
    ord.reserve(N);
    ord.push_back(root);
    par[root] = root;
    REP (i, N) {
	int v = ord[i];
	EACH (e, tree[v]) if (*e != par[v]) {
	    ord.push_back(*e);
	    par[*e] = v;
	}
    }

    REP (i_, N) {
	int v = ord[N-1-i_];
	if (tree[v].size() % 2 == 0) {
	    R[v] = v;
	} else {
	    R[v] = -1;
	}
	EACH (e, tree[v]) if (*e != par[v]) {
	    if (R[*e] != -1) {
		if (R[v] == -1) R[v] = R[*e];
		else {
		    G[R[v]].push_back(R[*e]);
		    G[R[*e]].push_back(R[v]);
		    R[v] = R[*e] = -1;
		}
	    }
	}
    }
}

int rootA, rootB;
VI treeA[100011];
VI treeB[100011];

int C[100011];
void paint() {

    REP (i, N) if (treeA[i].size() % 2 == 0) {
	C[i] = 1;
    }

    VI ord;
    memset(par, -1, sizeof par);

    REP (s, N) if (C[s] && par[s] == -1) {
	ord.clear();
	par[s] = s;
	ord.push_back(s);

	for (int i=0; i<(int)ord.size(); i++) {
	    int v = ord[i];
	    EACH (e, G[v]) if (par[*e] == -1) {
		C[*e] = -C[v];
		ord.push_back(*e);
		par[*e] = v;
	    }
	}
    }
}

void MAIN() {
    scanf("%d", &N);
    read(treeA, rootA);
    read(treeB, rootB);

    bool yes = true;
    REP (i, N) {
	if (treeA[i].size() % 2 != treeB[i].size() % 2) {
	    yes = false;
	    break;
	}
    }

    if (yes) {
	bfs(treeA, rootA);
	bfs(treeB, rootB);
	paint();
	puts("POSSIBLE");
	rprintf("%d", C, C+N);
	
    } else {
	puts("IMPOSSIBLE");
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

using namespace std;

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

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

#endif

void Main() {
    ll N;
    cin >> N;
    map<char, ll> cnt;
    rep(i, N) {
        string s;
        cin >> s;
        if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') {
            cnt[s[0]]++;
        }
    }
    ll ans = 0;
    vector<char> x = {'A', 'C', 'H', 'M', 'R'};
    set<string> used;
    do {
        string t = to_string(x[0]) + to_string(x[1]) + to_string(x[2]);
        sort(t.begin(), t.end());
        if (used.count(t) == 0) {
            ans += cnt[x[0]] * cnt[x[1]] * cnt[x[2]];
        }
        used.insert(t);
    } while (next_permutation(x.begin(), x.end()));
    cout << ans << '\n';
}

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


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

#define INF (2000000000000000000L)

using namespace std;

long mod(long n, long k) { return n % k >= 0 ? n % k : n % k + k; }

long pow(long x, long k, long num_mod) {
  long ret = 1, p = mod(x, num_mod);
  while (k > 0) {
    if (k % 2 == 1) {
      ret = mod(ret * p, num_mod);
    }
    p = mod(p * p, num_mod);
    k /= 2;
  }
  return ret;
}

long calc_e(long l, long r, long num_mod) {
  if (l == 0) {
    return 0;
  }
  if (l % 2 == 0) {
    const long l0 = l / 2, rpowl0 = pow(r, l0, num_mod),
               e0 = calc_e(l0, r, num_mod);
    return mod((rpowl0 + 1) * e0, num_mod);
  } else {
    const long l0 = l - 1, rpowl0 = pow(r, l0, num_mod),
               e0 = calc_e(l0, r, num_mod);
    return mod(e0 + rpowl0, num_mod);
  }
}

long calc_d(long l, long r, long num_mod) {
  if (l == 0) {
    return 0;
  }
  if (l % 2 == 0) {
    const long l0 = l / 2, rpowl0 = pow(r, l0, num_mod),
               d0 = calc_d(l0, r, num_mod), e0 = calc_e(l0, r, num_mod);
    const long t1 = mod((rpowl0 + 1) * d0, num_mod),
               t2 = mod(mod(l0, num_mod) * e0, num_mod);
    return mod(t1 + t2, num_mod);
  } else {
    const long l0 = l - 1, rpowl0 = pow(r, l0, num_mod),
               d0 = calc_d(l0, r, num_mod);
    const long t1 = mod(r * d0, num_mod), t2 = mod(l0, num_mod);
    return mod(t1 + t2, num_mod);
  }
}

int main(int argc, char *argv[]) {
  // read inputs
  long L, A, B, M;
  scanf("%ld %ld %ld %ld", &L, &A, &B, &M);

  // calculate vs[k]
  //     vs[k] : min(min_i {i | s_i >= 10^{k-1}}, L)
  vector<long> vs;
  vs.push_back(0);  // let vs[0] = 0
  for (long k = 1; k <= 19; k++) {
    const long ten_pow_km1 = pow(10, k - 1, INF);
    long le = -1, ri = L;
    while (ri - le > 1) {
      const long m = (le + ri) / 2;
      if (A + B * m >= ten_pow_km1) {
        ri = m;
      } else {
        le = m;
      }
    }
    vs.push_back(ri);
    // printf("k = %ld, vs[k] = %ld\n", k, vs[k]);
  }

  // solve
  long ans = 0;
  for (long k = 1; k < 19; k++) {
    // we need to be very careful taking the mod of l
    const long v_kp1 = vs[k + 1], v_k = vs[k], n_k = v_kp1 - v_k;
    const long l = n_k, r = pow(10, k, M), e0 = calc_e(l, r, M),
               d0 = calc_d(l, r, M), a = mod(A + B * v_k, M), b = mod(B, M);
    const long c_k = mod(mod(a * e0, M) + mod(b * d0, M), M);
    ans = mod(mod(pow(r, n_k, M) * ans, M) + c_k, M);
    // printf("k = %ld, sk0 = %ld, d0 = %ld, e0 = %ld, c_k = %ld\n", k, a, d0,
    //        e0, c_k);
  }
  printf("%ld\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
const int MOD = 1e9+7,mxN = 50,INF = 1e9;
int n,q;


void solve()
{
    ll a,b;
    cin >> a >> b;
    cout << (a*b)/__gcd(a,b);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    
}


Measured memory_bytes: 3656
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	int r, l;
	int count = 0;
	while (cin >> s){
		if (s.size() == 1){
			r = -1;
		}
		else if (s.size() % 2 == 0){
			r = s.size() / 2 - 1, l = s.size() / 2;
		}
		else{
			r = s.size() / 2 - 1, l = s.size() / 2 + 1;
		}
		bool flag = true;
		while (r != -1){
			if (s[r] == s[l]){
				r--;
				l++;
			}
			else{
				flag = false;
				break;
			}
		}
		if (flag){
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 1184
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
//Loopで使う文字列の長さは固定！
//intで大丈夫？オーバーフローしない？
//Loop回数は本当に10⁹以内になってる？Loopは回る？？
public class Main {
    public static void main(String[]$){
        Scanner sc = new Scanner(in);
        int N=0,W=0,E=0,S=0;
        String s=sc.next();
        int n=s.length();
        for (int i = 0; i < n; i++) {
            switch(s.charAt(i)){
                case 'N':
                    ++N;
                    break;
                case 'W':
                    ++W;
                    break;
                case 'S':
                    ++S;
                    break;
                case 'E':
                    ++E;
                    break;
                default:
                    break;
            }
        }
        String ans="Yes";
        if((N==0||S==0)&&(N+S>0))ans="No";
        else if((W==0||E==0)&&(W+E>0))ans="No";
        out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>
#include <cassert>

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

using namespace std;

template<class T, class U>
istream& operator>>(istream& is, pair<T, U>& pair)
{
    is >> pair.first >> pair.second;
    return is;
}

template<class T>
istream& operator>>(istream& is, T& collection)
{
    for(auto& item : collection) is >> item;
    return is;
}

// nC2 = n!/2!(n-2)! = n*(n-1)/2

int64_t nC2(int64_t n){
    return  n * (n-1) / 2;
}

void solution()
{
    int n;
    cin >> n;
    vector<int> as(n);
    cin >> as;
    unordered_map<int, int64_t> number_counts;
    rep(i,n){
        number_counts[as[i]] += 1;
    }
    int64_t no_ban_count = 0;
    for(const auto& p : number_counts){
        no_ban_count += nC2(p.second);
    }
    rep(i,n){
        int t = number_counts[as[i]];
        int u = number_counts[as[i]] - 1;
        cout << (no_ban_count - nC2(t) + nC2(u)) << '\n';
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solution();
    return 0;
}


Measured memory_bytes: 8392
import java.util.*

fun main(args : Array<String>) {
    println(inOutExec(null))
}

fun inOutExec(scanner: Scanner?): String {
    val (numOfPref, numOfCity) = readLine()!!.split(" ").map { it.toInt() }

    val citiesIn = mutableListOf<Pair<Int, Int>>()
    repeat(numOfCity) {
        val (pref, year) = readLine()!!.split(" ").map { it.toInt() }
        citiesIn.add(Pair(pref, year))
    }

    val cityCodeMap = citiesIn
            .asSequence()
            .groupByTo(mutableMapOf()) { it.first }
            .flatMap { entry -> entry.value
                        .asSequence()
                        .sortedBy { info -> info.second }
                        .mapIndexed { index, pair ->
                            pair to "%06d%06d".format(pair.first, index + 1) }
                    .toList()
            } // Pair<Pair<Int, Int>, String>
            .toMap()

    return citiesIn.joinToString(separator = "\n", postfix = "\n") { cityCodeMap[it]!! }
}


Measured memory_bytes: 145492
import collections
import math
from statistics import mode
N = int(input())
c = 0
ans = 0
def prime_factorize(n):
	a = []
	while n % 2 == 0:
		a.append(2)
		n //= 2
	f = 3
	while f * f <= n:
		if n % f == 0:
			a.append(f)
			n //= f
		else:
			f += 2
	if n != 1:
		a.append(n)
	return a
e = []
for i in set(prime_factorize(N)):
	e.append(prime_factorize(N).count(i))

for i in e:
	for j in range(math.ceil(math.sqrt(2*i))+1):
		if (j+1)*(j+2)//2 > i:
			break
		c += 1
	ans += c
	c = 0
print(ans)

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

string toUpper(string s){
    for ( int i = 0; i < s.size(); i++ ){
        s[i] = toupper(s[i]);
    }
    return s;
}

int main(){
    string word;
    string text;
    int count = 0;

    cin >> word;
    word = toUpper(word);
    while (true) {
        cin >> text;
        if (text == "END_OF_TEXT"){
            break;
        }
        text = toUpper(text);
        if (text == word){
            count++;
        }
    }
    cout << count << endl;

    return 0;
}



Measured memory_bytes: 3188
#include <stdio.h>
int main (void){
  int a,b,c,i,j,count;
  scanf("%d %d %d",&a,&b,&c);
  count = 0;
  if (a == b && b == c)
    printf("%d\n",count);
  if (a > b && b > c){
    j = a - b;
    for (i = 0; i < j; i++){
      count++;
      b++;
      c++;
    }
  }
  else if (a > b && a > c && c > b){
    j = a - c;
    for (i = 0; i < j; i++){
      count++;
      c++;
      b++;
    }
  }
  else if (b > c && c > a){
    j = b - c;
    for (i = 0; i < j; i++){
      count++;
      c++;
      a++;
    }
  }
  else if (b > c && b > a && a > c){
    j = b - a;
    for (i = 0; i < j; i++){
      count++;
      a++;
      c++;
    }
  }
  else if (c > a && a > b){
    j = c - a;
    for (i = 0; i < j; i++){
      count++;
      a++;
      b++;
    }
  }
  else if (c > a && c > b && b > a){
    j = c - b;
    for (i = 0; i < j; i++){
      count++;
      b++;
      a++;
    }
  }
  if (a == b && b > c){
    j = b - c;
    for (i = 0; i < j; i++){
      count++;
      c += 2;
      if (b == c){
	printf("%d\n",count);
	break;
      }
      else if (b < c){
	count++;
	printf("%d\n",count);
	break;
      }
    }
  }
  else if (a == b && b < c){
    for (i = 0; i < c - b; i++)
      count++;
    printf("%d\n",count);
  }
  else if (b == c && a < b){
    j = b - a;
    for (i = 0; i < j; i++){
      count++;
      a += 2;
      if (a == b){
	printf("%d\n",count);
	break;
      }
      else if (a > b){
	count++;
	printf("%d\n",count);
	break;
      }
    }
  }
  else if (b == c && a > b){
    for (i = 0; i < a - b; i++)
      count++;
    printf("%d\n",count);
  }
  else if (a == c && c > b){
    j = c - b;
    for (i = 0; i < j; i++){
      count++;
      b += 2;
      if (c == b){
	printf("%d\n",count);
	break;
      }
      else if (c < b){
	count++;
	printf("%d\n",count);
	break;
      }
    }
  }
  else if (a == c && b > c){
    for (i = 0; i < b - c; i++)
      count++;
    printf("%d\n",count);
  }
  return (0);
}
      
    
    


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using ll = long long;
const int inf = 99999999;

using namespace std;

const ll mod = 1e9 + 7;

int main(){
	ll n;
	cin >> n;
	if(n % 2 == 1 || n < 10){
		cout << 0 << endl;
		return 0;
	}
	while(n % 10 != 0){n--;}
	ll ans = 0;
	while(n >= 5){
		ll p = n / 10;
		ans += p;
		n /= 5;
	}
	cout << ans << endl; 
	return 0;
}
 


Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main(){
  int A,B,C;
  int c;   //最大可能回数
  cin >> A;//音の値段
  cin >> B;//所持金
  cin >> C;//音の回数の上限
  c = B/A;
  if(C <=c  ){
    c = C;
    }
  cout << c << "\n";   
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n, i, maxcount=0, max_number=1, count, tmp;
  scanf("%d", &n);
  for (i=0; i<=n; ++i){
    tmp = i;
    count = 0;
    while(tmp%2 == 0 && tmp != 0){
      tmp /= 2;
      count += 1;
    }
    if (count > maxcount) {
      maxcount = count;
      max_number = i;
    }
  }
  printf("%d\n", max_number);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
#define enl << endl
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n, tmpa;
    vector<int> a;
    cin >> n;

    a.push_back(0);
    rep(i, n){
        cin >> tmpa;
        a.push_back(tmpa);
    }
    a.push_back(0);

    ll sum = 0;
    rep(i, n+1){
        sum += abs(a[i+1]-a[i]);
    }

    //cout << sum << endl;

    reps(i, 1, n){
        cout << sum + abs(a[i-1]-a[i+1]) - (abs(a[i-1]-a[i]) + abs(a[i]-a[i+1])) << endl;
    }

    return 0;
}


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

int pop( vector<int>& a ) {
	int r = a.back();
	a.pop_back();

	return r;
}

int main() {
	vector<int> v;
	string s;

	while( cin >> s ) {
		if( s == "+" ) {
			int a = pop( v );
			int b = pop( v );
			v.push_back( b + a );
		}
		else if( s == "-" ) {
			int a = pop( v );
			int b = pop( v );
			v.push_back( b - a );
		}
		else if( s == "*" ) {
			int a = pop( v );
			int b = pop( v );
			v.push_back( b * a );
		}
		else {
			v.push_back( stoi( s ) );
		}
	}

	cout << v.back() << endl;
}



Measured memory_bytes: 3164
import sys
sys.setrecursionlimit(10**6)
n, m = map(int, input().split())
xy = []
for _ in range(m):
    x, y, _ = map(int, input().split())
    xy.append((x-1, y-1))

class UnionFind():
    def __init__(self, n):
        self.li = list(range(n))
    def root(self, x):
        if self.li[x]==x:
            return x
        self.li[x] = self.root(self.li[x])
        return self.li[x]
    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx==ry:
            return
        self.li[ry] = rx
    def same(self, x, y):
        return self.root(x)==self.root(y)

uf = UnionFind(n)
for x, y in xy:
    uf.unite(x, y)
for i in range(n):
    uf.root(i)
print(len(set(uf.li)))

Measured memory_bytes: 32424
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define pb push_back
#define SZ(a) ((int)a.size())
//#define TEST
 
const int oo = 1e9;
const int Maxn = 1e5;
const int N = 3e5 + 100;
const double PI = (-2.00) * asin(-1);
 
typedef pair<int, pair<int, int> > iii;
typedef pair<int, int> ii;    

signed main()
{
    #ifdef TEST
        freopen("test.inp", "r", stdin);
    #endif // TEST  
     ios_base::sync_with_stdio(false);                                      
     cin.tie(0); cout.tie(0);

    int x, y; cin >> x >> y;
    if(y >= 2 * x && y % 2 == 0 && 4 * x >= y) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll inf = 1e9;
ll n, m, sum;

int main() {
	ios::sync_with_stdio(0);
	cin >> n >> m >> sum;
	for (int i = 0;i < m;i++)
		cout << sum << " ";
	if (sum < inf) {
		for (int i = m;i < n;i++)
			cout << inf << " ";
	}
	else {
		for (int i = m;i < n;i++)
			cout << inf - 1 << " ";
	}
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int clz(int x) { return 31 - __builtin_clz(x); }
int clz(ll x) { return 63 - __builtin_clzll(x); }
int ctz(int x) { return __builtin_ctz(x); }
int ctz(ll x) { return __builtin_ctzll(x); }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int ans=0;
	if(n%10==2)ans++;
	if((n/10)%10==2)ans++;
	if((n/100)%10==2)ans++;
	if((n/1000)%10==2)ans++;
	cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int dfs(int now, vector<bool> &flg, vector<int> &g, int cnt) {
    //cout << now << endl;
    if (now == 1) return cnt;
    if (flg[now]) return -1;
    flg[now] = true;
    int next = g[now];
    if (flg[next]) return -1;
    return dfs(next, flg, g, cnt + 1);
}

int main() {
    int n;
    cin >> n;
    vector<int> g(n);
    rep(i, n) {
        int a;
        cin >> a;
        --a;
        g[i] = a;
    }

    vector<bool> flg(n, false);
    int num = dfs(0, flg, g, 0);
    cout << num << endl;
    return 0;
}


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

int main(){

    int color[3];
    int count = 0;

    for(int i = 0; i < 3; ++i){

        bool f = true;
        cin >> color[i];

        for(int j = 0; j < i; ++j){

            if(color[j] == color[i])f = false;

        }

        if(f)++count;

    }

    cout << count << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  char c = s.at(0);
    char d = s.at(1);
    char e = s.at(2);
    char f = s.at(3);
  if(c == d)
    cout << "Bad";
  else if(d == e)
    cout << "Bad";
  else if(e == f)
    cout << "Bad";
  else 
    cout << "Good";
  }

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char s[12],que[12];
int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1),pos=0;
	for(int i=1;i<=len;i++){
		if(s[i]=='0'){
			que[++pos]=s[i];
		}else if(s[i]=='1'){
			que[++pos]=s[i];
		}else if(s[i]=='B'){
			if(pos!=0){
				pos--;
			}
		}
	}
	for(int i=1;i<=pos;i++){
		printf("%c",que[i]);
	}
	return 0;
}

Measured memory_bytes: 128
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#define rep(i,a,b) for(i=a;i<(b);i++)
using namespace std;
int main(){
  int g,h,i,j;
  int n;
  vector<int> a,b,c;
  for(;;){
    cin>>n;
    if(n==0)
      break;
    a.clear();
    rep(i,0,n){
      int tmp;
      cin>>tmp;
      a.push_back(tmp);
    }
    g=0;
    do{
      b.clear();
      c.clear();
      rep(i,0,a.size()){
	rep(j,0,i){
	  if(a[i]==a[j])
	    break;
	}
	if(j==i)
	  b.push_back(a[i]);
      }
      rep(i,0,b.size())
	c.push_back(0);
      rep(i,0,c.size()){
	rep(j,0,n){
	  if(b[i]==a[j])
	    c[i]++;
	}
      }
      h=0;
      rep(i,0,n){
	rep(j,0,c.size()){
	  if(a[i]==b[j]){
	    if(a[i]!=c[j])
	      h=1;
	    a[i]=c[j];
	    break;
	  }
	}
      }
      if(h)
	g++;
    }while(h);
    cout<<g<<endl;
    rep(i,0,n-1)
      cout<<a[i]<<" ";
    cout<<a[i]<<endl;
  }
  return 0;
}	

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if (A + B == C + D) {
    cout << "Balanced" << endl;
  } else if (A + B > C + D) {
    cout << "Left" << endl;
  } else if (A + B < C + D) {
    cout << "Right" << endl;
  } else {
    cout << "error" << endl;
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N, M;
    cin >> N >> M;
    int A[N], B[N], C[N];
    rep(i, N) cin >> A[i] >> B[i] >> C[i];
    int D[M], E[M], F[M];
    rep(i, M) cin >> D[i] >> E[i] >> F[i];
    map<int, int> mpx, mpy;
    mpx[-inf]++, mpx[inf]++, mpy[-inf]++, mpy[inf]++;
    mpx[0]++, mpy[0]++;
    rep(i, N){
        mpx[A[i]]++, mpx[B[i]]++, mpy[C[i]]++;
    }
    rep(i, M){
        mpx[D[i]]++, mpy[E[i]]++, mpy[F[i]]++;
    }
    int n = 0, m = 0;
    for(auto &e: mpx) e.second = n++;
    for(auto &e: mpy) e.second = m++;
    int xs[n], ys[m];
    for(auto &e: mpx) xs[e.second] = e.first;
    for(auto &e: mpy) ys[e.second] = e.first;
    bool es[n-1][m-1][4];
    rep(i, n-1) rep(j, m-1) rep(k, 4) es[i][j][k] = true;
    rep(i, N){
        int a = mpx[A[i]], b = mpx[B[i]], c = mpy[C[i]];
        rep2(j, a, b-1){
            es[j][c-1][3] = false;
            es[j][c][1] = false;
        }
    }
    rep(i, M){
        int d = mpx[D[i]], e = mpy[E[i]], f = mpy[F[i]];
        rep2(j, e, f-1){
            es[d-1][j][2] = false;
            es[d][j][0] = false;
        }
    }
    int ex[] = {-1, 0, 1, 0}, ey[] = {0, -1, 0, 1};
    ll dx[n-1], dy[m-1];
    rep(i, n-1) dx[i] = xs[i+1]-xs[i];
    rep(i, m-1) dy[i] = ys[i+1]-ys[i];
    int sx = mpx[0], sy = mpy[0];
    ll ans = 0;
    bool used[n-1][m-1];
    fill(used[0], used[n-1], false);
    queue<pii> que;
    que.push(pii(sx, sy));
    while(!que.empty()){
        int x = que.front().first, y = que.front().second;
        que.pop();
        if(used[x][y]) continue;
        if(x == 0 || x == n-2 || y == 0 || y == m-2){
            cout << "INF" << endl;
            return 0;
        }
        used[x][y] = true;
        ans += dx[x]*dy[y];
        rep(k, 4){
            int nx = x+ex[k], ny = y+ey[k];
            if(!es[x][y][k] || used[nx][ny]) continue;
            que.push(pii(nx, ny));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 48016
#include <iostream>
#include <stack>
#include <cstdio>

using namespace std;

int main(){
    int n;
    std::stack<int> st;
    while(scanf("%d", &n) != EOF){
        if(n == 0){
            cout << st.top() << endl;
            st.pop();
        }
        else
            st.push(n);
    }
}

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

int w[100], v[100];
long long dp[101][100001] = {};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, W;
    cin >> n >> W;
    for (int i=0; i<n; i++)
        cin >> w[i] >> v[i];

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

    cout << dp[n][W] << "\n";

    return 0;
}


Measured memory_bytes: 78336
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A, B = [int(x) for x in input().split()]
    a = 1

    ans = 0
    while a < B:
        ans += 1
        a -= 1
        a += A

    print(ans)
    
    

if __name__ == '__main__':
    main()



Measured memory_bytes: 9104
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 3e5 + 10;
int N, M;
struct Node {
	int l, r, d;
} A[MAXN];
int tr[MAXN];

inline int lowbit(int x) {
	return x & (-x);
}

inline void update(int x, int d) {
	for(; x <= M; x += lowbit(x))
		tr[x] += d;
}

inline int query(int x) {
	int res = 0;
	for(; x; x -= lowbit(x))
		res += tr[x];
	return res;
}

int main() {
	register int i, d;
	scanf("%d%d", &N, &M);
	for(i = 1; i <= N; ++i)
		scanf("%d%d", &A[i].l, &A[i].r), A[i].d = A[i].r - A[i].l + 1;
	sort(A + 1, A + N + 1, [&](Node x, Node y) {return x.d < y.d;});
	int k = 1;
	for(d = 1; d <= M; ++d) {
		while(k <= N && A[k].d < d) {
			update(A[k].l, 1); update(A[k].r + 1, -1);
			++k;
		}
		int ans = N - k + 1;
		for(i = d; i <= M; i += d)
			ans += query(i);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 4736
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    int H,W;  cin >> H >> W;
    int h, w; cin >> h >> w;

    int ans = (H - h) * (W - w);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <unordered_map>
using namespace std;


int main(){
    int n, k;
    cin >> n >> k;
    long long h[n];
    for (int i = 0; i < n; i++){
        cin >> h[i];
    }
    sort(h, h + n);
    long long answer = h[n - 1] - h[0];
    for (int i = 0; i < n - k + 1; i++){
        answer = min(answer, h[k + i - 1] - h[i]);
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1024
def ii():
    return int(input())
def mi():
    return map(int, input().split())
def li():
    return list(mi())

n = ii()
a, b, c = input().strip(), input().strip(), input().strip()
ans = 0
for i in range(n):
    if a[i] == b[i] and b[i] == c[i]:
        pass
    elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        ans += 1
    else:
        ans += 2
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  long x;
  cin>>N>>x;
  long a[100];
  for(int i=0;i<N;i++){
  	cin>>a[i];
  }
  sort(a,a+N);
  int count=0;
  for(int i=0;i<N&&x>0;i++){
  	x-=a[i];
    count++;
  }
  if(x!=0)count--;
  cout<<count<<endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int[] x = new int[5];

        int res = 0;
        for (int i = 0; i < 5; ++i) {
            x[i] = fs.nextInt();
            if (x[i] == 0) {
                res = i + 1;
            }
        }

        System.out.println(res);
   }
}


Measured memory_bytes: 32556
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        int recCount = 0;
        int diaCount = 0;
        
        while(sc.hasNext()){
            String abc[] = sc.nextLine().split(",");
            int a = Integer.parseInt(abc[0]);
            int b = Integer.parseInt(abc[1]);
            int c = Integer.parseInt(abc[2]);
            if(rectangle(a,b,c) == true){
                recCount++;
            }
            if(diamond(a,b) == true){
                diaCount++;
            }
        }
        System.out.println(recCount + "\n" + diaCount);
    }
    private static boolean rectangle(int a, int b, int c){
        if(Math.pow(a,2) + Math.pow(b,2) == Math.pow(c,2)){
            return true;
        }
        return false;
    }
    private static boolean diamond(int a, int b){
        if(a == b){
            return true;
        }
        return false;
    }
}


Measured memory_bytes: 26040
cards = [[0 for i in range(13)] for j in range(4)]
s2n = {'S': 0, 'H': 1, 'C': 2, 'D': 3}
n2s = 'SHCD'
n = int(input())
for i in range(n):
    card = list(input().split())
    card[1] = int(card[1])
    cards[s2n[card[0]]][card[1]-1] = 1
for i in range(4): 
    for j in range(13):
        if not cards[i][j]:
            print(n2s[i], j+1)

Measured memory_bytes: 7680
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


S =  sys.stdin.readline().rstrip()
print(S.count("1"))

Measured memory_bytes: 66028
#include<iostream>
#include<vector>
#include<algorithm>
std::vector<std::vector<int> > vx(100003, std::vector<int>(2));
void isort(std::vector<int> &v1, std::vector<int> &v2, int size){
    if( size == 1) return;
    else{
        isort(v1, v2, size-1);
        if( v2[size-2] > v2[size-1]){
            int tmp1=v1[size-2], tmp2=v2[size-2];
            v1[size-2]=v1[size-1], v2[size-2]=v2[size-1];
            v1[size-1]=tmp1, v2[size-1]=tmp2;
            isort(v1, v2, size-1);
        }
    }
}
bool comp(const std::vector<int>& left, const std::vector<int>& right){
    return left[1] < right[1];
}
int main(){
    int  n, m;
    std::cin >> n >> m;

    for(int i=0; i<m; i++) std::cin >> vx[i][0] >> vx[i][1];
    std::sort(vx.begin(), vx.begin()+m, comp);

    int cnt=1;
    int pre_bridge=vx[0][1]-1;
    for(int i=1; i<m; i++){
        if(vx[i][0] > pre_bridge){
            cnt++; pre_bridge=vx[i][1]-1;
        }
    }
    std::cout << cnt << std::endl;
    return 0;

}


Measured memory_bytes: 5760
x = input()
y = x[0] + 't' + x[1] + 't' + x[2] + 't' + x[3]
for i in range(8):
  for j in range(3):
    if ((i>>j) & 1) == 1:
      z = list(y)
      z[5-2*j] = '+'
      y = ''.join(z)
    else:
      z = list(y)
      z[5-2*j] = '-'
      y = ''.join(z)
      
  if eval(y) == 7:
    print(y+ '=7')
    break

Measured memory_bytes: 8928