akhauriyash/Code-Regression huggingface dataset:
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define db double
const int M=1e5+1;
using namespace std;
const db eps=1e-10;
db dcmp(db x){if(fabs(x)<eps) return 0;return x;}
int n;
struct point{
    db x,y;
    point(db a=0,db b=0):x(a),y(b){}
    void in(){scanf("%lf%lf",&x,&y);}
}pp[M];

point operator +(point a,point b){return point(a.x+b.x,a.y+b.y);}
point operator -(point a,point b){return point(a.x-b.x,a.y-b.y);}
point operator *(point a,db    b){return point(a.x*b  ,a.y*b  );}
point operator /(point a,db    b){return point(a.x/b  ,a.y/b  );}

db cross(point a,point b){return a.x*b.y-a.y*b.x;}
db dot  (point a,point b){return a.x*b.x+a.y*b.y;}

double dis(point a,point b)
{return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}

point getmid(point a,point b){return point((a.x+b.x)/2,(a.y+b.y)/2);}
point rotate(point a){return point(-a.y,a.x);}

struct circle{
    point o;db r;
    circle(){}
    circle(point a,db r):o(a),r(r){}
};
struct triangle{
    point t1,t2,t3;
    circle cir2(){
        db Bx = t2.x-t1.x, By = t2.y-t1.y;
        db Cx = t3.x-t1.x, Cy = t3.y-t1.y;
        db D = 2*(Bx*Cy-By*Cx);
        db cx = (Cy*(Bx*Bx+By*By) - By*(Cx*Cx+Cy*Cy))/D + t1.x;
        db cy = (Bx*(Cx*Cx+Cy*Cy) - Cx*(Bx*Bx+By*By))/D + t1.y;
        point p = point(cx, cy);
        return circle(p, dis(t1,p));
    }
    triangle(){}
    triangle(point a,point b,point c):t1(a),t2(b),t3(c){}
};
circle circlein(point t1,point t2,point t3){
        point v1=t2-t1,v2=t1-t3;v1=rotate(v1),v2=rotate(v2);
        point p1=getmid(t1,t2),p2=getmid(t1,t3);point u=p1-p2;
        db t=cross(v2,u)/cross(v1,v2);
        point oo=p1+v1*t;
        return circle(oo,dcmp(dis(oo,t1)));
}
void work(){
    circle ans;
    ans.o=pp[1];ans.r=0;
    for(int i=2;i<=n;i++){
        if(dis(pp[i],ans.o)>ans.r+eps){
            ans=circle(pp[i],0);
            for(int j=1;j<i;j++){
                if(dis(pp[j],ans.o)>ans.r+eps){
                    ans.o=getmid(pp[i],pp[j]);
                    ans.r=dis(pp[j],pp[i])/2;
                    for(int k=1;k<j;k++){
                        if(dis(pp[k],ans.o)>ans.r+eps){
                            ans=circlein(pp[i],pp[j],pp[k]);
                        }
                    }
                }
            }
        }
    }
    printf("%.10lf\n",ans.r);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)pp[i].in();
    random_shuffle(pp+1,pp+n+1);
    work();
    return 0;
}

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

void solve() {
    int d, g;
    cin >> d >> g;
    vector<int> p(d), c(g);
    int ans = 1e5;
    for (int i = 0; i < d; i++) {
        cin >> p[i] >> c[i];
    }
    for (int i = 0; i <= (1 << d); i++) {

        long long sum = 0;
        int s = 0;
        for (int j = d - 1; j >= 0; j--) {
            if(i & (1 << j)) {
                int cnt = 0;
                while(cnt < p[j] && sum < g) {
                    sum += (j + 1) * 100;
                    cnt++;
                    s++;
                }
                if(cnt >= p[j]) {
                    sum += c[j];
                }

                if(sum >= g) {
                    break;
                }
            }
        }
        if(sum >= g)
            ans = min(ans , s);
    }
    cout << ans;
}

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


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

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

typedef long long ll;

using namespace std;

const int N = (int)3e5 + 123, mod = (int)1e9 + 7, inf = (int)1e9;
const ll INF = (ll)1e18;



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

	ll n, a, b;
	cin >> n >> a >> b;
	if(a % 2 == b % 2){
		cout << (b - a) / 2;
		return 0;
	}
	ll ans = a + (b - a) / 2;
	a = n - a + 1, b = n - b + 1;
	swap(a, b);
	cout << min(ans, a + (b - a) / 2);

	return 0;
}

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

int main() {
  long long deadline,konyu,eat;
  cin >> deadline >> konyu >> eat;
  
  if(konyu - eat >= 0){
    cout << "delicious";
  }else if(deadline - (eat - konyu) >= 0){
    cout << "safe";
  }else{
    cout << "dangerous";
  }
}


Measured memory_bytes: 256
import math
def like_2017(n):
    if n == 1: return False
    if n == 2: return False 

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
        
    for l in range(2,int(math.sqrt((n+1)/2)) + 1):
        if ((n+1)/2)%l ==0:
            return False
        
    return True

