akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
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)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

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;
vector<pair<int, int> > G[100011];
VI ord;
int par[100011];
int sz[100011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N-1) {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	a--; b--;
	G[a].emplace_back(b, c);
	G[b].emplace_back(a, c);
    }

    ord.reserve(N);
    ord.push_back(0);
    REP (i_, N) {
	int v = ord[i_];
	EACH (e, G[v]) if (e->first != par[v]) {
	    par[e->first] = v;
	    ord.push_back(e->first);
	}
    }

    LL ans = 0;
    bool half = false;
    REP (i_, N) {
	int v = ord[N-1-i_];
	sz[v] = 1;
	EACH (e, G[v]) if (e->first != par[v]) {
	    sz[v] += sz[e->first];
	    LL s = min(sz[e->first], N-sz[e->first]);
	    if (s * 2 == N) {
		half = true;
		ans += (2*s-1) * e->second;
	    } else {
		ans += 2*s * e->second;
	    }
	}
    }

    if (!half) {
	REP (v, N) {
	    int ma = N-sz[v];
	    EACH (e, G[v]) if (e->first != par[v]) amax(ma, sz[e->first]);
	    if (ma*2 <= N) {
		int mi = 1<<29;
		EACH (e, G[v]) if (e->first != par[v]) amin(mi, e->second);
		ans -= mi;
		break;
	    }
	}
    }
    printf("%lld\n", ans);
}

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



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

int gcd(int a,int b){
  if(a%b == 0)return b; 
  return gcd(b,a%b);
}

