akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-8;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    int d, t, s;
    cin >> d >> t >> s;
    cout << (s * t >= d ? "Yes" : "No") << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}

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

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

    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        --a[i];
    }

    int count = 0;
    for (int i = 0; i < n; ++i) {
        if (a[a[i]] == i) {
            ++count;
        }
    }

    count >>= 1;

    cout << count << endl;

    return 0;
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
ll N,M,s,t;
ll u,v,a,b;
const ll NODE_SIZE = 101010;
vector<pair<ll,ll>> edge1[NODE_SIZE];
vector<pair<ll,ll>> edge2[NODE_SIZE];
ll d1[NODE_SIZE];   //始点ノードからノードiへの最短距離
ll d2[NODE_SIZE];   //始点ノードからノードiへの最短距離
ll start1,start2;  //開始ノード番号
/*==================================================*/

//ダイクストラ法
void dijkstra1() {
    priority_queue<pair<ll, ll> > PQ;  //<(-1)*最短距離, ノード番号>

    REP(i, 0, N) d1[i] = inf;
    d1[start1] = 0;
    PQ.push(make_pair(0, start1));  //開始ノードを0とする。

    while (!PQ.empty()) {
        ll curCost = -PQ.top().first;
        ll curNode = PQ.top().second;
        PQ.pop();

        if (d1[curNode] < curCost) continue;
        d1[curNode] = curCost;

        REP(i, 0, edge1[curNode].size()) {
            ll nextNode = edge1[curNode][i].first;
            ll addCost = edge1[curNode][i].second;

            if (d1[nextNode] > d1[curNode] + addCost) {
                d1[nextNode] = d1[curNode] + addCost;
                //rev[nextNode] = curNode; // ** 最短経路のルートが欲しい場合
                PQ.push(make_pair(-d1[nextNode], nextNode));
            }
        }
    }
}
void dijkstra2() {
    priority_queue<pair<ll, ll> > PQ;  //<(-1)*最短距離, ノード番号>

    REP(i, 0, N) d2[i] = inf;
    d2[start2] = 0;
    PQ.push(make_pair(0, start2));  //開始ノードを0とする。

    while (!PQ.empty()) {
        ll curCost = -PQ.top().first;
        ll curNode = PQ.top().second;
        PQ.pop();

        if (d2[curNode] < curCost) continue;
        d2[curNode] = curCost;

        REP(i, 0, edge2[curNode].size()) {
            ll nextNode = edge2[curNode][i].first;
            ll addCost = edge2[curNode][i].second;

            if (d2[nextNode] > d2[curNode] + addCost) {
                d2[nextNode] = d2[curNode] + addCost;
                //rev[nextNode] = curNode; // ** 最短経路のルートが欲しい場合
                PQ.push(make_pair(-d2[nextNode], nextNode));
            }
        }
    }
}
int main() {
    cin>>N>>M>>s>>t;
    s--;
    t--;
    start1 = s;
    start2 = t;
    REP(i,0,M){
        cin>>u>>v>>a>>b;
        u--;v--;
        edge1[u].emplace_back(v,a);
        edge1[v].emplace_back(u,a);
        edge2[u].emplace_back(v,b);
        edge2[v].emplace_back(u,b);
    }
    dijkstra1();
    dijkstra2();
    ll mon=1e15;
    priority_queue<pair<ll,ll>> pq;
    REP(i,0,N){
        pq.push({mon-(d1[i]+d2[i]),i});
       // p(mon-(d1[i]+d2[i]));
    }
    p(pq.top().first);
    REP(i,1,N){
        auto now = pq.top();
        while(i-1>=now.second){
            pq.pop();
            now = pq.top();
        }
        p(now.first);

    }
    return 0;
}

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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void solve(){
	int n;
	cin>>n;
	if(n%1000==0){
		cout<<0<<endl;
	}
	else{
		cout<<1000-(n%1000)<<endl;
	}
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

string s, t;
int dp[3005][3005];

int solve(int i, int j)
{
  if(i == s.size() || j == t.size())
    return 0;
  int &ans = dp[i][j];
  if(ans != -1)
    return ans;
  ans = solve(i + 1, j);
  ans = max(ans, solve(i, j + 1));
  if(s[i] == t[j])
    ans = max(ans, solve(i + 1, j + 1) + 1);
  return ans;
}

void output(int i, int j)
{
    if(i == s.size() || j == t.size())
      return;
    int c1 = -1, c2 = -1, c3 = -1;
    c1 = solve(i + 1, j);
    c2 = solve(i, j + 1);
    if(s[i] == t[j])
      c3 = solve(i + 1, j + 1) + 1;
    if(c1 >= c2 && c1 >= c3)
      return output(i + 1, j);
    else if(c2 >= c1 && c2 >= c3)
      return output(i, j + 1);
    else
    {
      cout << s[i];
      return output(i + 1, j + 1);
    }
}

int main()
{
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> s >> t;
  memset(dp, -1, sizeof(dp));
  solve(0, 0);
  output(0, 0);
  return 0;
}


Measured memory_bytes: 35968
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
signed main()
{
	int n, a[200000], num = 1;
	scanf("%d", &n);
	for(int i = 0; i < n; scanf("%d", &a[i++]));
	for(int i = 0; i < n; ++i)
	{
		if(a[i] == num)
		{
			++num;
		}
	}
	printf("%d\n", num == 1 ? -1 : n - num + 1);
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define*/
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( i = a; i < b ; i++)
#define REP(i, n) for ( i = 0; i < n ; i++)
#define DER(i, n) for ( i = n; n ; i--)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1e9 + 7;

/* alias */
typedef long long ll;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}

/* main */
int i, j, k;

int main() {
	int n, k;
	char s[11];
	scanf("%d%s%d", &n, s, &k);
	REP(i, n) if (s[i] != s[k - 1])s[i] = '*';
	printf("%s", s);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define out(a) cout<<a<<" "
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
int main() {
    string s;
    int n,mod;
    mod=1000000007;
    cin >> s;
    n=s.size();
    vector<vector<int>> dp(100005,vector<int>(13));
    dp[0][0]=1;
    for (int i=1;i<=n;i++){
        if (s[i-1]=='?'){
            rep(j,13)rep(k,10){
                dp[i][(j*10+k)%13]+=dp[i-1][j];
                dp[i][(j*10+k)%13]%=mod;
            }
        }else{
            int num=s[i-1]-'0';
            rep(j,13){
                dp[i][(j*10+num)%13]+=dp[i-1][j];
                dp[i][(j*10+num)%13]%=mod;
            }
        }
    }
printf("%d\n",dp[n][5]);
return 0;
}

Measured memory_bytes: 8960
#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

S = input()

N = len(S)

List = []

for i in range(0,int(N/2)):
    List.append([S[0:i+1],S[i+1:2*i+2]])

del List[-1]

for a in List[::-1]:
    if a[0] == a[1]:
        print(2*len(a[0]))
        exit()



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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,a,b;
	cin>>n>>m;
	vector<int>v(n);
	for(int i=0;i<m;i++){
		cin>>a>>b;
		v.at(a-1)++;
		v.at(b-1)++;
	}
	for(int i=0;i<n;i++){
		cout<<v.at(i)<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

int n,m,r;
int q[100005],w[100005],z[100005];

int main(){
	scanf("%d%d",&n,&m);
	fore(i,0,n){
		int x;
		scanf("%d",&x);
		q[x]++;
		w[x%m]++;
	}
	fore(i,0,m){
		int j=(m-i)%m;
		if(i>j)break;
		if(i==j){
			r+=w[i]/2;
			z[i]=w[i]%2;
		}
		else {
			int k=min(w[i],w[j]);
			r+=k;z[i]=w[i]-k;z[j]=w[j]-k;
		}
	}
	fore(i,1,100005){
		int k=min(q[i],z[i%m])/2;
		r+=k;
		z[i%m]-=2*k;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] AB = Console.ReadLine().Split().Select(int.Parse).ToArray();
            string S = Console.ReadLine();
            string ans = "Yes";
            if (AB[0] + AB[1] + 1 == S.Length)
            {
                if (S[AB[0]] == '-')
                {
                    for (int i = 0; i < S.Length; i++)
                    {
                        if (AB[0] == i) { continue; }
                        switch (S[i])
                        {
                            case '0': break;
                            case '1': break;
                            case '2': break;
                            case '3': break;
                            case '4': break;
                            case '5': break;
                            case '6': break;
                            case '7': break;
                            case '8': break;
                            case '9': break;
                            default:ans = "No";
                                break;
                        }
                    }
                }
                else { ans = "No"; }
            }
            else { ans = "No"; }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
import math


def is_prime(n: int)-> bool:
    if n == 2:
        return True
    if n < 2 or n % 2 == 0:
        return False

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


def main():
    num = int(input())
    count_prime = 0
    for i in range(num):
        if is_prime(int(input())):
            count_prime += 1
    print(count_prime)
    return

main()


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n, k;cin >> n >> k;
    int ans = k;
    for(int i=1;i<n;i++){
        ans *= k-1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from bisect import bisect

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

f = S[0]

for i in range(N):
  if K == 0:
    break
  if S[i] != f:
    S[i] = f
    for j in range(i+1,N):
      if S[j] == f:
        break
      S[j] = f
    K -= 1
    
i = 0
res = 0

while i < N-1:
  f = S[i]
  for j in range(i+1,N):
    if S[j] != f:
      break
  else:
    res += 1
  res += j-i-1
  i = j
    
print(res)

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

int main(){
    ll H,W;cin >> H >> W;
    ll evenH;ll oddH;
    if (H == 1 || W == 1){
        cout << 1 << endl;
        return 0;
    }
    if (H % 2 == 0){
        evenH = (H / 2);
        oddH = (H / 2);
    }
    else {
        evenH = (H / 2);
        oddH = (H / 2) + 1;
    }
    ll sum;

    if (W % 2 == 0){
        sum = (oddH * (W / 2)) + (evenH * (W / 2));
    }
    else {
        sum = (oddH * ((W / 2) + 1)) + (evenH * (W / 2));
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        String sout = "";
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if ('a' <= c && c <= 'z') {
//                c = Character.toUpperCase(c);
                c = (char)(c - 'a' + 'A');
            } else if ('A' <= c && c <= 'Z') {
//                c = Character.toLowerCase(c);
                c = (char)(c - 'A' + 'a');
            } else {
                // nop
            }
            sout = sout + c;
        }
        System.out.println(sout);
    }
}


Measured memory_bytes: 31080
from collections import deque


def bfs(sy, sx, gy, gx):
    # yが下方向，xが右方向
    d = [[float("inf")] * w for _ in range(h)]

    dy = [0, 1, 0, -1]
    dx = [1, 0, -1, 0]

    que = deque([])
    que.append((sy, sx))
    d[sy][sx] = 0

    while que:

        p = que.popleft()

        if p[0] == gy and p[1] == gx:
            break

        for i in range(4):
            ny = p[0] + dy[i]
            nx = p[1] + dx[i]

            if 0 <= ny < h and 0 <= nx < w and maze[ny][nx] != "#" and d[ny][nx] == float("inf"):
                que.append((ny, nx))
                d[ny][nx] = d[p[0]][p[1]] + 1

    if d[gy][gx] == float("inf"):
        return -1
    else:
        return d[gy][gx]


h, w = map(int, input().split())
maze = [list(input()) for _ in range(h)]

res = 0
for y in range(h):
    for x in range(w):
        if maze[y][x] == '#':
            res += 1

dis = bfs(0, 0, h - 1, w - 1)

if dis == -1:
    print(-1)
else:
    print(h * w - res - dis - 1)

Measured memory_bytes: 9504
#include <stdio.h>
#include <string.h>

int main()
{
	char A[20], B[20], C[20];

	scanf("%s %s %s", A, B, C);

	int la = strlen(A), lb = strlen(B);

	if (A[la - 1] == B[0] && B[lb - 1] == C[0])
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        a[i] = a[i] - (i + 1);
    }
    sort(a.begin(), a.end());
    int b1 = a[n / 2];
    int b2  = a[(n - 1) / 2];
    ll tmp1 = 0, tmp2 = 0;
    rep(i,n){
        tmp1 += abs(a[i] - b1);
        tmp2 += abs(a[i] - b2);
    }
    cout << min(tmp1, tmp2) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include"bits/stdc++.h"
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }

lint N;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	int a = N % 10;
	if (a == 3) {
		cout << "bon";
	}
	else if (a == 0 || a == 1 || a == 6 || a == 8) {
		cout << "pon";
	}
	else {
		cout << "hon";
	}
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main(){
  ll a,b,c,d,e,f,g;
  cin>>a>>b>>c>>d>>e>>f>>g;

  ll ans=2*(a/2+d/2+e/2)+b;
  if(a&&d&&e)
    ans = max(ans,(ll)2*((a-1)/2+(d-1)/2+(e-1)/2)+3+b);

  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt() - 1;
        String S = sc.next();

        System.out.println(S.substring(0, K) + S.substring(K, K + 1).toLowerCase() + S.substring(K + 1));
    }
}

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

int digit(int i) {
    int tmp = 0;
    while(i != 0) {
        tmp += (i % 10);
        i /= 10;
    }
    return tmp;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int sum = 0, tmp;
    for (int i = 1; i <= n; i++) {
        tmp = digit(i);
        if(tmp >= a && tmp <= b) sum += i;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
int a[3],b[4];

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  while(true){
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[2]>=a[0]+a[1])break;
    b[0]++;
    int rec=a[2]*a[2]-a[1]*a[1]-a[0]*a[0];
    if(rec==0)b[1]++;
    if(rec>0)b[3]++;
    if(rec<0)b[2]++;
  }
  REP(i,4){
    cout<<b[i]<<" \n"[i==3];
  }
  return 0;
}



Measured memory_bytes: 3224
#include <cstdio>
#include <cmath>
using namespace std;
int N, M, s[10], c[10];
int main() {
  scanf("%d %d", &N, &M);
  for(int i = 1; i <= M; ++i) scanf("%d %d", &s[i], &c[i]);
  int st = N>1?pow(10, N-1):0, ans = -1;
  for(int i = st; i <= pow(10, N)-1; ++i) {
    int num[3] = {i/100, (i%100)/10, (i%10)/1}, cnt = 0;
    for(int j = 1; j <= M; ++j) {
      if(num[s[j]-N+2] == c[j]) ++cnt;
    }
    if(cnt != M) continue;
    ans = i;
    break;
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int main()
{
   int N;
   scanf("%d",&N);
   int S[1000];
   int C[1000];
   int F[1000];
   int n;
   for(n=1;n<N;n++)
   {
       scanf("%d %d %d",&C[n],&S[n],&F[n]);
   }
   int T[1000];
   for(n=1;n<N;n++)
   {
       int t=0;
       int cal;
       for(cal=n;cal<N;cal++)
       {
           if(t<S[cal])
            t=S[cal];
           while(t%F[cal]!=0)
           {
               t++;
           }
           t+=C[cal];
       }
       T[n]=t;
   }
   for(n=1;n<N;n++)
   {
       printf("%d\n",T[n]);
   }
   int z=0;
   printf("%d",z);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

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



const int MAX = 300000;
const long long MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    COMinit();
    ll n, m, k;
    cin >> n >> m >> k;
    ll c = COM(n * m - 2, k - 2);
    ll retx = 0;
    repi(d, 1, n) {
        retx += d * (n - d) * m * m;
        retx %= MOD;
    }
    ll rety = 0;
    repi(d, 1, m) {
        rety += d * (m - d) * n * n;
        rety %= MOD;
    }
    ll ret = retx + rety;
    ret *= c;
    ret %= MOD;
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int K;
  cin >> K;
  ll ans[100000] = {0};
  queue<ll> q;
  for (int i = 1; i < 10; i++) {
    q.push(i);
  }
  for (int i = 0; i < 100000; i++) {
    ans[i] = q.front();
    if (ans[i] % 10 != 0) q.push(10 * ans[i] + (ans[i] % 10) - 1);
    q.push(10 * ans[i] + (ans[i] % 10));
    if (ans[i] % 10 != 9) q.push(10 * ans[i] + (ans[i] % 10) + 1);
    q.pop();
  }
  cout << ans[K - 1] << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main() {
	string s;
	cin >> s;
	vector<long long int> dp1(s.size(), 0), dp2(s.size(), 0);
	const long long int div = 1000000007;
	dp1[0] = 1;
	dp2[0] = 2;
	for (int i = 1; i < s.size(); i++) {
		dp1[i] = (dp1[i - 1] * 3) % div;
		if (s[i] == '1') {
			dp2[i] = (2 * dp2[i - 1]) % div;
			dp1[i] = (dp1[i] + dp2[i - 1]) % div;
		} else {
			dp2[i] = dp2[i - 1];
		}
	}
	cout << (dp1[s.size() - 1] + dp2[s.size() - 1]) % div << endl;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

map<li, li> st[2];
vector<PI> m[2];

int main() {
    li n;
    cin >> n;
    rin{
        li x;
        cin >> x;
        st[i % 2][x]++;
    }

    rep(i, 2) {
        foreach (it, st[i]) {
            m[i].pb({it->second, it->first});
        }
        sort(allof(m[i]));
        reverse(allof(m[i]));
    }

    if (m[0][0].S != m[1][0].S) {
        cout << n - m[0][0].F - m[1][0].F << endl;
        return 0;
    }
    li res1 = n - m[0][0].F - (sz(m[1]) > 1 ? m[1][1].F : 0);
    li res2 = n - m[1][0].F - (sz(m[0]) > 1 ? m[0][1].F : 0);
    cout << min(res1, res2) << endl;

    return 0;
}

Measured memory_bytes: 8824
S = [int(x) if x != "?" else -1 for x in input()]
g = 10 ** 9 + 7
x = 1
DP = [[0] * 13 for _ in range(2)]
DP[0][0] = 1
for i in range(len(S)):
    for j in range(13):
        DP[1][j] = DP[0][j] % g
        DP[0][j] = 0
    for j in range(13):
        if S[i] == -1:
            s = (j*10)%13
            e = (s+10)%13
        else:
            s = (j*10+S[i])%13
            e = (s+1)%13
        DP[0][s] += DP[1][j]
        if s > e:
            DP[0][0] += DP[1][j]
        DP[0][e] -= DP[1][j]
    w = 0
    for j in range(13):
        w += DP[0][j]
        DP[0][j] = w

print(DP[0][5] % g)


Measured memory_bytes: 4092
A = list(input())
B = list(input())
C = list(input())
now = A[0]
while True:
    if now == 'a':
        if len(A) == 0:
            print("A")
            break
        now = A.pop(0)
    if now == 'b':
        if len (B) == 0:
            print("B")
            break
        now = B.pop(0)
    if now == 'c':
        if len (C) == 0:
            print("C")
            break
        now = C.pop(0)



Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
  int  top;
  int in[100];
  int i = 0;
  int out[100];
  int j = 0;
  int c;

  while((scanf("%d", &in[i])) != EOF)
    {
      if(in[i] != 0){
       	top = in[i];
	i++;
      }else{
	out[j] = top;
	j++;
	c = j;
	i--;
	top = in[i-1];	
      }
      if(i > 100) break;
    }

  for(j = 0; j < c; j++)
    printf("%d\n", out[j]);

return 0;

}
    

Measured memory_bytes: 600
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
b = a[0]
for i in a[1:]:
    b ^= i
ans = []
for i in a:
    ans.append(b^i)
print(*ans)

Measured memory_bytes: 108724
$<.map{|i|a=i.chop.split(?,).map(&:to_i).sort;b=a.uniq.map{|j|a.count(j)}.sort.reverse;s,c=b.size,b.max;puts c>3?"four card":c>2?s>2?"three card":"full house":c>1?s>3?"one pair":"two pair":a[4]-a[0]<5||a[1]>9?:straight: :null}

Measured memory_bytes: 8576
class henkan:

    def __init__(self, a):

        if(a.islower()):
            henkan.upper1(a)
        else:
            henkan.lower1(a)
    
    def upper1(a):
        print("a")
    
    def lower1(a):
        print("A")



a = input()
henkan(a)



Measured memory_bytes: 9004
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert
#define aer(v) (v).erase((v).begin(),(v).end()) 

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int n,m,ans;

main(){
	cin>>n>>m;
	int a[m+1]={};
	rep(i,n){
		int k;
		cin>>k;
		rep(j,k){
			int t;
			cin>>t;
			a[t]++;
		}
	}
	rep(i,m+1){
		if(a[i]==n)ans++;
	}
	dans;
}






Measured memory_bytes: 256
while(True):
    N=int(input())
    if N==0:
        quit()
    W,H=map(int,input().split())
    d=[[0]*W for i in range(H)]
    for i in range(N):
        x,y=map(int,input().split())
        d[y-1][x-1]=1

    dp=[[0]*(W+1) for i in range(H+1)]
    for i in range(H):
        for j in range(W):
            dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j]-dp[i][j]+d[i][j]
    ans=0
    S,T=map(int,input().split())
    for i in range(H):
        for j in range(W):
            if i+T>H or j+S>W:
                continue
            a=dp[T+i][S+j]-dp[i][S+j]-dp[T+i][j]+dp[i][j]
            ans=max(a,ans)
    print(ans)



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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

typedef pair<double, double> pd;
typedef vector<pd> vpd;


#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> t chmax(t&a,u b){if(a<b)a=b; return a;};
template<class t, class u> t chmin(t&a,u b){if(a>b)a=b; return a;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string X;
  IN(X);

  ll S_count=0;
  ll ans=0;

  REP(i,X.size()){
    if(X[i]=='S'){
      S_count++;
    }else{
      if(S_count>0){
        S_count--;
      }else{
        ans++;
      }
    }
  }

  OUT(2*ans);

  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<sstream>

using namespace std;

#define open  freopen("input.txt","r",stdin)
#define close  freopen ("output.txt","w",stdout)
#define db double
#define ll long long
#define llu unsigned long long
#define loop(i,a,n) for(int i=a;i<=n;i++)
#define sf scanf
#define sf1(a) sf("%d",&a)
#define sf2(a,b) sf("%d %d",&a,&b)
#define sf3(a,b,c) sf("%d %d %d",&a,&b,&c)
#define sf4(a,b,c,d) sf("%d %d %d %d",&a,&b,&c,&d)
#define sfd(a) sf("%lf",&a)
#define sfd2(a,b) sf("%lf %lf",&a,&b)
#define sfl1(a) sf("%lld",&a)
#define sfl2(a,b) sf("%lld %lld",&a,&b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pf printf
#define pfi(x) pf("%d",x)
#define pfl(x) pf("%lld",x)
#define NL puts("")
#define bug pf("here is bug\n")
#define pft(tc) printf("Case %d:",tc++)
#define PI (2.0*acos(0.0))
//#define PI acos(-1.0)
#define mem(a,v) memset(a,v,sizeof a)
#define endl '\n'
#define pb push_back
#define xx first
#define yy second
#define mp make_pair
#define all(a) a.begin(),a.end()


template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a,T b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
template <class T> inline T lcm(T a,T b)
{
    return (a/gcd(a,b))*b;
}
template <class T> inline T modinverse(T a,T M)
{
    return bigmod(a,M-2,M);
}   // M is prime}
template <class T> inline T bpow(T p,T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}




//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={0,1,0,-1};int dy[]={1,0,-1,0}; //4 Direction

#define linf 3000000000000000000ll
#define inf 999999999
#define MX 1000006
#define mod (ll) 1000000007
#define eps 1e-6
#define ub upper_bound // return the right most index of x<val
#define lb lower_bound // return the right most index of x<=val



struct data
{
    int ele1,ele2,ele3;
    data() {}
    data(int a,int b,int c)
    {
        ele1=a,ele2=b,ele3=c;
    }
    bool friend operator<(data a,data b)
    {
        return  a.ele1> b.ele1;// sort decreasingly but increasingly for priority_queue
    }
};


int n,m,k;
ll N,M,K;


int main()
{
    int t,tc=1;
	int a,b,c;
	sf3(a,b,c);
	if(b-a==c-b) pf("YES\n");
	else pf("NO\n");

    return 0;
}

/*




*/


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

using namespace std;

int n,m;
int a[9];
int costs[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
vector<int> cost;
int dp[10001];


int main(){
  cin >> n >> m;
  for(int i = 0 ; i < m ; i++){
    cin >> a[i];
  }

  dp[0] = 0;
  for(int i = 1 ; i <= n; i++){
      dp[i] = -1;
  }

  sort(a, a+m, greater<int>() );

  for(int j = 0; j < m; j++){
    for(int i = costs[a[j]-1] ; i <= n; i++){
        dp[i] = max(dp[i] , dp[i - costs[a[j]-1]] + 1);
    }
  }
  while(n > 0){
    for(int i = 0; i < m ; i++){
      if(dp[n] == dp[n - costs[a[i]-1]] + 1 && n >= costs[a[i]-1]){
        cout << a[i];
        n -= costs[a[i]-1];
        break;
      }
    }
  }
  cout << endl;
}


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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

#define DIV 2019 

vector<vector<int>> mul10_mod(DIV, vector<int>(9, -1));

int get_mul10_mod(int x, int y){
  if (mul10_mod[x][y-1] == -1) {
    mul10_mod[x][y-1] = (x * 10 + y) % DIV;
  }

  return mul10_mod[x][y-1];
}

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  string S;
  READ(S);

  // main procedure
  size_t len_S = S.size();
  
  vector<int> digits_vec(len_S);
  for (size_t i = 0; i < len_S; ++i) {
    digits_vec[i] = S[i] - '0';
  }

  ll ans = 0;

  vector<ll> mod_count_vec(DIV, 0);
  for (size_t i = 0; i < len_S; ++i) {
    vector<ll> tmp_vec = mod_count_vec;
    mod_count_vec = vector<ll>(DIV, 0);

    for (size_t j = 0; j < DIV; ++j) {
      mod_count_vec[get_mul10_mod(j, digits_vec[i])] += tmp_vec[j];
    }
    mod_count_vec[digits_vec[i]]++;

    ans += mod_count_vec[0];
  }
  
  // output
  WRITE_N(ans);

  return 0;
}


Measured memory_bytes: 4476
#include <iostream>
#include <iomanip>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
#include <bitset>

#define ll long long
const ll MOD = 1e9 + 7;
const ll INF = 1 << 29;

template <typename T>
class UnionFindTree
{
public:
    UnionFindTree(T size = 0)
    {
        if (size == 0)
            return;

        unitedSize.resize(size + 1, 1);
        rank.resize(size + 1, 0);
        parents.resize(size + 1);
        for (T i=0; i<size; ++i)
            parents[i] = i;
    }

    bool Union(T x, T y)
    {
        x = FindRoot(x);
        y = FindRoot(y);
        if (x == y)
            return false;

        if (rank[x] < rank[y])
        {
            parents[x] = y;
            unitedSize[y] += unitedSize[x];
            if (rank[y] == rank[x])
                rank[y]++;
        }
        else
        {
            parents[y] = x;
            unitedSize[x] += unitedSize[y];
            if (rank[x] == rank[y])
                rank[x]++;
        }

        return true;
    }

    T FindRoot(T x)
    {
        if (parents[x] == x)
            return x;

        while (parents[x] != x)
        {
            T parent = parents[x];
            parents[x] = parents[parent];
            x = parents[x];
        }

        return x;
    }

    bool IsUnited(T a, T b)
    {
        return FindRoot(a) == FindRoot(b);
    }

private:
    std::vector<T> parents;
    std::vector<T> rank;
    std::vector<T> unitedSize;
};

class Edge
{
public:
    Edge(ll from, ll to, ll weight)
    {
        From = from;
        To = to;
        Weight = weight;
    }

    ll From;
    ll To;
    ll Weight;
};

ll MSTWeight(int nodeNum, std::vector<Edge>& edgeList)
{
    UnionFindTree<int> vertexTree(nodeNum);

    std::sort(edgeList.begin(), edgeList.end(), [](Edge& lhs, Edge& rhs) {
        return lhs.Weight < rhs.Weight;
    });
    ll result = 0;
    for (auto& edge : edgeList)
    {
        if (!vertexTree.IsUnited(edge.From, edge.To) || edge.Weight < 0)
        {
            vertexTree.Union(edge.From, edge.To);
            result += edge.Weight;
        }
    }

    return result;
}

int main()
{
    ll N;
    std::cin >> N;
    std::vector<std::pair<ll, ll>> Xs(N, std::pair<ll, ll>(0, 0));
    std::vector<std::pair<ll, ll>> Ys(N, std::pair<ll, ll>(0, 0));
    for (auto i=0; i<N; ++i)
    {
        ll x, y;
        std::cin >> x >> y;

        Xs[i].first = x;
        Xs[i].second = i;
        Ys[i].first = y;
        Ys[i].second = i;
    }

    std::sort(Xs.begin(), Xs.end());
    std::sort(Ys.begin(), Ys.end());

    std::vector<Edge> edges;
    for (auto i=0; i<N-1; ++i)
    {
        edges.emplace_back(Edge(Xs[i].second, Xs[i+1].second, std::abs(Xs[i].first - Xs[i+1].first)));
        edges.emplace_back(Edge(Ys[i].second, Ys[i+1].second, std::abs(Ys[i].first - Ys[i+1].first)));
    }

    std::cout << MSTWeight(N, edges) << std::endl;
}


Measured memory_bytes: 12704
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int ans=0,w=1;
	char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans*w;
}
const int N=2005,Maxn=2000*2000+1e5+5,mod=1e9+7;
int n,k,f[N][N],fac[Maxn],ifac[Maxn];
inline int C(int n,int m){return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
int main(){
	n=read(),k=read(),ifac[0]=fac[0]=fac[1]=ifac[1]=1;
	if(k==1)return puts("1"),0;
	for(int i=2;i<=Maxn-5;++i)fac[i]=1ll*fac[i-1]*i%mod,ifac[i]=1ll*(mod-mod/i)*ifac[mod%i]%mod;
	for(int i=2;i<=Maxn-5;++i)ifac[i]=1ll*ifac[i]*ifac[i-1]%mod;
	f[1][0]=1;
	for(int i=1;i<=n;++i)
		for(int j=0;j<=i;++j){
			if(i^j)(f[i][j+1]+=f[i][j]%=mod);
			if(i^n)(f[i+1][j]+=1ll*f[i][j]*C((k-2)+(i*(k-1)+j),k-2)%mod)%=mod;
		}
	cout<<1ll*f[n][n]*fac[n]%mod;
	return 0;
}

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

int main()
{
    int num=10;
    int test[num];
    
    for(int i=0; i<10; i++)
    {
        cin>>test[i];
    }
    for(int s=0; s<9; s++)
    {
        for (int t=s+1; t<10; t++)
        {
            if(test[s]<test[t])
            {
                int a=test[t];
                test[t]=test[s];
                test[s]=a;
            }
        }
    }
   
        cout<< test[0] <<endl<< test[1] <<endl<< test[2]<<endl;
    
    return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

typedef long long ll;
const ll N = 2e5 + 10;
int f[N][2019];
ll a[2019], b[2019];
string s;
ll n;

int main() {
	cin >> s;
	n = s.size();

	ll t = s[0] - '0';
	ll x;
	//f[0][t % 2019] = 1;
	a[t] = 1;

	ll res = 0;
	for (ll i = 1; i < n; i++) {
		for (int j = 0; j < 2019; j++) b[j] = a[j];
		memset(a, 0, sizeof a);

		t = s[i] - '0';
		//cout << t << endl;
		//f[i][t % 2019]++;
		a[t % 2019]++;

		/*
		if (f[i - 1][0]) {
			f[i][t] += f[i - 1][0];
		}
		*/
		if (b[0]) {
			a[t] += b[0];
		}
		for (ll j = 1; j < 2019; j++) {
			x = j * 10 + t;
			//f[i][x % 2019] =f[i - 1][j];
			a[x % 2019] = b[j];
		}

		res += a[0];
	}
	/*
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 2019; j++) {
			if (f[i][j] != 0)
				cout << i << " " << j << " " << f[i][j] << endl;
		}
	}

	ll res = 0;
	for (ll i = 0; i < n; i++) {
		res += f[i][0];
	}
	*/
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3748
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)5e5 + 7;
const ld eps = 1e-13;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

int  n, k;
int a[N];
int main() {
	#ifdef wws
		freopen ("in.txt", "r", stdin);
	#endif
	Kazakhstan
	cin >> n >> k;
	rep(i, 1, n) {
		cin >> a[i];
	}
	rep(i, k + 1, n) {
		if (a[i] > a[i - k]) cout  << "Yes\n";
		else cout << "No\n";
	}
	ioi
}


Measured memory_bytes: 4388
# -*- coding: utf-8 -*-

import math
import fractions


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


if __name__ == '__main__':
    N, M = map(int, input().split(' '))
    S = input()
    T = input()

    L = lcm(N, M)

    S_index_X = [int(i * L / N) for i in range(N)]
    T_index_X = [int(i * L / M) for i in range(M)]

    common_index = set(S_index_X).intersection(set(T_index_X))
    for i in common_index:
        si = int(i * N / L)
        ti = int(i * M / L)
        if S[si] != T[ti]:
            print(-1)
            exit(0)
    print(L)


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

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>

int tc;
int a1[2500000];
int a2[2500000];

int cmpfunc (const void * a, const void * b) {
   return ( *(int*)a - *(int*)b );
}

int main(){
	scanf("%d", &tc);
	for(int i=0; i<tc; i++){
		scanf("%d %d", &a1[i], &a2[i]);
	}	
	long long jumlah = 0;
	
	qsort(a1, tc, sizeof(int), cmpfunc);
	qsort(a2, tc, sizeof(int), cmpfunc);
	
	if(tc % 2 == 1) printf("%lld\n",a2[tc/2]-a1[tc/2]+1);

	else{
		printf("%lld\n",a2[tc/2]+a2[tc/2-1]-a1[tc/2]-a1[tc/2-1]+1);
	}
	
	return 0;
}

Measured memory_bytes: 4024