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

string s;

void dfs(int m, int sum, string t)
{
  if (m == 3) {
    if (sum == 7) {
      cout << t + "=7\n";
      exit(0);
    }
    return;
  }

  dfs(m+1, sum + (s[m+1] - '0'), t + "+" + s[m+1]);
  dfs(m+1, sum - (s[m+1] - '0'), t + "-" + s[m+1]);
}

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

  cin >> s;
  int d = s[0] - '0';

  dfs(0, d, to_string(d));

  return (0);
}


Measured memory_bytes: 3692
#include <cstdio>
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d %d",&a,&b);
	c=a*b;
	if(c%2==0)
	{
		printf("Even");
	}
	else
	{
		printf("Odd");
	}
	return 0;
} 

Measured memory_bytes: 128
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = nextInt()
    let a = nextIntArray()
    a.sort((a, b) => b - a)
    let m = {}
    let one = 0
    let two = 0
    for (let i = 0; i < a.length; i++) {
        if (!m[a[i]]) m[a[i]] = 1
        else {
            if (one == 0) {
                one = a[i]
                m[a[i]] = 0
            } else {
                two = a[i]
                break
            }
        }
    }
    console.log((BigInt(one) * BigInt(two)).toString())
}
Main()



Measured memory_bytes: 46836
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;
#define LL long long
int main()
{
  //  freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
    int i,n,tot=0;
    scanf("%d",&n);if (n==1) {puts("YES");return 0;}
    for (i=1;i<=n;i++) {int x;scanf("%d",&x);if (x%2) tot++;}
    if (tot%2) puts("NO"); else puts("YES");
    
    return 0;
}


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

using i64 = long long int;

struct Node{
    int x, y, cost, hp;
};

char field[1003][1003];
int mini[1003][1003][11];

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

int main(){
    int h, w, n;
    cin >> h >> w >> n;

    int sx, sy;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            cin >> field[i][j];
            if(field[i][j] == 'S'){
                sx = j;
                sy = i;
            }
        }
    }

    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            for(int k=0;k<=n+1;++k)
                mini[i][j][k] = INT_MAX;
        }
    }

    mini[sy][sx][1] = 0;
    queue<Node> que;
    que.push((Node){sx, sy, 0, 1});
    while(!que.empty()){
        Node curr = que.front(); que.pop();
        if(curr.hp == n + 1){
            cout << curr.cost << endl;
            break;
        }
        for(int d=0;d<4;++d){
            int nx = curr.x + dx[d], ny = curr.y + dy[d], newcost = curr.cost + 1;
            if(nx < 0 || nx >= w)continue;
            if(ny < 0 || ny >= h)continue;
            if(field[ny][nx] == 'X')continue;
            int nhp = curr.hp;
            if(field[ny][nx] == curr.hp + '0')nhp++;
            if(newcost >= mini[ny][nx][nhp])continue;
            mini[ny][nx][nhp] = newcost;
            que.push((Node){nx, ny, newcost, nhp});
        }
    }

    return 0;
}



Measured memory_bytes: 47236
#include <cstdio>

int n,m,k;
const char s[]="RGBY";

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for(int i=0;i<n;++i,putchar('\n'))
        for(int j=0;j<m;++j)
            putchar(s[((m+i-j)/k&1)<<1|((m+i+j)/k&1)]);
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    ll n,k; cin >> n >> k;
    ll x = n/k, y = n/(k/2)-x;
    ll ans = x*x*x;
    if(k % 2 == 0) ans+=y*y*y;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
using namespace std;

int main()
{
string s;
cin >> s;
int ans=0;
for(int i=0;i<s.size();i++)
{
ans=ans+s[i]-'0';
}
if(ans%9==0){printf("Yes");}
else{printf("No");}
}


