akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vl a(n);
    cin >> a;
    ll ans = 1;
    rep(i, n) {
        if (a[i] == 0) {
            cout << 0 << '\n';
            return;
        }
    }
    rep(i, n) {
        if (a[i] <= 1e18 / ans)
            ans *= a[i];
        else {
            cout << -1 << '\n';
            return;
        }
    }
    if (ans > ll(1e18)) {
        cout << -1 << '\n';
    } else {
        cout << ans << '\n';
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 4052
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0050
{
    public class Program

    {
        public static void Main(string[] args)
        {
            const string APPLE = "apple";
            const string PEACH = "peach";
            const string TMP = "あいうえお";

            string line = RSt();
            line = line.Replace(APPLE, TMP);
            line = line.Replace(PEACH, APPLE);
            line = line.Replace(TMP, PEACH);
            Console.WriteLine(line);
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 13736
#include <stdio.h>
#include <stdlib.h>

int partition(int *A,int r);

int main(int argc, char** argv) {
    int size;
    scanf("%d",&size);
    int array[size+1];
    for(int i= 1; i<size+1;i++)
    {
        scanf("%d", &array[i]);
    }
    int a = array[size];
 
    int number;
    number = partition( array, size);

     for(int i= 1; i<size+1;i++)
    {
        if(i!=number && i!=size)
            printf("%d ", array[i]);
        if(i== number && i!=size)
            printf("[%d] ",array[i]);
        if(i==size && i!=number)
            printf("%d\n",array[i]);
        if(i==size && i== number)
            printf("[%d]\n",array[i]);
        
    }
    return (EXIT_SUCCESS);
}


int partition(int *A,int r)
{
  
    int a,b;
    int x = A[r];
    int i = 0;
    for(int j=1; j<r; j++)
    {
        if(A[j] <= x)
        {
            i = i+1;
            b=A[i];
            A[i]=A[j];
            A[j]=b;
        }
    } 
    a=A[i+1];
    A[i+1]=A[r];
    A[r] = a;
    return i+1;
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//


ll f(ll b, ll n) {
    ll sigma = 0;
    while (n) {
        sigma += n % b;
        n /= b;
    }
    return sigma;
}

inline ll llpow(ll x, ll k) {
    // x ^ k
    ll xk = 1LL;
    rep(i, k) xk *= x;
    return xk;
}

ll solve(ll n, ll s) {
    if (n < s) return -1LL;
    // if (s == 1) return n;
    if (n == s) return n+1LL;

    int maxk = 0;
    for (ll x=n; x; x>>=1LL) {
        ++maxk;
    }

    ll best = n+1LL;
    for (int k=maxk; k>=3; --k) {
        ll lo = ceill(powl(n, 1.0/k) - 1.0e-9); // lo < x <= hi
        ll hi = floorl(powl(n, 1.0/(k-1)) + 1.0e-9);
        if (lo > hi) continue;
        // fprintf(stderr, "k=%d, [%lld..%lld]\n", k,lo,hi);

        for (ll b=lo; b<=hi; ++b) {
            ll t = f(b,n);
            // fprintf(stderr, " f(b=%lld, n=%lld) = %lld : %lld\n", b,n,t,s);
            if (t == s) best = min(best, b);
        }
    }
    // if (best != n+1LL) return best;

    ll sq = sqrt(n);
    for (ll q=1; q<=sq; ++q) {
        ll r = s - q;
        if ((n - r) % q == 0) {
            ll b = (n-r) / q;
            if (f(b,n) == s) {
                best = min(best, b);
            }
        }
    }
    return (best == n+1LL) ? -1 : best;
}

int main() {
    ll n, s;
    cin >> n;
    cin >> s;
    cout << solve(n, s) << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t L, R;
  cin >> L >> R;
  if (R - L >= 2018) {
    cout << 0 << endl;
  }
  else {
    int ans = 2020;
    L = L % 2019;
    R = R % 2019;
    for (int i = L; i < R; i++) {
      for (int j = i + 1; j <= R; j++) {
        int memo = (i * j) % 2019;
        ans = min(ans, memo);
        if (ans == 0) {
          break;
        }
      }
    }
    cout << ans << endl;
  }
}

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

int main(){
  int n,ev=0,ans1=1; cin>>n;
  for(int i=0;i<n;i++){
    int a; cin>>a;
    if(a%2==0)ev++;
    ans1*=3;
  }
  
  int ans2=1;
  for(int i=0;i<ev;i++)ans2*=2;
  
  cout<<ans1-ans2<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    string s,t;
    cin >> s >> t;
    int cnt = 0;
    int min = INF;
    REP(i,s.size()){
        if(i > s.size() - t.size())
        break;
        REP(j,t.size()){
            if(s[i + j] != t[j])
                cnt++;
        }
        CMIN(min,cnt);
        cnt = 0;
    }
    if(min == INF)
    min = t.size();
    println(min);
    return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    VL x;
    LL cnt = 1;
    REP(i,n-1){
        if(s[i] == s[i+1]){
            cnt++;
        }else{
            x.PB(cnt);
            cnt = 1;
        }
    }
    x.PB(cnt);

    LL ans = 0;
    LL sz = x.size();
    REP(i,sz)ans += x[i]-1;
    REP(i,k){
        if(sz == 1){
            break;
        }
        else if(sz == 2){
            ans += 1;
            break;
        }else{
            ans += 2;
            sz -= 2;
        }
    }
    PUTS(ans);
}

Measured memory_bytes: 1480
#include <iostream>
#include <algorithm>

using namespace std;
int main() {
    int N, M;
    int L[100001], R[100001];
    cin >> N >> M;
    for (int i=0; i<M; i++) {
        cin >> L[i] >> R[i];
    }
    sort(L, L+M);
    sort(R, R+M);
    if (L[M-1] > R[0]) cout << 0 << endl;
    else {
        cout << (R[0] - L[M-1] + 1) << endl;
    }
    return 0;
}



Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Threading.Tasks;
 
static class Program
{
  static void Main()
  {
    var inputVal = Console.ReadLine().Split(' ');
    int A = int.Parse(inputVal[0]);
    int B = int.Parse(inputVal[1]);
    int val = 0;
    if(A > 12)
      val = B;
    else if (A >= 6)
      val = B / 2;
    Console.WriteLine(val);
  }
}

Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
 
 
int main() {
    int N;
    scanf("%d", &N);
    vector< tuple< int, int, int>> G;
    //G.emplace_back(make_tuple(1, 2, 0));
 
    int sink = 1;
    int val = 1;

    bool ok = false;
    for (int i = 30; i >= 0; i--) {
        if (ok or ((N >> i) & 1)) {
            ok = true;
            for (i--; i >= 0; i--) {
                val *= 2;
                for (auto& it : G) {
                    get<2>(it) = get<2>(it) * 2;
                }
                sink++;
                G.emplace_back(make_tuple(sink - 1, sink, 0));
                G.emplace_back(make_tuple(sink - 1, sink, 1));
 
                if ((N >> i) & 1) {
                    val++;
                    G.emplace_back(make_tuple(1, sink, val - 1));
                }
            }
        }
    }
 
    //assert(sink <= 20);
    printf("%d %d\n", sink, (int) G.size());
    for (auto it : G) {
        int u, v, w;
        tie(u, v, w) = it;
        printf("%d %d %d\n", u, v, w);
    }
}

Measured memory_bytes: 384
#include <stdio.h>

int main() {
	int i, j;

	for (i = 0; i < 9; i++)
		for (j = 0; j < 9; j++)
			printf("%dx%d=%d\n", i + 1, j + 1, (i + 1) * (j + 1));
	
	return 0;
}

Measured memory_bytes: 520
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int nums[50];
ll dp[51][2509];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,A;
    cin>>N>>A;
    
    rep(i,N) cin>>nums[i];
    
    ll cnt=0;
    rep1(n,N){
        int num=A*n;
        mem(dp,0);
        dp[0][0]=1;
        rep(i,N)for(int k=min(i+1,n);k>0;k--){
            for(int j=nums[i];j<=num;j++){
                if(dp[k-1][j-nums[i]]){
                    dp[k][j]+=dp[k-1][j-nums[i]];
                }
            }
        }
        cnt+=dp[n][num];
    }
    cout1(cnt);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>

int main(void){
  long long int N,K; scanf("%lld %lld",&N,&K);
  long long int A = 0;

  for(long long int i = K;i <= N+1;i++){
    A += N*i - i*i + i + 1;
  }

  printf("%lld",A%1000000007);
  return 0;
}


Measured memory_bytes: 1736
/*input

*/
#include<bits/stdc++.h>

using namespace std;

typedef long long           ll;
typedef vector<int>         vi;
typedef pair<int,int>       ii;

#define endl                '\n'
#define ff                  first
#define pf                  printf
#define ss                  second
#define MX                  109
#define pb                  push_back
#define DB                  pf("Hi\n")
#define pf1(a)              pf("%.0f\n",a)
#define sc1(a)              scanf("%lf",&a)
#define mod(a,m)            (((a%m)+m)%m)
#define all(c)              (c).begin(),(c).end()
#define mem(a,b)            memset(a, b, sizeof(a))
#define RD                  freopen("0iuput.txt","r",stdin)
#define WR                  freopen("0uput.txt","w",stdout)
#define rep(i,a,b)          for(int i=int(a)-(a>b);i!=(b)-(a>b);i+=1-2*(a>b))
#define TC                  int ___T,case_n = 1;scanf("%d ",&___T);while(___T-->0)

int main()
{
    string s1,s2;
    int pal=0,mn = 1000, mx = 0;

    cin>>s1>>s2;

    sort(all(s1));
    sort(all(s2));
    reverse(all(s2));

    int sz1 = s1.size();
    int sz2 = s2.size();

    for(int i=1;i<=min(sz1,sz2);i++)
    {
        if(s1[i-1]<s2[i-1])
        {
            //cout<<s1[i-1]<<" "<<s2[i-1]<<endl;
            puts("Yes");
            return 0;
        }
    }

    for(int i=1;i<=min(sz1,sz2);i++)
    {
        if(s1[i-1]!=s2[i-1])
        {
            //DB;
            pal=1;
        }
    }

    if(sz1<sz2 and pal==0)puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
 
int N;//10^4
int a[10004],b[10004];;
int c[100004];
int ans=0;
vector<int> edges[10004];
int edgenum[10004];
//int deledgenum[10004];
queue<int> oneedge;
int d[10004];//ans
signed main(){
    scanf("%lld",&N);
    //priority_queue< pair<int,int>, vector< pair<int,int> >, greater< pair<int,int> > > q;
    rep(i,N-1){
        scanf("%lld %lld",&a[i],&b[i]);a[i]--;b[i]--;
        edges[a[i]].pb(b[i]);
        edges[b[i]].pb(a[i]);
        edgenum[a[i]]++;edgenum[b[i]]++;
    }
    rep(i,N){
        scanf("%lld",&c[i]);ans+=c[i];
    }
    sort(c,c+N);
    ans-=c[N-1];
    //rep(i,N)q.push(mp(edgenum[i],i));
    rep(i,N){
        d[i]=-1;
        if(edgenum[i]==1){
            oneedge.push(i);
            edgenum[i]--;
        }
    }
    int count=0;
    while(!oneedge.empty()){
        
        int vil=oneedge.front();oneedge.pop();
        //printf("%lld,", vil);
        d[vil]=c[count];
        rep(i,edges[vil].size()){
            int nvil=edges[vil][i];edgenum[nvil]--;
            if(edgenum[nvil]==1)oneedge.push(nvil);
        }
        count++;
    }
    printf("%lld\n", ans);
    rep(i,N){
        if(d[i]==-1)printf("%lld",c[N-1]);
        else printf("%lld",d[i]);
        if(i!=N-1)printf(" ");
        else printf("\n");
    }
}

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

int main() {
	int n;
	cin >> n;
	long long a[n];
	long long sum[n][2];
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sum[0][0] = a[0] + a[1];
	sum[0][1] = -a[0] - a[1];
	for(int i = 1; i < n - 1; i++) {
		sum[i][0] = max(sum[i-1][0], sum[i-1][1]) + a[i+1];
		sum[i][1] = max(sum[i-1][0] - 2*a[i]- a[i+1], sum[i-1][1] + 2*a[i] - a[i+1]);
	}
	cout << max(sum[n-2][0], sum[n-2][1]);
	return 0;
}


Measured memory_bytes: 2560
def root(i):
    global roots
    if roots[i]==i:
        return i
    else:
        roots[i]=root(roots[i])
        return roots[i]

def unite(i, j):
    global roots
    ri=root(i)
    rj=root(j)
    #roots[max(ri, rj)]=min(ri, rj)
    if ri==rj: return
    roots[ri]=rj

directions=[(-1, 0), (1, 0), (0, -1), (0, 1), (-1, -1), (-1, 1), (1, -1), (1, 1)]
while True:
    l=input().split()
    w=int(l[0])
    h=int(l[1])
    if w==0 and h==0: break
    map=[[False for _ in range(h+2)] for _ in range(w+2)]
    roots=[i for i in range((w+2)*(h+2))]
    for hi in range(h):
        l=input().split()
        for wi in range(w):
            map[wi+1][hi+1]=bool(int(l[wi]))

    for hi in range(1, h+1):
        for wi in range(1, w+1):
            if not map[wi][hi]: continue
            i=hi*(w+2)+wi
            for d in directions:
                if not map[wi+d[0]][hi+d[1]]: continue
                j=(hi+d[1])*(w+2)+(wi+d[0])
                unite(i, j)
    res=set()
    for hi in range(1, h+1):
        for wi in range(1, w+1):
            if not map[wi][hi]: continue
            i=hi*(w+2)+wi
            res.add(root(i))
    print(len(res))



Measured memory_bytes: 6204
#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 2  # type: int


def main():
    N, M = map(int, input().split())
    K = []
    S = []
    for _ in range(M):
        kk, *rest = map(int, input().split())
        K.append(kk)
        S.append(rest)
    P = list(map(int, input().split()))
    # print(N, M)
    # print(K, S, P)

    counter = 0
    for n in range(2**N):    # 全探索
        flag = True
        # print("{0:04b}".format(n))
        for k, s, p in zip(K, S, P):
            # print(k, s, p)
            sumof = 0
            for ss in s:
                sumof += (n >> (ss-1))
            sumof %= 2
            if sumof != p:
                flag = False
                break
        if flag:
            counter += 1
    print(counter)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
x,y=map(str,input().split())
list=[['A',10],['B',11],['C',12],['D',13],['E',14],['F',15]]
for i in range(6):
  if x==list[i][0]:
    xx=list[i][1]
  if y==list[i][0]:
    yy=list[i][1]
if xx>yy:
  print('>')
if xx==yy:
  print('=')
if xx<yy:
  print('<')

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

const ll MOD = 1000000007;
int N, M;
map<int, int> factor;

ll inv[200010];
ll fac[200010], finv[200010];

void init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll i = 2; i < 200010; i++) {
    inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
    fac[i] = i * fac[i-1] % MOD;
    finv[i] = inv[i] * finv[i-1] % MOD;
  }
}

ll comb(ll n, ll k) {
  return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  init();
  cin >> N >> M;
  for (int i = 2; (ll)i*i <= M; i++) {
    if (M % i) continue;
    while (M % i == 0) {
      factor[i]++;
      M /= i;
    }
  }
  if (M != 1) factor[M]++;

  ll ans = 1;
  for (auto p : factor) {
    ans *= comb(N-1+p.second, N-1);
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4992
# coding: utf-8


def solve(*args: str) -> str:
    x = int(args[0])

    ret = None
    for b in range(120):
        for a in range(b, 120):
            a5, b5 = pow(a, 5), pow(b, 5)
            if a5-b5 == x:
                ret = (a, b)
                break
            elif a5+b5 == x:
                ret = (a, -b)
                break

    return ' '.join(map(str, ret))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 9156
n=input()
a=int(n[0])
b=int(n[1])
c=int(n[2])
d=int(n[3])

kotae=''

if a+b+c+d==7:
    kotae+=str(a)
    kotae+='+'
    kotae+=str(b)
    kotae+='+'
    kotae+=str(c)
    kotae+='+'
    kotae+=str(d)
    kotae+='='
    kotae+=str(7)
elif a+b+c-d==7:
    kotae+=str(a)
    kotae+='+'
    kotae+=str(b)
    kotae+='+'
    kotae+=str(c)
    kotae+='-'
    kotae+=str(d)
    kotae+='='
    kotae+=str(7)
elif a+b-c+d==7:
    kotae+=str(a)
    kotae+='+'
    kotae+=str(b)
    kotae+='-'
    kotae+=str(c)
    kotae+='+'
    kotae+=str(d)
    kotae+='='
    kotae+=str(7)
elif a+b-c-d==7:
    kotae+=str(a)
    kotae+='+'
    kotae+=str(b)
    kotae+='-'
    kotae+=str(c)
    kotae+='-'
    kotae+=str(d)
    kotae+='='
    kotae+=str(7)
elif a-b+c+d==7:
    kotae+=str(a)
    kotae+='-'
    kotae+=str(b)
    kotae+='+'
    kotae+=str(c)
    kotae+='+'
    kotae+=str(d)
    kotae+='='
    kotae+=str(7)
elif a-b+c-d==7:
    kotae+=str(a)
    kotae+='-'
    kotae+=str(b)
    kotae+='+'
    kotae+=str(c)
    kotae+='-'
    kotae+=str(d)
    kotae+='='
    kotae+=str(7)
elif a-b-c+d==7:
    kotae+=str(a)
    kotae+='-'
    kotae+=str(b)
    kotae+='-'
    kotae+=str(c)
    kotae+='+'
    kotae+=str(d)
    kotae+='='
    kotae+=str(7)
elif a-b-c-d==7:
    kotae+=str(a)
    kotae+='-'
    kotae+=str(b)
    kotae+='-'
    kotae+=str(c)
    kotae+='-'
    kotae+=str(d)
    kotae+='='
    kotae+=str(7)
print(kotae)

Measured memory_bytes: 38384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		for(;;){
			String[] sss=br.readLine().split(" ");
			int m = Integer.parseInt(sss[0]);
			int n = Integer.parseInt(sss[1]);
			if(n+m==0)break;
			boolean[] mem=new boolean[m];
			Arrays.fill(mem,true);
			int idx=-1,cnt=m;;
			for(int i = 0;i<n;i++){
				for(int j = 0;j<m;j++){
					idx++;
					idx=idx%mem.length;
					if(mem[idx]){
						break;
					}
				}
				int r=right(i+1);
				String s =br.readLine();
				if(cnt==1){
					continue;
				}
				int g=0;
				try{
					g=Integer.parseInt(s);
				}
				catch(NumberFormatException e){
					if(s.equals("Fizz")){
						g=-1;
					}
					else if(s.equals("Buzz")){
						g=-2;
					}
					else if(s.equals("FizzBuzz")){
						g=-3;
					}
					else{
						g=0;
					}
				}

				//System.out.println(r+" "+cnt);
				if(r!=g){
					mem[idx]=false;
					cnt--;
				}
			}
			boolean first=true;
			for(int i = 0;i<mem.length;i++){
				if(mem[i]){
					if(first){
						System.out.print(i+1);
						first=false;
					}
					else{
						System.out.print(" "+(i+1));
					}
				}
			}
			System.out.println();
			
		}
		
	}
	static int right(int a){
		if(a%15==0)
			return -3;
		else if(a%5==0){
			return -2;
		}
		else if(a%3==0){
			return -1;
		}
		return a;
	}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n){
    cin>>a[i];
    a[i]-=i+1;
  }
  sort(a,a+n);
  int mid=a[n/2];
  ll ans=0;
  rep(i,0,n) ans+=abs(a[i]-mid);
  cout<<ans<<endl;
}

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

bool overlap(long long x1, long long y1, long long x2, long long y2) {
    return !(y1<x2 || y2<x1);
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, A, B, C, D;
    cin >> n >> A >> B >> C >> D;
    for (int i=0; i<n-1; ++i) {
        if (overlap(1LL*(n-i-1)*C, 1LL*(n-i-1)*D, 1LL*i*C-B+A, 1LL*i*D-B+A)) {
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
}


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

using ll = long long;
using P = pair<int, int>;

static const ll MAX_N = 1e5+9;
static const ll MAX_M = 1e5+9;

int N, M;
int A[MAX_N];
P BC[MAX_M];

int main() {
  cin >> N >> M;
  for (int i{}; i < N; ++i) {
    cin >> A[i];
  }
  sort(A, A+N);

  for (int i{}; i < M; ++i) {
    int b, c;
    cin >> b >> c;
    BC[i] = P{b, c};
  }
  sort(BC, BC+M, [](P l, P r) {
    if (l.second == r.second)
      return l.first > r.first;
    return l.second > r.second;
  });

  for (int i{}, j{}; j < M; ++j) {
    int b = BC[j].first;
    int c = BC[j].second;
    for (int k{}; k < b && i < N && A[i] < c; ++k) {
      A[i++] = c;
    }
  }

  ll sum{};
  for (int i{}; i < N; ++i) sum += A[i];

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
 
 
int main() {
    int n,m,ans=0,sum=0;
    cin >> n >> m;
    vector<int> A(n);
    rep(i,n){
        cin >> A[i];
        sum += A[i];
    }
    rep(i,n){
        if(A[i]*4*m>=sum) ans++;
    }
    cout << ((ans>=m) ? "Yes":"No") << endl;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner reader = new Scanner(System.in);
		int[] bil;
		bil = new int[11];
		for(int i = 1; i <= 10; i++){
		bil[i] = reader.nextInt();
		}
		for(int i = 1; i <= 3; i++){
			int max = bil[0];
			int nomor = 0;
			for(int j = 1; j <= 10; j++){
				if (max < bil[j]){
					max = bil[j];
					nomor = j;
				}
			}
			bil[nomor]=0;
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 17360
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define NIL -1
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<char>>;
using P =pair<int,int>;

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const ll mod=1000000007;

int main(){
    string n;
    cin>>n;
    int len=n.size();
    int sum=0;
    rep(i,len){
        sum+=n[i]-'0';
    }
    if(sum%9==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
long long dp[100010];
int main() {
	int N; cin >> N;
	long long h[N];
	for (int i = 0; i < N; i++) cin >> h[i];
	for (int i = 0; i < 100010; i++)  dp[i] = INF;
	dp[0] = 0;
	for (int i = 1; i < N; i++) {
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[N - 1] << endl;
	return 0;
}

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

int main() {
    long long s,c;
    cin>>s>>c;
    long long count=0;
    if(s>=c/2){
        count=c/2;
    }else{
        c-=2*s;
        count=s+c/4;
    }
    cout<<count<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

typedef long long ll;

int main(){
    string s;
    vector<char> as;
    cin >> s;
    int l = s.size();
    for(int i=0;i<(1<<(l-1));i++){
        int ans = s[0]-'0';
        vector<char> v;
        v.push_back(s[0]);
        for(int j=1;j<l;j++){
            if(i&(1<<(j-1))){
                ans +=(s[j]-'0');
                v.push_back('+');
                v.push_back(s[j]);
            }else{
                ans -=(s[j]-'0');
                v.push_back('-');
                v.push_back(s[j]);
                
            }
        }
        if(ans==7){
            as = v;
            break;
        }
    }
    for(int i=0;i<as.size();i++){
        cout << as[i];
    }
    cout << "=7"<< endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int N,K;
int i,g;
int A[100000];
int tmp;
int main() {
  cin >> N >> K;
  for(i=0;i<N;i++) {
    cin >> A[i];
  }
  while(1) {
    tmp = K+(K-1)*(g-1);
    if(N<=tmp) {
      break;
    }
    else {
      g=g+1;
    }
  }
  cout << g <<'\n';
  return(0);
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node{int p,l,r;};

Node T[MAX];
int n,D[MAX];
void print(int u){
  int i,c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";
  if(T[u].p == NIL) cout << "root, ";
  else if(T[u].l == NIL) cout << "leaf, ";
  else cout << "internal node, ";
  cout << "[";
  for(i=0,c=T[u].l; c != NIL;i++,c=T[c].r){
    if(i) cout << ", ";
    cout << c;
  }
cout << "]" << endl;
}
int rec(int u,int p){
  D[u]=p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}
int main(){
  int i,j,d,v,c,l,r;
  cin >> n;
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;
  for(i=0;i<n;i++){
    cin >> v >> d;
    for(j=0;j<d;j++){
      cin >> c;
      if(j==0)T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p == NIL) r = i;
  }
  rec(r,0);
  for(i=0;i<n;i++) print(i);
  return 0;
}
  



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

int main() {
  int N,A,B,cnt=0,flag=0;
  cin >> N ;
  for(int i=0;i<N;i++){
    cin >> A >> B ;
    if(A==B)cnt+=1;
    else if(A!=B)cnt=0;
    
    if(cnt>=3)flag=1;
  }
    if(flag==1){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
}


Measured memory_bytes: 3636
package main

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

func main() {
	l, r, d := readInt(), readInt(), readInt()
	ans := 0
	for i := l; i <= r; i++ {
		if i%d == 0 {
			ans++
		}
	}

	fmt.Println(ans)
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    vector<int>P(N);
    for(int i = 0; i < N; i++)cin >> P[i];
    vector<vector<int> >path(N);
    for(int i = 0; i < M; i++){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        path[x].push_back(y);
        path[y].push_back(x);
    }
    vector<int>flg(N, 0);
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(flg[i])continue;
        set<int>S1, S2;
        vector<int>V;
        flg[i] = 1;
        queue<int>Q;
        Q.push(i);
        while(!Q.empty()){
            int q = Q.front();
            Q.pop();
            S1.insert(q);
            S2.insert(P[q] - 1);
            for(int j = 0; j < path[q].size(); j++){
                int nxt = path[q][j];
                if(flg[nxt] == 0){
                    flg[nxt] = 1;
                    Q.push(nxt);
                }
            }
        }
        for(set<int>::iterator it = S1.begin(); it != S1.end(); it++){
            if(S2.find(*it) != S2.end())ans++;
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 15872
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict

N, K, L = map(int, input().split())

# Group1
G1 = [[] for i in range(N)]
for i in range(K):
    p, q = map(int, input().split())
    p -= 1
    q -= 1
    G1[p].append(q)
    G1[q].append(p)
gids = [0]*N
done = [False]*N
def dfs1(i, gid):
    gids[i] = gid
    done[i] = True
    for nex in G1[i]:
        if done[nex]: continue
        dfs1(nex, gid)
gid = 0
for i in range(N):
    if not done[i]:
        dfs1(i, gid)
        gid += 1

# Group2
G = [[] for i in range(N)]
for i in range(L):
    r, s = map(int, input().split())
    r -= 1
    s -= 1
    G[r].append(s)
    G[s].append(r)
done = [False]*N
D = []
gids2 = [0]*N
def dfs(i, gid):
    D[gid][gids[i]] += 1
    done[i] = True
    gids2[i] = gid
    for nex in G[i]:
        if done[nex]: continue
        dfs(nex, gid)
gid = 0
for i in range(N):
    if not done[i]:
        D.append(defaultdict(int))
        dfs(i, gid)
        gid += 1

# answer
ans = [0]*N
for i in range(N):
    ans[i] = D[gids2[i]][gids[i]]
print(*ans)


Measured memory_bytes: 125304
import java.util.Calendar;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		Calendar cal = Calendar.getInstance();
		cal.set(Integer.valueOf(S.split("/")[0]), Integer.valueOf(S.split("/")[1]), Integer.valueOf(S.split("/")[2]));

		Calendar cal2 = Calendar.getInstance();
		cal2.set(2019, 4, 30);
		if (cal.compareTo(cal2) < 0) {
			System.out.println("Heisei");
		} else {
			System.out.println("TBD");
		}
	}
}


Measured memory_bytes: 22992
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

vector<ll> my_merge(vector<ll> a, vector<ll> b, int k) {
    k = min(k, int(a.size()*b.size()));
    ll sum = a[0] + b[0];
    for(int i = a.size()-1; i >= 0; i--)
        a[i] = a[0] - a[i];
    for(int i = b.size()-1; i >= 0; i--)
        b[i] = b[0] - b[i];
    ll l = a[0]+b[0];
    ll r = a.back() + b.back();
    // printf("(l, r) = (%lld, %lld)\n", l, r);
    while (l < r) {
        ll mid = l + (r-l) / 2;
        ll cnt = 0; // find counts that <= mid
        for(int i = 0; i < a.size(); i++) {
            ll target = mid-a[i];
            auto it = upper_bound(b.begin(), b.end(), target);
            auto idx = distance(b.begin(), it);
            cnt += idx;
        }
        if (cnt < k)
            l = mid+1;
        else
            r = mid;
    }
    // cout << "find level " << l << endl;
    ll level = l;
    vector<ll> ans;
    for(int i = 0; i < a.size(); i++) {
        ll target = level-a[i];
        auto it = upper_bound(b.begin(), b.end(), target);
        auto idx = distance(b.begin(), it);
        for(int j = 0; j < idx; j++) {
            ans.push_back(sum-a[i]-b[j]);
        }
    }
    sort(ans.begin(), ans.end());
    reverse(ans.begin(), ans.end());
    // cout << "ans sizs = " << ans.size() << endl;
    return ans;
}
int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> A(x, 0);
    vector<ll> B(y, 0);
    vector<ll> C(z, 0);
    for(auto& val: A)
        cin >> val;
    for(auto& val: B)
        cin >> val;
    for(auto& val: C)
        cin >> val;
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    sort(B.begin(), B.end());
    reverse(B.begin(), B.end());
    sort(C.begin(), C.end());
    reverse(C.begin(), C.end());
    auto AB = my_merge(A, B, k);
    auto ABC = my_merge(AB, C, k);
    while(ABC.size() > k)
        ABC.pop_back();
    for(auto val: ABC)
        cout << val << endl;
    return 0;
}




Measured memory_bytes: 133856
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define put(arr,v) fil(all(arr) , v)
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define sort(v) sort(all(v));
#define fill_vec(v,val)  fill(all(v) , val)
#define fill_arr(ar,n,val) fill(ar , ar+n ,val)
#define nl cout<<"\n";
#define input_i(v) generate(all(v),nxt_i);
#define input_s(v) generate(all(v),nxt_s);
#define vst vector<string>
#define vi vector<int>
#define pi pair<int,int>

// namespace ohuefmi{
    
//     int nxt_i(){
//         int x;
//         cin>>x;
//         return x;
//     }
//     string nxt_s(){
//         string x;
//         cin>>x;
//         return x;
//     }
//     void print(vector<int>v){
//         for(auto i : v){
//             cout<<i<<" ";
//         }nl;
//     }
//      void print(vector<string>v){
//         for(auto i : v){
//             cout<<i<<" ";
//         }nl;
//     }
    
//     string binary(int n)
//     {
//         bitset<32>b(n) ;
//         string p =b.to_string();
//         return p;

//     }
//     int decimal(string s)
//     {
//         int res = 0;
//         for(int i = 0; i < s.size() ; i++ ){
//             if(s[i] == '1')
//             res = res + pow(2,s.size() - i -1);
//         }
//         return res;
//     }
//     bool isPrime(int n){
//         if (n <= 1) return false; if (n <= 3) return true;
//     if (n % 2 == 0 || n % 3 == 0) 
//         return false;
//     for (int i = 5; i * i <= n; i = i + 6) 
//         if (n % i == 0 || n % (i + 2) == 0) 
//             return false; 
  
//     return true; 
//     }
    
//      int pow (int x, int n,int mod) {//calculate x^n
//     if (n == 0) return 1;

//       int res = pow (x, n / 2,mod);

//     res = (res * res) % mod;
//     if (n % 2) res = (res * x ) % mod;

//     return res;
//     }
    
// }

// using namespace ohuefmi;

bool isPal(string s){
    
    
    for(int i =0 ;i < s.size() ; i++ ){
        if(s[i] !=s[s.size() - i - 1])
            return false;
    }
    return true;
}
int32_t main(){
    
    
        ios_base::sync_with_stdio(cin.tie(NULL));
        cout.tie(NULL);
    
        int tc = 1; 
        // tc = nxt_i();

        while(tc -- ){
            
            
            string s ;
            cin>>s;
            int n  = s.size();
            
            int flag = isPal(s);
            int ind1 = (n-1)/2;
            string p = s.substr(0,ind1);
            
            
            int ind2 = (n+3)/2;
            
            int len = n - ind2;
            
            string q = s.substr(ind2-1,len+1);
            
            // cout<<s<<" "<<p<<" "<<q<<endl;
            
            if(isPal(q) && isPal(p) && isPal(s))
                {
                    cout<<"Yes\n";
                }
            else
                cout<<"No\n";
            
        }       
       
      
      
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n, k;
 cin >> n >> k;
  char ch[n];
  for(int i = 0; i < n; ++i)
  {
  	cin >> ch[i];
  }
  int ans = 0;
  for(int i = 0; i < n-1; ++i)
  {
    if(ch[i] == ch[i + 1])
      ++ans;
  }
  cout << min(n-1, ans + 2*k);
 
}

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

template <typename T> int sgn(T val) {
    return (T(0) < val) - (val < T(0));
}

void solve(long long a, long long b){
    int s = 1;
    for (int i = a; i <= b; i++)
    {
        s *= sgn(i);
    }
    string ans;
    if(s>0) ans = "Positive";
    else if(s<0) ans = "Negative";
    else ans = "Zero";
    std::cout << ans << endl;
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
def main():
  import sys
  input = sys.stdin.readline
  n = int(input())
  a = [int(i) for i in input().split()]
  Ss = set(a)
  s = list(Ss)
  import collections
  c = collections.Counter(a)
  j = 0
  #print(c[a[0]])
  for i in range(len(s)):
    j += int(c[s[i]]*(c[s[i]]-1)/2)
  #print(j)
  for i in range(n):
      print(int(j-(c[a[i]]-1)))
if __name__ == '__main__':
    main()


Measured memory_bytes: 29940
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
typedef long long ll;

ll N;

ll sum( ll x ) {
    ll t = ( N / x );
    return ( t * ( t + 1 ) / 2 ) * x;
}

int main()
{
    optimiza_io
    cin >> N;
    cout << sum( 1 ) - sum( 5 ) - sum( 3 ) + sum( 15 ) << "\n";
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 3660
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;

long long gcd(long long x, long long y){
			if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }

int main(){
   int D,G;
   cin >> D >> G;
   vector<int> p(D),c(D);
   for(int i = 0;i < D;i++){
       cin >> p[i] >> c[i];
   }
  long long res = 1<<29;
  for (int bit = 0; bit < (1<<D);++bit){
      long long sum = 0;
      long long num = 0;
      for(int i = 0; i<D;i++){
          if(bit & (1<<i)) sum += c[i]+p[i]*100*(i+1),num += p[i];
      }
      if(sum >= G)res = min(res,num);
      else{
          for(int i = D-1;i>=0;i--){
              if(bit&(1<<i))continue;
              for(int j= 0;j<p[i];j++){
                  if(sum >= G)break;
                  sum += 100 * (i+1);
                  ++num;
              }
          }
          res = min(res,num);
      }
  }
  cout << res <<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1000000,ha=998244353;
inline int add(int x,int y){ x+=y; return x>=ha?x-ha:x;}
inline void ADD(int &x,int y){ x+=y; if(x>=ha) x-=ha;}
inline int ksm(int x,int y)
{
    int an=1;
    for(;y;y>>=1,x=x*(ll)x%ha) if(y&1) an=an*(ll)x%ha;
    return an;
}
int jc[maxn+5],ni[maxn+5],n,m,ans;
inline int C(int x,int y){ return x<y?0:jc[x]*(ll)ni[y]%ha*(ll)ni[x-y]%ha;}
inline void init()
{
    jc[0]=1;
    for(int i=1;i<=maxn;i++) jc[i]=jc[i-1]*(ll)i%ha;
    ni[maxn]=ksm(jc[maxn],ha-2);
    for(int i=maxn;i;i--) ni[i-1]=ni[i]*(ll)i%ha;
}
inline void solve()
{
    for(int i=1;i<=m;i++)
        ADD(ans,C(i<<1,i)*(ll)C(n+m-i*2,n-i)%ha);    
}
int main()
{
    init();
    scanf("%d%d",&n,&m);
    if(n<m) swap(n,m);
    solve();
    ans=ans*(ll)ni[2]%ha*(ll)ksm(C(n+m,n),ha-2)%ha;
    ADD(ans,n);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 8064
using System;
using System.Collections.Generic;

namespace AtCoder2020Ned
{
    class Program
    {
        static void Main(string[] args)
        {
            var lengthLimit = Convert.ToInt32(Console.ReadLine());
            var inputString = Console.ReadLine();

            if (inputString.Length <= lengthLimit)
            {
                Console.WriteLine(inputString);
            }
            else
            {
                var trimmedString =  inputString.Substring(0, lengthLimit);
                Console.WriteLine(trimmedString + "...");
            }

            Console.Read();
        }
    }
}


Measured memory_bytes: 27500
N = int(input())
H = list(map(int,input().split()))

max_count = 0
b = 0
while(b != N-1):
    count = 0
    for i in range(b,N-1):
        if H[i] >= H[i+1]:
            count += 1
            if i == N-2:
                b = i+1
                break
        else:
            b = i+1
            break
    if count > max_count:
        max_count = count
print(max_count)

Measured memory_bytes: 15020
#include<cstdio>
#include<algorithm>
using namespace std;
const long long mod=998244353;
long long n,m,power[1000010],ans;
void exgcd(long long a,long long b,long long &x,long long &y)
{
	if(!b)
	{
		x=1;
		y=0;
	}
	else
	{
		exgcd(b,a%b,y,x);
		y-=x*(a/b);
	}
}
long long inv(long long x,long long y)
{
	long long res,w;
	exgcd(x,y,res,w);
	return ((res%y)+y)%y;
}
long long C(long long x,long long y)
{
//	if(x==y)	return 1;
//	if(x==0)	return 1;
//	if(y==0)	return 1;
	return ((((power[x]*inv(power[y],mod))%mod)*inv(power[x-y],mod))%mod);
}
int main()
{
	scanf("%lld %lld",&n,&m);
	if(n>m)	swap(n,m);
	power[0]=1;
	for(long long i=1;i<=1000000;++i)	power[i]=(power[i-1]*i)%mod;
	for(long long i=1;i<=n;++i)	ans=(ans+C(2*i,i)*C(n+m-i-i,n-i))%mod;
//	printf("%lld\n",ans);
	ans=(ans*inv(2,mod))%mod;
//	printf("%lld\n",ans);
	ans=(ans*inv(C(n+m,n),mod))%mod;
//	printf("%lld %lld\n",C(n+m,n),ans);
//	ans=(((ans*inv(2,mod))%mod)*inv(C(n+m,n),mod))%mod;
	printf("%lld",(ans+m)%mod);
	return 0;
}

Measured memory_bytes: 11040
N = int(input())

dp = [[0]*3 for _ in range(N)]
dp[0] = list(map(int, input().split()))

for i in range(1, N):
  h = list(map(int, input().split()))
  for j in range(3):
    dp[i][j] = max([dp[i-1][k]+h[j] for k in range(3) if k != j])

print(max([dp[N-1][j] for j in range(3)]))

Measured memory_bytes: 22824