akhauriyash/Code-Regression huggingface dataset:
program Project1;

    {$APPTYPE CONSOLE}

    uses
      SysUtils;
    var
      a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k:Integer;
      l:array of Integer;
      s,s123,s1,s2,s3:string;
      al:string = 'abcdefghijklmnopqrstuvwxyz';
      tf,tfl,tfr:Boolean;
    begin
      try
        { TODO -oUser -cConsole メイン : ここにコードを記述してください }
        Read(a);
        Readln(b);
        count:=0;
        max  :=0;


      if (a<=8)and(b<=8) then
        Writeln('Yay!')
      else
        Writeln(':(');

        Readln;
      except
        on E: Exception do
          Writeln(E.ClassName, ': ', E.Message);
      end;
    end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ot 100002
#define ll long long
ll n,a,b,c[ot*2],x,y,s;
vector <int> j[ot*2];
void dfs(int p)
{
	c[p]=1,p>ot?y++:x++;
	for(int i=0;i<j[p].size();i++)
		if(!c[j[p][i]])
			dfs(j[p][i]);
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a>>b,j[a].push_back(b+ot),j[b+ot].push_back(a);
	for(int i=0;i<ot*2;i++)
		if(!c[i]&&j[i].size())
			x=y=0,dfs(i),s+=x*y;
	cout<<s-n;
    return 0;
}

Measured memory_bytes: 11520
#include <stdio.h>

int main(void) {
	int m, f, r;
	char c[5] = {'F','A','B','C','D'};
	int grade;
	
	while (scanf("%d %d %d", &m, &f, &r), m != -1 || f != -1 || r != -1){
		if (m == -1 || f == -1) grade = 0;
		else if (m+f >= 80) grade = 1;
		else if (m+f >= 65) grade = 2;
		else if (m+f >= 50) grade = 3;
		else if (m+f >= 30){
			if (r >= 50) grade = 3;
			else grade = 4;
		}
		else grade = 0;
		
		printf("%c\n", c[grade]);
	}
		
	return 0;
}

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

void printLine(int b)
{
  for(int j = 0;  j < b ; j++) {
  printf("#");
  }
  printf("\n");
}

void printLine2(int b)
{
  for(int j = 0;  j < b ; j++) {
  if (j == 0 || j == b -1) {
  printf("#");
  continue;
  
  }
  printf(".");

  }
  printf("\n");
}

int main()
{
  int a, b;
  while(std::cin >> a >> b, a + b != 0 ){
  for(int i = 0 ; i < a;  i++) {
  if (i == 0 || i == a -1) {
   printLine(b);
   continue;
  }
      printLine2(b);

  }
  printf("\n");}
}

Measured memory_bytes: 3020
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a+b == c || a+c == b || b+c == a)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, h: "List[int]"):
    INF = float('inf')
    dp = [INF] * N
    dp[0] = 0
    for i in range(N - 1):
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
        if i < N - 2:
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))
    print(dp[N - 1])
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, h)

if __name__ == '__main__':
    main()


Measured memory_bytes: 17928
# coding: utf-8
# Here your code !
#coding: utf-8

while True:
    l = map(int,raw_input().split())
    if l == [0,0,0,0,0]:
        break
    else:
        A = l[1]
        B = l[2]
        C = l[3]
        X = l[4]
        f = -1
        Yl = map(int,raw_input().split())
        for Y in Yl:
            while f <= 10000:
                f = f + 1
                if X == Y:
                    X = (A * X + B) % C
                    break
                X = (A * X + B) % C
        if f > 10000:
            print -1
        else:
            print f

Measured memory_bytes: 6236
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
#include <climits>
#include <stack>
using namespace std; 
#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<pii> 
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,x,n)        for(int i=x;i<n;i++)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 

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

int N = (int)(2 * 1e5 + 10) ; 

//continue 

map<int,int> m ;

int32_t main(){
 
       #ifndef ONLINE_JUDGE
	   freopen("input.txt","r",stdin); 
	   freopen("output.txt","w",stdout);
       #endif
   
 
	  ios::sync_with_stdio(0);
      cin.tie(0); 
      cout.tie(0);  
      
      int n ; 
      cin >> n ; 

      bool a[N] = {0} ;  
      int sum = 0; 


      f(i,0,n){
          
          int x ; 
          cin >> x ; 
          if(!a[x] ) m[x] = 1; 
          else m[x] ++ ; 

          a[x] = 1 ; 

          sum += x ; 

      }


      int q ; 
      cin >> q ; 

      while(q--){

      	   int x , y ; 
      	   cin >> x >> y ; 

      	   sum = sum - x * m[x] + y * m[x] ; 


      	   if(!a[y]) m[y] = m[x] ; 
      	   else m[y] = m[y] + m[x] ; 

      	   m.erase(x) ; 

      	   a[y] = 1 ; 

      	   a[x] = 0 ; 

      	   cout << sum << "\n" ; 
      }

      
 }