q = int(input())
L = [[int(i) for i in input().split()] for _ in range(q)]
ans = [0 for _ in range(10**5+1)]

for i in range(3,10**5):
    ans[i+1] = ans[i] + 1 if like_2017(i) else ans[i] 

for l,r in L:
    print(ans[r+1] - ans[l])


Measured memory_bytes: 24644
s = input()
start = 0
end = len(s) -1
insertions = 0
while(start < end):
    if s[start] == s[end]:
        start += 1
        end -= 1
        continue

    if 'x' == s[end]:
        insertions += 1
        end -= 1
    elif 'x' == s[start]:
        insertions += 1
        start += 1
    else:
        print(-1)
        exit(0)

print(insertions)
    


Measured memory_bytes: 3316
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
using lint = long long int;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> void Min(T &m, const T q) { if (m > q) m = q; }

int N;
lint D;
vector<lint> A;
int main()
{
    cin >> N >> D;
    A.resize(N);
    for (auto &v : A) cin >> v;
    lint res = accumulate(A.begin(), A.end(), 0LL);
    REP(i, N - 1) Min(A[i + 1], A[i] + D);
    IREP(i, N - 1) Min(A[i], A[i + 1] + D);
    cout << res + accumulate(A.begin(), A.end(), 0LL) - A[0] - A[N - 1] + (N - 1) * D << endl;
}


Measured memory_bytes: 1792
from collections import deque
import sys
input = sys.stdin.readline

n = int(input())
lst = deque([])
for i in range(n):
    inp = input().split()
    op = inp[0]
    try:
        x = inp[1]
    except:
        pass
    if op == 'insert':
        lst.appendleft(x)
    if op == 'delete':
        try:
            lst.remove(x)
        except:
            pass
    if op == 'deleteFirst':
        lst.popleft()
    if op == 'deleteLast':
        lst.pop()
print(*lst)



Measured memory_bytes: 69736
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] t = new int[n];
    int std = 0;
    for (int i = 0; i < n; i++) {
      t[i] = sc.nextInt();
      std += t[i];
    }
    int m = sc.nextInt();
    for (int i = 0; i < m; i++) {
      int p = sc.nextInt();
      int x = sc.nextInt();
      System.out.println(std - t[p - 1] + x);
    }
    sc.close();
  }
}

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

using namespace std;

const int N = 8e3 + 100;

string s, sx, sy;
int x, y;

int pos(const int p) {
    return p + N;
}

bool now[2 * N], next_pos[2 * N];
void search(const string s) {
    int move = 0;
    for (int i = 0; i < s.size(); i++) {
	if (s[i] == 'T') {
	    for (int j = -N; j < N; j++) {
		if (now[pos(j)]) {
		    next_pos[pos(j + move)] = true;
		    next_pos[pos(j - move)] = true;
		}
	    }
	    move = 0;
	    copy(next_pos, next_pos + 2 * N, now);
	    fill(next_pos, next_pos + 2 * N, false);
	}
	else
	    move++;
    }
}

int main() {
    cin >> s >> x >> y;
    bool x_axis = true;
    for (auto &itr : s) {
	if (x_axis)
	    sx += itr;
	else
	    sy += itr;
	if (itr == 'T')
	    x_axis = !x_axis;
    }
    sx = sx + 'T';
    sy = sy + 'T';
    now[pos(0)] = true;
    search(sy);
    if (now[pos(y)] == false) {
	cout << "No" << endl;
	return 0;
    }
    fill(now, now + 2 * N, false);
    int movex = 0;
    for (int i = 0; i < sx.size(); i++) {
	if (sx[i] == 'T') {
	    now[pos(movex)] = true;
	    sx = sx.substr(i + 1);
	    break;
	}
	else {
	    movex++;
	}
    }
    search(sx);
    if (now[pos(x)] == false) {
	cout << "No" << endl;
	return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		Map<String, Integer> s = new TreeMap<>();
		int c = 0;
		int max = -1;
		for(int i = 0; i < n; i++) {
			String temp = scan.next();
			if(s.containsKey(temp)) {
				c = s.get(temp) + 1;
			} else {
				c = 1;
			}
			s.put(temp, c);
			max = Math.max(max, c);
		}
		for(var i : s.entrySet()) {
			if(i.getValue() == max) {
				System.out.println(i.getKey());
			}
		}
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}


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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  string s, t;
  cin >> s >> t;
  if (s.size() > t.size()) {
    for (int i = 0; i < t.size(); i++) {
      cout << s[i] << t[i];
    }
    cout << s[s.size() - 1] << endl;
  } else {
    for (int i = 0; i < s.size(); i++) {
      cout << s[i] << t[i];
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int x;
    cin>>x;
    int sum=0;
    int n=0;
    while(sum<x){
        n++;
        sum+=n;
    }
    cout<<n<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var s string
	con.Scan(&s)
	var p, g int
	for _, c := range s {
		switch c {
		case 'p':
			p++
		case 'g':
			g++
		}
	}
	con.Println((p+g)/2 - p)
	return nil
}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

// //素因数分解
// map<ll,ll> get_div(ll n){
//     map<ll,ll> div;
//     ll num = n;
//     for (ll i=2; i * i < n; i++)
//     {
//         while(num%i==0){
//             div[i]++;
//              num /= i;
//              }
//     }
//     if(num>1)
//         div[num]++;

//     return div;
// }
vector<ll> yakusu(ll n) {
    vector<ll> res;
    for(ll i = 1; i*i <= n; i++) {
        if(n%i == 0) {
            res.pb(i);
            if(i != n/i) {
                res.pb(n/i);
            }
        }
    }
    sort(res.begin(),res.end());
    return res;  
}
 
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll x;
cin >> x;
// map<ll, ll> div = get_div(x);
vector<ll> v=yakusu(x);
// if(div.size()==0){
//     div[1]++;
// }
ll a, b;
bool ok=false;

for (auto factor : v)
{
    // ll factor=v.first;
    reps(tmp_b,201,-200){
        ll tmp_a = tmp_b+factor;
        ll p=1,q=1;
        rep(i,5){
            p*=tmp_a;
            q*=tmp_b;
        }
        if (p-q == x)
        {
            ok = true;
            a = tmp_a;
            b = tmp_b;
        }
        if(ok){
            break;
        }
    }
    if(ok){
            break;
    }
}
cout << a << " " << b << endl;
return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//---------------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
//--------------------------------------------------------------
void Main(){
  int n,k;
  cin>>n>>k;
  vl h(n);
  cin>>h;
  sort(rng(h));
  ll ans =1e10;
  rep(i,n-k+1){
    mins(ans,h[k-1+i]-h[i]);
  }
  cout<<ans;
} int main(int argc,char** argv)
{fastio; myio; Main();}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
	static Boolean three(int n) {
		if(n%3 == 0)
			return true;

		do {
			if(n%10 == 3)
				return true;
		}while((n /= 10) > 0);

		return false;
	}

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		for(int i = 3; i <= n; i++)
			if(three(i))
				System.out.print(String.format(" %d", i));
		System.out.println();
	}
}



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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*
 */

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