int main(){
  int ans = 0,N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  for(int i=0;i<N;i++){
    ans = gcd(ans,A[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
using System;
using System.Numerics;
using System.Text;

namespace TaskA
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = BigInteger.Parse(ConsoleReader.Read<string>());
            var b = BigInteger.Parse(ConsoleReader.Read<string>());
            Console.WriteLine(a * b);
        }
    }
}

public static class ConsoleReader
{
    public static T Read<T>()
    {
        var inputBuffer = new StringBuilder();
        int currChar;

        while ((currChar = Console.Read()) != -1)
        {
            if (!char.IsWhiteSpace((char)currChar))
            {
                inputBuffer.Append((char)currChar);
            }
            else if (inputBuffer.Length != 0)
            {
                break;
            }
        }

        return (T)Convert.ChangeType(inputBuffer.ToString(), typeof(T));
    }

    public static T[] ReadArray<T>(int count)
    {
        if (count < 0)
        {
            throw new ArgumentOutOfRangeException(nameof(count), $"'{nameof(count)}' must be >= 0");
        }

        var result = new T[count];

        for (var i = 0; i < count; i++)
        {
            result[i] = Read<T>();
        }

        return result;
    }
}

Measured memory_bytes: 27904
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
int main()
{
	fast;
    int c[3][3],d=0,i,j;
    for(i = 0; i < 3; i++){
        for(j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }
    for(i = 0; i < 2; i++){
        for(j = 0; j < 2; j++){
            if(c[i+1][j] - c[i][j] == c[i+1][j+1] - c[i][j+1]){
                d++;
            }
        }
    }
    if(d==4){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ft(i,l,r) for(register int i=l;i<=r;i++)
#define fd(i,r,l) for(register int i=r;i>=l;i--)
using namespace std;
int n,a[233333],ans,mx;
int main()
{
	cin>>n;
	ft(i,1,n)
	{
		scanf("%d",&a[i]);
		if(a[i]<=a[i-1]) ans++;
		else mx=max(mx,ans),ans=0;
	}
	cout<<max(ans,mx);
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
    int a, b, d, r;
    double f;

    scanf("%d %d", &a, &b);

    d = a / b;
    r = a % b;
    f = (double)a / (double)b;

    printf("%d %d %f\n", d, r, f);
    return 0;
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

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

    int n, m;
    cin >> n >> m;
    vector<int> a(n-1+m), b(n-1+m);
    REP(i, n-1+m) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }

    vector<vector<int>> graph(n), rg(n);
    vector<int> h(n, 0);
    REP(i, n-1+m){
        graph[a[i]].pb(b[i]);
        rg[b[i]].pb(a[i]);
        h[b[i]]++;
    }

    stack<int> st;
    REP(i, n){
        if(h[i] == 0) st.push(i);
    }

    vector<int> topo;
    while(st.size()){
        int i = st.top(); st.pop();
        topo.push_back(i);
        for(auto &j : graph[i]){
            h[j]--;
            if(h[j] == 0) st.push(j);
        }
    }
    map<int, int> mp;
    int cnt = 0;
    for(int i: topo) {
        //cout << i + 1 << endl;
        mp[i] = cnt;
        cnt++;
    }

    vector<int> ans(n);
    reverse(all(topo));
    for(int i: topo) {
        int num = -1, index = -1;
        for(auto &j : rg[i]){
            if(num < mp[j]){
                num = mp[j];
                index = j;
            }
            //cout << i+1 << " " << j+1 << " " << mp[j] << endl;
        }
        //cout << i+1 << " " << index+1 << endl;
        ans[i] = index+1;
    }
    REP(i, n) cout << ans[i] << endl;
}

Measured memory_bytes: 18428
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#include <set>
#include <iterator>
using namespace std;
using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF INT_MAX
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

typedef tree<pll, null_type, less<pll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
const int N=2e5+10, M=(ll)1e9+1 ;
const int mod = 1e9+7  ;
vl g[N],vis(N,0);
ll cntx,cnty,x[N],y[N];

void dfs(ll u){
  vis[u]=1;
  if(u<=1e5)
    cntx++;
  else
    cnty++;
  for(auto &it:g[u]){
    if(vis[it])
      continue;
    dfs(it);
  }
}
void work(){
  ll n,u,v;
  cin >> n;
  for(ll i=1;i<=n;i++){
    cin >> u >> v;
    x[i]=u,y[i]=v;
    g[u].pb(v+(ll)1e5);
    g[v+(ll)1e5].pb(u);
  }

  ll ans=0;
  for(ll i=1;i<=n;i++){
    if(vis[x[i]])
      continue;
    cntx=0,cnty=0;
    dfs(x[i]);
    ans+=cntx*cnty;
  }
  ans-=n;
  cout << ans;
}
int main(){
 ios_base::sync_with_stdio(0);

    ll t,z;
    // cin >> t;
    // z=t;
    t=1;
    while(t--){
            // cout << "Case #" << z-t << ": ";
            work();
    }
   return 0;

}


Measured memory_bytes: 15104
n = int(input())
ren = 0
ren_max = 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        ren += 1
        ren_max = max(ren_max, ren)
    else:
        ren = 0

if ren_max >= 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9168
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a + b < c + d)
    {
        cout << "Right";
    }
    else if(a + b == c + d)
    {
        cout << "Balanced";
    }
    else
    {
        cout << "Left";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }



int solve(int A, int B, int K)
{
	int mask[10];
	for (int i = 0; i < 10; ++i)
		mask[i] = K-- > 0 ? 0 : 1;
	sort(mask, mask + 10);

	int res = -1;
	do
	{
		int c[10] = { 0 } ;
		int bor[10] = { 0 };
		for (int i = 0, a = A, b = B; i < 10; ++i, a /= 10, b /= 10)
		{
			int x = a % 10, y = b % 10;
			int z = x - y - (bor[i] & mask[i]);
			if (z < 0)
			{
				z += 10;
				bor[i + 1] = 1;
			}
			c[i] = z;
		}

		int r = 0;
		for (int i = 9; i >= 0; --i)
			r = r * 10 + c[i];
		max_swap(res, r);
	} while (next_permutation(mask, mask + 10));

	return res;
}
int main()
{
	int a, b, k;
	cin >> a >> b >> k;

	int res = -1;
	for (int i = 0; i <= k; ++i)
		max_swap(res, solve(a, b, i));
	cout << res << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)

signed main(){
    int n, m;
    cin >> n >> m;
    vi x(m);
    vi diff(m-1);
    rep(i, m) cin >> x[i];
    sort(x.begin(), x.end());

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


    rep(i, m-1){
        diff[i] = x[i+1] - x[i];
    }
    sort(diff.begin(), diff.end(), greater<int>());

    int ans = *(x.end()-1) - *x.begin();

    rep(i, n-1){
       /*  cout << "diff = " << diff[i] << " "; */
        ans -= diff[i];
    }
    cout << ans << endl;
}

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

int main() {
  int n,m; cin>>n>>m;
  vector<int> a(n,-1);
  bool frag=true;
  rep(i, m) {
    int s,c; cin>>s>>c;
    if (a[s-1]!=-1&&a[s-1]!=c) frag=false;
    a[s-1]=c;
  }
  if (n!=1&&a[0]==0) frag=false;

  if (!frag) cout<<-1<<endl;
  else {
    if (n==1) cout<<max(0, a[0])<<endl;
    else {
      rep(i, n) {
        if (i) cout<<max(0, a[i]);
        else cout<<max(1, a[i]);
      }
      cout<<endl;
    }
  }
}


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


int main() {
    while(1){
        int a,b;
        cin >> a >> b;
        if(a == 0 && b == 0)break;
        else{
            int ans = 0;
            for(int i = 1;i<=a;i++){
                for(int j = i;j<=a;j++){
                    for(int k = j;k<=a;k++){
                        if(i != j && j != k && i+j+k == b)ans++;
                    }
                }
            }
            cout << ans << endl;
        }
    }
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/


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

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

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

typedef long long ll;

const string YES = "Yes";
const string NO = "No";

bool isPalindrome(string str)
{
    bool ans = false;
    int N = str.length();
    if (N % 2 == 0)
    {
        string str1 = str.substr(0, N / 2);
        string str2 = str.substr(N / 2, N / 2);
        // cout << str1 << endl;
        // cout << str2 << endl;
        reverse(str2.begin(), str2.end());
        if (str1 == str2)
        {
            ans = true;
        }
    }
    else
    {
        string str1 = str.substr(0, (N - 1) / 2);
        string str2 = str.substr((N - 1) / 2 + 1, (N - 1) / 2);
        // cout << str1 << endl;
        // cout << str2 << endl;
        reverse(str2.begin(), str2.end());
        if (str1 == str2)
        {
            ans = true;
        }
    }
    return ans;
}

void solve(std::string S)
{
    int N = S.length();
    string ans = NO;
    if (isPalindrome(S))
    {
        string str1;
        string str2;
        if (N % 2 == 0)
        {
            str1 = S.substr(0, (N / 2));
            str2 = S.substr(N / 2, N / 2);
            // cout << str1 << endl;
            // cout << str2 << endl;
        }
        else
        {
            str1 = S.substr(0, (N - 1) / 2);
            str2 = S.substr((N - 1) / 2 + 1, (N - 1) / 2);
            // cout << str1 << endl;
            // cout << str2 << endl;
        }
        if (isPalindrome(str1))
        {
            if (isPalindrome(str2))
            {
                ans = YES;
            }
        }
    }
    cout << ans << endl;
}

int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+10;
char laz[maxn];
int pi[12*maxn],dp[12*maxn];
int prefix_function(const string &s,const string &t) {
    ///search t on s
    int m=(int)t.length();
    int n = t.length()+s.length()+1;
    auto ss=[&](int idx){
        if(idx==m)return '#';
        if(idx<m)return t[idx];
        return s[idx-m-1];
    };
    pi[0]=0;
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && ss(i) != ss(j))
            j = pi[j-1];
        if (ss(i) == ss(j))
            j++;
        pi[i] = j;
    }
    int ma=-1;
    for(int i=n-1;i>m;i--){
        dp[i]=0;
        if(pi[i]==m){
            dp[i]=1;
        }
        if(i+m<n&&dp[i]==1){
            dp[i]+=dp[i+m];
        }
        ma=max(ma,dp[i]);
    }
    return ma;
}
string s,t,a,ss,tt;
/**
There exists a non-negative integer j
such that the concatenation of i copies of t
is a substring of the concatenation of j copies of s.
*/


int main(){
    scanf("%s",laz);
    ss=string(laz);
    scanf("%s",laz);
    t=string(laz);
    s=ss;
    while((int)s.length()<=(int)t.length()+(int)ss.length()){
        s+=ss;
    }
    s+=ss;
    int c=prefix_function(s,t);
    if(c==-1){
       return !printf("0");
    }
    s+=s;
    int cc=prefix_function(s,t);
    if(cc==c){
        return !printf("%d\n",cc);
    }
    else{
        return !printf("-1");
    }
}
/*
    Good Luck
        -Lci70121
*/


Measured memory_bytes: 44424
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, A[11];

  long long X = 1, Y = 1;

  std::cin >> N;

  for (int i = 0; i < N; i ++) {
    std::cin >> A[i];

    X *= A[i] % 2 ? 1 : 2;
    Y *= 3;
  }

  std::cout << Y - X << std::endl;

  return 0;
}