Measured memory_bytes: 7780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define fr(j, n)for(int i=j; i<=n; i++)
#define scan(cr)for(auto &it:cr)cin >> it
#define all(cr)cr.begin(), cr.end()
#define F cout << "First\n"
#define S cout << "Second\n"
#define fi(x)m[x]

int main()
{	
	int n, ans;
	cin >> n;
	map<string, int>m;
	m["WA"] = 0, m["TLE"] = 0, m["RE"] = 0, m["AC"] = 0;
	while(n--){
		string s;
		cin >> s;
		m[s]++;
	}
	printf("AC x %d\n", fi("AC"));
	printf("WA x %d\n", fi("WA"));
	printf("TLE x %d\n", fi("TLE"));
	printf("RE x %d\n", fi("RE"));
	return 0;
}



Measured memory_bytes: 3732
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    unordered_set<int> paper;
    loop(i, N){
        scanInt(Ai);
        if (0 < paper.count(Ai)){
            paper.erase(Ai);
        }else{
            paper.emplace(Ai);
        }
    }
    printf("%lu\n", paper.size());
}


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

int main(void){
    int n, q, c = 0, s[100000], t[50000];
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> s[i];
    cin >> q;
    for(int i = 0; i < q; ++i) cin >> t[i];
    
    for(int i = 0; i < q; ++i){
        int left = 0, right = n;
        while(left < right){
            int mid = (left + right) / 2;
            if(s[mid] == t[i]) {
                c++;
                break;
            }
            else if(t[i] < s[mid]) right = mid;
            else left = mid + 1;
        }
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int res = 1, n;

    cin >> n;
    for(int i = 0; i <= n; i++) {
        if (res * 2 <= n){
            res = res * 2;
        }
    }
    cout <<  res  << endl;
    return 0;
}

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


using namespace std;


void security()
{
  string s;
  cin >> s;

  for (int i = 1; i < s.size(); ++i)
  {
    if (s[i - 1] == s[i])
    {
      cout << "Bad\n";
      return;
    }
  }
  cout << "Good\n";
}


void fifty_fify()
{
  string s;
  cin >> s;

  sort(s.begin(), s.end());

  if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes\n";
  else cout << "No\n";
}


void dodecagon()
{
  int r;
  cin >> r;

  cout << 3 * r * r << "\n";
}


int main()
{
  //security();
  //fifty_fify();
  dodecagon();

}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container;

void main()
{
    auto a = readln.split.to!(long[]);
    auto N = a[0];
    auto A = a[1];
    auto B = a[2];
    auto C = a[3];
    auto D = a[4];

    foreach (i; 0..N-1) {
        auto l = A + C * i - D * (N-i-1);
        auto r = A + D * i - C * (N-i-1);
        if (l <= B && B <= r) {
            writeln("YES");
            return;
        }
    }
    writeln("NO");
}

Measured memory_bytes: 2768
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int ans = (h2 -h1)*60 + (m2 -m1) -k;
    cout << ans << endl;
}



Measured memory_bytes: 3636
h, w = map(int, input().split())
s = [list(map(str, list(input()))) for i in range(h)]

for i in range(1, h-1):
    for j in range(1, w-1):
        if s[i][j] == '#':
            if not (s[i+1][j] == '#' or s[i-1][j] == '#' or s[i][j+1] == '#' or s[i][j-1] == '#'):
                print('No')
                exit()
print('Yes')