Measured memory_bytes: 3752
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string a,b,c;
    cin >> a >> b >> c;
    if(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0] ){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;

int main() {
  string s;
  cin >> s;
  if ((s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) || (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) || (s[0] == s[3] && s[1] == s[2] && s[0] != s[2])) cout << "Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll x, y, z;
  cin >> x >> y >> z;
  ll count = 1;
  x -= 2 * z;
  x -= y;
  while(x-y-z>=0){
    x -= y + z;
    count++;
  }
  print(count);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
//typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	string s,t,u;
	cin>>s>>t>>u;
	if(s.back()==t[0]&&t.back()==u[0]){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; cin >> n;
	vi b(n); rep(i,n) cin >> b[i];
	vi num(n); rep(i,n) num[i] = i+1;
	vector<bool> in(n,true);
	vi ans(n);
	rep(i,n){
		bool ext = true;
		for(int j=n-1; j>=0; j--){
			if(in[j]&&(b[j]==num[j])){
				in[j] = false;
				for(int k=j+1; k<n; k++) num[k]--;
				ans[i] = num[j];
				ext = false;
				break;
			}
		}
		if(ext){
			cout << -1 << endl;
			return 0;
		}
	}
	REV(ans);
	rep(i,n) cout << ans[i] << endl;
}


Measured memory_bytes: 256
import numpy as np

N=int(input())
x=[0]*N
y=[0]*N

for i in range(0,N):
    x[i],y[i]=map(int,input().split())

L=[[0 for i in range(N)] for j in range(N)]

for i in range(0,N-1):
    for j in range(i+1,N):
        L[i][j]=np.sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))
        L[j][i]=L[i][j]

S=0
for i in range(0,N):
    S+=sum(L[i])
print(S/N)

Measured memory_bytes: 12512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <algorithm>

template <class T>
inline void read(T &res)
{
	char ch; 
	while (ch = getchar(), !isdigit(ch));
	res = ch ^ 48;
	while (ch = getchar(), isdigit(ch))
		res = res * 10 + ch - 48;
}

const int mod = 1e9 + 7;
const int N = 405;
int n, c, l[N], r[N], g[N], f[N], sum[N][N], ex[N][N];

inline int ksm(int x, int k)
{
	int res = 1;
	while (k)
	{
		if (k & 1) res = 1ll * res * x % mod;
		x = 1ll * x * x % mod; k >>= 1;
	}
	return res;
}

inline void add(int &x, int y)
{
	x += y;
	x >= mod ? x -= mod : 0;
}

int main()
{
	read(n); read(c);
	for (int i = 1; i <= n; ++i) read(l[i]);
	for (int i = 1; i <= n; ++i) read(r[i]);
	
	for (int j = 0; j <= c; ++j)
		for (int k = 1; k <= 400; ++k)
			ex[j][k] = ksm(k, j);
	for (int i = 1; i <= n; ++i)
		for (int j = 0; j <= c; ++j)
			for (int k = l[i]; k <= r[i]; ++k)
				add(sum[i][j], ex[j][k]);
	f[0] = 1;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 0; j <= c; ++j)
			g[j] = 0;
		for (int j = 0; j <= c; ++j)
			for (int k = c; k >= j; --k)
				if (f[k - j])
					g[k] = (1ll * f[k - j] * sum[i][j] + g[k]) % mod;
		for (int j = 0; j <= c; ++j)
			f[j] = g[j];
	}
	printf("%d\n", f[c]);
	return 0;
}

Measured memory_bytes: 1536
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main(){
    int i;
    int c = 0;
    char s[200001], t[200001];

    scanf("%s", s);
    scanf("%s", t);

    for(i = 0;s[i] != '\0';i++) if(s[i] != t[i]) c++;
    printf("%d", c);

    return 0;
}

Measured memory_bytes: 2024
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - HSI
            var line = ReadLine();
            int N = line[0];
            int M = line[1];

            var magnification = (int)Math.Pow(2, M);
            int times = 1900 * M + (N - M) * 100;

            Console.WriteLine(times * magnification);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 11348
#include<stdio.h>
#include<math.h>

int main(void){
	
	int i,j,n,m[10000],count,coun;
	count=0;
	coun=0;
	
	scanf("%d",&n);
	
	for(i=0; i<n; i++){
		scanf("%d",&m[i]);
	}
	
	for(i=0; i<n; i++){
		if(m[i]==2){
			coun++;
		}
	}
	
	for(i=0; i<n; i++){
		if(m[i]%2 != 0){
			for(j=3; j<= sqrt(m[i]); j=j+2){
						if(m[i]%j==0){
							count++;
						}
				}
				if(count==0){
					coun++;
				}
			count=0;
		}
	}
	
	printf("%d\n",coun);
	
	return 0;
	
}


Measured memory_bytes: 2100
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()

using namespace std;