const int mod = 1e9+7;

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

  vi c(n);
  rep(i, 0, n) cin >> c[i];

  sort(all(c));
  reverse(all(c));

  int p = 1, q = 1;
  rep(i, 0, n) q = q*2%mod;

  int sum = 1, ans = 0;
  rep(i, 0, n){
    q = q*(mod+1)/2%mod;
    (ans += (c[i] * sum)%mod*q) %= mod;
    sum = (sum*2+p)%mod;
    p = p*2%mod;
  }

  cout << ans*p%mod << endl;

  return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<class T, class U>
inline void chmin(T &t, U f) { if (t > f)t = f; }

template<class T, class U>
inline void chmax(T &t, U f) { if (t < f)t = f; }

template<typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val) { //usage: int dp[10][10]; Fill(dp,INF);
    std::fill((T *) array, (T *) (array + N), val);
}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9 LLの時はLLONG_MAX
/*const int MAXN = 100001;

struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};*/

//-----Template---------

LL modPow(LL x, LL y, LL mod) {
    LL res = 1;
    for (int i = 0; i < y; i++) {
        res = (res * x) % mod;
    }
    return res;
}

int memo[100001];
int n;

int main() {
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    cin >> n;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        memo[tmp]++;
    }
    bool flag = true;
    LL res = 0;
    if (n % 2 == 0) {//1,3,5..n-1
        for (int i = 0; i < n; i++) {//0 to n-1
            if (i % 2 == 0){
                if(memo[i] != 0) {
                    flag = false;
                    break;
                }
            } else{
                if (memo[i] != 2) {
                    flag = false;
                    break;
                }
            }
        }
        if (flag)
            res = modPow(2, n / 2, MODULE);
    } else {
        for (int i = 0; i < n; ++i) {
            if (i % 2 == 0) {
                if (i == 0){
                    if(memo[0] != 1) {
                        flag = false;
                        break;
                    }
                } else {
                    if(memo[i]!=2){
                        flag=false;
                        break;
                    }
                }
            } else {
                if(memo[i]!=0){
                    flag=false;
                    break;
                }
            }
        }
        if (flag)
            res = modPow(2, (n - 1) / 2, MODULE);
    }
    cout << (flag ? res : 0) << endl;
}

Measured memory_bytes: 640
n, y = list(map(int, input().split()))
ans = 0
for i in range(n+1):
    for j in range(n+1-i):
        x = y
        if x - 10000*i - 5000*j == 1000*(n-i-j):
            ans += 1
            a = i
            b = j
            c = n-i-j
            
        else:
            continue
        
    
if ans == 0:
    print(-1, -1, -1)
