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

#define REP(i, s, n) for(int i = s; i < n; ++i)
#define rep(i, n)		 REP(i, 0, n)
#define SORT(c)			 sort((c).begin(), (c).end())
#define IINF					INT_MAX
#define LLINF					LLONG_MAX
#define DEBUG					false

int main(){
    int a,b;
    int temp=0;
    int ans=1;
    while(cin>>a>>b){
        temp=a+b;
        ans=1;
        while(10<=temp){
            temp=temp/10;
            ans++;
        }
        cout<<ans<<endl;
    }     
}

Measured memory_bytes: 3064
class UnionFind:
    def __init__(self, size):
        self.parent = list(range(size))
        self.height = [0] * size
        self.size = [1] * size
        self.componentCount = size

    def root(self, index):
        if self.parent[index] == index:  # 根の場合
            return index
        rootIndex = self.root(self.parent[index])  # 葉の場合親の根を取得
        self.parent[index] = rootIndex  # 親の付け直し
        return rootIndex

    def union(self, index1, index2):  # 結合
        root1 = self.root(index1)
        root2 = self.root(index2)

        if root1 == root2:  # 連結されている場合
            return

        self.componentCount -= 1  # 連結成分を減らす

        if self.height[root1] < self.height[root2]:
            self.parent[root1] = root2  # root2に結合
            self.size[root2] += self.size[root1]
        else:
            self.parent[root2] = root1  # root1に結合
            self.size[root1] += self.size[root2]
            if self.height[root1] == self.height[root2]:
                self.height[root1] += 1
        return

    def isSameRoot(self, index1, index2):
        return self.root(index1) == self.root(index2)

    def sizeOfSameRoot(self, index):
        return self.size[self.root(index)]

N, M = map(int, input().split())
tree = UnionFind(N)

for _ in range(M):
    a, b = map(lambda a: int(a) - 1, input().split())
    tree.union(a, b)

ans = 1
for i in range(N):
    ans = max(ans, tree.sizeOfSameRoot(i))
print(ans)


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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int N, M; cin >> N >> M;
    vector<int> P(N); for(int i = 0; i < N; i++) cin >> P[i];
    UnionFind tree(N+1);
    for(int i = 0; i < M; i++){
        int x, y; cin >> x >> y;
        tree.unite(x, y);
    }
    int cnt=0;
    for(int i = 1; i < N+1; i++){
        if(tree.same(P[i-1], i)) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
# include <stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    int ini, fim;
    int total = 0;
    
    for (int i = 0; i < n; ++i){
        scanf("%d %d", &ini, &fim);
        total += fim - ini;
        total += 1;
    }
    printf("%d\n", total);
    
    
    
    return 0;
}

Measured memory_bytes: 128
import sys
n = int(input())
S = [int(input()) for _ in range(n)]
SUM = sum(S)
if SUM % 10 != 0:
    print(SUM)
    sys.exit(0)
S2 = []
for s in S:
    if s % 10 != 0:
        S2.append(s)
if len(S2) == 0:
    print(0)
    sys.exit(0)
print(SUM-min(S2))


Measured memory_bytes: 3060
def solve():
    N,M,Q = map(int,input().split())
    global info
    info = []
    for _ in range(Q):
        a,b,c,d = map(int,input().split())
        a -= 1
        b -= 1
        info.append([a,b,c,d])

    print(dfs(list(),M,N))

def dfs(A,M,N):
    if len(A) == N:
        return calcPoint(A)
    
    res = 0
    prev = A[-1] if len(A) > 0 else 1
    for i in range(prev,M+1):
        A.append(i)
        res = max(res,dfs(A,M,N))
        A.pop()
    
    return res

def calcPoint(A):
    result = 0
    for a,b,c,d in info:
        if A[b] - A[a] == c:
            result += d
    return result
                
if __name__ == '__main__':
    solve()

Measured memory_bytes: 75768
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <climits>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    bool flag = false;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (4 * i + 7 * j == n) {
                flag = true;
            }
        }
    }
    if (flag) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}


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

namespace ABC137
{
    class Program
    {
        static void Main(string[] args)
        {
            B();
            Console.Read();
        }


        static void B()
        {
            string[] input = Console.ReadLine().Split(' ');
            int K = int.Parse(input[0]);
            int X = int.Parse(input[1]);

            int min =  -1000000;
            int max = 1000000;

            for(int i = -(K - 1);i <= (K -1); i++)
            {
                Console.Write((i + X).ToString());
                Console.Write(" ");
            }

            Console.WriteLine("");
        }
        static void A()
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);

            int plus = A + B;
            int minus = A - B;
            int product = A * B;