Measured memory_bytes: 256
def abc173_b():
    N = int(input())

    #AC WA TLE RE
    l = [0 for i in range(4)]

    for i in range(N):
        Inp = input()
        if Inp == "AC":
            l[0] += 1
        if Inp == "WA":
            l[1] += 1
        if Inp == "TLE":
            l[2] += 1
        if Inp== "RE":
            l[3] += 1

    print("AC x "+str(l[0]))
    print("WA x "+str(l[1]))
    print("TLE x "+str(l[2]))
    print("RE x "+str(l[3]))



abc173_b()


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

using namespace std;

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

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

struct Data {
	int t, s, d;
};

istream& operator>>(istream& is, Data& dt) {
	int t, s, d; is >> t >> s >> d;
	dt.t = t;
	dt.s = s-1;
	dt.d = d-1;
	return is;
}
bool operator<(const Data& d1, const Data& d2) {
	return d1.t < d2.t;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N, M;
	while ( cin >> N >> M, N || M ) {
		vector<Data> d(M); cin >> d;
		sort(ALL(d));
		vector<bool> isInfected(N, false);
		isInfected[0] = true;
		REP(i,M) {
			if ( isInfected[d[i].s] ) {
				isInfected[d[i].d] = true;
			}
		}
/*
		vector< vector<int> > G(N);
		REP(i,M) {
			int t, s, d; cin >> t >> s >> d; --s, --d;
			G[s].pb(d);
		}
		vector<bool> isInfected(N, false); isInfected[0] = true;
		queue<int> Q; Q.push(0);
		while (!Q.empty()) {
			int v = Q.front(); Q.pop();
			EACH(e,G[v]) {
				if (isInfected[e.to]) continue;
				isInfected[e.to] = true;
				Q.push(e.to);
			}
		}
		int ans = 0;
		REP(i,N) ans += isInfected[i];
		cout << ans << endl;
*/
		int ans = 0;
		REP(i,N) ans += isInfected[i];
		cout << ans << endl;
	}
}