else:
    print(a, b, c)
    

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  int ans[n];
  vector<vector<int>> s(n,vector<int>());
  for(int i=1;i<=n;i++){
    for(int j=i;j<=n;j+=i){
      s[j-1].push_back(i-1);
    }
  }
  /*for(int i=0;i<n;i++){
    for(int j:s[i]){
      cout << j << endl;
    }
  }*/
  for(int i=n;i>=1;i--){
    ans[i-1]=a[i-1];
    for(int j:s[i-1]){
      if(ans[i-1]) a[j]^=1;
    }
  }
  int count=0;
  for(int i=0;i<n;i++){
    count+=ans[i];
  }
  cout << count << endl;
  for(int i=0;i<n;i++){
    if(ans[i]) cout << i+1 << ' ';
  }
  cout << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main(){
    string S;
    cin >> S;

    if(S[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }

    /*
    if(!(S[2] == 'C' && S[S.length() - 2] == 'C')){
        cout << "WA" << endl;
        return 0;
    }
    */
    ll cn = 0;
    for(ll i = 1; i < S.length(); i++){
        if((i < S.length()-1 && i > 1) && S[i] == 'C'){
            cn++;
            if(cn > 1){
                cout << "WA" << endl;
                return 0;              
            }
            continue;
        }
        if(S[i] <= 'Z' && S[i] >= 'A'){
            cout << "WA" << endl;
            return 0;            
        }
    }

    if(cn == 0){
        cout << "WA" << endl;
        return 0;
    }

    cout << "AC" << endl;

}

Measured memory_bytes: 256
s = input()
t = input()
sl = len(s)
tl = len(t)

if sl < tl:
  print("UNRESTORABLE")
  exit()
  
possible = []
for i in range(sl - tl + 1):
  temp = s[i:i+tl]
  flag = True
  for a, b in zip(t, temp):
    if b != "?" and a != b:
      flag = False
  if flag:
    w = s[:i] + t + s[i+tl:]
    possible.append(w.replace("?", "a"))
if len(possible) == 0:
  print("UNRESTORABLE")
  exit()
print(sorted(possible)[0])

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend() 
#define pb(x) push_back(x)

using namespace std;
using ll=long long;

long mod=1e9+7;

int main() {
  int n;cin>>n;
  int t2=0;
  int t4=0;

  rep(i,n){
    ll a;cin>>a;
    if(a%4==0)t4++;
    if(a%2==0 && a%4)t2++;
  }
  int non=n-t2-t4;
  if(non<=t4+1&&t2==0){cout<<"Yes";return 0;}
  if(non<=t4)cout<<"Yes";
  else cout<<"No";
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define maxn 200010
#define LL long long
#define mod 998244353
using namespace std;
struct node{
	LL x,y;
}a[maxn];
int st[maxn],top,r;//st[]记录脚标,r用来记录留下的脚标
LL dp[maxn];
int cmp(node a,node b){
	return a.x<b.x;
}
int main(){
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%lld%lld",&a[i].x,&a[i].y),a[i].y+=a[i].x;
	sort(a+1,a+1+n,cmp);//按机器人安放顺序进行排序
	a[n+1].x=2e9+1,a[n+1].y=2e9+1,st[++top]=n+1,dp[n+1]=1;//边界设置
	for(i=n;i>=1;i--){
		while(top&&a[i].y>a[st[top]].x)top--;
		r=st[top];
		st[++top]=i;
		dp[i]=(dp[i+1]+dp[r])%mod;//dp[n]=2的说明，第n位机器人不动是一种情况，动又是另一种情况
	}
	printf("%lld\n",dp[1]);
	return 0;
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define nmax 1000000
#define INF 1000000000
int dp[nmax],dp2[nmax];


int main()
{
    for (int i=0;i<nmax;i++)
    {
        dp[i]=INF;
        dp2[i]=INF;
    }
    int i=1;
    dp[0]=0;dp2[0]=0;
    vector<int> nums;
    while (i*(i+1)*(i+2)/6<nmax)
    {
        nums.push_back(i*(i+1)*(i+2)/6);
        dp[i*(i+1)*(i+2)/6]=1;
        if (i*(i+1)*(i+2)/6%2==1) dp2[i*(i+1)*(i+2)/6]=1;
        i++;
    }
    for (int i=0;i<nums.size();i++)
    {
        for (int j=0;j<nmax;j++)
        {
            if (j+nums[i]<nmax) dp[j+nums[i]]=min(dp[j+nums[i]],dp[j]+1);
            if (j+nums[i]<nmax && nums[i]%2==1) dp2[j+nums[i]]=min(dp2[j+nums[i]],dp2[j]+1);
        }
    }
    while (true)
    {
        int n;cin >> n;
        if (n==0) break;
        cout << dp[n] << " " << dp2[n] << endl;
    }
    return 0;
}


Measured memory_bytes: 10932
A = list(input())
B = []
for i in range(len(A)):
    if A[i] == "0":
        B.append("0")
    elif A[i] == "1":
        B.append("1")
    else:
        try:
            B.pop(-1)
        except IndexError:
            pass
print("".join(B))

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
	Scanner in= new Scanner(System.in);
	ArrayList<Short> list = new ArrayList<Short>();
        list.add(in.nextShort());
        list.add(in.nextShort());
        list.add(in.nextShort());
	Collections.sort(list);

	byte c = 0;
	String s;
	for (Short i: list){
		if (c <list.size()-1)
			s = " ";
		else
			s = "";
	        System.out.printf("%d%s", i, s);
		c += 1;
	}
        System.out.println();
    }   
}

Measured memory_bytes: 17176
#include <bits/stdc++.h>
using namespace std;
#define MAX_V 2000
const long long INF = 11451419194545;
using ll = long long;
#define int long long
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
vector <ll> d(MAX_V,-INF);
vector <edge> edges;
void BellmanFord(int V){
        for (int i = 0; i < 2*V; i++) {
            long long tmp = d[V-1];
        for (int j = 0; j < (int)edges.size(); j++) {

            struct edge e = edges[j];

            if (d[e.to] < d[e.from] + e.cost) {  
                d[e.to] = d[e.from] + e.cost;
                if (i == 2*V-1) {         
                    if(d[V-1]!= tmp) {
                        cout<<"inf"<<endl; exit(0);
                    }
                } 
            }
        }
    }
}
signed main(void){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b,c; cin>>a>>b>>c;
        a--; b--;
        struct edge tmp = {a,b,c};
        edges.push_back(tmp);
    }
    d[0] = 0;
    BellmanFord(n);
    cout<<d[n-1]<<endl;
}



Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

