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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

typedef unsigned int  UI;
typedef vector<UI>    VUI;
typedef vector<VUI>   VVUI;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP(x) cerr << #x << " = " << (x) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent=false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);

template<typename T = int> inline T in() { T x; cin >> x; return x; }
template<typename T = int> inline vector<T> in(int n) { vector<T> xs(n); rep(i, n) cin >> xs[i]; return xs; }
template<typename T = int> inline vector<vector<T>> in(int n, int m) { vector<vector<T>> xs(n, vector<T>(m)); rep(i, n) rep(j, m) cin >> xs[i][j]; return xs; }

int main(void) {
    int N, T;
    cin >> N >> T;
    VI as = in(N);

    VI maxs(N);
    int t = 0;
    rrep(i, N) {
        maxs[i] = t;
        MAXUD(t, as[i]);
    }

    int cnt = 0;
    int m = 0;

    rep(i, N) {
        int d = maxs[i] - as[i];
        if (d < m) continue;
        if (d > m) {
            cnt = 0;
            m = d;
        }
        ++cnt;
    }

    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

ll inf=1e18;

int main() {
  ll a,b,q;
  cin >> a >> b >> q;
  vector<ll> s(a);
  vector<ll> t(b);
  for(ll i=0;i<a;i++) {
    cin >> s[i];
  }
  for(ll i=0;i<b;i++) {
    cin >> t[i];
  }
  vector<ll> x(q);
  for(ll i=0;i<q;i++) {
    cin >> x[i];
  }
  for(ll i=0;i<q;i++) {
    ll temp=lower_bound(s.begin(),s.end(),x[i])-s.begin();
    ll sx=-1;
    ll si=-1;
    ll tx=-1;
    ll ti=-1;
    if(temp<a) sx=s[temp];
    if(temp>0) si=s[temp-1];
    temp=lower_bound(t.begin(),t.end(),x[i])-t.begin();
    if(temp<b) tx=t[temp];
    if(temp>0) ti=t[temp-1];
    ll ans=inf;
    if(si!=-1&&ti!=-1) {
      ans=min(ans,x[i]-min(si,ti));
    }
    if(sx!=-1&&tx!=-1) {
      ans=min(ans,max(sx,tx)-x[i]);
    }
    if(sx!=-1&&ti!=-1) {
      ans=min(ans,(sx-ti)+min(sx-x[i],x[i]-ti));
    }
    if(si!=-1&&tx!=-1) {
      ans=min(ans,(tx-si)+min(tx-x[i],x[i]-si));
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3712
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if i % 2 == 0:
                if j % 2 == 0:
                    print('#', end = '')
                else:
                    print('.', end = '')
            else:
                if j % 2 == 0:
                    print('.', end = '')
                else:
                    print('#', end = '')
        print()
    print()


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

const int N = (int)1e6+7;
const int INF = (int)1e9+17;
const int mod = 998244353;

typedef long long ll;

int n, m;
ll d[N];
vector<pair<int,int>> g[N];



multiset<ll> dist;
multiset<pair<int,ll>> life_time;

ll getmin(int p) {
    while (!life_time.empty() && life_time.begin()->first < p) {
        dist.erase(dist.find(life_time.begin()->second));
        life_time.erase(life_time.begin());
    }
    if (dist.empty()) {
        cout << -1 << endl;
        exit(0);
    }
    return *dist.begin();
}

void update(int l, int r, ll dist) {
    life_time.insert({r, dist});
    ::dist.insert(dist);
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    cin >> n >> m;
    vector<int> ls = {1, n};
    for(int i = 0; i < m; ++i) {
        int l, r, x;
        cin >> l >> r >> x;
        g[l].emplace_back(r, x);
        ls.emplace_back(l);
    }
    sort(ls.begin(), ls.end());
    ls.erase(unique(ls.begin(), ls.end()), ls.end());
    for(int v : ls) {
        d[v] = (v == 1 ? 0 : getmin(v));
        for(const auto& e : g[v]) {
            update(v, e.first, d[v] + e.second);
        }
    }
    cout << d[n] << endl;

    return 0;
}


Measured memory_bytes: 33144
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}


int h,w;

/*P pro(int n){
    P res;
    res.first = n/w;
    if(n/h%2==0){
        res.second = n%w;
    }else{
        res.second = w-n%w;
    }
    return res;
}*/
vector<int> a;
int pro(int cnt){
    int res = 0;
    while(cnt>a[res]){
        cnt-=a[res];
        res++;
    }
    return res;
}

int main(){
    cin >> h >> w;
    int n;
    cin >> n;
    a.resize(n);
    REP(i,n){
        cin >> a[i];
    }
    vector<vector<int>> res(h,vector<int>(w,0));
    /*int cnt = 0;
    REP(i,n){
        REP(j,a[i]){
            P r = pro(i);
            res[r.first][r.second] = i+1;
            cnt++;
        }
        
    }*/
    int cnt = 0;
    for(int i=0;i+1<h;i+=2){
        REP(j,w){
            int c = pro(cnt+1);
            res[i][j]=c+1;
            cnt++;
        }
        RREP(j,w){
            int c = pro(cnt+1);
            res[i+1][j]=c+1;
            cnt++;
        }
    }
    if(h%2==1){
        REP(j,w){
            int c = pro(cnt+1);
            res[h-1][j]=c+1;
            cnt++;
        }
    }
    REP(i,h){
        REP(j,w){
            cout << res[i][j] << " ";
        }
        put("");
    }
    return 0;
}


Measured memory_bytes: 384
n = int(input())
nmax = 55556

prime = [True]*nmax
prime[0] = prime[1] = False
for i in range(2, int(nmax**0.5)+1):
  if not prime[i]: continue
  for j in range(2*i, nmax, i):
    prime[j] = False

arr = []
for i in range(2, nmax):
  if not prime[i]: continue
  if i%10 == 3:
    arr.append(i)
    if len(arr) == n: break

print(*arr, sep=' ')

Measured memory_bytes: 9260
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <cassert>
using namespace std;
int A[100005];
int main()
{
	int lo = 1000000000, hi = 0;
	int n;
	cin>>n;
	for (int i = 0; i < n; ++i)
	{
		cin>>A[i];
		lo = min(lo, A[i]);
		hi = max(hi, A[i]);
	}
	if(hi - lo > 1)
	{
		cout<<"No\n";
		return 0;
	}
	if(lo < hi)
	{
		int cols = hi;
		int lc = 0, gc = 0;
		for (int i = 0; i < n; ++i)
		{
			if(A[i] == lo)
				lc++;
			else
				gc++;
		}
		if(lc < cols && 2*(cols - lc) <= gc)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	else
	{
		if(n >= 2*lo)
			cout<<"Yes\n";
		else
		{
			if(n == lo + 1)
				cout<<"Yes\n";
			else
				cout<<"No\n";
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep4(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
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;}

void solve(vector<ll> x, vector<ll> y){
    vector<double> d;
    rep(i,3){
        d.push_back(sqrt((x[i]-x[(i+1)%3])*(x[i]-x[(i+1)%3])+(y[i]-y[(i+1)%3])*(y[i]-y[(i+1)%3])));
    }
    sort(all(d));

    double cosB=(d[2]*d[2]+d[0]*d[0]-d[1]*d[1])/(2*d[2]*d[0]);
    double cosC=(d[2]*d[2]-d[0]*d[0]+d[1]*d[1])/(2*d[2]*d[1]);
    double b=acos(cosB)/2;
    double c=acos(cosC)/2;

    double high=d[2];
    double low=0;
    rep(i,100){
        double r=(high+low)/2;
        if(r*(2+1/tan(b)+1/tan(c))<d[2])low=r;
        else high=r;
    }
    cout.precision(10);
    cout<<low<<endl;
}

int main(){
    vector<ll> x(3);
    vector<ll> y(3);
    for(int i = 0 ; i < 3 ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(move(x), move(y));
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;

const ll mod = 2019;

int main()
{
  ll L;
  scanf("%lld",&L);
  ll R;
  scanf("%lld",&R);

  ll l = L%mod;
  ll r = R%mod;
  if (R-L>=mod||l>=r) r+=mod;
  ll ans = inf;
  for (ll i=l; i<=r-1; i++) {
    for (ll j=i+1; j<=r; j++) {
      ans = min(ans, i*j%mod);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,t;cin>>n;
  int* a=new int[n]();
  for(int i=0;i<n-1;i++){
    cin>>t; a[t-1]++;
  }
  for(int i=0;i<n;i++){
  	cout<<a[i]<<endl;
  }
  return 0;
}  


Measured memory_bytes: 4360
N = int(input())
D, X = map(int, input().split())

sum = 0
A = []
for i in range(N):
    A.append(int(input()))

for i in range(N):
    if D % A[i] == 0:
        sum += int(D/A[i])
    else:
        sum += int(D/A[i])+1

print(sum+X)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

inline lli getint(){
    lli n;
    scanf("%lld",&n);
    return n;
}

inline vector<lli> getints(int n){
    vector<lli> a(n);
    for(int i=0;i<n;i++)scanf("%lld",&a[i]);
    return a;
}

inline string getstr(){
  string s;
  cin>>s;
  return s;
}

inline string slice(string s,int a,int b){
  return s.substr(a,b-a-1);
}
void dumpints(vector<lli> a){
  cout<<"[";
  for(int i=0;i<a.size()-1;i++){
    cout<<a[i]<<",";
  }
  cout<<a[a.size()-1]<<"]"<<endl;
}

template<class T> bool ifinclude(vector<T> a,T x){
    auto itr=find(a.begin(),a.end(),x);
    return distance(a.begin(),itr)!=a.size();
}

int main(void){
  lli N=getint();
  vector<lli> A(N),B(N);
  FOR(i,N){
    A[i]=getint();
    B[i]=getint();
  }
  lli c=0;
  for(int i=N-1;i>=0;i--){
    if((A[i]+c)%B[i]!=0&&B[i]>1)c+=B[i]-(A[i]+c)%B[i];
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 1792
uses crt;
var i,n,count,j: longint;
a: array[1..300000] of longint;
begin
clrscr;
read(n);
FOR i:=1 TO n do read(a[i]);
i:=1;  j:=1;
while (i<=n) and(j<=n) do
begin
while (a[j]<>i) and (j<=n) do begin inc(count);  inc(j); end;
inc(j);
inc(i);
end;
if count=n then write('-1') else write(count);
readln;
readln;
end.


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

int main() {
    int x, n;
    cin >> x >> n;
    if (n == 0) {
        cout << x << endl;
        return 0;
    }
    vector<int> p(n);
    rep(i, 0, n) {
        cin >> p[i];
    }

    vector<int> ans;
    int i = 0;
    while (true) {
        int a = x + i;
        bool flag1 = true;
        rep(i, 0, n) {
            if (p[i] == a) {
                flag1 = false;
                break;
            }
        }
        if (flag1) ans.push_back(a);
        int b = x - i;
        bool flag2 = true;
        rep(i, 0, n) {
            if (p[i] == b) {
                flag2 = false;
                break;
            }
        }
        if (flag2) ans.push_back(b);
        if (flag1 || flag2) break;
        i++;
    }
    sort(ans.begin(), ans.end());
    cout << ans[0] << endl;

    return 0;
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
char f(int i) {
	if (i)return '-';
	return '+';
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int a = s[0] - '0', b = s[1] - '0', c = s[2] - '0', d = s[3] - '0';
	REP(i, 1 << 3) {
		
		
			int tb = b, tc = c, td = d;
			if (i & 1)tb *= -1;
			if (i & 2)tc *= -1;
			if (i & 4)td *= -1;
			if (a + tb + tc + td == 7) {
				cout << a <<f(i&1)<< b <<f(i&2)<< c <<f(i&4)<< d << "=7" << endl;
				return 0;
			}
		
	}
}


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



int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif


    int n;
    while (scanf("%d", &n) == 1) {
        vector<vector<int> > p(2, vector<int>(n));
        vector<vector<vector<int> > > e(2, vector<vector<int> >(n));
        vector<int> root(2);
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < n; j++) {
                scanf("%d", &p[i][j]);
                if (p[i][j] != -1) e[i][--p[i][j]].push_back(j);
                else root[i] = j;
            }
        }

        bool ok = 1;
        for (int i = 0; i < n; i++) {
            ok &= e[0][i].size() % 2 == e[1][i].size() % 2;
        }
        if (!ok) {
            printf("IMPOSSIBLE\n");
            continue;
        }
        printf("POSSIBLE\n");

        const int T = 999;
        vector<int> ans(n + 1, -T);
        vector<vector<int> > g(n);
        for (int i = 0; i < 2; i++) {
            function<int(int)> dfs = [&](int v) {
                vector<int> vct;
                if (e[i][v].size() % 2 == 0) {
                    vct.push_back(v);
                } else ans[v] = 0;
                for (int to : e[i][v]) {
                    int o = dfs(to);
                    if (o != -1) vct.push_back(o);
                }
                while (vct.size() > 1) {
                    int v1 = vct.back();
                    vct.pop_back();
                    int v2 = vct.back();
                    vct.pop_back();
                    g[v1].push_back(v2);
                    g[v2].push_back(v1);
                }
                if (vct.size() > 0) return vct[0];
                return -1;
            };
            dfs(root[i]);
        }
        for (int i = 0; i < n; i++) {
            if (ans[i] == -T) {
                function<void(int, int)> dfs = [&](int v, int c) {
                    if (ans[v] != -T) {
                        assert(ans[v] == c);
                        return;
                    }
                    ans[v] = c;
                    c *= -1;
                    for (int to : g[v]) {
                        dfs(to, c);
                    }
                };
                dfs(i, 1);
            }
        }


        for (int i = 0; i < n; i++) printf("%d%c", ans[i], " \n"[i + 1 == n]);
    }


#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

Measured memory_bytes: 18640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  string A,B,C;
  cin >> A >> B >> C;
  if(A.at(A.size()-1)==B.at(0) && B.at(B.size()-1)==C.at(0))  cout << "YES" << endl;
  else  cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[]d = new int[6];
		for(int i = 0; i < 6; i++) {
			d[i] = scan.nextInt();
		}
		int q = scan.nextInt();
		for(int i = 0; i < q; i++) {
			int a = scan.nextInt();
			int b = scan.nextInt();
			if((a==d[1]&&b==d[2])||(a==d[3]&&b==d[1])||(a==d[4]&&b==d[3])||(a==d[2]&&b==d[4])) {
				System.out.println(d[0]);
			}else if((a==d[0]&&b==d[3])||(a==d[2]&&b==d[0])||(a==d[5]&&b==d[2])||(a==d[3]&&b==d[5])) {
				System.out.println(d[1]);
			}else if((a==d[0]&&b==d[1])||(a==d[4]&&b==d[0])||(a==d[5]&&b==d[4])||(a==d[1]&&b==d[5])) {
				System.out.println(d[2]);
			}else if((a==d[0]&&b==d[4])||(a==d[1]&&b==d[0])||(a==d[5]&&b==d[1])||(a==d[4]&&b==d[5])) {
				System.out.println(d[3]);
			}else if((a==d[0]&&b==d[2])||(a==d[3]&&b==d[0])||(a==d[5]&&b==d[3])||(a==d[2]&&b==d[5])) {
				System.out.println(d[4]);
			}else {
				System.out.println(d[5]);
			}
		}
		scan.close();
	}
}


Measured memory_bytes: 26340
object Main {
  def main(args: Array[String]): Unit = {
    val Array(problem_num, answer_num) = io.StdIn.readLine.split(" ").map{_.toInt}

    var count = 0
    var problem = Vector.empty[Tuple2[Int, String]]

    while(count < answer_num) {
      val Array(ans_num, pass_or_fail) = io.StdIn.readLine.split(" ")
      problem = problem :+ (ans_num.toInt, pass_or_fail)
      count += 1
    }

    var check_num = 0
    var check = false
    var fail_count = 0
    var fail_each_count = 0
    var pass_count = 0
    problem.sortBy(_._1).foreach { i =>
      if ( check_num != i._1 ) {
        check_num = i._1
        check = false
        fail_each_count = 0
      }

      if(!check) {
        if(i._2 == "AC") {
          pass_count += 1
          check = true
          fail_count += fail_each_count
        }
        else {
          fail_each_count += 1
        }
      }
    }
    println(pass_count.toString + " " + fail_count.toString)
  }
}

Measured memory_bytes: 79684
#include <vector>
#include <iostream>

using namespace std;

typedef vector<int> int_vec;

bool linear_search(const int_vec& v, int n) {
    for (int_vec::const_iterator it = v.begin(); it != v.end(); ++it) {
        if (*it == n) {
            return true;
        }
    }
    return false;
}

bool binary_search(int_vec::iterator begin, int_vec::iterator end, int n) {
    while (begin < end) {
        int_vec::iterator mid = begin + ((end - begin) / 2);
        if (*mid == n)
            return true;
        else if (n < *mid)
            end = mid;
        else
            begin = mid+1;
    }
    return false;
}

int main()
{
    int n;
    cin >> n;
    int_vec S;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        S.push_back(x);
    }

    int q;
    cin >> q;
    int_vec T;
    for (int j = 0; j < q; ++j) {
        int x;
        cin >> x;
        T.push_back(x);
    }

    int c = 0;
    for (int_vec::iterator it = T.begin(); it != T.end(); ++it) {
        if (binary_search(S.begin(), S.end(), *it))
            c++;
    }
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 3440
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,m;
    string s,t;
    cin >> n >> m >> s >> t;
    ll l = n * m / __gcd(n,m);
    map<ll,char> mp;
    for (int i = 0; i < n; ++i)
        mp[l/n*i] = s[i];
    for (int i = 0; i < m; ++i) {
        ll j = l / m * i;
        if (mp.count(j) && mp[j] != t[i])
            return cout<<"-1\n",0;
        mp[j] = t[i];
    }
    cout << l << endl;
}


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N, K;
  cin >> N >> K;
  ll ans = 1;
  vector<vector<int> > v(N);
  vector<int> a(N);
  vector<int> b(N);
  vector<int> d(N);
  vector<bool> seen(N, false);
  queue<int> que;
  rep(i, N-1) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    v[a[i]].pb(b[i]);
    v[b[i]].pb(a[i]);
  }
  int s = 0;
  que.push(s);
  seen[s] = true;
  d[s] = 0;
  ans *= ll(K);
  int tmp = K;
  int cnt = 0;
  while(!que.empty()) {
    s = que.front();
    que.pop();
    if (d[s] == 0)
      tmp = K-1;
    else
      tmp = K-2;
    for (int i = 0; i < v[s].size(); i++) {
      int t = v[s][i];
      if (seen[t] == false) {
        que.push(t);
        seen[t] = true;
        d[t] = d[s]+1;
        // cout << tmp << ' ';
        ans *= (ll)tmp;
        ans %= MOD;
        tmp--;
      }
    }
    // cout << s << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 7672
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll N, C[200010];
ll pow2[200010];

signed main(){
    cin >> N;
    REP(i, N) cin >> C[i];
    sort(C, C + N, greater<ll>());
    pow2[0] = 1;
    REP(i, N) pow2[i + 1] = (pow2[i] * 2) % MOD;
    ll L, R, ans = 0;
    REP(i, N){
        if(i == 0) L = 1;
        else L = (i + 2) * pow2[i] % MOD * pow2[i - 1] % MOD;
        R = pow2[N - 1 - i] * pow2[N - 1 - i] % MOD;
        ans = (ans + 2 * L % MOD * R % MOD * C[i] % MOD) % MOD;
    }
    PRINT(ans);
    return 0;
}



Measured memory_bytes: 6776
#入力の高速化
import sys
input = sys.stdin.readline

#####segfunc#####
def segfunc(x, y):
    return max(x,y)
#################

#####ide_ele#####
ide_ele =-float('inf')
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res


n,k= map(int, input().split())
a= [int(input()) for i in range(n)]


v = [-float('inf')]*(pow(10,5)*3+1)
seg = SegTree(v, segfunc, ide_ele)

# dp[i]:最終要素が1の時に作れる最長部分列
for i in a:
    r=min(i+k+1,3*pow(10,5)+1)
    l=max(i-k,0)
    if seg.query(l, r)==-float('inf'):
        seg.update(i, 1)
    else:
        x=seg.query(l, r)
        seg.update(i,x+1)

print(seg.query(0,pow(10,5)*3+1))

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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  auto count_div = [&](int x) {
    int res = 0;
    for (int i = 1; i <= x; ++i) {
      res += (x % i == 0);
    }
    return res;
  };
  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    ans += count_div(i) == 8;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MAXN = 1024;

vector<bool> seen;
VI p, q, x;
int cnt = 0, a = -1, b = -1;

// 再帰関数による全探索 (深さ優先探索)
void permutation(int depth, int n) {
    // cout << depth << n << endl;
    if(depth == n) {
        ++cnt;
        if(x == p) a = cnt;
        if(x == q) b = cnt;
        // PRINT(x);
        return;
    }

    for(int i = 0; i < n; ++i) {
        if(seen[i] == false) {
            x[depth] = i + 1;
            seen[i] = true;
            permutation(depth + 1, n);
            seen[i] = false;
        }
    }
}

void saiki(int d) {
    cout << d << endl;
    if (d == 4) return;
    saiki(d + 1);
}

int main()
{
    int n; cin >> n;
    p.assign(n, 0);
    q.assign(n, 0);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    
    seen.assign(n, false);
    
    x.assign(n, 0); // rep(i, n) x[i] = i + 1;
    permutation(0, n);

    cout << abs(a - b) << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
count = {}
max_count = 0
for _ in range(N):
  s = input()
  if s not in count:
    count[s] = 0
  count[s] += 1
  max_count = max(max_count, count[s])

longest = []
for s, c in count.items():
  if c == max_count:
    longest.append(s)

longest.sort()
for s in longest:
  print(s)

Measured memory_bytes: 146984
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
inline int read(){
	int x=0;char ch=getchar();
	while (!isdigit(ch)) ch=getchar();
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x;
}
int a[100005],n,c[100005],x=0,y,v;
ll p[100005],inv[100005];
ll q_pow(ll x,ll y){
	ll res=1;
	while (y){
		if (y&1) res=(res*x)%mod;
		x=(x*x)%mod;
		y>>=1;
	}
	return res;
}
ll C(int n,int m){
	if (n<m||m<0||n<0) return 0;
	return p[n]*inv[m]%mod*inv[n-m]%mod;
}
int main(){
	n=read();
	for (int i=1;i<=n+1;++i) a[i]=read(),++c[a[i]];
	for (int i=1;i<=n;++i) if (c[i]==2) v=i;
	for (int i=1;i<=n+1;++i) if (a[i]==v){
		if (x) y=i;
		else x=i;
	}
	p[0]=1;for (int i=1;i<100005;++i) p[i]=(p[i-1]*i)%mod;
	for (int i=0;i<100005;++i) inv[i]=q_pow(p[i],mod-2);
	for (int k=1;k<=n+1;++k){
		printf ("%lld\n",((C(n-1,k-2)-C(n-y+x,k-1)+C(n-1,k)+2*C(n-1,k-1)%mod+mod))%mod);
	}
	return 0;
}


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


int main(){
    int n, m;
    cin >> n >> m;
    map<ll, ll> mp;
    vector<ll> a(n), b(n);
    rep(i,n) cin >> a[i] >> b[i];
    rep(i,n) mp[a[i]] += b[i];
    sort(a.begin(), a.end());
    int i = 0;
    ll sum=0, ans = 0;
    for(i=0;i<n;i++){
        if(i>0 && a[i]==a[i-1]) continue;
        if(sum + mp[a[i]] >= m){
            ans += (m-sum)*a[i]; 
            break;
        }
        sum += mp[a[i]];
        ans += a[i] * mp[a[i]];
    }
    cout << ans << endl;
}

Measured memory_bytes: 8064
a,b,c=map(int,input().split())
q=set()
ans=0
while True:
    if (a,b,c) in q:
        print(-1)
        exit()
    q.add((a,b,c))
    if a%2==0 and b%2==0 and c%2==0:
        ans+=1
        a,b,c=(b+c)//2,(a+c)//2,(b+a)//2
    else:
        break
print(ans)
    
    


Measured memory_bytes: 3060
N = int(input())
T = list(map(int, input().split()))
M = int(input())
L = []
res = []
for i in range(M):
    P, X = map(int, input().split())
    buf = []
    for j in range(len(T)):
        if P == j+1:
            buf.append(X)
        else:
            buf.append(T[j])
    res.append(sum(buf))

for i in res:
    print(i)


Measured memory_bytes: 9164
/*
 * WelcomeToAtCoder.cpp
 *
 *  Created on: 2020/02/19
 *      Author: black
 */

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
	    int a, b;

	    cin >> a >> b;


	    cout << a*b << endl;

	    return 0;
}


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

void update(ll& res, vector<pair<ll, ll>> candl, vector<pair<ll, ll>> candr) {
    for (auto pl : candl)for (auto pr : candr) {
        ll mn = min(min(pl.first, pl.second), min(pr.first, pr.second));
        ll mx = max(max(pl.first, pl.second), max(pr.first, pr.second));
        res = min(res, mx - mn);
    }
}

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N)cin >> A[i];
    auto imos = A;
    imos.insert(imos.begin(), 0);
    rep(i, N)imos[i + 1] += imos[i];

    ll res = 1ll << 60;
    REP(mid, 2, N - 1) {
        vector<pair<ll, ll>> candl, candr;
        ll tgtl = imos[mid] / 2, tgtr = (imos.back() + imos[mid]) / 2;
        ll idxl = lower_bound(imos.begin(), imos.begin() + mid + 1, tgtl) - imos.begin() - 3;
        REP(l, idxl, idxl + 7) {
            if (0 < l && l < mid) {
                candl.push_back({ imos[mid] - imos[l], imos[l] });
            }
        }
        ll idxr = lower_bound(imos.begin() + mid + 1, imos.end(), tgtr) - imos.begin() - 3;
        REP(r, idxr, idxr + 7) {
            if (mid < r&&r < N) {
                candr.push_back({ imos.back() - imos[r],imos[r] - imos[mid] });
            }
        }
        update(res, candl, candr);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 6400
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int t[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	cout << t[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 764
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())
d = {"r":r,"s":s,"p":p}
d_ = {"r":"p","s":"r","p":"s"}
t = [d_[i] for i in t]
l = [[] for _ in range(k)]
for i,j in enumerate(t):
    l[i%k].append(j)

def solve(l):
    score = 0
    k_ = {}
    for i,j in enumerate(l):
        if i == 0:
            score += d[j]
            k_[j] = 1
        elif l[i-1] != j:
            score += d[j]
            k_ = {}
            k_[j] = 1
        else:
            if k_[j] == -1:
                score += d[j]
            k_[j] *= -1
    return score
score = 0
for i in l:
    score += solve(i)

print(score)


Measured memory_bytes: 56456
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

inline long long f(long long x) {
  long long s = 1;
  while (1) {
    if (s&x) return s;
    s <<= 1;
  }
}

long long grundy;
int N;
long long L;

class Trie {
public:
  Trie *a[2];
  int rank;
  bool dead, after;

  Trie(int rank) : rank(rank) {
    a[0] = a[1] = NULL;
    dead = false;
    after = false;
  }
  void insert(const char *s) {
    assert(rank <= L);
    dead = true;
    if (*s == '\0') {
      after = true;
      return;
    }
    int k = *s - '0';
    if (a[k] == NULL) a[k] = new Trie(rank+1);
    a[k]->insert(s+1);
  }

  void solve() {
    if (after) return;
    if (!dead) {
      assert(false);
      return;
    }
    if (rank == L) return;
    rep(k, 2) {
      if (a[k] == NULL) {
        grundy ^= f(L-rank);
      }
      else a[k]->solve();
    }
  }
};

Trie trie(0);

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> L;
  trie.dead = true;
  rep(i, N) {
    string s;
    cin >> s;
    trie.insert(s.c_str());
  }
  grundy = 0;
  trie.solve();
  if (grundy == 0) cout << "Bob\n";
  else cout << "Alice\n";
  return 0;
}


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

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

int main()
{
  int W, H;
  while (cin >> W >> H) {
    if ((W|H) == 0)
      break;

    int x = 1, y = 1, d = 3;
    for ( ; ; ) {
      string cmd;
      cin >> cmd;
      if (cmd == "FORWARD") {
	int k;
	cin >> k;
	while (k-- && 
	       1 <= x + dx[d] && x + dx[d] <= W && 
	       1 <= y + dy[d] && y + dy[d] <= H) {
	  x += dx[d];
	  y += dy[d];
	}
      } else if (cmd == "BACKWARD") {
	int k;
	cin >> k;
	while (k-- &&
	       1 <= x + dx[(d+4-2)%4] && x + dx[(d+4-2)%4] <= W &&
	       1 <= y + dy[(d+4-2)%4] && y + dy[(d+4-2)%4] <= H) {
	  x += dx[(d+4-2)%4];
	  y += dy[(d+4-2)%4];
	}
      } else if (cmd == "RIGHT") {
	d = (d + 1) % 4;
      } else if (cmd == "LEFT") {
	d = (d + 4 - 1) % 4;
      } else {
	break;
      }
    }
    cout << x << " " << y << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	int N, M, C;
	cin >> N >> M >> C;

	vector<int> B(M);
	for (int i = 0; i < M; i++)
		cin >> B[i];

	int ans = 0;
	for (int i = 0; i < N; i++) {
		int sum = 0;
		int a;
		for (int j = 0; j < M; j++) {
			cin >> a;
			sum += a * B[j];
		}

		sum += C;
		if (sum > 0)
			ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b,c=1;cin>>a>>b;
  rep(i,a){
    c*=100;
  }
  if(b==100)cout<<c*(b+1);
  else cout<<c*b;
}


Measured memory_bytes: 23680
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <random>
#include <functional>
#include <bit>
#include <cstdint>

#include <fstream>
#include <vector>
#include <algorithm>

#define ll long long int
#define MOD 1000000007

using namespace std;

bool isPrime(ll n)
{
    if(n == 1)
    {
        return false;
    }
    for(ll i = 2; i*i <= n; i++)
    {
        if(n % i == 0)
        {
            return false;
        }
    }
    
    return true;
}

int main(void)
{

    
    ll n,res,t,k;
    vector<ll> a;
    
    res = 1000;
    k = 0;
    
    cin >> n;
    
    for(ll i = 0; i < n; i++)
    {
        cin >> t;
        a.push_back(t);
    }
    
    for(ll i = 0; i < n-1; i++)
    {
        if(a[i] < a[i+1])
        {
            k += res / a[i];
            ll tmp = res / a[i];
            res -= a[i] * tmp;
        }
        else if(a[i] > a[i+1])
        {
            res += a[i] * k;
            k = 0;
        }
    }
    
    for(;k > 0;)
    {
        k--;
        res += a[n-1];
    }
    
    cout << res;
    
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;



int main(void){
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> dist(n, vector<ll>(n, INF));
  REP(i, n) dist[i][i] = 0;
  vector<tuple<ll, ll, ll>> edge;
  REP(i, m){
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    dist[a][b] = c;
    dist[b][a] = c;
    edge.emplace_back(a, b, c);
  }
  REP(k, n) REP(i, n) REP(j, n) chmin(dist[i][j], dist[i][k] + dist[k][j]);

  ll ans = 0;
  REP(i, m){
    ll a, b, c;
    tie(a, b, c) = edge[i];
    bool ok = false;
    REP(j, n){
      if(dist[j][a] + c == dist[j][b]) ok = true;
    }
    if(!ok) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int N,M;
  cin>>N>>M;
  
  vector<int>oks(N+1,true);
  for(int i=0;i<M;++i){
    int a;cin>>a;
    oks[a]=false;
  }
  
  vector<long long int>dp(N+1);
  dp[0]=1;
  for(int now=0;now<N;++now){
    for(int next=now+1;next<=min(N,now+2);++next){
      if(oks[next]){
        dp[next]+=dp[now];
		dp[next]%=mod;
      }
    }
  }
  
    cout<<dp[N]<<endl;
    return 0;
}

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

int main(){
    string g,
        s="ABCDEFGHIJKLMNOPQRSTUVWXYZ ',-.?",
        str[34]={
            "100101","10011010","0101","0001","110","01001","10011011","010000",
            "0111","10011000","0110","00100","10011001","10011110","00101","111",
            "10011111","1000","00110","00111","10011100","10011101","000010",
            "10010010","10010011","10010000",
            "101","000000","000011","10010001","010001","000001"
        };
    while(getline(cin,g)){
        string t,tem;
        for(int i=0;i<g.length();i++)
            switch(g[i]){
                case ' ': t+=str[26];break;
                case '\'':t+=str[27];break;
                case ',': t+=str[28];break;
                case '-': t+=str[29];break;
                case '.': t+=str[30];break;
                case '?': t+=str[31];break;
                default:  t+=str[g[i]-'A'];
            }
        while(t.length()%5)t+='0';
        g="";
        for(int i=0;i<t.length();i++){
            tem+=t[i];
            if(tem.length()==5){
                int n=0;
                for(int j=0;j<5;j++)
                    n=n*2+tem[j]-'0';
                switch (n){
                    case 26:g+=' ';break;
                    case 27:g+='.';break;
                    case 28:g+=',';break;
                    case 29:g+='-';break;
                    case 30:g+='\'';break;
                    case 31:g+='?';break;
                    default:g+='A'+n;
                }
                tem="";
            }
        }
        cout<<g<<endl;
    }
}

Measured memory_bytes: 1192
from itertools import accumulate
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = list(accumulate(a))
b = [0] + list(accumulate(b))
ans = 0
for i in range(n):
  tmp = a[i] + b[-1] - b[i]
  if tmp > ans:
    ans = tmp
print(ans)

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

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3 = x2 - (y2-y1);
    int y3 = y2 + (x2-x1);
    int x4 = x3 - (y3-y2);
    int y4 = y3 - (x2-x3);
    cout << x3 << " " << y3 << " " << x4 << " "  << y4 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define double /*long*/ double
#define endl '\n'
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vppll vector<pair<pll,pll>>
#define mp make_pair
#define pb push_back
#define mapll map<ll,ll>
#define fir first
#define sec second
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define fo(i,b) for(i=0;i<b;i++)
#define repa(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define all(x) (x).begin(), (x).end()
#define s(v) v.size()
const long long int MAX = (ll)(1e18+1);
const long long int MIN = (ll)(-1e18-1);
const long long int mod = (ll)(1e9+7);
using namespace std;

ll max(ll a,ll b,ll c) {return max(max(a, b), c);}
ll min(ll a,ll b,ll c) { return min(min(a, b), c);}
ll max(ll a,ll b) {return (a>b) ? a : b;}
ll min(ll a,ll b) {return (a<b) ? a : b;}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power_mod(ll a, ll n, ll mod_){ ll p=1; while(n){ if(n%2){ p=(p*a)%mod_;} n/=2; a=(a*a)%mod_;} return p%mod_;}
                                                 /*Code Begins*/


int main(){
    _cin;
    // cout << setprecision(15);
    ll mn = MAX, mx = MIN;
    ll n, t, m, k, i, j,  sum=0,  prev, flag=0, cnt=0;
    ll x=0, y=0, fx, diff, tot=0, l , r;
    int TC=1;
    // cin >> TC;
while(TC--){
    cin >> n >> m;
    x = n*(n-1)/2 + m*(m-1)/2;
    cout << x;

}
    return 0;
}


Measured memory_bytes: 256
n = int(input())
talk = [[] for i in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x,y = map(int,input().split())
        talk[i].append([x-1,y])
ans = 0
for i in range(1,2**n):
    flag = 0
    for j in range(n):
        if (i>>j)&1 == 1:
            for x,y in talk[j]:
                if (i>>x)&1 != y:
                    flag = 1
                    break
    if flag == 0:
        ans = max(ans,bin(i).count("1"))
print(ans)

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

using namespace std;

#define ll long long

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif // ONLINE_JUDGE
	int n;
	cin>>n;
	vector<int> arr[n];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			int temp;
			cin>>temp;
			arr[i].push_back(temp);
		}
	}
	int dp[n][3];
	dp[0][0]=arr[0][0];
	dp[0][1]=arr[0][1];
	dp[0][2]=arr[0][2];
	for(int i=1;i<n;i++)
	{
		dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=arr[i][2]+max(dp[i-1][1],dp[i-1][0]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 10172
n = int(input())
alice_cards = []
bob_cards = []
all_cards = list(map(int, input().split()))
all_cards.sort()
while len(all_cards) > 0:
    alice_cards.append(all_cards.pop(-1))
    if len(all_cards) == 0:
        break
    else:
        bob_cards.append(all_cards.pop(-1))
print(sum(alice_cards) - sum(bob_cards))

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<ll>());

  priority_queue<ll> que;
  ll ans = 0;
  rep(i, n) {
    if(i == 0) {
      que.push(a[i]);
      continue;
    }
    ll top = que.top();
    que.pop();
    ans += top;
    que.push(a[i]);
    que.push(a[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6916
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] XN = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();
            int X = XN[0];
            int N = XN[1];
            List<int> P = new List<int>();
            if(N == 0)
            {
                Console.WriteLine(X);
                return;
            }
            else
            {
                P = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToList();
            }
            for(int i = 0; i < 100; i++)
            {
                if(!P.Contains(X - i))
                {
                    Console.WriteLine(X - i);
                    return;
                }
                else if(!P.Contains(X + i))
                {
                    Console.WriteLine(X + i);
                    return;
                }
            }
        }
    }
}
//int[] N = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();

Measured memory_bytes: 28232
/** author: __nishad__ **/
//#pragma GCC optimize(2)
//#pragma GCC optimize(3, "Ofast", "inline")
#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a,b) for(ll i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    int n, num;
    bool ans=false;

    cin>>n>>num;

    loop(i, 0, n){
        loop(j, 0, n){
            if(i+j == n){
                if(4*i+2*j == num)
                    ans = true;
            }
        }
    }

    if(ans)
        cout<<"Yes";
    else
        cout<<"No";



}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr ll mod998=998244353;

int H,W,K,res;
char c[6][6];

int main(){
	cin>>H>>W>>K;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin>>c[i][j];
		}
	}
	for(int i=0;i<(1<<H);i++){
		char cc[6][6];
		for(int j=0;j<H;j++){
			for(int k=0;k<W;k++){
				if(i&(1<<j)){
					cc[j][k]='R';
				}
				else{
					cc[j][k]=c[j][k];
				}
			}
		}
		for(int j=0;j<(1<<W);j++){
			char ccc[6][6];
			for(int k=0;k<H;k++){
				for(int l=0;l<W;l++){
					if(j&(1<<l)){
						ccc[k][l]='R';
					}
					else{
						ccc[k][l]=cc[k][l];
					}
				}
			}
			int cnt=0;
			for(int k=0;k<H;k++){
				for(int l=0;l<W;l++){
					if(ccc[k][l]=='#')cnt++;
				}
			}
			if(cnt==K)res++;
		}
	}
	cout<<res<<endl;
}


Measured memory_bytes: 3620