Measured memory_bytes: 39152
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		ArrayList<Integer> array = new ArrayList<Integer>();
		for (int i = 1; i <= 100; i++) {
			if (a % i == 0 && b % i == 0) {
				array.add(i);
			}
		}
		System.out.println(array.get((array.size() - c)));
	}

}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
unsigned long long c[10000001],n,a,b,t,s=0;
int main()
{
		cin>>n>>a>>b;
		for(int i=1;i<=n;i++)
			cin>>c[i];
		for(int i=1;i<=n-1;i++){
			t=(c[i+1]-c[i])*a;
			if(t<=b)
				s=s+t;
			else 
				s=s+b;
		}
		cout<<s;
		return 0;		 
} 

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){

int number, tou, kai, banme, ninzu;

int building1[3][10]={
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
};

int building2[3][10]={
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
};
int building3[3][10]={
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
};
int building4[3][10]={
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
};

cin >> number;


    for(int i=0;i< number ; i++){

        cin >> tou >> kai >> banme >> ninzu;

        if (tou == 1){
            building1[kai-1][banme-1] += ninzu;
        }else if(tou == 2){
            building2[kai-1][banme-1] += ninzu;
        }else if(tou == 3){
            building3[kai-1][banme-1] += ninzu;
        }else if(tou == 4){
            building4[kai-1][banme-1] += ninzu;
        }
    }

    for(int i=0; i<3; i++){
            for(int j=0; j<10 ;j++){
        cout << " " << building1[i][j];

            }
        cout << endl;
    }

    cout <<"####################" << endl;

    for(int i=0; i<3; i++){
            for(int j=0; j<10 ;j++){
        cout << " " << building2[i][j];
            }
        cout << endl;
    }

    cout <<"####################" << endl;

    for(int i=0; i<3; i++){
            for(int j=0; j<10 ;j++){
        cout << " " << building3[i][j];
            }
        cout << endl;
    }

    cout <<"####################" << endl;

    for(int i=0; i<3; i++){
            for(int j=0; j<10 ;j++){
        cout << " " << building4[i][j];
            }
        cout << endl;
    }
}



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

using namespace std;

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

  string S;
  cin >> S;

  int cmax = 0, count = 0;
  for (char ch : S) {
    if (ch == 'A' || ch == 'C' || ch == 'G' || ch == 'T') {
      count++;
      cmax = max(cmax, count);
    } else {
      count = 0;
    }
  }
  cout << cmax << '\n';
  return 0;
}


Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    //vector<vector<ll>> v(tate,vector<ll> (yoko));
    vector<ll> v(n);
    rep(i,n)   cin >> v[i];
    for(ll i=0;i<n;i+=2){
        if(v[i]%2) sum++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3616
# http://drken1215.hatenablog.com/entry/2019/03/21/234900
# 写経

from bisect import bisect_left

n, m = map(int, input().split())
PY = []
e = [[] for _ in range(n + 1)]
for _ in range(m):
    _p, _y = map(int, input().split())
    e[_p].append(_y)
    PY.append((_p, _y))

for idx in range(n + 1):
    e[idx] = tuple(sorted(set(e[idx])))

for p, y in PY:
    id = bisect_left(e[p], y)
    print('{:06d}{:06d}'.format(p, id + 1))


Measured memory_bytes: 82844
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdlib>
#include <set>
#include <queue>
using namespace std;

#define X first
#define Y second
#define Mod 1000000007
#define N 100010
#define M 101

typedef long long ll;
pair<int,int> p[N];
ll s[N];

const int INF=1<<30;

int main()
{
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
	
	int n,ans; scanf("%d",&n); ans=n;
	for (int i=1;i<=n;i++) scanf("%d",&p[i].X),p[i].Y=i;
	sort(p+1,p+n+1); int pos=0;
	for (int i=1;i<=n;i++) 
	{
		s[i]=s[i-1]+p[i].X;
		if (i<n && s[i]*2<p[i+1].X) ans--,pos=i;
	}
	ans=n-pos;
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll n;cin>>n;
    string s;cin>>s;
    ll c[26];rep(i,0,25)c[i]=0;
    rep(i,0,s.size()-1){
        ll k=0;
        rep(j,0,25){
            if(s[i]==alp[j]){
                k=j;
                break;
            }
        }
        c[k]++;
    }
    ll ans=1;
    rep(i,0,25){
        ans=(ans*(c[i]+1))%i_7;
    }
    cout<<((ans-1)%i_7+i_7)%i_7<<endl;
    
    return 0;
}



Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
  int N;
  int Max = -1;
  int Sum = 0;
  scanf("%d", &N);
  for(int i = 0; i < N; i++) {
    int L;
    scanf("%d", &L);
    Sum += L;
    if(Max < L) {
      Max = L;
    }
  }

  if(Max < (Sum - Max)) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	void run(){

		for(;sc.hasNextInt();){

			int[] data = new int[3];

			boolean[] used = new boolean[11];

			used[0] = true;

			for(int i=0; i < 3;i++){

				data[i] =sc.nextInt();

				used[data[i]] = true;

			}

			int sum = 0;

			for(int l=0; l <= 10;l++){

				if(used[l]) continue;

				if(data[0]+data[1]+l <= 20) sum++; 

			}

			System.out.println(sum>3.5?"YES":"NO");

		}

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

		

	}

}