            int max = Math.Max(plus, minus);
            max = Math.Max(max, product);
            Console.WriteLine(max.ToString());


        }

    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int n;
	
	cin >> n;
	for (int x = 1; x <= 500000; x++) {
		if (n == x * 108 / 100) {
			cout << x << endl;
			return 0;
		}
	}
	
	cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 768
#ifdef debug
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>
//#include "optimization.h"

using namespace std;

#define vec vector
#define ALL(x) begin(x), end(x)

typedef unsigned int ui;
typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< long long, long long > pll;

const int inf = 1e9;
const ll inf64 = 1e18;

const int N = 2e5 + 5;

int n;
pii a[N];
int res[N];

int main() {

#ifdef debug
    freopen("input.txt", "r", stdin);
#endif

    scanf("%d", &n);

    for(int i = 1;i <= n;i++) {
        scanf("%d", &a[i].first);
        a[i].second = i;
    }

    sort(a + 1,a + n + 1);

    for(int i = 1;i <= n;i++) {
        if(i <= n / 2) {
            res[a[i].second] = a[n / 2 + 1].first;
        }else {
            res[a[i].second] = a[n / 2].first;
        }
    }

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

    return 0;
}


Measured memory_bytes: 4480
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n; ll a, b;
    cin >> n >> a >> b;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    ll ans = 0;
    rep(i, n-1) {
        ll dist = x[i+1] - x[i];
        if (dist * a <= b) ans += dist * a;
        else ans += b;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3736
n, k = map(int, input().split())

MOD = 1000000007

def pow_mod(x, y):
    if y == 0: return 1
    ans = 1
    while y > 1:
        if y % 2 != 0: 
            ans *= x
            ans %= MOD
        x *= x
        x %= MOD
        y //= 2
    return ans * x % MOD

mod_inv = lambda x: pow_mod(x, MOD - 2)

if k >= n-1:
  n2_1 = (n * 2 - 1) % MOD 
  nHr = {0:1}
  for i in range(1, n):
    nHr[i] = nHr[i-1] * (n2_1 - i + 1)
    nHr[i] %= MOD
    nHr[i] *= mod_inv(i)
    nHr[i] %= MOD
  print(nHr[n-1])
else:
  mod_inv_d = {i: mod_inv(i) for i in range(1, max(k+1, n-k+1))}
  nCr = {0:1}
  n_1Cr = {0:1}
  ans = nCr[0] * n_1Cr[0]
  for i in range(1, k+1):
    hoge = (n - i + 1)
    nCr[i] = nCr[i-1] * hoge
    nCr[i] %= MOD
    nCr[i] *= mod_inv_d[i]
    nCr[i] %= MOD
    n_1Cr[i] = n_1Cr[i-1] * (hoge - 1)
    n_1Cr[i] %= MOD
    n_1Cr[i] *= mod_inv_d[i]
    n_1Cr[i] %= MOD
    ans += (nCr[i] * n_1Cr[i]) % MOD
    ans %= MOD
  print(ans)



Measured memory_bytes: 115292
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> data(N);
    for (int i = 0; i < N; i++) {
        cin >> data.at(i);
    }
    sort(data.begin(), data.end());
    reverse(data.begin(), data.end());
    int a = 0;
    int b = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) {
            a += data.at(i);
            continue;
        }
        b += data.at(i);
    }
    int ans = a - b;
    cout << ans << endl;
}

Measured memory_bytes: 256
class P:
    def __init__(self, name, t):
        self.name  = name
        self.t = t

n, q = map(int, input().split())

LEN = 100005  # 100005は十分大きければなんでも良い(n以上になるように)

head = 0
tail = n
Q = [P('', 0) for _ in range(LEN)]
for i in range(n):
    Q[i].name, num = input().split()
    Q[i].t = int(num)

def enqueue(Q, x, tail):
    Q[tail] = x
    tail = (tail+1)%LEN
    return tail

def dequeue(Q, head):
    x = Q[head]
    head = (head+1)%LEN
    return x, head

elaps = 0

while head != tail:
    u, head = dequeue(Q, head)
    c = min(q, u.t)
    u.t -= c
    elaps += c
    if u.t > 0:
        tail = enqueue(Q, u, tail)
    else:
        print(u.name + ' ' + str(elaps))



Measured memory_bytes: 25952
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    double n, m, d;
    cin >> n >> m >> d;
    cout << fixed << setprecision(16);
    if (d == 0) cout << (m - 1) / n << endl;
    else cout << 2 * (n - d) * (m - 1) / n / n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int H, W;
int num[53][53];
string S[51];



