akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	static int n, k;
	static int[][] arr;
	static long[][] memo;
	static boolean f = false;
	static boolean t = false;
	static int OO = (int) 1e18;

	static long dp(int i, int k) {
		if (k < 0)
			return -OO;
		if (i == n) {
			return 0;
		}

		if (memo[k][i] != -1)
			return memo[k][i];

		long take = arr[i][1] + dp(i + 1, k - arr[i][0]);
		long leave = dp(i + 1, k);

		return memo[k][i] = Math.max(take, leave);
	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);

		StringTokenizer st = new StringTokenizer(br.readLine());
		n = Integer.parseInt(st.nextToken());
		k = Integer.parseInt(st.nextToken());

		arr = new int[n + 1][2];
		for (int i = 0; i < n; i++) {
			st = new StringTokenizer(br.readLine());
			arr[i][0] = Integer.parseInt(st.nextToken());
			arr[i][1] = Integer.parseInt(st.nextToken());
		}
		memo = new long[k+1][n+1];

		for (int i = 0; i < k+1; i++)
			Arrays.fill(memo[i], -1);
		long ans = -1;

		for(int i = 0;i<n;i++)
			ans= Math.max(ans, dp(i, k));
		pw.print(ans);
		pw.close();
	}
}


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

using namespace std;
int main()
{
	string str;
	getline(cin, str);
	int K = stoi(str);
	int odd = K % 2 == 0 ? K / 2 : (K + 1) / 2;
	int even = K - odd;
	cout << odd * even << endl;
	return 0;
}

Measured memory_bytes: 256
import bisect
import math
n = int(input())
a = list(map(int,input().split()))

s = [0]*(n+1)

for i,e in enumerate(a):
    s[i+1] = s[i] + e

def comb(n,m):
    return math.factorial(n)//math.factorial(m)//math.factorial(n-m)

ans = 0
s = sorted(s)

l = 0
r = 0
#print(s)
while l < n+1:
    while r < n+1  and s[l] == s[r]:
        #print(r,s[r])
        r += 1

    if r-l >= 2:
        ans += comb(r-l,2)
    l = r

print(ans)


Measured memory_bytes: 25604
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		Node W[] = new Node[n];
		int s=Integer.MAX_VALUE; 
		int cost = 0;
		for(int i=0; i<n; i++){
			W[i] = new Node();
			W[i].value = scanner.nextInt();
			W[i].place = -1;
			if(s > W[i].value) s = W[i].value;
		}

		for(int j=0; j<n; j++){
			int min=Integer.MAX_VALUE, place=-1;
			for(int i=0; i<n; i++){
				if(W[i].place != -1) continue;
				if(min > W[i].value){
					min = W[i].value;
					place = i;
				}
			}
			W[place].place = j;
		}

		for(int i=0; i<n; i++){
			int j=W[i].place;
			if(j != -1 && j != i){
				int cnt=1, min, sum;
				min = sum = W[i].value;
				while(j != i){
					int next = W[j].place;
					if(min > W[j].value) min = W[j].value;
					sum += W[j].value;
					cnt++;
					W[j].place = -1;
					j = next;
				}
				cost += sum+(cnt-2)*min<sum+min+(cnt+1)*s?
				        sum+(cnt-2)*min:
				        sum+min+(cnt+1)*s;
			}
		}

		System.out.println(cost);
	}
}
class Node{
	int value;
	int place;
}


Measured memory_bytes: 32028
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define INF 1e9
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    vector<int> v(3*n);
    rep(i,3*n) cin >> v[i];
    sort(RALL(v));
    ll ans = 0;
    int num = 1;
    rep(i,n){
        ans += v[num];
        num += 2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
n = int(input())
lst = list(map(int, input().split()))

MOD = 1000000007

def mod(n):         
  return n % MOD

def multiply(a, b): #mod(a*b)を求める
  return mod(mod(a)*mod(b))

ans = sum(lst)**2

for i in range(n):
  ans -= lst[i]**2
  
ans = ans//2
print(mod(ans))

Measured memory_bytes: 94212
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

n=int(input())
ab=[list(map(int,input().split())) for i in range(n-1)]
dic=defaultdict(list)
for i in range(n-1):
    a,b=ab[i]
    dic[a].append(b)
    dic[b].append(a)
# print(dic)

lst=[0]*(n+1)
f=deque([1])
s=deque([n])
fcnt,scnt=0,0
while 1:
    flag=0
    for i in range(len(f)):
        tmp=f.popleft()
        if lst[tmp]==0:
            lst[tmp]=1
            fcnt+=1
            flag=1
            for j in dic[tmp]:
                f.append(j)
    
    for i in range(len(s)):
        tmp=s.popleft()
        if lst[tmp]==0:
            lst[tmp]=1
            scnt+=1
            flag=1
            for j in dic[tmp]:
                s.append(j)
    
    if flag==0:
        break
    

if fcnt>scnt:
    print("Fennec")
else:
    print("Snuke")

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

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

  long long L, R;
  cin >> L >> R;

  long long ans = 1e7;
  for(long long i = L; i <= min(R, L + 2019); i++) {
    for(long long j = i + 1; j <= min(R, L + 2019); j++) {
      ans = min(ans, (i * j) % 2019);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            String s = in.next();
            StringBuilder res = new StringBuilder();
            for (int i = 0; i < s.length(); i++) {
                if (i % 2 == 0) {
                    res.append(s.charAt(i));
                }
            }
            System.out.println(res.toString());
        }
    }
}