int n,x,l[101],arr[101],d=0,ret=1;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n>>x;
	for(int i=0;i<n;i++){
		cin>>l[i];
		arr[i]=l[i]+d;
		d=arr[i];
	}
	for(int i=0;i<n;i++){
		if(arr[i]<=x)
			ret++;
		else
			break;
	}
	cout<<ret;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    map<string, ll> mp;
    ll res = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        res += mp[s];
        mp[s]++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <set> 
#include <iterator>
#include <bitset> 
#include <bits/stdc++.h> 
using namespace std;
typedef  long long int ll;
ll mod=1000000007;


int main() {
    int t=1;
    //cin>>t;
    while(t--)
    {   string s;
        cin>>s;
        ll sum=0;
        for(int i=0;i<s.length();i++)
        {   sum=sum+s[i]-'0';
        }
        if(sum%9==0)
            cout<<"Yes";
        else
            cout<<"No";
            
            
    }
	return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long h,w,k,mod=1000000007;
  cin >> h >> w >> k;
  if(w==1) {
    cout << 1 << endl;
    return 0;
  }
  vector<long> sayu(w-1),sonomama(w);
  vector<vector<long>> amida(h+1,vector<long>(w));
  amida[0][0]=1;
  for(long bit=0;bit<(1<<(w-1));bit++) {
    bool imp=false;
    for(long i=0;i<w-2;i++) {
      if((bit&(1<<i))&&(bit&(1<<(i+1)))) imp=true;
    }
    if(imp) continue;
    for(long i=0;i<w-1;i++) if(bit&(1<<i)) sayu[i]++;
    
    if(!(bit&(1<<0))) sonomama[0]++;
    if(!(bit&(1<<(w-2)))) sonomama[w-1]++;
    for(long i=1;i<w-1;i++) if(!(bit&(1<<(i-1))||bit&(1<<i))) sonomama[i]++;
  }
  
  for(long i=0;i<h;i++) {
    for(long j=0;j<w-1;j++) {
      amida[i+1][j]=(amida[i+1][j]+amida[i][j+1]*sayu[j])%mod;
      amida[i+1][j+1]=(amida[i+1][j+1]+amida[i][j]*sayu[j])%mod;
    }
    for(long j=0;j<w;j++) {
      amida[i+1][j]=(amida[i+1][j]+amida[i][j]*sonomama[j])%mod;
    }
  }
  
  cout << amida[h][k-1] << endl;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main() {
  uint32_t S = 0, W = 0;
  std::cin >> S >> W;

  std::cout << (S <= W ? "unsafe" : "safe") << std::endl;

  return 0;
}

Measured memory_bytes: 3636
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

vector<string> V(3);

signed main(){

    in(V);
    cout<<V[0][0]<<V[1][0]<<V[2][0]<<endl;

    return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  if (k == 1) cout << 0 << endl;
  else
    cout << (n - k) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <string>
using namespace std;
int main(void){
    
    string S;
    cin >> S;
    
    string ago_S = S.substr(0,2);
    string after_S = S.substr(2,2);
    int ago_S_Num = stoi(ago_S);
    int after_S_Num = stoi(after_S);
    
    
    if(ago_S_Num > 0 && ago_S_Num <= 12 && after_S_Num > 0 && after_S_Num <= 12)
        cout << "AMBIGUOUS" << endl;
    
    else if(ago_S_Num >= 0 && after_S_Num > 0 && after_S_Num <= 12)
        cout << "YYMM" << endl;
        
    else if(after_S_Num >= 0 && ago_S_Num > 0 && ago_S_Num <= 12)
        cout << "MMYY" << endl;
    
    else cout << "NA" << endl;
    

}

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

///////////////////////////////////////////
//const long long int INF = 1000000000000000000LL;
const long long int INF = 1000000;
using ll = long long int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return 1; } return 0; }
template<class T>T sqar(T x){ return x*x; }
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(    v[0])>()) //降順でVをソート
///////////////////////////////////////////