int main(){
	
	cin>>H>>W;
	
	REP( i, H ) cin>>S[i];
	
	REP( i, H ){
		REP( j, W ){
			if( S[i][j] == '#' ){
				FOR( x, j, j+3 ){
					FOR( y, i, i+3 ){
						num[y][x]++;
					}
				}
			}
		}
	}
	
	REP( i, H ){
		REP( j, W ){
			if( S[i][j] == '.' ){
				cout<<num[i+1][j+1];
			}
			else{
				cout<<S[i][j];
			}
		}
		puts("");
	}
	
}



Measured memory_bytes: 256
List="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
n=int(input())
s=input()
ans=""
for i in range(len(s)):
  num=List.index(s[i])+n
  #print(num)
  if (num>25):
    num=num-26
  ans=ans+List[num]
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    ll N, K;
    cin >> N >> K;

    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll maxA = *max_element(A.begin(), A.end());
    if (maxA < K) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    ll gcd = __gcd(A[0], A[1]);
    for (ll i = 2; i < N; i++) {
        gcd = __gcd(gcd, A[i]);
    }

    if (K % gcd == 0)
        cout << "POSSIBLE" << endl;
    else
        cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 4056
#include<iostream>
using namespace std;
int  main()
{
    int N;
    int m=0;
    cin>>N;
    int a[100];
    for(int i=0;i<N;i++)
        cin>>a[i];
    for(int i=0;i<N-1;i++)
        for(int j=0;j<N-1-i;j++)
    {
    int t;
    if(a[j]>a[j+1])
    {

        t=a[j];
        a[j]=a[j+1];
        a[j+1]=t;
        m++;
    }
    }
    for(int i=0;i<N;i++)
    {
        if(i)
            cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a<=0&&b>=0) cout<<"Zero";
	else if(a>=0) cout<<"Positive";
	else if(a<0&&abs(a-b-1)%2==1)  cout<<"Negative";
	else cout<<"Positive";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 2e5 + 5, M = 2 * N + 5;

int n, m,freq[N];

int main()
{
    cin>>n;
    int x,sum=0;
    for(int i=0;i<n-1;++i)
    {
        cin>>x;
        freq[x-1]++;
    }
    for(int i=0;i<n;++i)
        cout<<freq[i]<<endl;
	return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto& e : a) cin >> e;
	sort(a.begin(), a.end(), greater<int>());
	int alice = 0;
	int bob = 0;
	for(int i=0; i<n; i+=2){
		alice += a[i];
		bob += a[i+1];
	}
	cout << alice - bob << 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 REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;
#define _USE_MATH_DEFINES

int main(){
    int a,b,x;
    cin>>a>>b>>x;

    double V = a*a*b;
    if(V/2<x){
        double e=(double)2*(V-x)/a/a;
        cout <<setprecision(10)<< 180*atan(e/(double)a)/M_PI<<endl;
    }else{
        double e=(double)2*x/a/b;
        cout<<setprecision(10)<< 180*atan((double)b/e)/M_PI <<endl;

    }
}

Measured memory_bytes: 384
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int n;
	cin >> n;
	map<int, int> mp;
	REP(i,n){
		cin >> tmp;
		mp[tmp]++;
	}
	vector<int> v;
	int only = 0;
	bool zero = false;
	for(auto it = mp.begin(); it != mp.end(); it ++){
		if(it->second >= 3) zero = true;
		if(it->second == 2){
			v.push_back(-12 + it->first);
			v.push_back(12 - it->first);
		}
		if(it->second == 1) only += 1 << it->first;
	}
	vector<int> now;
	ans = 0;
	REP(i, 1 << 13){
		now.clear();
		now.push_back(-12);
		now.push_back(12);
		copy(v.begin(), v.end(), back_inserter(now));
		REP(j, 13){
			if(only & (1<<j)){
				if(i & (1<<j)) now.push_back(-12 + j);
				else now.push_back(12 - j);
			}
		}
		sort(now.begin(), now.end());
		tmp = 24;
		REP(i, now.size()-1) tmp = min(tmp, now[i+1] - now[i]);
		ans = max(ans, tmp);
	}
	if(zero) cout << 0 << endl;
	else cout << ans << endl;
}

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


//TEMPLATE
#define pb                push_back
#define mp                make_pair
#define ll                long long
#define ld                long double
#define pii               pair <ll, ll>
#define piii              pair <ll, pii>
#define F                 first
#define S                 second