Measured memory_bytes: 30768
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 998244353;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

clock_t start=clock();
const double tl = 1.9;
const double T0=1500;
const double T1=6e2;
double T=T0;

const int w=5;
const int k=50;
const int n=26;

int d;
VI c(n);
VVI s(365,VI(n));

struct st{
	VI a;
	ll score;
	bool operator<(const st &another) const {return score < another.score;};
};

ll f(VI a){
	ll ret=0;
	VI last(n,-1);
	REP(i,d){
		last[a[i]]=i;
		ret+=s[i][a[i]];
		REP(j,26)
			ret-=c[j]*(i-last[j]);
	}
	return ret;
}

vector<st> f2(st p){
	VI a=p.a; ll score=p.score;
	int now=a.size()+1;
	VI last(n,0);
	REP(i,a.size())
		last[a[i]]=i+1;
	VI down(n); ll downsum=0;
	REP(i,n){
		down[i]=c[i]*(now-last[i]);
		downsum+=down[i];
	}
	a.push_back(-1);
	vector<st> tmp;
	REP(i,n){
		a[now-1]=i;
		tmp.push_back({a,score-downsum+down[i]+s[now-1][i]});
	}
	sort(ALL(tmp));
	vector<st> ret;
	REP(i,w)
		ret.push_back(tmp[n-1-i]);
	return ret;
}

int main(){
	cin >> d;
	REP(i,n) cin >> c[i];
	REP(i,d)REP(j,n) cin >> s[i][j];
	priority_queue<st> q;
	VI a(0);
	q.push({a,0});
	REP(i,d){
		priority_queue<st> next;
		REP(j,k){
			if(q.empty())
				break;
			for(auto nx:f2(q.top()))
				next.push(nx);
			q.pop();
		}
		q=next;
	}
	VI ans(d,10); ans=q.top().a;
	int cnt=0;
	while(1){
		cnt++;
		if(cnt%100==0){
			double t=(double)(clock()-start)/CLOCKS_PER_SEC/tl;
			if(t>=1.0)
				break;
			T=pow(T0,1.0-t)*pow(T1,t);
		}
		ll oldscore=f(ans);
		if(rand()%2){
			int cd=rand()%d;
			int old=ans[cd];
			ans[cd]=rand()%26;
			ll newscore=f(ans);
			if(rand()%1000000<=exp((newscore-oldscore)/T)*1e6)
				continue;
			ans[cd]=old;
		}
		else{
			int cd1=rand()%(d-1);
			int cd2=cd1+1+(rand()%(d-cd1-1));
			swap(ans[cd1],ans[cd2]);
			ll newscore=f(ans);
			if(rand()%1000000<=exp((newscore-oldscore)/T)*1e6)
				continue;
			swap(ans[cd1],ans[cd2]);
		}
	}
	REP(i,d)
		cout << ans[i]+1 << endl;
	//cout << f(ans) << endl;
	return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <vector>
using namespace std;

int W, H;
char field[100][100];
string dp[100][100];

bool compare(const string& s1, const string& s2){
  if(s1.size() != s2.size()) return !(s1.size() > s2.size());
  else return !(s1 > s2);
}

void output(){  
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      cout << dp[i][j] << ' ';
    }
    cout << endl;
  }
}

void init(){
  for(int i = 0 ; i < 71 ; i++){
    for(int j = 0 ; j < 71 ; j++){
      dp[i][j] = "";
    }
  }
}

string adjust(string s){
  if(s.size() == 1) return s;
  bool f = false;
  for(int i = 0 ; i < s.size() ; i++){
    if(s[i] != '0') f = true;
  }
  if(!f) return "0";
  for(int i = 0 ; i < s.size() ; i++){
    if(s[i] == '0') continue;
    else{
      //cout << s.substr(i) << endl;
      return s.substr(i);
    }
  }
}