ll N;
ll ma[2][200]={0};
ll dp[2][200]={0};

int main(){
    cin>>N;
    rep(i,2){
        rep(j,N){
            cin>>ma[i][j];
        }
    }
    rep(i,2){
        rep(j,N){
            if(i==0&&j==0){
                chmax(dp[1][0],ma[0][0]+ma[1][0]);
                chmax(dp[0][1],ma[0][0]+ma[0][1]);
            }else{
                if(i==1){
                    chmax(dp[i][j+1],dp[i][j]+ma[i][j+1]);
                }else{
                    chmax(dp[i][j+1],dp[i][j]+ma[i][j+1]);
                    chmax(dp[i+1][j],dp[i][j]+ma[i+1][j]);
                }
            }
        }
    }
    cout<<dp[1][N-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define Rep(i,v) rep(i,0,(int)v.size()-1)
#define lint long long
#define ull unsigned lint
#define db long double
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define gc getchar()
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
typedef pair<int,int> pii;
typedef set<int>::iterator sit;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
const int N=1010;
int a[N];lint s[N];
inline int con(int n,lint v)
{
	int cnt=0;
	rep(i,1,n) rep(j,i,n)
	{
		lint x=s[j]-s[i-1];
		if((x&v)==v) cnt++;
	}
	return cnt;
}
int main()
{
	int n=inn(),k=inn();rep(i,1,n) a[i]=inn();
	rep(i,1,n) s[i]=s[i-1]+a[i];lint ans=0;
	for(int i=45;i>=0;i--)
	{
		ans|=(1ll<<i);
		if(con(n,ans)<k) ans^=(1ll<<i);
	}
	return !printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b;
	scanf("%d",&a);
	if(a%2==0){
		printf("%d\n",(a/2)*(a/2));
	}else{
		printf("%d\n",(a/2)*(a/2+1));
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a,b;
		a=scan.nextInt();
		b=scan.nextInt();
		double c=(double)a/b;
		System.out.println((int)a/b+" "+a%b+" "+String.format("%.5f",c));
		scan.close();
	}

}


Measured memory_bytes: 26476
#include <iostream>
#include <math.h>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

ll c[10000][10000];
bool v[10000];
ll N, M;
ll cnt = 0;

void dfs(int id) {
	bool valid = true;
	rep(i, 0, N) {
		valid &= v[i];
	}

	if (valid) {
		cnt++;
		return;
	}

	rep(i, 0, N) {
		if (id != i && c[id][i] != 0 && !v[i]) {
			v[i] = true;
			dfs(i);
			v[i] = false;
		}
	}
}

int main() {
	cin >> N >> M;
	rep(i, 0, M) {
		int a, b; cin >> a >> b;
		c[a - 1][b - 1] = 1;
		c[b - 1][a - 1] = 1;
	}

	v[0] = true;
	dfs(0);

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			long N = long.Parse(Console.ReadLine());
			string[] strA = Console.ReadLine().Split(' ');
			string[] strB = Console.ReadLine().Split(' ');
			long[] A = new long[N+1];
			long[] B = new long[N+1];
			for (long i = 0; i < N; i++)
			{
				A[i] = long.Parse(strA[i]);
				B[i] = long.Parse(strB[i]);
			}
			A[N] = long.Parse(strA[N]);
			long ans = 0;
			for (int i = 0; i < N; i++)
			{
				if (A[i] >= B[i])
				{
					ans = ans + B[i];
					continue;
				}
				else
				{
					if (B[i] >= A[i] + A[i + 1])
					{
						ans = ans + A[i] + A[i + 1];
						A[i + 1] = 0;
						continue;
					}
					else {
						ans = ans + B[i];
						A[i + 1] = A[i + 1] - (B[i] - A[i]);
						continue;
					}
				}

			}
			Console.WriteLine(ans);
			Console.ReadLine();

		}
	}
}


Measured memory_bytes: 31956
import numpy as np

card = np.array([list(map(int, input().split())) for _ in range(3)])
bingo = np.zeros([3, 3])

n = int(input())
for _ in range(n):
    b = int(input())
    bingo[card == b] = 1

if np.any(np.all(bingo == 1, axis=1)):
    print('Yes')
elif np.any(np.all(bingo == 1, axis=0)):
    print('Yes')
elif (bingo[0, 0] == 1 and bingo[1, 1] == 1 and bingo[2, 2] == 1) or \
      (bingo[0, 2] == 1 and bingo[1, 1] == 1 and bingo[2, 0] == 1):
    print('Yes')
else:
    print('No')

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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N;  cin >> N;
	vector<ll> A(N), B(N);
	for(int i = 0 ; i < N ; i++)
	 cin >> A[i] >> B[i];

	ll ans = 0;
	for(int i = N - 1 ; 0 <= i ; i--){
		if(B[i] == 0 || B[i] == 1)  continue;

		A[i] += ans;
		if(A[i] % B[i] != 0)
			ans += B[i] - (A[i] % B[i]);
	}

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


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

ll n, cnt = 0;