Measured memory_bytes: 12000
n, m = map(int,input().split())
stairs = set([int(input()) for i in range(m)])
dp = [0] * (n+1)
dp[0] = 1

for i in range(1, n+1):
    if i in stairs: 
        dp[i] = 0
        continue

    dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7)

print(dp[n])

Measured memory_bytes: 13212
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, A, B, C, D;
ll dp[1050][1050];


ll fac[MAX_N], inv[MAX_N], fiv[MAX_N]; //fiv:inv(fac(i))

ll mod_pow(ll a, ll n) {
	if(n == 0) return 1;
	ll res = mod_pow(a, n / 2);
	if(n % 2 == 0) return res * res % mod;
	else return a * res % mod * res % mod;
}

ll invf(ll a) {
	return mod_pow(a, mod - 2);
}

void C_init(int n) {
	fac[0] = fac[1] = 1; inv[1] = 1;
	fiv[0] = fiv[1] = 1;
	rep(i, 2, n + 1) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fiv[i] = fiv[i - 1] * inv[i] % mod;
	}
}

ll C_(int a, int b) { //assume a >= b
	if(a < b || a < 0 || b < 0) return 0;
	return fac[a] * fiv[b] % mod * fiv[a - b] % mod;
}

void solve() {
	cin >> N >> A >> B >> C >> D;
	C_init(N + 50);

	dp[A][N] = 1;

	for(int i = A; i <= B; i++) {
		rep(n, 0, N + 1) {
			if(!dp[i][n]) continue;
			for(int j = C; j <= D; j++) {
				if(n - i * j >= 0) {
					// debug(i, n, j,n - i * j );
					ADD(dp[i + 1][n - i * j], 
							dp[i][n] * C_(n, i * j) % mod * fac[i * j] % mod * invf(mod_pow(fac[i], j)) % mod * fiv[j] % mod);
				}
				else break;
			}
			ADD(dp[i + 1][n], dp[i][n]);
		}
		// debug(i, vl(dp[i], dp[i] + N + 1));
	}
	cout << dp[B + 1][0] << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

int main() {
  int s1s2s3;
  cin >> s1s2s3;
  int t1 = s1s2s3 / 100;
  int t2 = (s1s2s3 - s1s2s3 / 100 * 100) / 10;
  int t3 = s1s2s3 - s1s2s3 / 100 * 100 - (s1s2s3 - s1s2s3 / 100 * 100) / 10 *10;
  cout << t1 + t2 + t3 << endl;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a<=b&&b<=c) cout<<a<<" "<<b<<" "<<c<<endl;
    else if(a<=c&&c<=b) cout<<a<<" "<<c<<" "<<b<<endl;
    else if(b<=a&&a<=c) cout<<b<<" "<<a<<" "<<c<<endl;
    else if(b<=c&&c<=a) cout<<b<<" "<<c<<" "<<a<<endl;
    else if(c<=a&&a<=b) cout<<c<<" "<<a<<" "<<b<<endl;
    else if(c<=b&&b<=a) cout<<c<<" "<<b<<" "<<a<<endl;
    return 0;
}


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


def main():
    N = int(readline())
    count = Counter(readline().decode('utf-8').strip())
    for _ in range(N-1):
        count &= Counter(readline().decode('utf-8').strip())
    ans = ''
    for key, value in count.items():
        ans += key*value
    ans = sorted(ans)
    print(''.join(map(str,ans)))