namespace Dump {
#define dump(...) Dump::print(#__VA_ARGS__, __VA_ARGS__)
static std::vector<string> dumpKey;
static string dumpKeyBuf;

void print() { cerr << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
  if (dumpKey.empty()) {
    dumpKeyBuf = head;
    dumpKeyBuf.erase(std::remove_if(dumpKeyBuf.begin(), dumpKeyBuf.end(),
                                    [](char c) { return c == ' '; }),
                     dumpKeyBuf.end());

    std::istringstream stream(dumpKeyBuf);
    string field;
    while (std::getline(stream, field, ','))
      dumpKey.push_back(field);

    reverse(dumpKey.begin(), dumpKey.end());
  } else {
    cerr << dumpKey.back() << ":" << head << "  ";
    dumpKey.pop_back();
  }
  Dump::print(std::move(tail)...);
}
}

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pii; // p.first p.second

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(string S) {
  if (S.size() < 4) {
    cout << "No" << endl;
    return;
  }

  string ss = S.substr(0, 4);
  if (ss == "YAKI") {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  dump(ss);
}

int main() {
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  solve(S);
  return 0;
}


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

int H,W;
int field[1000][1000];
long path[1001][1001];

int main(){
    int H,W;
    cin >> H >> W;
    char inp;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> inp;
            if(inp=='#') field[i][j] = 1;
            else field[i][j] = 0;
            path[i][j]=0;
        }
        cin.ignore();
    }
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            path[i][j]=0;
        }
    }
    path[0][0]=1;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            path[i][j]%=DIV;
            if(field[i][j]==1){
                path[i][j]=0;
            }else{
                path[i+1][j]+=path[i][j];
                path[i][j+1]+=path[i][j];
            }
            //cout << path[i][j];
        }
        //cout << endl;
    }
    cout << path[H-1][W-1];
    return 0;
}

Measured memory_bytes: 12032
def main():
    tableA,tableB = make_table()
    while True:
        try:
            s = "".join(map(lambda c: tableA[c],raw_input()))
        except:
            break
        tmp,ans = "",""
        for c in s:
            tmp += c
            if tmp in tableB:
                ans += tableB[tmp]
                tmp = ""
        print ans
    
def make_table():
    tableA={
        "A":"00000",
        "B":"00001",
        "C":"00010",
        "D":"00011",
        "E":"00100",
        "F":"00101",
        "G":"00110",
        "H":"00111",
        "I":"01000",
        "J":"01001",
        "K":"01010",
        "L":"01011",
        "M":"01100",
        "N":"01101",
        "O":"01110",
        "P":"01111",
        "Q":"10000",
        "R":"10001",
        "S":"10010",
        "T":"10011",
        "U":"10100",
        "V":"10101",
        "W":"10110",
        "X":"10111", 
        "Y":"11000",
        "Z":"11001",
        " ":"11010",
        ".":"11011",
        ",":"11100",
        "-":"11101",
        "'":"11110",
        "?":"11111"}
    tableB ={
        "101":" ",
        "000000":"'",
        "000011":",",
        "10010001":"-",
        "010001":".",
        "000001":"?",
        "100101":"A",
        "10011010":"B",
        "0101":"C",
        "0001":"D",
        "110":"E",
        "01001":"F",
        "10011011":"G",
        "010000":"H",
        "0111":"I",
        "10011000":"J",
        "0110":"K",
        "00100":"L",
        "10011001":"M",
        "10011110":"N",
        "00101":"O",
        "111":"P",
        "10011111":"Q",
        "1000":"R",
        "00110":"S",
        "00111":"T",
        "10011100":"U",
        "10011101":"V",
        "000010":"W",
        "10010010":"X",
        "10010011":"Y",
        "10010000":"Z"}
    return tableA,tableB

if __name__ == "__main__":
    main()

Measured memory_bytes: 4348
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    N=ii()
    D=lmis()
    ans=0
    for i in range(N-1):
        for j in range(i+1,N):
            ans+=D[i]*D[j]
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>

using namespace std;

int m[6] = {200, 300, 500, 1000, 1200, 1500};

int v[6] = {380, 550, 850, 1520, 1870, 2244};