#define newline           printf("\n")
#define minusone          printf("-1\n")
#define zeroo             printf("0\n")
#define scl1(a)           scanf("%lld", &a)
#define scl2(a, b)        scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)     scanf("%lld %lld %lld", &a, &b, &c)
#define prl1(a)           printf("%lld\n", a)
#define prl2(a, b)        printf("%lld %lld\n", a, b)
#define ssl1(s)           scanf(" %[^\n]", s)
#define scd1(a)           scanf("%lf", &a)
#define scd2(a, b)        scanf("%lf %lf", &a, &b)
#define prd(a)            printf("%lf\n", a)
#define prld(a)           printf("%Lf\n", a)
#define prcase(cs)        printf("Case %lld: ", cs)
#define cin1(a)           cin >> a
#define cin2(a, b)        cin >> a >> b
#define cin3(a, b, c)     cin >> a >> b >> c
#define cin4(a, b, c, d)  cin >> a >> b >> c >> d
#define cot1(a)           cout << a << "\n"
#define cot2(a, b)        cout << a << " " << b << "\n"
#define cot3(a, b, c)     cout << a << " " << b << " " << c << "\n"
#define cot4(a, b, c, d)  cout << a << " " << b << " " << c << " " << d << "\n"
#define cotline           cout << "\n"
#define cotminus          cout << "-1\n"
#define cot0              cout << "0\n"
#define cotyes            cout << "YES\n"
#define cotno             cout << "NO\n"
#define cotcase(cs)       cout << "Case " << cs << ": "

#define reversed(s)       reverse(s.begin(), s.end())
#define asort(s)          sort(s.begin(), s.end())
#define dsort(s)          sort(s.rbegin(), s.rend())
#define all(s)            s.begin(), s.end()
#define uniq(s)           s.resize(distance(s.begin(),unique(s.begin(), s.end())))
#define found(s, x)       (s.find(x) != s.end())

#define for0(i, n)        for (i = 0; i < n; i++)
#define for1(i, n)        for (i = 1; i <= n; i++)
#define fora(i, a, b)     for (i = a; i <= b; i++)
#define forb(i, b, a)     for (i = b; i >= a; i--)
#define fori(it, s)       for(auto it = s.begin(); it != s.end(); it++)

#define FR                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(a, x)          memset(a, x, sizeof a)
#define bitcount(n)       __builtin_popcountll(n)

//#define pi              3.1415926536
#define pi                acos(-1)

const ll INF = LLONG_MAX;
const ll SZ = 4e5+5;
const ll mod = 1e9+7;


string s, s1, s2;
ll n, k, ans = 0;
ll a[SZ];
ll cm[SZ];



int main() {
    FR;
    ll cs = 0, tc = 1, x, y, z, i, j, g, p, q, sum = 0, c = 0, t = 0;
//    ll a, b, d;
//    string s, s1, s2;

    cin1(n);
    for1(i, n) cin1(a[i]);

    for1(i, n) cm[i] = cm[i-1] + a[i];

    for1(i, n) {
        x = cm[n] - cm[i];
        x %= mod;
        x = (a[i] * x) % mod;
        ans = (ans + x) % mod;
    }
    cot1(ans);

    return 0;
}



Measured memory_bytes: 6776
#include <iostream>
typedef long long int ll;
using namespace std;
#define P 998244353
#define N_MAX 300000
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
    return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
    fac[0] = 1;
    finv[0] = 1;
    fac[1] = 1;
    finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i <= N_MAX; i++){
        fac[i] = (fac[i-1]*i)%P;
        inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
        finv[i] = (finv[i-1]*inv[i])%P;
    }
}