int main(){
  while(cin >> W >> H){
    if(W == 0 && H == 0) break;
    init();
    vector<string> vec;
    vec.clear();
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
	cin >> field[i][j];
      }
    }
    
    string ans = "";
    
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
	if(!isdigit(field[i][j])) continue;
	if(i == 0 && j == 0) dp[i][j] = field[i][j];
	else if(i == 0) dp[i][j] = dp[i][j-1] + field[i][j];
	else if(j == 0)	dp[i][j] = dp[i-1][j] + field[i][j];
	else dp[i][j] = max(dp[i][j-1]+field[i][j], dp[i-1][j]+field[i][j], compare);
	vec.push_back(dp[i][j]);
      }
    }
    for(int i = 0 ; i < vec.size() ; i++){
      vec[i] = adjust(vec[i]);
      ans = max(ans, vec[i], compare);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1544
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define int long long
#define F first
#define S second
using namespace std;
typedef long long ll;
ll n,m;
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
ll num[105];
signed main()
{

    //ios_base::sync_with_stdio(0),cin.tie(0);
    while(cin>>n)
    {
        priority_queue<double,vector<double>,greater<double> > pq;
        rep(i,n)
        {
            double tmp;
            cin>>tmp;
            pq.push(tmp);

        }
        while(pq.size()>1)
        {
            double tmp1=pq.top();
            pq.pop();
            double tmp2=pq.top();
            pq.pop();
            //cout<<tmp1<<" "<<tmp2<<"\n";
            pq.push((tmp1+tmp2)/2);
        }
        cout<<pq.top()<<"\n";
    }
    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<long> h(n);
    int ans=0;
    int count=0;
    rep(i,n){
        cin>>h[i];
        if(i>0 && h[i-1]>=h[i]){
            count++;
        }else if(i>0 && h[i-1]<h[i]){
            ans=max(ans,count);
            count=0;
        }
    }
    ans=max(ans,count);
    cout<<ans<<endl;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> A(N), B(N), C(N-1);
    rep (i, N) {
        cin >> A[i];
        A[i]--;
    }

    rep (i, N) {
        cin >> B[i];
    }

    rep (i, N-1) {
        cin >> C[i];
    }

    ll ans = 0;
    rep (i, N) {
        ans += B[i];
    }

    rep (i, N-1) {
        if (A[i]+1 == A[i+1]) {
            ans += C[A[i]];
        }
    }

    cout << ans << 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 eee(a) (cerr << (#a) << ": " << (a) << endl);

using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){
    return (a%b+b)%b;
}
ll gcd(ll a, ll b){
    return b ? gcd(b, a%b) : a;
}
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}
void Yes(){
    cout << "Yes" << endl;
}
void No(){
    cout << "No" << endl;
}
void Judge(bool b){
    b ? Yes() : No();
}
void YES(){
    cout << "YES" << endl;
}
void NO(){
    cout << "NO" << endl;
}
void JUDGE(bool b){
    b ? YES() : NO();
}
ll powmod(ll b, ll e){
    ll r = 1; while(e > 0) {if(e&1) r = (r%MOD)*(b%MOD)%MOD; b = (b%MOD)*(b%MOD)%MOD; e >>= 1;} return r;
}
double distance(ll x1, ll y1, ll x2, ll y2){
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

template<class T>bool chmax(T &a, const T &b) {
    if(a < b) { a = b; return 1; } return 0;
}
template<class T>bool chmin(T &a, const T &b) {
    if(b < a) { a = b; return 1; } return 0;
}
template<typename T>
void ppp(T n){
    cout << n << endl;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for(int i = 0; i < len; ++i) {
        s << v[i]; if(i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa {
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
} fastio;

vector<vector<vector<int> > > dp;

int main(){

    string s;
    int d;
    cin >> s >> d;
    int n = s.size();
    dp.resize(n+1, vector<vector<int> >(d, vector<int>(2)));
    dp[0][0][0] = 1;
    rep(i, n){
        int x = s[i]-'0';
        rep(j, d){
            rep(k, 10) (dp[i+1][(j+k)%d][1] += dp[i][j][1]) %= MOD;
            rep(k, x)  (dp[i+1][(j+k)%d][1] += dp[i][j][0]) %= MOD;
            (dp[i+1][(j+x)%d][0] += dp[i][j][0]) %= MOD;
        }
    }
    ppp((dp[n][0][0]+dp[n][0][1]-1+MOD)%MOD);

    return 0;
}


Measured memory_bytes: 55424
#include <stdio.h>
int main()
{
  long A,B,K;
  scanf("%ld %ld %ld",&A,&B,&K);
  long i;
  i = 0;
  i = A - K;
  if (i < 0)
  {
    i = i+B;
   	if (i <= 0)
    {
      printf("0 0");
      return (0);
    }
    printf("0 %ld",i);
    return(0);
  }
  else
    printf("%ld %ld",i,B);
}

Measured memory_bytes: 128
using namespace std;
#include <bits/stdc++.h>
#define frr(i, r, l) for(int i = r; i >= l; --i)
#define fr(i, l, r) for(int i = l; i < r; ++i)
#define forit(it, type, var) for(type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define MEMS(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define ll long long
#define ld long double
typedef pair<ll, ll> iPair; 
priority_queue< ll, vector <ll> , greater<ll>>pq1,pq2;
#define maxN 1000000000000000000
ll power(ll a,ll b){ll res=1;while(b>0){res*=a;b--;}return res;}
ll n,m,p,rw[300005],cl[300005],mx1=0,mx2=0,x,y,temp[300005];
vector<ll>w[300005],v1,v2;
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin>>n>>m>>p;

    fr(i,0,p)
    {
        cin>>x>>y;
        rw[x]++;
        if(rw[x]>=mx1)
        mx1=rw[x];

        cl[y]++;
        if(cl[y]>=mx2)
        mx2=cl[y];

        w[x].pb(y);
    }

    fr(i,1,n+1)
    {
        if(rw[i]==mx1)
        v1.pb(i);
    }
    fr(j,1,m+1)
    {
        if(cl[j]==mx2){
        v2.pb(j);}
    }
    ll fl=0;
    fr(i,0,v1.size())
    {
        ll st=v1[i];
        if(v2.size()>w[st].size())
        {
            fl=1;
            break;
        }
        fr(j,0,w[st].size())
        {
            temp[w[st][j]]++;
        }

        fr(j,0,v2.size())
        {
            if(temp[v2[j]]==0)
            {
                fl=1;
                break;
            }
        }
        fr(j,0,w[st].size())
        {
            temp[w[st][j]]=0;
        }
    }

    if(fl==1)
    {
        cout<<mx1+mx2<<endl;
    }
    else
    {
        cout<<mx1+mx2-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 32708
/**
 *    author:  tourist
 *    created: 10.05.2020 20:16:33       
**/
#include <bits/stdc++.h>

using namespace std;

bool Ok(vector<pair<int, int>>& a) {
  int n = (int) a.size();
  sort(a.begin(), a.end(), [&](pair<int, int> x, pair<int, int> y) {
    return x < y;
  });
  multiset<int> s;
  int sum = 0;
  int ptr = 0;
  for (int it = 0; it < n; it++) {
    while (ptr < n && a[ptr].first <= sum) {
      s.emplace(a[ptr].second - a[ptr].first);
      ++ptr;
    }
    if (s.empty()) {
      return false;
    }
    auto iter = prev(s.end());
    sum += *iter;
    s.erase(iter);
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  long long total = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    vector<char> st;
    for (char c : s) {
      if (c == '(') {
        st.push_back(c);
      } else {
        if (!st.empty() && st.back() == '(') {
          st.pop_back();
        } else {
          st.push_back(c);
        }
      }
    }
    for (char c : st) {
      if (c == ')') {
        a[i] += 1;
      } else {
        b[i] += 1;
      }
    }
    total += b[i] - a[i];
  }
  vector<pair<int, int>> pos, neg;
  for (int i = 0; i < n; i++) {
    if (a[i] < b[i]) {
      pos.emplace_back(a[i], b[i]);
    } else {
      neg.emplace_back(b[i], a[i]);
    }
  }
  if (Ok(pos) && Ok(neg) && total == 0) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}


Measured memory_bytes: 42348
#include<iostream>
using namespace std;
int main(){
  string b;
  cin>>b;
  if(b=="A"){
    cout<<"T"<<endl;
  }
  else if(b=="C"){
    cout<<"G"<<endl;
  }
  else if(b=="G"){
    cout<<"C"<<endl;
  }
  else if(b=="T"){
    cout<<"A"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
main(){
  int r,d,x[11];
  cin >> r >> d >> x[0];
  
  for(int i=0;i<10;i++){
    x[i+1]=r*x[i]-d;
    cout << x[i+1] << '\n';
  }
  return 0;
}

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

using namespace std;
typedef long long ll;

string str;
ll ct[26];

int main() {
	cin >> str;
	for (int i = 0; i < str.size(); i++) {
		ct[str[i] - 'a']++;
	}
	ll ans = str.size() * (str.size() - 1) / 2 + 1;

	for (int i = 0; i < 26; i++) {
		if (ct[i] > 1) {
			ans -= (ct[i] * (ct[i] - 1) / 2);
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
        string str;
        cin >> str;
        int w=0,s=0,n=0,e=0;
        rep(i,str.size()){
                if(str[i]=='W') {
                        w=1;
                }
                if(str[i]=='N') {
                        n=1;
                }
                if(str[i]=='S') {
                        s=1;
                }
                if(str[i]=='E') {
                        e=1;
                }
        }
        if(w==e&&n==s) {
                cout << "Yes" << endl;
        }else{
                cout << "No" << 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 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

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

void Main(){
    string s; cin >> s;
    cout << s.substr(0, s.size()-8) << endl;    
    return;
}

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

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  bool res = true;
  for(int i = 0;i < (int)s.size();i++){
    if((i % 2 == 0 && s[i] == 'L') || (i % 2 == 1 && s[i] == 'R'))res = false;
  }
  if(res)cout << "Yes" << endl;
  else cout<< "No" << endl;
}

Measured memory_bytes: 3624
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
a1,a2,a3 = i2()
b1,b2,b3 = i2()
c1,c2,c3 = i2()
l = [a1,a2,a3,b1,b2,b3,c1,c2,c3]
n = i()
for i in range(n):
    k = int(input())
    if k in l:
        try:
            l[l.index(k)] = 0
        except IndexError:pass  
if (l[0] == 0 and l[1] == 0 and  l[2]== 0):
    print("Yes")
elif (l[3] == 0 and l[4] == 0 and  l[5]== 0):
    print("Yes")
elif (l[6] == 0 and l[7] == 0 and  l[8] == 0):
    print("Yes")
elif (l[0] == 0 and l[3] == 0 and  l[6]== 0):
    print("Yes")
elif (l[1] == 0 and l[4] == 0 and  l[7] == 0):
    print("Yes")
elif (l[2] == 0 and l[5] == 0 and  l[8] == 0):
    print("Yes")
elif (l[0] == 0 and l[4] == 0 and  l[8] == 0):
    print("Yes")
elif (l[2] == 0 and l[4] == 0 and l[6] == 0):
    print("Yes")
else:print("No")

Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<ll,ll>;
const ll M = 1e9+7;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}

int main() {
  string s; cin>>s;
  string t="CODEFESTIVAL2016";
  int an=0;
  for(int i=0;i<16;i++) {
    an += s[i]!=t[i];
  }
  cout<<an<<endl;
}

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

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

const int N=2e5+5;
 
int x,y,a,b,c,p[N],q[N],r[N];
int ans;

priority_queue<int,vector<int>,greater<int> > q1,q2;

signed main()
{
	x=read(),y=read(),a=read(),b=read(),c=read();
	for(int i=1;i<=a;++i)
		p[i]=read();
	for(int i=1;i<=b;++i)
		q[i]=read();
	for(int i=1;i<=c;++i)
		r[i]=read();
	sort(p+1,p+a+1,greater<int>());
	sort(q+1,q+b+1,greater<int>());
	sort(r+1,r+c+1,greater<int>());
	for(int i=1;i<=x;++i)
		ans+=p[i],q1.push(p[i]);
	for(int i=1;i<=y;++i)
		ans+=q[i],q2.push(q[i]);
	for(int i=1;i<=c;++i){
		if(q1.top()<q2.top()){
			if(r[i]>q1.top()){
				ans-=q1.top();
			q1.pop();
			ans+=r[i];
			q1.push(r[i]);
			}
			else break;
		}
		else{
			if(r[i]>q2.top()){
				ans-=q2.top();
				q2.pop();
				ans+=r[i];
				q2.push(r[i]);
			}
			else break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5876
#from string import ascii_lowercase
from bisect import bisect_right
s = input()
t = input()
p = {c: [] for c in s}
for x, c in enumerate(s):
    p[c].append(x)
z = 0
l = -1
for c in t:
    if c not in p:
        print(-1)
        exit()
    x = bisect_right(p[c], l)
    if x == len(p[c]):
        x = 0
        z += 1
    l = p[c][x]

print(z * len(s) + l + 1)


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

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

    int N, L;
    cin >> N >> L;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    deque<int> dq;
    for (int i = 0; i < L; i++) {
        while (!dq.empty() && a[dq.back()] >= a[i]) dq.pop_back();
        dq.push_back(i);
    }
    for (int i = L; i < N; i++) {
        cout << a[dq.front()] << " ";
        while (!dq.empty() && a[dq.back()] >= a[i]) dq.pop_back();
        dq.push_back(i);
        if (dq.front() == i - L) dq.pop_front();
    }
    cout << a[dq.front()] << endl;
}


Measured memory_bytes: 6796
def main():
    w, h = map(int, input().split())

    if w == 1 or h == 1:
        print(1)
        exit()

    h1 = (h + 1) // 2
    h2 = h // 2

    if (w % 2) == 1:
        print(h1 * ((w // 2) + 1) + (h2 * (w // 2)))
    else:
        print((h1 + h2) * (w // 2))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>

using namespace std;
int main() {

    int A,B;
    cin>>A>>B;

    if(A<B){

        cout<<"0"<<endl;

    }
    else{

        cout<<"10"<<endl;

    }

}



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

using namespace std;

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define sort_unique(x) sort(ALL(x)); x.resize(distance(x.begin(), unique(ALL(x))))
#define MP make_pair
#define PB push_back
#define X first
#define Y second

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(15);
    cout << fixed;

	int n, m;
	cin >> n >> m;

	if (n == m) {
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N;
  cin >> N;
  
  int max_h = 0;
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    int H;
    cin >> H;
    if (max_h <= H) ans++;
    chmax(max_h, H);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, k = map(int,input().split())
A = list(map(int,input().split()))

l = 0
r = 10**9+3
m = (l+r)//2
while r-l > 1:
    ans = 0
    for i in range(n):
        ans += -((-A[i])//m) - 1
    if ans > k:
        l = m
    else:
        r = m
    m = (l+r)//2
print(m+1)


# Q = []
# from heapq import heappush, heappop

# for i in range(n):
#     heappush(Q, [-A[i], 1])

# print(Q)

# while k > 0:
#     q = heappop(Q)
#     a = -q[0]
#     k -= q[1]
#     heappush(Q, [-a/2, q[1]*2])

# print(Q)

# if k==0:
#     print(max(A))
# else:
#     print(-((-a)//1))


# # D = {}
# I = []

# for i in range(n):
#     a = A[i]
#     D[a] = 0
#     I.append(a)
#     for j in range(40):
#         a/=2
#         D[a] = 0
#         I.append(a)

# for i in range(n):
#     D[A[i]] = 1

# I.sort(reverse=True)
# ind = 0



Measured memory_bytes: 92064
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	carrieableNums := ScanNums(5)
	sort.Ints(carrieableNums)
	fmt.Println(int(math.Ceil(float64(n)/float64(carrieableNums[0]))) + 4)
}

func ScanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 512
import bisect

def solve(N, A, B, C):
     A.sort()
     B.sort()
     C.sort()
     ret = 0
     for j in range(N):
         i = bisect.bisect_right(A, B[j] - 1)
         k = bisect.bisect_left(C, B[j] + 1)
         ret += i * (N - k) if 0 <= i and 0 <= k < N else 0
     print(ret)

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    solve(N, A, B, C)


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

int main() {
	int n;
	cin >> n;
	int k1 = n / 1.08;
	int k2 = (n + 1) / 1.08;
	int k = -1;
	for(int i = k1;i <= k2;i++)
	{
		int k3 = (i * 1.08) / 1;
		if( k3 == n)
		{
			k = i;
		}
	}
	if(k == -1)
	{
		cout << ":(" << endl;
	}
	else
	{
		cout << k << endl;
	}
	return 0;
}


Measured memory_bytes: 256
/// Bismillah Hir Rahmanir Rahim

/**
    Practice like Cristiano Ronaldo
        Play Like Leo Messi..
**/

#include <bits/stdc++.h>

using namespace std;

#define PI                    acos(-1.0)
#define Pi                    3.141592653589793
#define ff                    first
#define ss                    second
#define pb                    push_back
#define space                 " "
#define all(x)                (x).begin(), (x).end()
#define clr(ar)               memset(ar, 0, sizeof(ar))
#define eprintf(...)          fprintf(stderr, __VA_ARGS__)

/*
template <class T> T gcd(T a,T b){ if(b == 0) return a; return gcd( b,a % b ); }
template <class T> T lcm(T a, T b ){ return ( a * b ) / gcd( a,b ); }
template<class T> string ToString(const T &x){ stringstream s; s << x; return s.str(); }
template<class T> int ToInteger(const T &x){ stringstream s; s << x; int r; s >> r; return r; }
*/

typedef  long long int            ll;
typedef  map<string,int>          msi;
typedef  map<int,int>	          mii;
typedef  map<char,int>            mci;
typedef  map<int,string>	      mis;
typedef  pair<int,int> 	          ii;
typedef  pair<string, int>        psi;
typedef  vector<int> 	          vi;
typedef  vector<string> 	      vs;
typedef  vector< ii >             vii;

template<class T1> void deb(T1 e1)
{
    cout << e1 << endl;
}
template<class T1,class T2> void deb(T1 e1, T2 e2)
{
    cout << e1 << space << e2 << endl;
}
template<class T1,class T2,class T3> void deb(T1 e1, T2 e2, T3 e3)
{
    cout << e1 << space << e2 << space << e3 << endl;
}

#define sf                    scanf
#define pf                    printf

#define sf1(a)                scanf("%d", &a)
#define sf2(a,b)              scanf("%d %d",&a, &b)
#define sf3(a,b,c)            scanf("%d %d %d", &a, &b, &c)
#define sf4(a,b,c,d)          scanf("%d %d %d %d", &a, &b, &c, &d)

#define sf1ll(a)              scanf("%I64d", &a)
#define sf2ll(a,b)            scanf("%lld %lld", &a, &b)
#define sf3ll(a,b,c)          scanf("%I64d %I64d %I64d", &a, &b, &c)
#define sf4ll(a,b,c,d)        scanf("%I64d %I64d %I64d %I64d", &a, &b, &c, &d)

#define READ                  freopen("in.txt", "r", stdin);
#define WRITE                 freopen("out.txt", "w", stdout);
/// The End.

void check_time()
{
#ifdef the_badcoder
    eprintf("%.5lf\n", (double)clock() / CLOCKS_PER_SEC);
#endif
}

const int res = 1e4 + 50;
const int oo = 0x3f3f3f3f; /// only for "INT".
const ll mod = 1e9 + 7;

int main()
{

    int n, m;
    ll sum;

    sf2( n, m );

    sum = n * m;

    if( sum & 1 ){
        deb("Odd");
    }
    else {
        deb("Even");
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())
S_set = set(S)

ans = 0
for num in range(0, 1000):
    n0, n1, n2 = list(str(num).zfill(3))
    if n0 in S_set and n1 in S_set and n2 in S_set:
        idx0 = S.index(n0)
        idx2 = N - S[::-1].index(n2) - 1
        if idx0 < idx2:
            if n1 in S[idx0 + 1: idx2]:
                ans += 1
print(ans)

Measured memory_bytes: 3572
# -*- coding: utf-8 -*-
n,k = list(map(int,input().split()))
r,s,p = list(map(int,input().split()))
t = input()

hist = [[0 for i in range(3)] for _ in range(k)]
#0r1s2p
for i,v in enumerate(t):
    md = i%k
    cur_0 = hist[md][0]
    cur_1 = hist[md][1]
    cur_2 = hist[md][2]
    cur_max = max(hist[md])
    hist[md]=[cur_max]*3
    if v=="r":
        hist[md]=[cur_max]*3
        hist[md][2]=max(cur_1,cur_0)+p
    elif v=="s":
        hist[md][0]=max(cur_1,cur_2)+r
    else:
        hist[md][1]=max(cur_0,cur_2)+s

print(sum([max(i) for i in hist]))


Measured memory_bytes: 16756
N = int(input())
S = input()

cnt = left = 0
for s in S:
    if s == "(":
        cnt += 1
    elif s == ")":
        cnt -= 1

        if cnt < 0:
            left = max(left, -cnt)

S = "(" * left + S

right = 0
for s in S:
    if s == "(":
        right += 1
    elif s == ")":
        right -= 1

S = S + ")" * right

print(S)

Measured memory_bytes: 3064
import math

inputList = []
for i in range(5):
    a = int(input())
    inputList.append((math.ceil(a/10)*10 - a, a))

inputList.sort()

ans = 0
for i in range(4):
    ans = ans + inputList[i][0] + inputList[i][1]

ans = ans + inputList[4][1]
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 int main(){
     int X;cin>>X;
     int i;
     for(i=X;;i++){
         bool ok=true;
         for(int j=2;j*j<=i;j++){
             if(i%j==0)ok=false;
         }
         if(ok)break;
     }
     cout<<i<<endl;
    }
        






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

class bipartite_matching {
public:
    int n;
    std::vector<std::vector<int> > g;
    std::vector<int> match;

    bipartite_matching(int n_) : n(n_), g(n_), match(n_), used(n_) {}

    void add_edge(int u, int v) {
        g[u].push_back(v);
        g[v].push_back(u);
    }

    int maximum_matching(void) {
        int res = 0;
        fill(begin(match), end(match), -1);
        for (int v = 0; v < n; ++v) {
            if (match[v] == -1) {
                fill(begin(used), end(used), false);
                if (dfs(v)) res++;
            }
        }
        return res;
    }

private:
    std::vector<int> used;
    bool dfs(int v) {
        used[v] = true;
        for (int u : g[v]) {
            int w = match[u];
            if (w == -1 || (!used[w] && dfs(w))) {
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }
};

int main() {
    int n;
    cin >> n;
    int a[n],b[n];
    int c[n],d[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    for(int i = 0; i < n; i++) {
        cin >> c[i] >> d[i];
    }

    bipartite_matching bm(n * 2);

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(a[i] < c[j] && b[i] < d[j]) {
                bm.add_edge(i,j + n);
            }
        }
    }

    int ans = bm.maximum_matching();
    cout << ans << endl;

}

Measured memory_bytes: 888
s = input()
t = input()

m = 0
for i in range(len(s) - len(t) + 1):
    b = s[i : i + len(t)]
    cnt = 0
    for j, v in enumerate(b):
        if v == t[j]:
            cnt += 1
    m = max(m, cnt)
print(len(t) - m)


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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#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 sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 200001;

int ad(int a, int b) { return (a+b)%MOD; }
int sub(int a, int b) { return (a-b+MOD)%MOD; }
int mul(int a, int b) { return (ll)a*b%MOD; }

pi ad(pi a, pi b) { return {ad(a.f,b.f),ad(a.s,b.s)}; }
pi sub(pi a, pi b) { return {sub(a.f,b.f),sub(a.s,b.s)}; }

template<int SZ> struct BIT {
    typedef pi T;
    
    T bit[SZ+1];
    
    BIT() { memset(bit,0,sizeof bit); }
    
    void upd(int k, T val) { // add val to index k
        for( ;k <= SZ; k += (k&-k)) bit[k] = ad(bit[k],val);
    }
    
    T query(int k) {
        T temp = {0,0};
        for (;k > 0;k -= (k&-k)) temp = ad(temp,bit[k]);
        return temp;
    }
    T query(int l, int r) { return sub(query(r),query(l-1)); } // range query [l,r]
};

ll po (ll b, ll p) { return !p?1:po(b*b%MOD,p/2)*(p&1?b:1)%MOD; }
ll inv (ll b) { return po(b,MOD-2); }

ll S = 1, cnt[MX], D[MX], prev0[MX], ans = 0;
int N;
vl A;

BIT<MX> B;

void process(int x, int y = 0) {
    B.upd(A[x],{inv(D[A[x]]),1});
}

ll solve(int ind, int x) {
    if (ind == 0) {
        pi z = B.query(prev0[A[x]],A[x]);
        return mul(mul(z.f,D[A[x]]),inv(2));
    }
    pi z = B.query(prev0[A[x]],A[x]-1);
    return sub(B.query(1,A[x]-1).s,mul(mul(z.f,D[A[x]]),inv(2)));
}

void gen(int ind) {
    B = BIT<MX>();
    FOR(i,1,N+1) {
        ans = ad(ans,solve(ind,i));
        process(i);
    }
}

int main() {
    cin >> N;
    A.resize(N+1); 
    FOR(i,1,N+1) cin >> A[i];
    FOR(i,1,N+1) cnt[A[i]] ++;
    FORd(i,1,N) cnt[i] += cnt[i+1];
    FOR(i,1,N+1) {
        cnt[i] = max(0LL,cnt[i]-(N-i));
        S = mul(S,cnt[i]);
    }
    if (S == 0) {
        cout << 0;
        exit(0);
    }
    D[0] = 1;
    FOR(i,1,N+1) {
        D[i] = D[i-1];
        if (cnt[i] > 1) {
            D[i] = mul(D[i],cnt[i]-1);
            D[i] = mul(D[i],inv(cnt[i]));
        }
    }
    FOR(i,1,N+1) {
        prev0[i] = max(prev0[i-1],1LL);
        if (cnt[i] == 1) prev0[i] = i;
    }
    gen(0);
    reverse(A.begin()+1,A.begin()+N+1);
    gen(1);
    ans = mul(ans,S);
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)

Measured memory_bytes: 9600
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 998244353;
int main(){
	int n,s;
	cin >> n >> s;
	vector<int> a(n);
	for(int i = 0;i < n;i++)cin >> a[i];

	vector<vector<vector<ll>>> dp(n+1,vector<vector<ll>>(s+1,vector<ll>(3,0)));
	//dp[i][j][t]:=(t=0で,Lをまだ決めていない状態),(t=1で,Lを決めたがRを決めていない状態),(t=2で,LもRも決めた状態.)
	dp[0][0][0] = 1;
	for(int i = 0;i < n;i++){
		for(int j = 0;j <= s;j++){
			//0->0
			dp[i+1][j][0] += dp[i][j][0];
			dp[i+1][j][0] %= MOD;
			//0->1は取って決める場合と取らずに決める場合の2通り.
			dp[i+1][j][1] += dp[i][j][0];
			dp[i+1][j][1] %= MOD;
			if(j + a[i] <= s){
				dp[i+1][j+a[i]][1] += dp[i][j][0];
				dp[i+1][j+a[i]][1] %= MOD;
			}
			//0->2はそれのみを取る場合.
			if(j + a[i] <= s){
				dp[i+1][j+a[i]][2] += dp[i+1][j][0];
				dp[i+1][j+a[i]][2] %= MOD;
			}

			//1->1はA[i]を取る場合と取らない場合の2通り.
			dp[i+1][j][1] += dp[i][j][1];
			dp[i+1][j][1] %= MOD;
			if(j + a[i] <= s){
				dp[i+1][j+a[i]][1] += dp[i][j][1];
				dp[i+1][j+a[i]][1] %= MOD;
			}

			//1->2は取る場合と取らない場合の2通り.
			dp[i+1][j][2] += dp[i][j][1];
			dp[i+1][j][2] %= MOD;

			if(j + a[i] <= s){
				dp[i+1][j+a[i]][2] += dp[i][j][1];
				dp[i+1][j+a[i]][2] %= MOD;
			}

			//2->2もある.
			dp[i+1][j][2] += dp[i][j][2];
			dp[i+1][j][2] %= MOD;
		}
	}

	cout << dp[n][s][2] << endl;
}


Measured memory_bytes: 496068
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
vector<vector<ll>> vec;
ll N, M, Q;
ll res=0;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cin>>N>>M>>Q;
    vec.resize(Q,vector<ll>(4));
    rep(i,Q){
        rep(j,4){
            cin>>vec[i][j];
        }
    }
    queue<string> q;
    q.push("1");
    while(!q.empty()){
        string s=q.front();
        q.pop();
        if(s.size()==N+1){
            ll tempres=0;
            rep(i,Q){
                if ((s[vec[i][1]]-'0')-(s[vec[i][0]]-'0')==vec[i][2]) {
                    tempres += vec[i][3];
                }
            }
            chmax(res,tempres);
            continue;
        }
        for(int i=s.back()-'0';i<=M;i++){
            q.push(s+(char)(i+'0'));
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 6380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	int m; cin >> m;
	cout << 48 - m << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string s, t;
    cin >> s >> t;
    int n = s.length();
    int m = t.length();
    int dp[n + 1][m + 1]{};
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i] == t[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            } else {
                dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
            }
        }
    }
    string ans = "";
    int r = n;
    int c = m;
    while (r > 0 && c > 0) {
        if (s[r - 1] != t[c - 1]) {
            if (dp[r - 1][c] > dp[r][c - 1]) r--;
            else c--;
        } else {
            ans += s[r - 1];
            r--;
            c--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if((A==B && A!=C) || (B==C && B!=A) || (C==A && C!=B)){
    cout << "Yes" << endl;}
  else {
    cout << "No" << endl;}
  }

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

int main(void){
    int n;
    int sum = 0;
    string s;
    cin >> n >> s;
    
    for(int i = 0;i < 1000;i++){
        int a[3] = {i/100,(i/10)%10,(i%10)%10};
        int b = 0;
        //cout << a[0] << a[1] << a[2] << endl;
        for(int j = 0;j < s.size();j++){
            if(a[b] == (s[j]-'0'))b++;
            if(b == 3)break;
        }
        if(b == 3)sum++;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
while True:
    h,w = map(int, input().split())
    
    if h == 0 and w == 0:
        break
        
    for i in range(h):
        if i == 0 or i == h-1:
            print('#' * w)
        else:
            print('#'+'.'*(w-2)+'#') 
        
    print()


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;

int main(void)
{
	ll  n;
	cin >> n;
	map<string, ll> m;
	ll u = 0;
	rep(i, n) {
		string s;
		cin >> s;
		m[s]++;
		u = max(u, m[s]);
	}
	for (auto p : m) {
		if (p.second == u) {
			cout << p.first << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 26880
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<cstdio>

using namespace std;

int dp[1001][1001];

int main() {
	string m1, m2;

	cin >> m1 >> m2;

	memset(dp, 0x7f, sizeof(dp));
	int m = m1.size();
	int mm = m2.size();

	for (int i = 0; i <= mm; i++) dp[0][i] = i;
	for (int i = 0; i <= m; i++) dp[i][0] = i;

	for (int i = 0; i < m; i++) {
		for (int j = 0; j < mm; j++) {
			dp[i + 1][j + 1] = min(dp[i][j], min(dp[i + 1][j], dp[i][j + 1]))+1;
			if (m1[i] == m2[j]) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]);
		}
	}
	
	printf("%d\n", dp[m][mm]);
}


Measured memory_bytes: 7256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> deg(n);
    vector<queue<int> > es(n);
    vector<set<int> > G(n); 
    rep(i, 0, n - 1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        deg[a]++;
        deg[b]++;
        G[a].insert(b);
        G[b].insert(a);
    }
    vector<int> c(n);
    rep(i, 0, n) cin >> c[i];
    sort(c.begin(), c.end());
    vector<int> ans(n);
    int val = 0;
    queue<int> q;
    rep(i, 0, n){
        if(deg[i] == 1){
            q.push(i);
        }
    }
    rep(i, 0, n){
        int tmp = q.front(); q.pop();
        if(i != n - 1) val += c[i];
        ans[tmp] = c[i];
        int idx = *G[tmp].begin();
        G[idx].erase(tmp);
        deg[idx]--;
        if(deg[idx] == 1) q.push(idx);
    }
    cout << val << endl;
    for(int ii = 0; ii < ans.size(); ii++){
        if(ii) cout << ' ';
        cout << ans[ii];
    }
    cout << endl;
}

Measured memory_bytes: 8832