if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
def solve(N):
    e = lambda x, y, N: (4*x + 7*y) == N
    for x in range(N//4+1):
        for y in range(N//7+1):
            if e(x, y, N):
                print("Yes")
                return
    else:
        print("No")

N = int(input())
solve(N)


Measured memory_bytes: 2940
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n, m = inm()
if n == 1 and m == 1:
    print(1)
elif n == 1:
    print(m-2)
elif m == 1:
    print(n-2)
else:
    print((m-2) * (n-2))

Measured memory_bytes: 9060
<?php

while (true) {
    
    fscanf(STDIN, "%d %d", $height, $width);
    
    if ($height == 0 && $width == 0){
        break;
    }
    
    $rectangle = new Rectangle($height, $width);
    $rectangles[] = $rectangle->draw();
}

echo implode(PHP_EOL, $rectangles),PHP_EOL;

class Rectangle {
    
    private $height;
    private $width;
    
    public function __construct($height, $width){
        $this->height = $height;
        $this->width = $width;
    }
    
    public function draw(){
        $rectangle = [];
        for($i = 0; $i < $this->height; $i++){
            $rectangle[] = str_repeat("#", $this->width);
        }
        return implode(PHP_EOL, $rectangle).PHP_EOL;
    }
    
}

Measured memory_bytes: 15340
#include <bits/stdc++.h>
#define debug(...)
#include <complex.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;


int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0);
    ll n , k;
    string s;
    cin >> s >> k;
     n = (int)s.size();
    if(s == string(n , s[0])){
        cout << (n * k) / 2 << '\n';
    }
    else {
        ll pref = 0 , suf = 0 , mid = 0;
        for(int i = 0; s[0] == s[i]; i++)
            pref++;
        for(int i = n - 1; s[n - 1] == s[i]; i--)
            suf++;
        for(int i = pref + 1; i < n - suf; i++){
            if(s[i] == s[i - 1]){
                mid++;
                i++;
            }
        }
        ll ans = pref / 2 + suf / 2 + mid * k + (s[0] == s[n - 1] ? (pref + suf)/ 2 : pref/ 2 + suf/2) * (k - 1);
        cout << ans << '\n';

    }



    return 0;
}













Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var S = cin.Read;
            var length = S.Length;
            var s1 = S.ToCharArray();
            int half = length / 2;

            var ans = true;
            for (var i = 0; i < half; i++)
            {
                if (s1[i] != s1[length -1 - i]){
                  ans = false; 
                  break;
                }
                if (s1[i] != s1[half - 1 - i]){
                  ans = false; 
                  break;
                }
            }

            WriteLine(ans ? "Yes" : "No");
        }

    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }


        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13268
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		// 整数の入力
		int a = sc.nextInt();
    int b = sc.nextInt();
    int cnt= 0;
		int i=0,j=0;
			for(i=1; i<= a; i++){
      	if(i!=a){
        	for(j=1; j<=31;j++){
            if(i==j){
              cnt=cnt+1;
            	}
        	}
      	}else if(i==a){
        	for(j=1; j<=b;j++){
            if(i==j){
              cnt=cnt+1;
            }
        }
    }
    }
  System.out.println(cnt);
	}
}


Measured memory_bytes: 22996
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
int main(){
    string S,T;
    cin >> S >> T;
    string S_replaced;
    vector<string> keys;
    bool flag;
    REP(i,S.size()-T.size()+1){
        REP(j,T.size()){
            S_replaced = S;
            if(S[i+j]==T[j] || S[i+j]=='?'){
                flag = true;
            }else{
                flag = false;
                break;
            }
        }
        if(flag){
            S_replaced.replace(i,T.size(),T);
            keys.push_back(S_replaced);
        }
    }
    if(keys.size()!=0){
        REP(i,keys.size()){
            REP(j,keys[i].size()){
                if(keys[i][j]=='?'){
                    keys[i].replace(j,1,"a");
                }
            }
        }
        sort(keys.begin(),keys.end());
        cout << keys[0];
    }else{
        cout << "UNRESTORABLE";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> ans;
int main() {
    int  k,x;
    scanf ("%d %d",&k,&x);
    for (int i = 0; i < k; i++) {
        if (x-i >= -100000) ans.push_back(x-i);
        if (i && x+i <= 100000) ans.push_back(x+i);
    }
    sort(ans.begin(),ans.end());
    for (int i : ans) printf ("%d ",i);
    printf ("\n");
    return 0;
}


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

int main() 
{
    long H;
    cin>>H;

    if(H==1)
    {
        cout<<"1"<<endl;
        return 0;
    }

    long cnt=0;
    while (H>0)
    {
        H/=2;
        ++cnt;
    }

    long ans=1;
    for (long i = 1; i < cnt; ++i)
    {
        long p=1,j=i;
        while (j>0)
        {
            p*=2;
            --j;
        }
        
        ans+=p;
    }
    cout<<ans<<endl;
}

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

const int INF = (1 << 30) - 1;

struct Edge
{
    int to, time;
    Edge () {}
    Edge ( int to, int time ) : to(to), time(time) {}
};

int N, M;
using T = pair < int , int >;
priority_queue < T , vector < T > , greater < T > > pq;
int min_cost[100005];
vector < Edge > G[100005];

int main()
{
    int maxv = -1;

    scanf("%d %d", &N, &M);

    while ( M-- ) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c); --a, --b;
        G[a].emplace_back(b, c);
    }

    fill_n(min_cost, 100005, INF);
    min_cost[0] = 0;
    pq.emplace(0, 0);

    while ( !pq.empty() ) {
        T d = pq.top(); pq.pop();
        if ( d.first > min_cost[d.second] ) continue;
        for ( auto x : G[d.second] ) {
            if ( x.to == N - 1 ) {
                if ( d.first <= x.time ) {
                    maxv = max(maxv, x.time);
                }
            } else {
                if ( d.first <= x.time && x.time < min_cost[x.to] ) {
                    min_cost[x.to] = x.time;
                    pq.emplace(x.time, x.to);
                }
            }
        }
    }
    cout << maxv << endl;

    return ( 0 );
}