/*int main(){
    init();
    ll N, A, B, K, ans =0;
    std::cin >> N >> A >> B >> K;
    for(ll i=0;i<N+1;i++){
      ll j = (K - A * i)/B;
      if(j >= 0 && (K - A * i) % B == 0 && j <= N){
        ans = (ans + comb(N, i) * comb(N, j) %P);
      }
    }
    std::cout << ans << '\n';
}*/
int main(){
    long N, A, B, K;
    cin >> N >> A >> B >> K;
    init();
    long ans = 0;
    for(int na = 0; na <= N; na++){
        long nb = (K-A*na)/B;
        if((K-A*na)%B == 0 && nb <= N && nb >= 0){
            //cout << na << ' ' << nb << endl;
            ans = (ans + comb(N, na)*comb(N, nb))%P;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include <queue>
using namespace std;
using point = pair<int, int>;
vector<int> x_ = {0, 1};
vector<int> y_ = {1, 0};
int main() {
    int H, W;
    cin >> H >> W;
    vector<string>vec(H);
    vector<vector<int>> seen(H, vector<int>(W, -1));
    for (int i=0; i < H; i++) {
        cin >> vec.at(i);
    }

    queue<point> que;
    que.push(point(0, 0));
    while (!que.empty()) {
        point p = que.front();
        que.pop();
        if (vec[p.first][p.second] == '#') {
            seen[p.first][p.second] = 1;
        } else {
            continue;
        }

        bool souhoukou = false;
        int count = 0;
        for (int i=0; i<2; i++) {
            int new_y = p.first + y_[i];
            int new_x = p.second + x_[i];
            if (new_y < 0 || new_y >= H) continue;
            if (new_x < 0 || new_x >= W) continue;
            if (vec[new_y][new_x] == '#') ++count;
            point new_p = point(new_y, new_x);
            que.push(new_p);
        }

        if (count == 2) {
            seen[p.first][p.second] = 0;
        }
    }

    bool possible = true;
    for (int i=0; i < H; i++) {
        for (int j=0; j < W; j++) {
            if (vec[i][j] == '#' && seen[i][j] != 1) {
                possible = false;
            }
        }
    }

    if (possible) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

 
void solve(){
 
 
}

const ll mod=1e9+7;
const int maxn = 200009;
vi f(maxn, 1);
ll modpow(ll b, ll e) {
	ll ans = 1;
	for (; e; b = b * b % mod, e /= 2)
		if (e & 1) ans = ans * b % mod;
	return ans;
}
ll inv(ll x){
    return modpow(x, mod-2);
}
void pre(){
    ll p=1;
    repA(i,2,maxn-1) p=p*i%mod, f[i]=p;
}

int cn(int n, int k){
    if(n<0||k<0||n<k) return 0;
    return f[n]*inv(f[k])%mod*inv(f[n-k])%mod;
}

int n;
vi g[200009], s;
map<int, ll > dp[200009];
ll dfs0(int u,int p){
    ll a=1;
    trav(v,g[u])if(v!=p)a+=dfs0(v,u);
    return s[u]=a;
}
ll dfs(int u, int p){
    ll a=f[s[u]-1];
    trav(v, g[u])if(v!=p) a=a*dfs(v,u)%mod*inv(f[s[v]])%mod;
    return dp[u][p]=a;
}
void dfs1(int u,int p){
    ll a=1;
    trav(v,g[u])if(v!=p) a=a*dp[v][u]%mod*inv(f[s[v]])%mod;
    if(p!=-1){
        a=a*f[n-1]%mod;
        dp[u][-1]=a=a*dp[p][u]%mod*inv(f[n-s[u]])%mod;
        a=a*inv(f[n-1])%mod;
    }
    trav(v,g[u])if(v!=p){
        a=a*f[n-s[v]-1]%mod;
        a=a*inv(dp[v][u])%mod*f[s[v]]%mod;
        dp[u][v]=a;
        a=a*dp[v][u]%mod*inv(f[s[v]])%mod;
        a=a*inv(f[n-s[v]-1])%mod;
    }
    trav(v,g[u])if(v!=p) dfs1(v,u);
}


int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    cin>>n;
    s.resize(n,0);
    rep(i,n-1){
        int u,v;cin>>u>>v;u--,v--;
        g[u].pb(v), g[v].pb(u);
    }
    dfs0(0,-1);
    dfs(0,-1);
    dfs1(0,-1);
    rep(i,n)cout<<dp[i][-1]<<'\n';

	return 0;
}
 



Measured memory_bytes: 62324
#include<bits/stdc++.h>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pt;
const int N=2e5+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const double eps=1e-8;
const double pi=acos(-1);
LL n,m;
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
LL qpow(LL a,LL p)
{
    LL res=1;
    while(p){
        if(p&1) res=res*a%mod;
        a=a*a%mod;
        p>>=1;
    }
    return res;
}
LL inv(LL x)
{
    return qpow(x,mod-2);
}
LL hhh(LL a,LL b)
{
    a++; b++;
    LL res=1;
    FOR(i,1,a)
	{
        res=res*(a+b-i+1)%mod;
    }
    FOR(i,1,a)
	{
        res=res*inv(i)%mod;
    }
    return (res-1+mod)%mod;
}
int main()
{
    LL r1,r2,c1,c2;
    rrr(r1,c1,r2); r(c2);
    LL a1=hhh(r2,c2);
    LL a2=hhh(r1-1,c1-1);
    LL a3=hhh(r1-1,c2);
    LL a4=hhh(r2,c1-1);
    cout<<(a1+a2-a3-a4+mod+mod)%mod<<endl;
    return 0;
}

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

using namespace std;

int main(){

    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    //freopen("input.txt", "r", stdin);

    int n, k;

    cin >> n >> k;

    // oops i am illiterate

    cout << n - k + 1;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
 
ll a, b, c, d, e, f, g;
 
int main() {
	cin >> a >> b >> e >> c >> d >> f >> g; // no e,f,g
 
	ll ret = a/2*2 + c/2*2 + d/2*2;
	if (a && c && d) {
		ret = max(ret, 3 + (a-1)/2*2 + (c-1)/2*2 + (d-1)/2*2);
	}
 
	cout << ret + b << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
A=[int(i) for i in input().split()]

A.sort(reverse=True)


if N%2==1:
    if N==3:
        ans=A[0]+A[1]
    else:
        ans=A[0]
        for i in range(1,N//2):
            ans+=A[i]*2
        ans+=A[N//2]
else:
    ans=A[0]
    for i in range(1,N//2):
        ans+=A[i]*2

print(ans)


Measured memory_bytes: 104900
alpha = "abcdefghijklmnopqrstuvwxyz"

s = input()
if len(s) < 26:
  a = sorted(list(set(alpha) - set(s)))
  print(s+a[0])
  exit(0)

def a():
  A = [chr(i) for i in range(ord('a'), ord('z')+1)]
  B = {}
  for i in range(26):
    B[A[i]] = i
  C = [0]*26
  for i in range(len(s)):
    C[B[s[i]]] = 1
  for i in range(25, -1, -1):
    t = s[i]
    for j in range(B[s[i]]+1, 26):
      if C[j] == 0:
        return s[:i] + A[j]
    C[B[t]] = 0
  return -1

print(a())

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    ll res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}

ll f[200001];
 
ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
 
 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
 


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxtl(),k=nxtl();
    ll mod=1e9+7;
    ll r=0;
    ll test=0;
    f[0] = 1;
    for(ll i = 1 ; i <= 200000 ; i++)
        f[i] = (f[i-1]*i)%mod;
    while(r<n&&r<=k)
    {
        test=(test+(C(n,r,mod)*C(n-1,n-r-1,mod))%mod)%mod;
        r++;
    }
    cout<<test%mod<<endl;


    return 0;   
}


 
 


Measured memory_bytes: 1792
n, k = [int(x) for x in input().split()]
a_list = [int(x) for x in input().split()]
s=0
l = len(bin(k)) - 2
b = n / 2
x = 0
for i in range(l, -1, -1):
    count = sum([(a >> i) & 1 for a in a_list])
    if count < b:
        temp = 1 << i
        if x + temp <= k:
            x += temp
print(sum([x ^ a for a in a_list]))


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

ll g1(ll n, int p) {
  if (n == 0) return 0;
  return n/p + g1(n/p,p);
}
ll g2(ll n, int p) {
  if (n%2 == 1) {
    return g1(n,p) - g2(n-1,p);
  }
  ll res = g1(n/2,p);
  if (p == 2) res += n/2;
  return res;
}

int main() {
  ll n;
  cin >> n;
  ll ans = min(g2(n,2), g2(n,5));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        
#define pb push_back
#define ll long long
#define f first
#define s second
#define ld long double
#define fa fflush(stdout); 
#define mp make_pair
using namespace std;
void data() {
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
  //  ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);;                                                      
} 
const int N = 1e5 + 100;
const ll mod = 1e9 + 7;
const ll big = 1e16;
const int p = 37;

ll dp[3105][3105][10];
ll was[3105][3105];
int main() 
{
	data();
	#define int ll
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);;                                                       
	int r, c, k;
	cin >> r >> c >> k;
	int row[k + 1], col[c + 1], sum[k + 1];
	for (int i = 1; i <= k; i++)
	{
		cin >> row[i] >> col[i] >> sum[i];
		was[row[i]][col[i]] += sum[i];
	}
	for (int i = 1; i <= r; i++)
	{
		for (int j = 1; j <= c; j++)
		{
			dp[i][j][0] = -1;
			dp[i][j][1] = -1;
			dp[i][j][2] = -1;
			dp[i][j][3] = -1;
		}
	}
	dp[1][1][0] = 0;
	if (was[1][1])
	{
		dp[1][1][1] = was[1][1];
	}             
	for (int i = 1; i <= r ;i++)
	{
		for (int j = 1; j <= c; j++)
		{
			for (int k = 0; k <= 3; k++)
			{
				if (dp[i][j][k] != -1)
				{
					if (i + 1 <= r)
					{
						if (was[i + 1][j])
						{
							dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][k] + was[i + 1][j]);
						}
						dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
					}
					if (j + 1 <= c)
					{
						if (was[i][j + 1] && k + 1 <= 3)
						{
							dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j][k] + was[i][j + 1]);
						}
						dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
					}
				}
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i <= 3 ;i++)
	{
		ans = max(ans, dp[r][c][i]);
	}
	cout << ans;
}


Measured memory_bytes: 794276
using System;

namespace aoj
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inputs = Console.ReadLine().Split(' ');
            var x = int.Parse(inputs[0]);
            var y = int.Parse(inputs[1]);

            GCD(x, y);
        }

        static void GCD(int _x, int _y)
        {
            // できるだけ数字を小さくする
            while (true)
            {
                // _xが常に大きくなるように入れ替え
                if (_x < _y) { Swap(ref _x, ref _y); }

                if (_x == 0 || _y == 0) { break; }

                _x = _x % _y;
            }

            Console.WriteLine(_x);
        }

        static void Swap(ref int _x, ref int _y)
        {
            var tmp = _x;
            _x = _y;
            _y = tmp;
        }
    }
}



Measured memory_bytes: 17816
import std.stdio, std.math;

int[] to_array(int n) {
  int[] res;
  for(size_t i = n; i > 0; i /= 10) res ~= i % 10;
  for(size_t i = 5 - res.length; i > 0; i--) res ~= 0;
  return res.reverse;
}

void main() {
  bool f = true;
  for(int num; readf("%d\n", &num);) {
    if (f) f = false;
    else writeln;
    int[] arr = to_array(num);
    for(int i = 1; i >= 0; i--) {
      for(int j = 0; j <= 4; j++) {
        if ((arr[j] > 4) ^ i) write("*");
        else write(" ");
      }
      writeln;
    }
    writeln("=====");
    for(int i = 0; i <= 4; i++) {
      for(int j = 0; j <= 4; j++) {
        if (i == (abs((arr[j] > 4 ? arr[j] - 5 : arr[j]) % 5))) write(" ");
        else write("*");
      }
      writeln;
    }
  }
}

Measured memory_bytes: 1096
#!/usr/bin/env python
"""AtCoder Beginner Contest 170: B - Crane and Turtle
https://atcoder.jp/contests/abc170/tasks/abc170_b
"""


def main():
    X, Y = list(map(int, input().split()))

    b = (Y - (2*X)) / 2
    a = X - b
    # print('a:{}, b:{}'.format(a, b))

    if int(b) != b:
        print('No')
    elif a < 0 or b < 0:
        print('No')
    elif a == 0 and b == 0:
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
#include<cstdio>
int main()
{
    int n;double a,d,ans=0;
    scanf("%d%lf%lf",&n,&a,&d);
    for(a-=d;n;--n) ans+=a+(n+0.5)*d,a+=(2*a+3*d)/n/2,d+=2.0/n*d;
    printf("%.10lf",ans);
}



Measured memory_bytes: 128
import fractions
import sys
from functools import reduce
import math

input = sys.stdin.readline


def main():
    n = int(input())
    a = input_list()
    print(gcd_list(a))

def get_camulative(l):
    import itertools
    # 累積和
    return [0] + list(itertools.accumulate(l))

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if __name__ == "__main__":
    main()


Measured memory_bytes: 84460
#include<bits/stdc++.h>
using namespace std;
int n,k;
long long num[55];
long long hand[55];
vector<long long> q;
bool cmp(long long a,long long b){
	return a>b;
}
long long solve(int l,int r){
	while(!q.empty())q.clear();
	long long ans=0;
	for(int i=1;i<=l;i++){
		ans+=num[i];
		q.push_back(num[i]);
	}
	for(int i=n;i>=n-r+1;i--){
		ans+=num[i];
		q.push_back(num[i]);
	}
	sort(q.begin(),q.end(),cmp);
	for(int i=0;i<k-r-l;i++){
		if(q.empty()) break;
		ans-=min(q[q.size()-1],(long long ) 0);
		q.pop_back();
	}
	return ans;
}
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>num[i];
	}
	long long maxn=0;
	for(int i=0;i<=k;i++){
		for(int j=0;j+i<=min(n,k);j++){
			maxn=max(solve(i,j),maxn);
		}
	}
	cout<<maxn;
}

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