Measured memory_bytes: 3364
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, pos[4010][4010];
ll w[4000], s[4001], dp[4010][4010];

int main(){
	cin >> n;
	rep(i, n) cin >> w[i], s[i + 1] = s[i] + w[i];
	rep(i, n - 1){
		dp[i][i + 1] = w[i] + w[i + 1];
		pos[i][i + 1] = i;
	}
	rep(i, n) for(int j = i + 2; j < n; j++) dp[i][j] = 1ll << 60;
	
	for(int w = 3; w <= n; w++) rep(l, n - w + 1){
		int r = l + w - 1;
		int A = pos[l][r - 1], B = pos[l + 1][r];
		for(int k = A; k <= B; k++)
		if(dp[l][r] > dp[l][k] + dp[k + 1][r] + s[r + 1] - s[l]){
			dp[l][r] = dp[l][k] + dp[k + 1][r] + s[r + 1] - s[l];
			pos[l][r] = k;
		}
	}
	cout << dp[0][n - 1] << endl;
	return 0;
}

Measured memory_bytes: 189576
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int64 powi(int64 base, int64 num){
    int64 ret=1;
    for(uint i=0; i<num; ++i){
        ret *= base;
    }
    return ret;
}

int main(){
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    
    int64 N, K; cin >> N >> K;
    
    int64 mulNum=0ll;
    for(int i=K; i<=N; i+=K){ ++mulNum; }
    
    if(K%2!=0){ cout << powi(mulNum, 3) << endl; return 0; }
    
    int64 Kdiv2 = K/2;
    int64 mulNum2=0ll;
    for(int i=Kdiv2; i<=N; i+=K){ ++mulNum2; }
    
    cout << powi(mulNum, 3) + powi(mulNum2, 3) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sort stable_sort
#define all(x) (x).begin(),(x).end()
#define rep(i,x) for (register int (i)=(1);(i)<=(x);(i)++)
#define rep2(i,x) for (register int (i)=(x);(i)>=(1);(i)--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
using namespace std;
long long n,i,pre[200005],ans=0x1212121212121212ll;
int main()
{
	cin>>n;
	rep(i,n){
		cin>>pre[i];
		pre[i]+=pre[i-1];
	}
	for(i=0;i<=n;i++){
		ans=min(ans,abs(pre[i]-(pre[n]-pre[i])));
	}
	cout<<ans<<endl;
	return 0;
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int64_t a,int64_t b){return a/gcd(a, b)*b;}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int64_t a){if(a<=1)return false;for(int64_t i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }



int main()
{
	int64_t ans = 0;
	int n, temp, r = 0, g = 0, b = 0;
	string s;

	cin >> n >> s;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'R')
			r++;
		else if (s[i] == 'G')
			g++;
		else
			b++;
	}
	ans = (int64_t)r * g * b;
	for (int i = 1; i <= n / 2; i++)
	{
		for (int j = i; j < n - i; j++)
		{
			if (s[j] != s[j - i] && s[j] != s[j + i] && s[j - i] != s[j + i])
				ans--;
		}
	}
	ans = (ans < 0 ? 0 : ans);
	// cout << r << " " << g << " " << b << endl;
	// cout << r * g * b << endl;
	cout << ans << endl;
}