Measured memory_bytes: 9532
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

x1, y1, x2, y2 = rm()
c1, c2 = x1+y1*1j, x2+y2*1j
c3, c4 = -1j*(c1-c2) + c2, 1j*(c2-c1) + c1
print(int(c3.real), int(c3.imag), int(c4.real), int(c4.imag))




Measured memory_bytes: 27064
import math
n = int(input())
a = list(map(int, input().split()))
X = []

x1 = 0
for i in range(n):
    x1 += (-1) ** i * a[n-1-i]
X.append(x1)

for j in range(n-1):
    x = (a[j] - X[j]/2) * 2
    X.append(int(x))

for k in range(n):
    print(X[k], end = " ")












                                        




    




        


    







        



Measured memory_bytes: 14404
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
void Input(); void Prepare(); void Setup(); void Solve(); void Clean();

#ifdef DEBUG6500
double a = 2, b = 2, x = 4;
int main(){ Prepare(); Solve(); return 0; }
#else
double a, b, x;
int main(){ Input(); Prepare(); Solve(); Clean(); return 0; }
#endif

double S; // 横から見た時の水の面積

void Solve_mini(); void Solve_big();

void Solve()
{
	S = x / a;
	double podS = a * b;
	if (podS > S * 2) Solve_mini();
	else Solve_big();
}

void Solve_mini()
{
	double c; // 傾けた時にできる直角三角形の底側の辺
	c = 2.0f * S / b;

	double tan_theta = b / c;
	double radian = atan(tan_theta);
	double degree = radian * 180 /M_PI;

	printf("%.8f\n", degree);
}

void Solve_big()
{
	double S2 = a * b - S; // 上に残る三角形の面積

	double c; // 傾けた時にできる直角三角形の壁側の辺
	c = 2.0f * S2 / a;

	double tan_theta = c / a;
	double radian = atan(tan_theta);
	double degree = radian * 180 /M_PI;

	printf("%.8f\n", degree);
}

void Prepare()
{
}

#ifndef DEBUG6500
void Clean()
{
}