using namespace std;
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007
#define INF 200000000
#define int long long
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)


vector<int> match(string a,string b){
	int al=a.size(),bl=b.size();
	vector<int> ans;
	if(al<bl) return ans;
	int t=1;
	int ah=0,bh=0;
	lp(i,bl){
		int x=a[i];
		int y=b[i];
		ah=ah*DEKAI+x;
		bh=bh*DEKAI+y;
		t*=DEKAI;
	}
	if(ah==bh) ans.push_back(0);
	for(int i=0;i+bl<al;i++){
		ah=ah*DEKAI+a[i+bl]-a[i]*t;
		if(ah==bh) ans.push_back(i+1);
	}
	return ans;
}

signed main(){
	string t,p;
	cin>>t>>p;
	vector<int> m=match(t,p);
	lp(i,m.size()) cout<<m[i]<<endl;
	return 0;
}


Measured memory_bytes: 13596
#テンプレート
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
#テンプレート終わり

N = int(input())
A = list(map(int,input().split()))
cumulativeGcdLeft = [A[0]]
cumulativeGcdRight = [A[N-1]]
for i in range(N-1):
    cumulativeGcdLeft.append(fractions.gcd(A[i+1],cumulativeGcdLeft[i]))
    cumulativeGcdRight.append(fractions.gcd(A[N-1-i-1],cumulativeGcdRight[i]))