Measured memory_bytes: 3720
N = int(input())
p_list = []
for i in range(N):
        p_list.append(list(map(int, input().split())))
#flag = 0
#print(p_list)

l = len(p_list)

for i in range(l):
        if p_list[i][0] < (p_list[i][1] + p_list[i][2]) or p_list[i][0] % 2 != (p_list[i][1] + p_list[i][2]) % 2:
                print('No')
                exit(0)
        for j in range(3):
                if i != l-1:
                        p_list[i+1][j] -= p_list[i][j]

print('Yes')

Measured memory_bytes: 27324
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

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

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

bool ispa(string s)
{
    ll n = s.length();
    bool pos = 1;
    rep(n)
        if(s[i]!=s[n-1-i])
            pos = 0;
    return pos;        
}

int main()
{
   FAST/**/
   
   ld l;
   cin>>l;
   
   ld ans = l*l*l;
   ans/=(ld)27;
   cout<<fixed<<setprecision(12)<<ans;
   
   
   return 0;        
}  
   

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
long long a[55];
int main()
{
    long long x,s,sum,n,i;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
        scanf("%lld",&a[i]);
    sum=0;
    while(1)
    {
        sort(a,a+n);
        if(a[n-1]<n)
            break;
            s=a[n-1]/n;
        sum=sum+s;
        for(i=0;i<n-1;i++)
            a[i]=a[i]+s;
        a[n-1]=a[n-1]%n;
    }
    printf("%lld\n",sum);
    return 0;
}


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

int main() {
  string S;
  int C;
  cin >> S;
  C = 0;
  
  if (S.at(2) != S.at(3)) { // 3文字目と4文字目 No
  }
  else if (S.at(2) == S.at(3)) { // 3文字目と4文字目 Yes
    C = C + 1;
    if (S.at(4) != S.at(5)) { // 5文字目と6文字目 No
    }
    else if (S.at(4) == S.at(5)) { // 5文字目と6文字目 Yes
      C = C + 1;
    }
  }

  if (C == 2) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }

}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
m = map(int,read().split())
AB = zip(m,m)

MOD = 10 ** 9 + 7

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

root = 1
parent = [0] * (N+1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

# (1/2)^n
x = (MOD + 1) // 2
power = [1] * (N+100)
power_inv = [1] * (N+100)
for i in range(1,N+100):
    power[i] = power[i-1] * 2 % MOD
    power_inv[i] = power_inv[i-1] * x % MOD

# 部分木の大きさ
answer = 0
size = [1] * (N+1)
p_size = [N-1] * (N+1)
prod = [1] * (N+1)
coef = [1] * (N+1)
for v in order[::-1]:
    p = parent[v]
    x = size[v]
    size[p] += x
    prod[p] *= power_inv[x]; prod[p] %= MOD
    coef[p] += power[x] - 1
    x = N - x
    prod[v] *= power_inv[x]
    coef[v] += power[x] - 1
    E = 1 - prod[v] * coef[v] % MOD
    answer += E

answer *= power_inv[1]
answer %= MOD
print(answer)

Measured memory_bytes: 84744
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
#define non __builtin_popcount
#define ml map<ll, ll> 
#define ms map<string , ll> 
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	
	string s;
	ll i,j;
	cin>>s;
	ll l=s.size();
	for(i=1; i<l; i++)
	{
		if(s[i]== s[i-1])
        {
          cout<<"Bad";
          break;
        }
	}
	if(i==l)
	cout<<"Good";
    return 0;
}