// a:7 b:5 c:3
void dfs(ll num, bool p, bool q, bool r) {
  // n を超えたら終了
  if(num > n) return;

  if(p&&q&&r) ++cnt;

  dfs(num*10+7, true, q, r);
  dfs(num*10+5, p, true, r);
  dfs(num*10+3, p, q, true);
}

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

  cin >> n;

  dfs(0, false, false, false);
  cout << cnt << '\n';
  return 0;
}


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

const int MOD = 1E9 + 7;

const int NMAT[7][7] = {
	{1, 0, 0, 0, 0, 0, 0},
	{0, 1, 0, 0, 0, 0, 0},
	{0, 0, 1, -1, 0, 0, 0},
	{0, 0, 0, 10, 0, 0, 0},
	{0, 0, 0, 0, 1, -1, 0},
	{0, 0, 0, 0, 0, 10, 0},
	{0, 0, 0, 0, 0, 0, 1}
};

const int MMAT[7][7] = {
	{1, 0, 0, 0, 0, 0, 0},
	{0, 0, 0, 0, 1, 0, 0},
	{0, 0, 0, 0, 0, 0, 0},
	{0, 0, 0, 0, 0, 0, 1},
	{0, 0, 0, 0, 0, 0, 0},
	{0, 0, 0, 0, 1, 0, 0},
	{0, 0, 0, 0, 0, 0, 1},
};

const int AMAT[7][7] = {
	{1, 0, 0, 0, -1, 0, 0},
	{0, 0, 0, 0, 0, 0, 1},
	{0, 0, 0, 0, 0, 0, 0},
	{0, 0, 0, 0, 0, 0, 1},
	{0, 0, 0, 0, 0, 0, 0},
	{0, 0, 0, 0, 0, 0, 1},
	{0, 0, 0, 0, 0, 0, 1}
};

struct mat {
	int d[7][7];
	mat () { for (int i = 0; i < 7; ++i) for (int j = 0; j < 7; ++j) d[i][j] = 0; }
	int *operator [] (int x) { return d[x]; }
	int const *operator [] (int x) const { return d[x]; }
};

mat operator * (const mat &a, const mat &b) {
	mat res;
	for (int i = 0; i < 7; ++i)
		for (int j = 0; j < 7; ++j)
			for (int k = 0; k < 7; ++k)
				res[i][j] = (res[i][j] + 1ll * a[i][k] * b[k][j]) % MOD;
	return res;
}

mat id () {
	mat res;
	for (int i = 0; i < 7; ++i)
		res[i][i] = 1;
	return res;
}

mat nmat[10], mmat, amat, smat;

void init () {
	for (int digit = 0; digit < 10; ++digit)
		for (int i = 0; i < 7; ++i)
			for (int j = 0; j < 7; ++j)
				nmat[digit][i][j] = (NMAT[i][j] < 0) ? digit : NMAT[i][j];
	for (int i = 0; i < 7; ++i)
		for (int j = 0; j < 7; ++j)
			mmat[i][j] = MMAT[i][j];
	for (int i = 0; i < 7; ++i)
		for (int j = 0; j < 7; ++j)
			amat[i][j] = (AMAT[i][j] < 0) ? 1 : AMAT[i][j];
	for (int i = 0; i < 7; ++i)
		for (int j = 0; j < 7; ++j)
			smat[i][j] = (AMAT[i][j] < 0) ? MOD - 1 : AMAT[i][j];
}

int N;
int R[11000];
char S[11000][20];

int ans[7] = {0, 1, 0, 1, 0, 1, 1}, tmp[7];

int main () {
	init ();
	scanf ("%d", &N);
	for (int i = 0; i < N; ++i)
		scanf ("%d %s", &R[i], S[i]);
	for (int i = N - 1; i >= 0; --i) {
		mat mul = id (), ter = id ();
		for (int j = strlen (S[i]) - 1; j >= 0; --j) {
			if (S[i][j] >= '0' && S[i][j] <= '9') mul = nmat[S[i][j] - '0'] * mul;
			else if (S[i][j] == '*') mul = mmat * mul;
			else if (S[i][j] == '+') mul = amat * mul;
			else mul = smat * mul;
		}
		while (R[i]) {
			if (R[i] & 1) ter = mul * ter;
			mul = mul * mul;
			R[i] >>= 1;
		}
		for (int i = 0; i < 7; ++i) {
			tmp[i] = 0;
			for (int j = 0; j < 7; ++j)
				tmp[i] = (tmp[i] + 1ll * ans[j] * ter[i][j]) % MOD;
		}
		for (int i = 0; i < 7; ++i) ans[i] = tmp[i];
	}
	for (int i = 0; i < 7; ++i) {
		tmp[i] = 0;
		for (int j = 0; j < 7; ++j)
			tmp[i] = (tmp[i] + 1ll * ans[j] * amat[i][j]) % MOD;
	}
	for (int i = 0; i < 7; ++i) ans[i] = tmp[i];
	printf ("%d\n", ans[0]);
}