ans = 1
# print(cumulativeGcdLeft)
# print(cumulativeGcdRight)
for i in range(N):
    if i == 0:
        candidate = cumulativeGcdRight[N-2]
    elif i == N-1:
        candidate = cumulativeGcdLeft[N-2]
    else:
        left = cumulativeGcdLeft[i-1]
        right = cumulativeGcdRight[N-i-2]
        candidate = fractions.gcd(left,right)
        # print(i,left,right,candidate)
    ans = max(ans,candidate)
print(ans)

Measured memory_bytes: 17244
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;
public:
  u64 a;
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
#pragma endregion

int main() {
  cin >> A >> B >> C;
  if(4*A*B < (C - A - B)*(C - A - B) && (C > A + B)) cout << "Yes";
  else cout << "No";
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    cout << (a+b)/2 << endl;

    return 0;
}


Measured memory_bytes: 3196
#include<stdio.h>
#define FOR( i,a ) for( i = 0;i < a;i++ )
int main(){
    int i = 1,j = 1;
    FOR( i,9 ){ FOR( j,9 ){ printf( "%dx%d=%d\n",(i+1),(j+1),(i+1)*(j+1)); }}
    return 0;
}

Measured memory_bytes: 520
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, k = nm()

    if 2*k >= b - a + 1:
        for i in range(a, b+1):
            print(i) 
        exit()

    for i in range(a, a+k):
        print(i)

    for i in range(b-k+1, b+1):
        print(i)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3696
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


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