Measured memory_bytes: 256
/*
        Author: Prokash
                CSE48, JU

*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int ara[2005];
int main()
{
    FAST;
    ll n,k;
    cin>>n>>k;
    if(k%2)
    {
        ll ans=n/k;
        cout<<ans*ans*ans<<endl;//every place has (ans) choice.. so total choices ans*ans*ans;
        return 0;
    }
    else
    {
        ll cnt=0,d=0;
        for(ll i=1;i<=n;i++)
        {
            if((i%k==0)||(i%k==k/2))
            {
                if(i%k==0)
                {
                    d++;
                }
                else{
                cnt++;
                }
//                cout<<i<<endl;
            }
        }
        cout<<(cnt*cnt*cnt)+(d*d*d)<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
from sys import stdin
S = stdin.readline().rstrip()
n = len(S)
def dfs(i, f):
    if i == n-1:
        return sum(list(map(int, f.split('+'))))
    return dfs(i+1, f + S[i + 1]) + dfs(i + 1, f + '+' + S[i+1])
print(dfs(0, S[0]))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define inf 1000000005
#define mod 1000000007
#define eps 1e-10
#define rep(i,n) for(int i = 0; i < (n); ++i) /*0からn-1までのrepeat*/
#define rrep(i,n) for(int i = 1; i <= (n); ++i) /*1からnまでのrepeat*/
#define drep(i,n) for(int i = (n)-1; i >= 0; --i) /*n-1から0までのrepeat*/
#define srep(i,s,t) for (int i = s; i < t; ++i) /*sからt-1までのrepeat*/
#define isin(x,l,r) ((l) <= (x) && (x) < (r)) /*l以上r未満のx*/
#define each(a,b) for(auto& (a): (b)) /*よくわからん*/
#define pct __builtin_popcountll /*1bitの数*/
#define all(a) a.begin(),a.end() /*範囲*/
#define sz(v) (int)(v).size() /*大きさ*/
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end()) /*重複削除*/
#define cmx(x,y) x=max(x,y) /*最大*/
#define cmn(x,y) x=min(x,y) /*最小*/
#define rev(v) reverse((v).begin(),(v).end()); /*逆順*/
#define so(v) sort((v).begin(), (v).end()); /*ソート*/
#define yn {puts("Yes");}else{puts("No");} /*はい・いいえ*/
#define dame { puts("-1"); return 0;}/*だめ*/
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using namespace std;

using ll = long long;
using unit = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;
using T = tuple<int, int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vp = vector<P>;
using vt = vector<T>;
using vs = vector<string>; 