Measured memory_bytes: 3448
#include <bits/stdc++.h>
using namespace std;
int main()
{	
	ios::sync_with_stdio(false);
    	cin.tie(0);
	long long L[100]={2,1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127,24476,39603,64079,103682,167761,271443,439204,710647,1149851,1860498,3010349,4870847,7881196,12752043,20633239,33385282,54018521,87403803,141422324,228826127,370248451,599074578,969323029,1568397607,2537720636,4106118243,6643838879,10749957122,17393796001,28143753123,45537549124,73681302247,119218851371,192900153618,312119004989,505019158607,817138163596,1322157322203,2139295485799,3461452808002,5600748293801,9062201101803,14662949395604,23725150497407,38388099893011,62113250390418,100501350283429,162614600673847,263115950957276,425730551631123,688846502588399,1114577054219522,1803423556807921,2918000611027443,4721424167835364,7639424778862807,12360848946698171,20000273725560978,32361122672259149,52361396397820127,84722519070079276,137083915467899403,221806434537978679,358890350005878082,580696784543856761,939587134549734843};
	long long N;
	cin>>N;
	cout<<L[N]<<endl;
	return 0;
}


Measured memory_bytes: 256
import numpy as np

N,S = map(int, input().split())
A = list(map(int, input().split()))

MOD = 998244353

dp = np.zeros(S + 1, dtype=int)
dp[0] = 1

for i in A:
    ep = dp * 2
    ep[i:] += dp[:-i]
    dp = ep % MOD

print(dp[S])

Measured memory_bytes: 27280
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"

using namespace std;
#define int long long


class BRingosFavoriteNumbers {
public:
    int mpow(const int &a, int n) noexcept {
      if (n == 0) return 1;
      auto t = mpow(a, n / 2);
      t = t * t;
      if (n & 1) t = t * a;
      return t;
    }

    void solve(std::istream &in, std::ostream &out) {
      int d, n;
      in >> d >> n;
      out << (n == 100 ? mpow(100, d) * n + mpow(100, d) : mpow(100, d) * n) << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  BRingosFavoriteNumbers solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


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


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

    ll n, a[200010], b[200010];
    b[0] = 0;
    cin >> n;
    rep(i, n){
        cin >> a[i];
        b[i+1] = a[i]+b[i];
    }

    //adebug(b, n);

    map<ll, ll> cnt;
    ll mark = 0;
    reps(i, 0, n){
        cnt[b[i]]++;
    }

    //mdebug(cnt);

    ll res = 0;
    for(auto const& c : cnt){
        res += ((c.second-1)*c.second)/2;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
const ll mod = 1e9 + 7;
int main()
{
    // ARC031-A, 1014, 
    int n; string s; cin >> n >> s;
    map<char, int> mp;
    rep(i, 26) {
        char a = 'a' + i;
        mp[a] = 1;
    }
    rep(i, n) {
        mp[s[i]]++;
    }
    ll ans = 1;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        ans *= ll((*itr).second);
        ans %= mod;
    }
    cout << ans - 1 << endl;

    return 0;
}

Measured memory_bytes: 3768
#include<map>
#include<set>
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>

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

using namespace std;

typedef	vector<int>	vi;

void rotx(vi &v){
	vi t=v;
	v[0]=t[3];	v[1]=t[2];	v[2]=t[6];	v[3]=t[7];
	v[4]=t[0];	v[5]=t[1];	v[6]=t[5];	v[7]=t[4];
}

void roty(vi &v){
	vi t=v;
	v[0]=t[4];	v[1]=t[0];	v[2]=t[3];	v[3]=t[7];
	v[4]=t[5];	v[5]=t[1];	v[6]=t[2];	v[7]=t[6];
}

void rotz(vi &v){
	vi t=v;
	v[0]=t[3];	v[1]=t[0];	v[2]=t[1];	v[3]=t[2];
	v[4]=t[7];	v[5]=t[4];	v[6]=t[5];	v[7]=t[6];
}

vi findRegularPaint(vi a){
	vi reg=a;
	rep(i,4){
		rep(j,4){
			reg=min(reg,a);
			rotz(a);
		}
		rotx(a);
	}
	roty(a);
	rep(i,4){
		reg=min(reg,a);
		rotz(a);
	}
	roty(a),roty(a);
	rep(i,4){
		reg=min(reg,a);
		rotz(a);
	}

	return reg;
}

int vi2int(const vi &a){
	int res=0;
	rep(i,a.size())	res=res*10+a[i];
	return res;
}

int main(){
	while(1){
		string s[8];
		rep(i,8) if(!(cin>>s[i])) return 0;

		int clr[8];
		{
			int id=0;
			map<string,int> colorid;
			rep(i,8){
				if(colorid.count(s[i])==0)	colorid[s[i]]=id++;
				clr[i]=colorid[s[i]];
			}
		}
		sort(clr,clr+8);

		set<int> cube;
		do{
			cube.insert(vi2int(findRegularPaint(vi(clr,clr+8))));
		}while(next_permutation(clr+1,clr+8));

		cout<<cube.size()<<endl;
	}
}

Measured memory_bytes: 964