void Input()
{
	cin >> a >> b >> x;
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string S, T; int p, q;
int main() {
  cin >> S >> T;
  for(p = S.size()-T.size(); p >= 0; p--) {
    for(q = 0; q < T.size(); q++) {
      if(S[p+q] != '?' && S[p+q] != T[q]) break;
    }
    if(q == T.size()) break;
  }
  if(q < T.size()) {
    cout << "UNRESTORABLE";
  } else {
    S.replace(p, q, T);
    replace(S.begin(), S.end(), '?', 'a');
    cout << S;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		String s = sc.next();
		sc.close();

		if (k >= s.length()) {
			System.out.println(s);
		}else {
			System.out.println(s.substring(0, k) + "...");
		}
	}
}

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

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

  map<string, int> mp1, mp2;
  int n,m;cin>>n;
  for(int i=0;i<n;i++){
    string s;cin>>s;
    mp1[s]++;
  }
  cin>>m;
  for(int i=0;i<m;i++){
    string s;cin>>s;
    mp2[s]++;
  }
  int res=0;
  for (auto& kv : mp1) {
    res=max(res, kv.second-mp2[kv.first]);
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll n, k; cin >> n >> k;
    string s; cin >> s;
    char now = s[0];
    ll cnt = 0; vl ds;
    if(now == '0') ds.pb(0);
    REP(i, n){
        if(s[i] == now) cnt++;
        else{
            ds.pb(cnt);
            cnt = 1;
            now = now == '0' ? '1' : '0';
        }
    }
    if(cnt > 0) ds.pb(cnt);
    if(ds.size() % 2 == 0) ds.pb(0);
    vl acc(ds.size()+1, 0);
    REP(i, ds.size()) acc[i+1] = acc[i] + ds[i];
    
    ll ans = 0;
    for (ll i = 0; i < ds.size(); i++) {
        if(i % 2 == 1) continue;
        ll r = min(i+2*k+1, (ll)ds.size());
        ans = max(ans, acc[r] - acc[i]);
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 2164
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using P = pair<int,int>;
typedef long long ll;


const int nmax=100009; 
const int mmax=12;
const ll INF=100000000;
vector <ll> C(nmax);
vector < vector <ll>> A(nmax,vector <ll>(12,0));

int n, m;
ll x; 

ll check(int xbit){
    ll cost; 
    vector <ll> studied(mmax);
    cost = 0;
    rep(j,m) studied[j] = 0;
    rep(i,n){
        if (xbit % 2 == 1){
            cost += C[i];
            rep(j,m) studied[j] += A[i][j];
        }
        xbit = xbit >> 1;
    }
    rep(j,m){
        // cout << " " << studied[j]; 
        if (studied[j] < x) return INF;
    }
    // cout << " " << cost;
    return cost;
}

void solve(void){
    int endbit;
    ll mincost;
    endbit = 1 << n;
    // cout << "endbit: " << endbit << endl;
    mincost = INF;
    rep(i,endbit){
        // cout << i << endl;
        mincost = min(mincost,check(i));
        // cout << endl;
    }
    if ( mincost == INF){
        cout << -1 << endl;
    } else {
        cout << mincost << endl;
    }
}

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

    cin >> n >> m >> x ;
    // cout << n << " " << m << " " << x << endl;
    rep(i,n){
        cin >> C[i];
        rep(j,m){
            cin >> A[i][j];
        }
    }


    solve();
    
}


Measured memory_bytes: 17068
import std.stdio;
import std.string;

bool[101][101] memo;
string[] s;
int h, w, ans;

void main(){
	while (readf("%d %d\n", &h, &w), h != 0 || w != 0) {
		s = [];
		ans = 0;
		for (int i = 0; i < h; i++) {
			s ~= chomp(readln());
			memo[i] = false;
		}
		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				if (!memo[y][x]) {
					ans++;
					scan(s[y][x], x, y);
				}
			}
		}
		writeln(ans);
	}
}