int main(){
	int n;
	
	int price[10000];
	
	for(int i = 0; i < 10000; i++){
		price[i] = 1 << 30;
	}
	
	for(int i = 0; i < 6; i++){
		price[m[i]] = v[i];
	}
	
	for(int loop = 0; loop < 50; loop++){
		for(int i = 0; i <= 5000; i++){
			for(int j = 0; j < 6; j++){
				if(price[i + m[j]] > price[i] + v[j]){
					price[i + m[j]] = price[i] + v[j];
				}
			}
		}
	}
	
	cin >> n;
	
	while(n != 0){
		
		printf("%d\n", price[n]);
		
		cin >> n;
	}
	
	return 0;
}

Measured memory_bytes: 1180
#include<stdio.h>
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int h[n];
	int flag[n];
	for(int i=1;i<=n;i++){
	scanf("%d",&h[i]);
	flag[i]=1;
	}
	for(int i=1;i<=m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		if(h[a]>=h[b]){
			flag[b]=0;
		}
		if(h[a]<=h[b])
		flag[a]=0;
	}
	int count=0;
	for(int i=1;i<=n;i++){
		if(flag[i]==1)
		count++;
	}
	printf("%d",count);
}

Measured memory_bytes: 2460
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
const int INF = 1 << 16;
const int zero = 0b0000000000000000;
const int ones = 0b1111111111111111;
const int abcd[] = {
    0b1111111100000000,
    0b1111000011110000,
    0b1100110011001100,
    0b1010101010101010
};

int flip(int x) { return ones ^ x; }
int calc(int x, char op, int y) { return op == '*' ? x & y : x ^ y; }

int expr(string &s, int &i) {
    if (s[i] == '-') {
        i++;
        return flip(expr(s, i));
    } else if (s[i] == '(') {
        i++;
        int left = expr(s, i);
        char op = s[i++];
        int right = expr(s, i);
        i++;
        return calc(left, op, right);
    } else {
        if (s[i] == '0') return i++, zero;
        if (s[i] == '1') return i++, ones;
        return abcd[s[i++] - 'a'];
    }
}