int main(){
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    a = 60 * (c-a) - b + d;
    a = a - e;
    if (a <= 0) {
        cout << 0 << endl;
    }
    else {
        cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	string S;
	cin >> S;

	int are = 0;
	rep(i, S.size()) are += S[i] - '0';

	if (are % 9 == 0) co("Yes");
	else co("No");

	Would you please return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>//復習必須
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int main () {
    int N ;
    cin >> N ;
    string s ;
    cin >> s ;
    size_t a = s.length() ;
    if(a <= N){
        cout << s << endl;
    }else{
        for(int i = 0 ; i < N ; i++){
            cout << s[i] ;
        }
        cout << "..." << endl;
    }
   
    return 0 ;
}

 


Measured memory_bytes: 3628
#include <iostream>
#include <string>

#define rep(i, a, b) for(int i = a; i < b; i ++)

using namespace std;

int main() {
	int n, m;
	char A[100], B[100], C;

	while(cin >> n, n) {
		rep(i, 0, 100) {
			A[i] = 0;
			B[i] = 0;
		}

		rep(i, 0, n) {
			cin >> A[i] >> B[i];
		}

		cin >> m;
		rep(i, 0, m) {
			cin >> C;
			rep(j, 0, n) {
				if(C == A[j]) {
					C = B[j];
					break;
				}
			}
			cout << C;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	if(a+b<10)
		cout << a+b << endl;
	else
		cout << "error" << endl;
}

Measured memory_bytes: 3540
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#define llong long long
#define pb(a) push_back(a)
#define SORT(strVec) sort(strVec.begin(), strVec.end());
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;

int main(){
  int X,A,B;
  cin>>X>>A>>B;
  if(B<=A){
    cout<<"delicious"<<endl;
  }else if(B-A<=X){
    cout<<"safe"<<endl;
  }else{
    cout<<"dangerous"<<endl;
  }
}

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

int main(void) {
    ll X;
    cin >> X;

    ll dep = 100;

    int yr = 0;
    while (dep < X)
    {
        dep += dep / 100;
        yr++;
    }
    
    cout << yr << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;
 
const int oo = 1e9 + 7;
const int mod = 1e9 + 7;
const double PI = acos(-1);

bool isprime[1000100]={};
vector<int> primos;

void sieve(){
    isprime[0] = isprime[1] = true;
    primos.push_back(2);
    for (int i=3; i<1010; i+=2){
        if (!isprime[i]){
            primos.push_back(i);
            for (int j=i*i, k = (i << 1); j<=1000100; j+= k){
                isprime[j] = true;
            }
        }
    }

    for (int i=1011; i<1000100; i+=2){
        if (!isprime[i]) primos.push_back(i);
    }
}
 
 
int main (){
    sieve();
    ll n, ans = 0, power;
    cin >> n;

    for (auto p: primos){
        if (p > n) break;
        power = 0;
        while (n%p == 0) n/=p, power++;
        if (power) ans += (1 + ll(sqrt(1 + 8*power)))/2 - 1;
    }

    if (n > 1) ans++;
    cout << ans  << endl;

    return 0;
}

Measured memory_bytes: 4780
//============================================================================
// Name        : HelloWorld.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
typedef long long ll;
using namespace std;
string S;
int main() {
	cin>>S;
    int a=0;
    if(S[0]=='o')a++;
    if(S[1]=='o')a++;
    if(S[2]=='o')a++;

    cout<<700+a*100<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111




	void solve(){


		
		ini(n);
		ini(n1);
		ini(x);
		int morty[n][n1];
		int morty1[n];
		FOR(i,0,n){in(morty1[i]);FOR(i1,0,n1)in(morty[i][i1]);}
		int rick =	inf;
		FOR(i,0,1<<(n)){
			vi mortyy(n1,0);
			int tmp = 0;
			FOR(i1,0,n){
				if(i & (1<<i1)){
					tmp +=morty1[i1];
					FOR(i2,0,n1){
						mortyy[i2]+=morty[i1][i2];
					}
				}
			}
			//FORR(x,mortyy)cout<<i<<" "<<x<<" ";
			//out();
			int one = 0;
			FOR(i1,0,n1){
				if(mortyy[i1]<x)one = 1;
			}
			if(one)continue;
			else{
				rick = min(rick,tmp);
			}
		}
		if(rick == inf)out(-1);
		else out(rick);









	}























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 3648
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end

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

    string w;
    in >> w;

    int alphabet[26] = {};
    REP(i, w.size()){
        alphabet[w[i] - 'a']++;
    }
    REP(i, 26){
        if (alphabet[i] % 2 == 1){
            out << "No" << endl;
            return 0;
        }
    }
    out << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>

#define N_MAX 101
#define INF 100000000

using namespace std;

int main(){
  int n; cin >> n;
  int G[n][n];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      G[i][j]=-1;
    }
  }
  for(int i=0;i<n;i++){
    int u,k; cin >> u >> k;
    for(int i=1;i<=k;i++){
      int v,c; cin >> v >> c;
      G[u][v]=c;
    }
  }
  //dijkstra's algorithm
  int visited[n],d[n];
  for(int i=0;i<n;i++){
    visited[i]=0;
    d[i]=INF;
  }
  d[0]=0;

  while(1){
    int mind=INF;
    int u;
    for(int i=0;i<n;i++){
      if(visited[i]==0 && d[i]<mind){
        mind=d[i];
        u=i;
      }
    }
    if(mind==INF) break;
    visited[u]=1;
    for(int v=0;v<n;v++){
      if(G[u][v]!=-1 && visited[v]==0){
        if(d[u]+G[u][v]<d[v]) d[v]=d[u]+G[u][v];
      }
    }
  }
  for(int i=0;i<n;i++) cout << i << " " << d[i] << endl;
}

Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 8000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};

typedef long long ll;

using namespace std;


int ans,ans2;
string s;
int dp[111111][11];

signed main(){
	cin>>s;
	for(int i=s.size();i>=0;i--){
		for(int j=3;j>=0;j--){
			if(i==s.size()){
				if(j==3)dp[i][j]=1;
				else dp[i][j]=0;
			}
			else{
				if(s[i]=='?')dp[i][j]+=dp[i+1][j]*3;
				else dp[i][j]+=dp[i+1][j];
				if(j<3/*(３つ選び終わってない)*/ && (s[i]=='?' || s[i]=="ABC"[j])){//選んだj文字目が?もしくは「1文字目ならA,2文字目ならB,3文字目ならC」
					dp[i][j]+=dp[i+1][j+1];
				}
			}
			dp[i][j]%=MOD;
		}
	}
	cout<<dp[0][0]<<endl;
}


Measured memory_bytes: 9088
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize
    };
    // (0..6).map{|i| 2**i}.reverse()
    println!(
        "{}",
        [64, 32, 16, 8, 4, 2, 1].iter().find(|&&i| i <= n).unwrap()
    );
}


Measured memory_bytes: 2104
/**Bismillahir Rahmanir Rahim.**/

/**
 *    author:  nasimnoob
**/

#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<cstring>
#include<cstdio>

using namespace std;

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

typedef long long int                        ll;
typedef unsigned long long int              ull;
typedef long double                          ld;

//-----------------------------------------------------------//
#define      test                       int t; cin>>t;  while(t--)

#define      cube(x)                    (x*x*x)
#define      sqr(x)                     (x*x)

#define      sc1(x)                     scanf("%lld",&x);
#define      sc2(x,y)                   scanf("%lld %lld", &x, &y)
#define      scf1(x)                    scanf("%lf",&x)
#define      scf2(x,y)                  scanf("%lf %lf", &x, &y)

#define      INPUT                      freopen("input.txt", "r", stdin)
#define      OUTPUT                     freopen("output.txt", "w", stdout)

#define      srev                       reverse(s.begin(),s.end())
#define      sortstr                    sort(s.begin(), s.end());
#define      gtl(x)                     getline(cin, (x))
#define      dot(x)                     fixed << setprecision(x)

#define      PI                         acos(-1) // 3.1415926535897932
#define      MIN                        9999999

#define      Faster                     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);


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

int main()
{
    Faster;



    int n ;

    cin >> n ;

    vector < int > ar ;
    int  b ;

    for (int i = 0 ; i < n ; i++)
    {
        cin >> b ;
        ar.push_back(b);
    }

    int cnt = 0 ;

    sort(ar.begin() , ar.end());

    for (int i = 0 ; i < n ; i++)
    {
        for (int j = i+1 ; j < n ; j++)
        {
            for (int k = j+1 ; k < n ; k++)
            {
                if (ar[i] != ar[j] && ar[j] != ar[k])
                {
                    if (ar[i] + ar[j] > ar[k])
                    {
                        cnt ++;
                    }

                }
            }
        }
    }

    cout << cnt << endl;



   return 0 ;
}







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

using namespace std;

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

    switch(n%10)
    {
    case 2:

    case 4:

    case 5:

    case 7:

    case 9:
        cout<<"hon"<<"\n";
        break;
    case 0:

    case 1:

    case 6:

    case 8:
        cout<<"pon"<<"\n";
        break;

    case 3:
        cout<<"bon"<<"\n";
        break;
    }
}