Measured memory_bytes: 256
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

int ans;
#define MAXN 100000
vector<LL> fa;
vector<int> ch[MAXN+10];
int k;
int dfs(int now)
{
	int mx=1;
	for(auto son:ch[now]) {
		mx=max(mx,dfs(son)+1);
	}
	if (mx==k && fa[now-1]!=1) {
		mx=0;
		++ans;
	}
	return mx;
}
void solve(long long N, long long K, vector<long long> a){
	k=K;
	if (a[0]!=1) ++ans;
	a[0]=1;
	fa=a;
	for(int i=1; i<N; ++i) {
		ch[a[i]].push_back(i+1);
	}
	dfs(1);
	cout<<ans<<endl;
}

int main(){	
#ifdef WAAUTOMATON
	freopen("1_03.txt","r",stdin);
#endif
	long long N;
	long long K;
	scanf("%lld",&N);
	scanf("%lld",&K);
	vector<LL> a(N);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, K, a);
	return 0;
}



Measured memory_bytes: 12800
import java.io.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		
		while(true) {
			String[] str = br.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			
			if(H==0 && W==0) {
				break;
			}
			
			for(int i=0; i<H; i++) {
				for(int j=0; j<W; j++) {
					if(i==0 || j==0 || i==H-1 || j==W-1) {
						sb.append("#");
					} else {
						sb.append(".");
					}
				}
				sb.append("\n");
			}
			sb.append("\n");
		}
		System.out.print(sb);
	}
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a == b){
        cout << 0 << endl;
        return 0;
    }
    int k = abs(a - b) / 2;
    if(a < b){
        if(b - k == a + k){
            cout << b-k << endl;
            return 0;
        }else{
            cout << "IMPOSSIBLE" << endl;
            return 0;
        }
    }else{
        if(b + k == a - k){
            cout << b+k << endl;
            return 0;
        }else{
            cout << "IMPOSSIBLE" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
class Factor
  attr_reader :id
  def initialize(id)
    @id = id
    @parent = self
  end

  def union
    if @parent != self
      @parent = @parent.union
      @parent
    else
      self
    end
  end

  def unite(other)
    @parent.union.unite(other.union) if @parent != self
    @parent = other.union
  end

  def same(other)
    if union == other.union
      puts 1
    else
      puts 0
    end
  end

  def ==(other)
    @id == other.id
  end
  
end
class String
  def com(x, y)
   x.send(self, y)
  end
end
def main
  n, q = gets.split(" ").map(&:to_i)
  array = Array.new(n){|i|Factor.new(i)}
  comand = ["unite", "same"]
  q.times do
    arg = gets.split(" ").map(&:to_i)
    comand[arg[0]].com(array[arg[1]], array[arg[2]])
  end
end
main

Measured memory_bytes: 8588
n,k=map(int, input().split())
l=[tuple(map(int, input().split())) for _ in range(n)]
l.sort()
a,b=0,0
for t in l:
    b=a+t[1]
    if a<k<=b:
        print(t[0])
        exit()
    a=b
print(l)

Measured memory_bytes: 22708