int main() {
    map<int, int> dp;
    dp[zero] = dp[ones] = 1;
    for (int i = 0; i < 4; i++) dp[abcd[i]] = 1, dp[flip(abcd[i])] = 2;
    for (int i = 0; i < 3; i++) {
        map<int, int> nxt = dp;
        for (auto p: dp) for (auto q: dp) {
            int val = p.second + q.second + 3;
            if (val > 16) continue;
            for (char op: "*^") {
                int key = calc(p.first, op, q.first);
                if (nxt[key] == 0) nxt[key] = INF, nxt[flip(key)] = INF;
                nxt[key] = min(nxt[key], val);
                nxt[flip(key)] = min(nxt[flip(key)], val + 1);
            }
        }
        swap(nxt, dp);
    }
    string s;
    while (cin >> s, s != ".") {
        int i = 0;
        cout << dp[expr(s, i)] << endl;
    }
    return 0;
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL sum;
int a[3030], n, s;
LL dp[3030];
void add(LL &x, LL y){
  x += y;
  if (x >= 998244353) x -= 998244353;
}
int main(){
  	cin>>n>>s;
  	for (int i=1;i<=n;i++) cin>>a[i];
  	sum = 0;
  	for (int i=1;i<=n;i++){
    	dp[0] += 1;
      	for (int j=s; j>=a[i]; j--) add(dp[j], dp[j-a[i]]);
      	add(sum, dp[s]);
    }
  	cout<<sum<<endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    int a, b, c;
    cin >> a >> b >> c;

    if(a == b && b == c) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}



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

bool sub() {
  string s;
  cin >> s;
  
  int cap = 0;
  int A = 0;
  int C = 0;
  for (char c : s) {
    if (c == 'A') ++A;
    if (c == 'C') ++C;
    if (c >= 'A' && c <= 'Z') ++cap;
  }
  if (cap != 2) return false;
  if (!A || !C) return false;
  if (s[0] != 'A') return false;
  if (s[1] == 'C') return false;
  if (s.back() == 'C') return false;
  return true;
}
int main() {
  cout << (sub() ? "AC" : "WA") << endl;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int n;
	cin >> n;
	vi x(n), y(n);
	rep(i,n) cin >> x[i]; 

	y = x;
	sort(all(x));
  
	// n = 4 のとき x[0] < x[1] < x[2] < x[3]
	// y[i] を x[2] と比較  
	rep(i,n){
		if(y[i] < x[n/2]) cout << x[n/2] << endl;
		else cout << x[n/2-1] << endl;
	}
	return;
}

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

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

int main() {
int m, f, r;
    while(cin >> m >> f >> r){
        if(m==-1 && f==-1 && r==-1) break;
        if(m==-1 || f==-1){
            cout << "F" << endl;
        }
        else if(m+f>=80){
            cout << "A" << endl;
        }
        else if(m+f>=65 && m+f<80){
            cout << "B" << endl;
        }
        else if(m+f>=50 && m+f<65){
            cout << "C" << endl;
        }
        else if(m+f>=30 && m+f<50){
            if(r>=50){
                cout << "C" << endl;
            }
            else{
            cout << "D" << endl;
            }
        }
        else{
            cout << "F" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1156
import numpy as np
n,k = map(int,input().split())
c = [0] * (10**5+1)
for _ in range(n):
  a,b = map(int,input().split())
  c[a] += b

A = np.array(c,dtype=np.int64)
A = A.cumsum()
answer = (A >= k).nonzero()[0].min()
print(answer)

Measured memory_bytes: 16312
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = a * b;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 35632
s = input()
n = int(input())
for _ in range(n):
    l = input().split()
    i_1 = int(l[1])
    i_2 = int(l[2]) + 1
    if l[0] == 'replace':
        s = s[:i_1] + l[3] + s[i_2:]
    elif l[0] == 'reverse':
        s = s[:i_1] + s[i_1:i_2][::-1] + s[i_2:]
    elif l[0] == 'print':
        print(s[i_1:i_2])



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

typedef long long ll;
#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define int ll

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;


void solve() {
	int n;
	cin >> n;
	if(n==1) cout << 0;
	else cout << 1;
}

int32_t main() {
	_

#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
	solve();
	cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}

Measured memory_bytes: 3784
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1277

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>
#include<iomanip>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

const int NONE = 0;
const int LOSE = 1;
const int BACK = 2;

int N,T,L,B;
vector< vector<double> > dp; //dp[turn][pos]
vector<int> board;	

int main()
{
	cout << setiosflags(ios::fixed) << setprecision(8) << endl;

	while(cin >> N >> T >> L >> B && N)
	{
		board.assign(N+1, NONE);
		dp.assign(T+3, vector<double>(N+1,0.0));
		
		int i;
		rep(nth,L){ 
			cin >> i;
			board[i] = LOSE;
		}

		rep(nth,B){ 
			cin >> i; 
			board[i] = BACK;
		}

		dp[0][0] = 1.0;

		REP( turn, 0, T ) //現在のターン数
		{
			REP( pos, 0, N ) //現在のマス
			{
				if(dp[turn][pos] == 0.0){ continue; } //存在しないパターン
				REP( i, 1, 7 ) //サイコロを振る
				{
					int npos =  pos + i; 
					int nturn = turn + 1;
					if(npos > N){ npos = N - (npos-N); }
					if(board[npos] == LOSE){ nturn += 1; }
					if(board[npos] == BACK){ npos = 0; }
					dp[nturn][npos] += dp[turn][pos] * (1.0/6.0);
				}
			}
		}

		double ans=0;
		rep(i,T+1){
			ans += dp[i][N];
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

int main(void) {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    while(B <= A) {
        --K;
        B *= 2;
    }
    while(C <= B) {
        --K;
        C *= 2;
    }

    if(K >= 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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

int main(){
    int n; cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    int ans = a[0];
    for(int t : a) ans = gcd(ans, t);

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

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

int main() {
  int N;
  cin >> N;
  vector<long> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  reverse(A.begin(), A.end());
  reverse(B.begin(), B.end());
  long ans = 0;
  for (int i = 0; i < N; i++) {
    long a = A[i], b = B[i];
    a += ans;
    int r = a % b;
    if (r) {
      ans += b - r;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  for(int loop=1;loop<=9;loop++){
    for(int loop2=1;loop2<=9;loop2++){
      if(loop*loop2==n){
        printf("Yes");
        return 0;
      }
    }
  }
  printf("No");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int N, M, K;

double rec(int k, double sum) {
  if(k == N) {
    return max(1.0, sum-K);
  }
  double res = 0;
  for(int i = 1; i <= M; ++i) {
    res += rec(k+1, sum+i);
  }
  return res;
}

int main() {
  while(cin >> N >> M >> K && (N|M|K)) {
    printf("%.10f\n", rec(0, 0.0)/pow((double)M, (double)N));
  }
  return 0;
}

Measured memory_bytes: 1248
import fractions


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    mul = a[0]
    for i in range(1, n):
        mul = mul * a[i] // fractions.gcd(mul, a[i])
    for i in a:
        if mul // i % 2 == 0:
            print(0)
            exit()
    if m >= mul // 2:
        ans = (m - mul // 2) // mul + 1
        print(int(ans))
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 16280
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end());
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, m, b[N], e[N];
ll s[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  int p;
  ll _ans = 0;
  int c = 0;
  FOR(i, 0, n){
    int a;
    cin >> a;
    a--;
    if(i && a!=p){
      b[p]++;
      e[a]++;
      s[a] += (a-p+m-1)%m;
      _ans += (a<p ? a+1 : a-p);
      if(a<p && 1<=a) c++;
    }
    p = a;
  }
  ll ans = _ans;
  FOR(i, 1, m){
    _ans -= c;
    _ans += s[i-1];
    mins(ans, _ans);
    c += b[i-1];
    c -= e[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
typedef long long ll;
const int N=200010;

int n;
int sum,a[N];

int main()
{
	cin>>n;
	int s=0;
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
		s^=a[i];
	}
	
	for(int i=0; i<n; i++)
	{
		int x=s^a[i];
		cout<<x<<' ';
	}
	
	return 0;
}

Measured memory_bytes: 4300
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

constexpr Int mod = 1e9+7;
vector<Int> p;

Int calc_nod(Int n){
	Int cnt = 0;
	for(auto i:p){
		if(i > n) break;
		if(n % i == 0){
			++cnt;
			n /= i;
			if(n % i == 0){
				cnt = -1e9;
			}
		}
	}
	return max<Int>(cnt, 0ll);
}

Int calc_pn(Int m, Int n){
	Int res = 1;
	while(n > 0){
		if((n & 1) == 1){
			res = res * m % mod;
		}
		m = m * m % mod;
		n >>= 1;
	}
	return res;
}

Int func(Int m, vector<Int> &pn, vector<Int> &nod){
	Int res = pn[m];
	for(Int i=2; i<=m; ++i){
		if(nod[i] == 0) continue;
		res = (res + (1-2*(nod[i]%2)) * pn[m/i] + mod) % mod;
	}
	return res;
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	Int n, k; cin >> n >> k;
	for(Int i=2; i<=k; ++i){
		bool f = true;
		for(auto j:p){
			if(i % j == 0){
				f = false;
				break;
			}
		}
		if(f) p.push_back(i);
	}
	vector<Int> nod(k+1);
	for(Int i=1; i<=k; ++i)
	nod[i] = calc_nod(i);
	vector<Int> pn(k+1);
	for(Int i=1; i<=k; ++i)
		pn[i] = calc_pn(i, n);
//	for(Int i=1; i<=k; ++i)
//		cout << i << " " << pn[i] << "\n";
	Int ans = 0;
	for(Int i=1; i<=k; ++i){
//		cout << i << " " << func(k/i, pn, nod) << "\n";
		ans = (ans + i * func(k/i, pn, nod) % mod) % mod;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 4920
# import sys
# input = lambda: sys.stdin.readline().rstrip()

def resolve():
    while True:
        n = int(input())

        if n == 0:
            exit()
        w = list(map(int, input().split()))
        
        dp = [[0]*(n+1) for _ in range(n+2)]
        for gap in range(2,n+1):
            for l in range(n-gap+1):
                r = l + gap
                if dp[l+1][r-1] == gap-2:
                    if abs(w[l] - w[r-1]) <= 1:
                        dp[l][r] = gap
                    else:
                        dp[l][r] = gap - 2
                for k in range(l,r):
                    if dp[l][k] + dp[k][r] > dp[l][r]:
                            dp[l][r] = dp[l][k] + dp[k][r]
                    # dp[l][r] = max(dp[l][r], dp[l][k] + dp[k][r])
        # for i in range(n):
        #     print(*dp[i])
        print(dp[0][-1])
if __name__ == "__main__":
    resolve()


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

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;

void solve() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll ans = 0;
	
	while(k > 0) {
		//cout << ans << " ";
		if(a > 0) {
			
			ans += (k >= a ? a : k);
			k -= a;
			a = 0;
		}
		else if(b > 0) {
			k -= b;
			b = 0;
		}
		else {
			ans -= k;
			k = 0;
			c = 0;
		}
	}

	cout << ans << "\n";
}

int32_t main() {_
	//tc(t)
		solve();
}



Measured memory_bytes: 3652
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;

int main(){
    int h, m, s;
    cin >> s;

    h = s / 3600;
    m = s%3600 / 60;
    s = s % 60;

    cout << h << ":" << m << ":" << s << endl;
}


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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  sort(l.rbegin(), l.rend());
  
  int sum = 0;
  rep(i, k) {
    sum += l[i];
  }
  
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <math.h>

int main(int argc, char** argv)
{
	int i, num;
	scanf("%d", &num);

	for (i = 1; i <= num; i++) {
		int x = i;
		if (x % 3 == 0) {
			printf(" %d", i);
		}
		else {
			while (1) {
				if (x % 10 == 3) {
					printf(" %d", i);
					break;
				}

				x /= 10;
				if (x == 0) {
					break;
				}
			}
		}
	}

	printf("\n");
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
  	cin >> s;
  	int mi = 999;
  	for(int i = 0 ; i <= s.size() - 3; i++){
      	int x = 100 , num = 0;
		for(int j = i ; j < i + 3 ; j++){
			// cout  << s[j] - '0'<< endl;
			num += ((s[j] - '0' ) * x);
          	x /= 10;
        }
        // cout << num << endl;
      	mi = min(mi , abs(num - 753));
    }
  	cout << mi << endl;
 	return 0; 	
}

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d.at(i);
  bool fin = false;
  while (!fin) {
    fin = true;
    rep(i, n-1) {
      if (d.at(i) < d.at(i+1)) {
        fin = false;
        int temp = d.at(i);
        d.at(i) = d.at(i+1);
        d.at(i+1) = temp;
      }
    }
  }
  int x, ans = 0;
  rep(i, n) {
    if (i == 0 || x > d.at(i)) {
      x = d.at(i);
      ans++;
    }
  } 
  cout << ans << endl;
}


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

int main(){
  string s;
  cin >> s;
  if (s == "Sunny") cout << "Cloudy" << endl;
  if (s == "Cloudy") cout << "Rainy" << endl;
  if (s == "Rainy") cout << "Sunny" << endl;

  
  
 
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int _=2e5+5;
const int mod=1e9+7;
inline int read()
{
	char ch='!';int z=1,num=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')z=-1,ch=getchar();
	while(ch<='9'&&ch>='0')num=(num<<3)+(num<<1)+ch-'0',ch=getchar();
	return z*num;
}
int n,f[_],g[_],zhan[_],top,sz[_],jc[_];
struct ha{int c,w;
	bool operator < (const ha &A) const
		{
			return c^A.c?c<A.c:w<A.w;
		}
}t[_];
int ksm(int a,int b)
{
	int r=1;
	for(;b;b>>=1,a=1ll*a*a%mod)if(b&1)r=1ll*r*a%mod;
	return r;
}
int main()
{
	n=read();int x=read(),y=read();
	jc[0]=1;for(int i=1;i<=n;++i)t[i].c=read(),t[i].w=read(),jc[i]=1ll*jc[i-1]*i%mod;
	sort(t+1,t+1+n);f[0]=g[n+1]=g[0]=1e9+5;
	for(int i=1,j=1;i<=n;++i)
	{
		while(j<=n&&t[i].c==t[j].c)f[j++]=min(f[i-1],t[i].w);
		i=j-1;
	}
	for(int i=n,j=n;i;--i)
	{
		while(j&&t[i].c==t[j].c)g[j]=min(g[i+1],t[j].w),--j;
		i=j+1;
	}
	for(int i=1;i<=n;++i)
	{
		int j=i+1;
		zhan[++top]=i;sz[top]=1;
		while(j<=n&&t[i].c==t[j].c)++j;
		for(int k=i+1;k<j;++k)
			if(t[k].w+t[i].w<=x||t[k].w+min(f[i-1],g[j])<=y)sz[top]++;
		i=j-1;
	}
	int fz=0,fm=1;
	for(int i=1;i<=top;++i)
		if(t[zhan[i]].w+min(f[zhan[i-1]],g[zhan[i+1]])<=y)(fz+=sz[i])%=mod,fm=1ll*fm*jc[sz[i]]%mod;
	printf("%lld\n",1ll*jc[fz]*ksm(fm,mod-2)%mod);
	return 0;
}

Measured memory_bytes: 5760
#![allow(dead_code)]
#![allow(unused_imports)]

use std::cmp;
use std::mem::swap;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        h: i64,
        w: i64,
        img: [String; h],
    }
    for _ in 0..w+2 {
        print!("#");
    }
    println!();
    for i in 0..h {
        println!("#{}#", img[i as usize]);
    }
    for _ in 0..w+2 {
        print!("#");
    }
    println!();
}


Measured memory_bytes: 4352
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return(false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return(true);
  }

  int find(int k)
  {
    if(data[k] < 0) return(k);
    return(data[k] = find(data[k]));
  }

  int size(int k)
  {
    return(-data[find(k)]);
  }

  bool same(int x, int y)
  {
      return find(x) == find(y);
  }
};

string op(int sign)
{
    return sign == 0 ? "+" : "-";
}

int main()
{
    int N;
    cin >> N;
    int a;
    map<int, int> m;
    REP(i, N)
    {
        cin >> a;
        ++m[a];
    }
    int ans = 0;
    for (auto pair : m)
    {
        if (pair.second >= pair.first)
        {
            ans += pair.second - pair.first;
        }
        else
        {
            ans += pair.second;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4736
import sys
import datetime
def input(): return sys.stdin.readline().strip()

s  = lambda: input()

S = s()

a = S[:2]
b = S[2:]

yymm = True
mmyy = True
try:
  datetime.datetime.strptime(a+b, "%y%m")
except:
  yymm = False

try:
  datetime.datetime.strptime(b+a, "%y%m")
except:
  mmyy = False

if yymm and mmyy:
  print('AMBIGUOUS')
elif yymm:
  print('YYMM')
elif mmyy:
  print('MMYY')
else:
  print('NA')



Measured memory_bytes: 4668
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef long long int llint;
typedef vector<int> vint;
typedef vector< vector<int> > vvint;
typedef vector<string> vstr;


int main(void) {
	int a, b, c, d,jur;
	cin >> a >> b >> c >> d;
	if (a != 1 && a != 9 && a != 7 && a != 4)jur = 0;
	else if (b != 1 && b != 9 && b != 7 && b != 4)jur = 0;
	else if (c != 1 && c != 9 && c != 7 && c != 4)jur = 0;
	else if (d != 1 && d != 9 && d != 7 && d != 4)jur = 0;
	else if (a != b && a != c && a != d && b != c && b != d && c != d)jur = 1;
	else jur = 0;
	if (jur == 0)cout << "NO" << endl;
	else cout << "YES" << endl;
}


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

using namespace std;

int main()
{
	int n, r = 0;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	sort(a.begin(), a.end());
	for (auto p = a.begin(); p != a.end();) {
		auto u = upper_bound(p, a.end(), *p);
		if (u - p < *p)
			r += u - p;
		else r += u - p - *p;
		p = u;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 768
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
from collections import defaultdict
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    d = defaultdict(int)
    for _ in range(N):
        c = readline().decode('utf-8').strip()
        d[c]+=1
    d['AC'] += 0
    d['WA'] += 0
    d['TLE'] += 0
    d['RE'] += 0

    print('AC x ' + str(d['AC']))
    print('WA x ' + str(d['WA']))
    print('TLE x ' + str(d['TLE']))
    print('RE x ' + str(d['RE']))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9520
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>

using namespace std;

int main () {
  int n, H[252];

  cin >> n;

  for (int i = 1; i <= n; i++) {
    cin >> H[i];
  }

  for (int i = 1; i <= n; i++) {
    cout << "node " << i << ": ";
    cout << "key = " << H[i] << ", ";
    
    if (i != 1)
      cout << "parent key = " << H[(int)floor(i / 2)] << ", ";
    
    if ((i * 2) <= n)
      cout << "left key = " << H[i * 2] << ", ";
    if ((i * 2 + 1) <= n)
      cout << "right key = " << H[i * 2 + 1] << ", ";

    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3088