void scan(char fruit, int x, int y){
	memo[y][x] = true;
	if(x+1 < w && !memo[y][x+1] && s[y][x+1] == fruit) scan(fruit, x+1, y);
	if(x-1 >= 0 && !memo[y][x-1] && s[y][x-1] == fruit) scan(fruit, x-1, y);
	if(y+1 < h && !memo[y+1][x] && s[y+1][x] == fruit) scan(fruit, x, y+1);
	if(y-1 >= 0 && !memo[y-1][x] && s[y-1][x] == fruit) scan(fruit, x, y-1);
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
 
using namespace std;
 
#ifdef DEBUG_MODE
    #define DBG(n) n;
#else
    #define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007
 
 
typedef long long ll;
typedef pair<ll,ll> P;
 
string a,b;
int placeA,placeB;
 
void dfs(){
    cout << '(';
    int num = 0;
    int tmp;
    if(a[placeA+1] == '(' && b[placeB+1] == '('){
        placeA++;
        placeB++;
        dfs();
    }
    else{
        tmp = 0;
        do{
            if(a[placeA] == '(')tmp++;
            if(a[placeA] == ')')tmp--;
            placeA++;
        }while(tmp != 0);
        tmp = 0;
        do{
            if(b[placeB] == '(')tmp++;
            if(b[placeB] == ')')tmp--;
            placeB++;
        }while(tmp != 0);
    }
    while(!isdigit(a[placeA]))placeA++;
    while(!isdigit(b[placeB]))placeB++;
    cout << ")[";
    tmp = 0;
 
    while(isdigit(a[placeA])){
        tmp *= 10;
        tmp += a[placeA] - '0';
        placeA++;
    }
    num += tmp;
    tmp = 0;
    while(isdigit(b[placeB])){
        tmp *= 10;
        tmp += b[placeB] - '0';
        placeB++;
    }
    num += tmp;
    cout << num <<  "](";
    placeA++;
    placeB++;
     
    if(a[placeA+1] == '(' && b[placeB+1] == '('){
        placeA++;
        placeB++;
        dfs();
    }
    else{
        tmp = 0;
        do{
            if(a[placeA] == '(')tmp++;
            if(a[placeA] == ')')tmp--;
            placeA++;
        }while(tmp != 0);
        tmp = 0;
        do{
            if(b[placeB] == '(')tmp++;
            if(b[placeB] == ')')tmp--;
            placeB++;
        }while(tmp != 0);
    }
    cout << ")";
}
 
int main()
{
    cin >> a >> b;
    dfs();
    cout << endl;
    return 0;
}


Measured memory_bytes: 3208
def binarySearch(S, x, l, r):
    if r-l<=1:
        if S[l]==x:
            return True
        else:
            return False
    else:
        m=(l+r)//2
        if x<S[m]:
            return binarySearch(S, x, l, m)
        elif S[m]<x:
            return binarySearch(S, x, m+1, r)
        else:
            return True

n=int(input())
S=list(map(int,input().split()))
q=int(input())
T=list(map(int,input().split()))
ans=0
for x in T:
    if binarySearch(S, x, 0, n):
        ans+=1
print(ans)


Measured memory_bytes: 16712
#include <stdio.h>
int main(){
	
	int n;
	scanf("%d", &n);
	long long sum=0;
	
	for (int i=1; i<=n; i++){
		if(i % 3 == 0 || i % 5 == 0){
			continue;
		}
		else sum += i;
	}
	printf("%lld", sum);
	
	return 0;
}

Measured memory_bytes: 1724
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;

char a[20];
int main(){
  scanf("%s",a);
  int res=0;
  for(int i=0;i<16;i++){
    if(i==0 && a[i]!='C') res++;
    else if(i==1 && a[i]!='O') res++;
    else if(i==2 && a[i]!='D') res++;
    else if(i==3 && a[i]!='E') res++;
    else if(i==4 && a[i]!='F') res++;
    else if(i==5 && a[i]!='E') res++;
    else if(i==6 && a[i]!='S') res++;
    else if(i==7 && a[i]!='T') res++;
    else if(i==8 && a[i]!='I') res++;
    else if(i==9 && a[i]!='V') res++;
    else if(i==10 && a[i]!='A') res++;
    else if(i==11 && a[i]!='L') res++;
    else if(i==12 && a[i]!='2') res++;
    else if(i==13 && a[i]!='0') res++;
    else if(i==14 && a[i]!='1') res++;
    else if(i==15 && a[i]!='6') res++;
  }

  printf("%d\n",res);

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
const int MN = 200012;
ll n,p,fr[10012];
char s[MN];
int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  cin >> n >> p;
  cin >> s;
  ll ans = 0;
  if (p == 2 or p == 5) {
    for (ll i = 0; i < n; i++) {
      if ((s[i]-'0')%p == 0) ans += i+1;
    }
  } else {
    ll cur = 0, t = 1;
    for (ll i = n-1; i >= 0; i--) {
      cur = (cur + (s[i]-'0')*t) % p;
      fr[cur]++;
      t = (10*t) % p;
    }
    ans += fr[0]*(fr[0]+1)/2;
    for (ll i = 1; i < 10012; i++) {
      ans += fr[i]*(fr[i]-1)/2;
    }
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 512
MM = input().split()
N = int(MM[0])
X = int(MM[1])
mini = 1000
for i in range(N):
  a = int(input())
  X -= a
  if mini > a:
    mini = a
count = 0

while X >= mini:
  count +=1
  X -= mini
print(count + N)

Measured memory_bytes: 9192
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
from collections import deque


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
	
def count_str(m):
	tmp={}
	for i in range(10):
		if i in tmp:
			tmp[i]=1
		else:
			tmp[i]+=1
	return tmp

def is_prime(n):
	if n==1: return True

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

n=input1()
A=input_array()
B=input_array()
next_num=0 #繰越
count=0 #合計

for i in range(n+1):
	if A[i]<=next_num:
		count+=A[i]
		A[i]=0
	else:
		A[i]-=next_num
		count+=next_num
	if i==n:
		break
	if A[i]<B[i]:
		count+=A[i]
		next_num=B[i]-A[i]
	else:
		count+=B[i]
		next_num=0

print(count)








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

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9 + 7;

    int n;
    cin>>n;
    vector<int> a(n),b(n);
    rep(i,n)cin>>a[i]>>b[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end(),greater<>());
    if(n%2){
        cout<<b[n/2]-a[n/2]+1<<endl;
    }
    else{
        int A=a[n/2-1]+a[n/2];
        int B=b[n/2-1]+b[n/2];
        cout<<B-A+1<<endl;
    }
}

Measured memory_bytes: 6368
p['   '];t['   '];n,x,j;main(i){for(;++i<998;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i+*t]|=t[i];for(;p[x]|!t[x];x--);}}

Measured memory_bytes: 0