Measured memory_bytes: 3596
n = int(input())
s = list(input())

l = [0]
r = [0]
l_cnt = 0
r_cnt = 0
for i in range(n-1):
    if s[i] == 'W':
        l_cnt += 1
    if s[n-i-1] == 'E':
        r_cnt += 1
    l.append(l_cnt)
    r.append(r_cnt)
print(min(l[i]+r[n-i-1] for i in range(n)))

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

int factorial(int k) {
    if (k == 1) return 1;
    else return k * factorial(k - 1);
}

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    for (int i = 0; i < n; i++) {
        int k;
        cin >> p.at(i);
    }

    for (int i = 0; i < n; i++) {
        int k;
        cin >> q.at(i);
    }

    vector<int> vec(n);
    for (int i = 1; i <= n; i++) {
        vec.at(i-1) = i;
    }

    int index_p = 0;
    int index_q = 0;
    int num = 1;
    do {
        if (vec == p) index_p = num;
        if (vec == q) index_q = num;
        num++;
    } while (next_permutation(vec.begin(), vec.end()));
    cout << abs(index_p - index_q) << endl;

    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 100005
typedef long long ll;
using namespace std;
const int mod=1e9+7;
int n;
char S[M];
int cnt[26];
ll FP(ll a,ll b){
	ll res=1;
	while(b>0){
		if(b&1)res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}
int main(){
	scanf("%d%s",&n,S+1);
	ll ans=0;
	for(int i=1;i<=n;i++){
		int &c=cnt[S[i]-'a'];
		ll res=1;
		for(int j=0;j<26;j++)
			if(j!=S[i]-'a')(res*=cnt[j]+1)%=mod;
		ans=1LL*(ans+res)%mod;
		c++;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
def dfs(i,k,s):
    if k == s == 0: return 1
    if i > n: return 0
    if k > 0 and s <= 0: return 0
    if k == 0 and s != 0 or s < sum(i+j for j in range(k)): return 0
    return dfs(i+1,k,s)+dfs(i+1,k-1,s-i)

while 1:
    n,k,s = map(int,raw_input().split())
    if n == k == s == 0: break

    print dfs(1,k,s)

Measured memory_bytes: 4224