akhauriyash/Code-Regression huggingface dataset:
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	c = S()
	if c in ['a','i','u','e','o']:
		print('vowel')
	else:
		print('consonant')

if __name__ == '__main__':
    main()

Measured memory_bytes: 27156
n, m = map(int, raw_input().split())
xl = map(int, raw_input().split())
yl = map(int, raw_input().split())

def listsum(l):
    ret = 0
    n = len(l)
    for k, v in enumerate(l):
        ret += k * v
        ret -= (n - k - 1) * v
    return ret

ans = listsum(xl) * listsum(yl)
ans %= (10 ** 9 + 7)
print ans


Measured memory_bytes: 14492
from fractions import gcd
import math

def prime(x):
  if x==2:
    return True
  else:
      for j in range(2,math.ceil(math.sqrt(x))+1):
        if x%j==0:
          return False
          break
        else:
          pass
      else:
        return True
  
a,b = map(int,input().split())
ab = gcd(a,b)
lis = []
for i in range(1,math.ceil(math.sqrt(ab))+1):
  if ab%i==0:
    if prime(i) and i not in lis:
      lis.append(i)
    if prime(ab//i) and ab//i not in lis:
      lis.append(ab//i)
print(len(lis))
    

Measured memory_bytes: 67176
///
// File:  a.cpp
// Author: ymiyamoto
//
// Created on Thu Sep 28 01:31:36 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  uint32_t a, b, c;
  cin >> a >> b >> c;

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

  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
n = int(input())
a = list(map(int, input().split()))

for i in a:
    if i % 2 == 0:
        if i % 3 == 0 or i % 5 == 0:
            continue
        else:
            break
    else:
        continue
else:
    print('APPROVED')
    exit()

print('DENIED')

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

using namespace std;

int f(int x, int y, int z)
{
    return (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
}

int main()
{
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++)
        arr[i] = 0;
    for (int x = 1; (x * x) <= n; x++)
    {
        for (int y = 1; ((x * x) + (y * y) + (x * y)) <= n; y++)
        {
            for (int z = 1; f(x, y, z) <= n; z++)
            {
                int result = f(x, y, z);
                if (result <= n)
                    arr[result - 1]++;
            }
        }
    }
    for (int i = 0; i < n; i++)
        cout << arr[i] << endl;
    return 0;
}


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

int main(){
  string s; cin>>s;
  if(s.size()==1){
    cout<<1<<endl;
  }int ans=1,cut=1,i=1;
  string now=s.substr(0,1);
  while(i+cut-1<s.size()){
    if(now==s.substr(i,cut)){
      cut++;
    }else{
      now=s.substr(i,cut);
      i+=cut;
      cut=1; ans++;
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;

#define PB push_back
#define SZ(a) (int)a.size()
#define MP make_pair

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;

int step[] = {0,1,3,6,10,15,21,28,36,45,55,66};

int main() {

	vector<bool> arr(1000001, false);
	VI prim;

	prim.push_back(2);

	for(int i = 3; i * i < 1000000; i+=2) {
		if(arr[i]) continue;
		prim.push_back(i);
		for(int j = 3*i; j < 1000000; j += 2*i) {
			arr[j] = true;
		}
	}

	for(int i = 1001; i < 1000000; i+=2) {
		if(!arr[i]) {
			prim.push_back(i);
		}
	}

	ll N;
	scanf("%lld", &N);

	int ans = 0;

	for(int p : prim) {
		if (p > N) break;
		int k = 0;
		while(N%p == 0) {
			N /= p;
			k++;
		}
		int i = 0;
		while(step[i] <= k) i++;
		ans += i-1;
	}

	if(N > 1) ans++;

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

	return 0;
}


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

int main(void){

    int A, B, C, K;

    scanf("%d%d%d%d", &A, &B, &C, &K);

    int max;

    if(A >= B && A >= C){
        max = A;
    }else if(B >= A && B >= C){
        max = B;
    }else{
        max = C;
    }

    int k = max;

    for(int i = 0; i < K; i++){
        max *= 2;
    }

    printf("%d\n", A + B + C - k + max);

    return 0;
}

Measured memory_bytes: 1732
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
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 T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
//

set<string> st;
// i -> N の間にxがあるか
int ok[30303][10];

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

  int N;
  string s;
  cin >> N >> s;

  for (int i = 0; i <= N; i++) {
    for (int j = 0; j < 10; j++) {
      ok[i][j] = -1;
    }
  }
  for (int i = N - 1; 0 <= i; i--) {
    int num = s[i] - '0';
    for (int j = 0; j < 10; j++) {
      ok[i][j] = ok[i + 1][j];
    }
    ok[i][num] = i;
  }

  for (int i = 0; i + 2 < N; i++) {
    for (int j = 0; j < 10; j++) {
      if (ok[i + 1][j] == -1) continue;

      for (int k = 0; k < 10; k++) {
        int id = ok[i + 1][j];
        if (ok[id + 1][k] == -1) continue;
        string c = "";
        c += s[i];
        c += to_string(j);
        c += to_string(k);
        // cout << c << endl;
        st.insert(c);
      }
    }
  }

  cout << st.size() << endl;

  return 0;
}

Measured memory_bytes: 1536
#入力
n,m,r=map(int,input().split())
abc=[list(map(int,input().split())) for _ in [0]*m]
#グラフ
g=[[] for _ in [0]*n]
[g[a-1].append([b-1,c]) for a,b,c in abc]
#逆辺
g2=[[] for _ in [0]*n]
[g2[b-1].append([a-1,c]) for a,b,c in abc]

#ベルマンフォード
dist=[-10**15 for _ in [0]*n]
dist[0]=0
a,b=-10**15,-10**15

for k in range(n):
    for p in range(n):
        for i,j in g[p]:
            dist[i]=max(dist[i],dist[p]+j-r)
    if k==n-2:
        d1=[t for t in dist]
    if k==n-1:
        d2=[t for t in dist]
    
#負の経路上の頂点の一覧
loop=set()
for i in range(n):
    if d1[i]!=d2[i]:
        loop.add(i)    
ans=max(d2[n-1],0)

#1からの到達可能地点
q=[0]
memo=[True for _ in range(n)]
memo[0]=False
while q:
    qq=q.pop()
    for i,j in g[qq]:
        if memo[i]:
            q.append(i)
            memo[i]=False
            
#nからの逆辺による到達可能地点
q=[n-1]
memo2=[True for _ in range(n)]
memo2[n-1]=False
while q:
    qq=q.pop()
    for i,j in g2[qq]:
        if memo2[i]:
            q.append(i)
            memo2[i]=False
            
#1からでもnからでも行ける点でかつ負の閉路に入っているものがあるときは-1
for i in loop:
    if memo[i]==False and memo2[i]==False:
        ans=-1
        
print(ans)

Measured memory_bytes: 58072
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

/*
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()
*/

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.14159265358979323846;

void solve() {
    string s;
    cin >> s;
    bool ans = true;
    if(s[0] != 'A') ans = false;
    ll idxc = 0;
    ll cntc = 0;
    for(ll i = 2; i < s.size() - 1; i++) {
        if(s[i] == 'C') {
            idxc = i;
            cntc++;
        }
    }
    if(!(idxc != 0 && cntc == 1)) ans = false;
    for(ll i = 1; i < s.size(); i++) {
        if(i == idxc) continue;
        if(!('a' <= s[i] && s[i] <= 'z')) ans = false;
    }
    cout << (ans ? "AC" : "WA") << endl;
    return;
}

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


Measured memory_bytes: 256
N,M = map(int,input().split())
L = []
for _ in range(M):
    a,b = map(int,input().split())
    L.append([a,b])
L = sorted(L,key = lambda x:x[1])
cnt = 0
while len(L):
    now = L.pop(0)
    cnt += 1
    while len(L):
        if L[0][0] <= now[1] - 0.5 and now[1] - 0.5  <= L[0][1]:
            L.pop(0)
        else:
            break
print(cnt)





Measured memory_bytes: 22104
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define LL long long
using namespace std;
const int N=1e5+10; 
int n,head,tail,tmp,dis[N],q[N*50];
bool f[N];
void work()
{
	for(int i=1;i<n;i++)dis[i]=i;dis[0]=n;
	tail=n;for(int i=1;i<=n;i++)q[i]=i-1,f[i-1]=true;
	while(head!=tail)
	{
		int x=q[++head];
		for(int i=0;i<=9;i++)
		{
			tmp=(x*10+i)%n;
			if(dis[x]+i<dis[tmp])
			{
				dis[tmp]=dis[x]+i;
				if(!f[tmp])f[tmp]=true,q[++tail]=tmp;
			}
			f[x]=false;
		}
	}
}
int main()
{
	scanf("%d",&n);work();printf("%d",dis[0]);
	return 0;
}

Measured memory_bytes: 4608
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int a,b;
    while(scanf("%d%d",&a,&b),a||b){
        if(a<b)swap(a,b);
        int cnt=0;
        while(b){
            cnt++;
            a%=b;
            swap(a,b);
        }
        printf("%d %d\n",a,cnt);
    }
    return 0;
}

Measured memory_bytes: 1028
import java.util.Scanner;

public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);

for(int j=0;;j++){
int h = sc.nextInt();
int w = sc.nextInt();

if(h==0&&w==0){
    break;
}

for(int i=0;i<h;i++){
    for(int k=0;k<w;k++){
        if(i%2==0){
            if(k%2==0){
                System.out.printf("#");
            }else{
                System.out. printf(".");
            }
        }else{
            if(k%2==0){
                System.out. printf(".");
            }else{
                System.out. printf("#");
            }

        }
    }
    System.out. printf("\n");
}
System.out. printf("\n");

}

sc.close();

}

}


Measured memory_bytes: 59284
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const ll MOD=1e9+7;
#define MAX 1000000

const ll mod=1e9+7;
inline int read()
{
    int x=0,t=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')t=-1,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
    return x*t;
}
int n,m;
bool zs[MAX+1000];
int pri[MAX+1000],tot,mu[MAX+1000],smu[MAX+1000];
long long ans;
void pre()
{
    zs[1]=true;mu[1]=1;
    for(int i=2;i<=MAX;++i)
    {
        if(!zs[i])pri[++tot]=i,mu[i]=-1;
        for(int j=1;j<=tot&&i*pri[j]<=MAX;++j)
        {
            zs[i*pri[j]]=true;
            if(i%pri[j]==0){mu[i*pri[j]]=0;break;}
            else mu[i*pri[j]]=-mu[i];
        }
    }
    for(int i=1;i<=MAX;++i)smu[i]=(smu[i-1]+mu[i])%MOD;
}
ll ad(ll a,ll b)
{
	return (((a%mod+b%mod)%mod)+mod)%mod;
}
ll ap(ll a,ll b)
{
	return ((a%mod)*(b%mod))%mod;
}
ll ksm(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b%2==1)
		res=ap(res,a);
		a=ap(a,a);
		b/=2;
	}
	//cout<<res<<endl;
	return res;
}
int kk;
int Solve(int a)
{
    int i=1,j;
    long long ret=0;
    //cout<<a<<endl;
    while(i<=a)
    {
        j=a/(a/i);
      //  cout<<j<<" "<<i<<" "<<smu[j]-smu[i-1]<<" "<<ksm(a/i,kk)<<" "<<kk<<" "<<a<<" "<<i<<" "<<(a/i)<<" ";
        ret+=1ll*(smu[j]-smu[i-1]+MOD)%MOD*ksm((ll)(a/1ll/i),kk)%MOD;
       // cout<<ksm((ll)(a/i),kk)%MOD<<endl;
        ret%=MOD;
        i=j+1;
    }
    return (ret+MOD)%MOD;
}
int main()
{
    kk=read();n=read();
    int i=1,j;
    pre();
   // cout<<Solve(2)<<"!"<<endl;
    while(i<=n)
    {
        j=n/(n/i);
     //   cout<<i<<"?"<<endl;
        int tt=1ll*(i+j)*(j-i+1)/2%MOD;
        ans+=1ll*tt*Solve(n/i);
        ans%=MOD;
        i=j+1;
    }
    printf("%lld\n",(ans+MOD)%MOD);
    return 0;
}


Measured memory_bytes: 12876
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
vector<pair<int, int>> to[100010];
bool visited[100010];
ll dist[100010];

int main() {
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx-sx;
    int dy = ty-sy;
    
    cout << string(dy,'U') << string(dx,'R');
    cout << string(dy,'D') << string(dx,'L');
    cout << 'L' << string(dy+1,'U') << string(dx+1,'R') << 'D';
    cout << 'R' << string(dy+1,'D') << string(dx+1,'L') << 'U' << endl;
    
   return 0;
}


Measured memory_bytes: 6004
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,p,even=0,odd=0;
  cin >> n >> p;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i]%2==0){
			even++;
		}else{
			odd++;
		}
	}
	long long x=1;
	for(int i=0;i<n;i++){
		x*=2;
	}
	if(odd==0){
		if(p==1){
			cout << 0 << endl;
		}else if(p==0){
			cout << x << endl;
		}
	}else{
		cout << x/2 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
c = [[int(i) for i in input().split()] for _ in range(10)]
A = [[int(i) for i in input().split()] for _ in range(H)]
ans = 0

manacost = [0]*11
for i in range(10):
    if i == 1:
        continue
    manacost[i] = c[i][1]
    stack = []
    for j, m in enumerate(c[i]):
        if j == 1 or i == j:
            continue
        else:
            if manacost[i] > m:
                stack.append((j, m, 0))
    while len(stack):
        j, m, t = stack.pop()
        for k, n in enumerate(c[j]):
            if j == k:
                continue
            elif k == 1:
                manacost[i] = min(manacost[i], m+n)
            else:
                if manacost[i] > m+n and t < 9:
                    stack.append((k, n+m, t+1))
for ary in A:
    for a in ary:
        ans += manacost[a]
print(ans)


Measured memory_bytes: 41308
import sys
import math
import queue
import copy
import bisect#2分探索
from collections import deque #popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s): return sorted(range(len(s)), key=lambda k: s[k])

#mod = 10**9+7

ss = input()
#N, K = map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = list(map(int, input().split()))
#S = [inputl() for i in range(H)]
#q = queue.Queue() #q.put(i) #q.get() 
#q = queue.LifoQueue() #q.put(i) #q.get() 

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b=copy.deepcopy(a)  #2次元配列はこうコピーする
#w.sort(key=lambda x:x[1],reverse=True)  #二個目の要素で降順並び替え

#素数リスト
# n = 100
# primes = set(range(2, n+1))
# for i in range(2, int(n**0.5+1)):
#     primes.difference_update(range(i*2, n+1, i))
# primes=list(primes)

#bisect.bisect_left(a, 4)#aはソート済みである必要あり。aの中から4未満の位置を返す。rightだと以下
#bisect.insort_left(a, 4)#挿入

#ss=str(S)
# #print(ss)
ls=len(ss)
# l=[0]*(ls+1)

    #print(l[i])
#print(l)

# #優先度付きqueue

kl=[0]*2019
kl[0]=1
# a = [0]
# heapq.heapify(a)  # aを優先度付きキューに

tmp=0
t2=1
count=0
for s in reversed(ss):
    tmp=(tmp+int(s)*pow(10,count,2019))%2019#ここを単純にint(s[i:sl-1])%2019とか、%10**i%2019すると、TLEになる！！！DPで求めなければならない
    kl[tmp]+=1
    #t2=t2*10%2019
    count+=1
    #print(tmp)

#print(a)




ans=0
for k in kl:
    ans+=k*(k-1)//2
print(ans)

# cur=-1
# ans=0
# for i, li in enumerate(l):
#     if cur==-1:
#         cur=li
#         count=1
#     elif li==cur:
#         count+=1
#     else:
#         ans+=count*(count-1)//2
#         cur=li
#         count=1

# print(ans)

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

int main() {
  int n;
  std::cin >> n;
  std::vector<int> c(n - 1), s(n - 1), f(n - 1);
  for (int ni = 0; ni < n - 1; ++ni) {
    std::cin >> c[ni] >> s[ni] >> f[ni];
  }
  for (int ni = 0; ni < n; ++ni) {
    int time = 0;
    for (int nj = ni; nj < n - 1; ++nj) {
      time = std::max(time, s[nj]);
      time = (time + f[nj] - 1) / f[nj] * f[nj];
      time += c[nj];
    }
    std::cout << time << std::endl;
  }
  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int cnt[30];
int main()
{
	char s[20];
	int t;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%s",s);
		if(s[0]=='A') cnt[1]++;
		if(s[0]=='W') cnt[2]++;
		if(s[0]=='T') cnt[3]++;
		if(s[0]=='R') cnt[4]++; 
	}
	printf("AC x %d\n",cnt[1]);
	printf("WA x %d\n",cnt[2]);
	printf("TLE x %d\n",cnt[3]);
	printf("RE x %d\n",cnt[4]);
}

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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

class Main {
	Scanner sc;
	int N, P;
	String S;
	long[] c;
	
	void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		P = sc.nextInt();
		S = sc.next();
		if (P == 2 || P == 5) pis2or5();
		else inv10exists();
	}
	
	void pis2or5() {
		long ans = 0;
		for (int i = 0; i < N; i++) {
			int d = S.charAt(i) - '0';
			if (d%P == 0) ans += i+1;
		}
		System.out.println(ans);
	}
	
	void inv10exists() {
		c = new long[P];
		c[0] = 1;
		long q = 1;
		long s = 0;
		for (int i = 0; i < N; i++) {
			long a = S.charAt(N-i-1) - '0';
			a = (a*q)%P;
			q = (10*q)%P;
			s = (s+a)%P;
			c[(int)s]++;
		}
		long ans = 0;
		for (int i = 0; i < P; i++)
			ans = ans + c[i]*(c[i]-1)/2;
		System.out.println(ans);
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 40964
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define all(x) x.begin(),x.end()

class inter {
  const i64 le, ri;
public:
  class iter {
    friend inter;
    i64 i;
    iter(const i64 x) : i(x) {}
  public:
    void operator++() { ++i; }
    i64 operator*() const { return i; }
    bool operator!=(const iter x) const { return i != x.i; }
  };
  inter(const i64 left, const i64 right) : le(left), ri(right) {  }
  iter begin() const { return iter(le); }
  iter end() const { return iter(ri); }
};

int main() {
  i64 N,M,C;
  cin >> N >> M >> C;
  vector<i64> B(M);
  for_each(begin(B), end(B), [](i64& a){ cin >> a; });
  i64 ans = 0;
  for(const i64 i: inter(0, N)) {
    vector<i64> A(M);
    for_each(begin(A), end(A), [](i64& a){ cin >> a; });
    i64 sum = 0;
    for(const i64 j: inter(0, M)) sum += A[j] * B[j];
    if(sum + C > 0) ans++;
  }
  cout << ans << endl;
}




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

int main()
{
    int a[1005];
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<k;i++)
        ans+=a[i];
    cout<<ans;
    return 0;
}


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

int main(){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(abs(c-a)<=d) puts("Yes");
  else if(abs(b-a)<=d&&abs(c-b)<=d) puts("Yes");
  else puts("No");


  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
  int n,i;
  n<999;
  scanf("%d",&n);
  i=n%10;
  switch(i)
  {
  case 2:
  case 4:
  case 5:
  case 7:
  case 9: printf("hon");break;
  case 0:
  case 1:
    case 6:
    case 8: printf("pon");break;
    case 3: printf("bon");break;

  }
  return 0;
}


Measured memory_bytes: 2152
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;
typedef double db;
const ll INF = 0xffffffffff;
p cap[100000];
ll N,A[100000],B[100000],K,V[100000],P[100000];
vector<ll> G[100000];
ll odd[100000];//-1 未定　１奇数　0偶数

p dfs(ll v,p fcap,ll from){
	if(fcap.second+1<cap[v].first || cap[v].second< fcap.first-1 || (odd[v]!=-1&&from!=-1&&odd[v]==odd[from]) ){
		puts("No");
		return p(-INF,-INF);
	}
	cap[v].first=max(cap[v].first,fcap.first-1);
	cap[v].second=min(cap[v].second,fcap.second+1);
	odd[v]=(cap[v].first%2+2)%2;
	if(cap[v].first>cap[v].second || (cap[v].first%2+2)%2 != (cap[v].second%2+2)%2 ){
		puts("No");
		return p(-INF,-INF);
	}
	for(ll i=0;i<G[v].size();i++){
		if(G[v][i]==from) continue;
		p gen=dfs( G[v][i],cap[v],v );
		if(gen.first==-INF&&gen.second==-INF) return gen;
		cap[v].first=max(cap[v].first,gen.first-1);
		cap[v].second=min(cap[v].second,gen.second+1);
		if(gen.second+1<cap[v].first || cap[v].second< gen.first-1 || (odd[v]==odd[G[v][i]]) ){
			puts("No");
			return p(-INF,-INF);
		}
	}
	return cap[v];
}

ll vs[100000];

void rdfs(ll v,ll val,ll from){
	if(cap[v].first<=val-1&&val-1<=cap[v].second){
		vs[v]=val-1;
	}
	else vs[v]=val+1;
	for(ll i=0;i<G[v].size();i++){
		if(G[v][i]==from) continue;
		rdfs(G[v][i],vs[v],v);
	}
	return;
}

int main()
{
	cin>>N;
	for(ll i=0;i<N-1;i++){
		cin>>A[i]>>B[i];
		A[i]--;
		B[i]--;
		G[A[i]].push_back(B[i]);
		G[B[i]].push_back(A[i]);
		cap[i]=p(-INF,INF);
		odd[i]=-1;
	}
	odd[N-1]=-1;
	cap[N-1]=p(-INF,INF);
	cin>>K;
	for(ll i=0;i<K;i++){
		cin>>V[i]>>P[i];
		V[i]--;
		cap[V[i]]=p(P[i],P[i]);
		odd[V[i]]=P[i]%2;
	}
	if(dfs(V[0],p(-INF,INF),-1).second!=-INF){
		puts("Yes");
		rdfs(V[0],cap[V[0]].first+1,-1);
		for(ll i=0;i<N;i++){
			cout<<vs[i]<<endl;
		}
	}
}

Measured memory_bytes: 17664
#include<iostream>
#include<numeric>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;

int main(){
    int l,r,d;
    cin>>l>>r>>d;
    int ans=0;
    for(int i=l;i<=r;i++){
        if(i%d==0) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool>    vecbool;
typedef vector<int>     vecint;
typedef vector<ll>      vecll;
typedef vector<string>  vecstr;
typedef vector<vecint>  vec2int;
typedef vector<vecbool> vec2bool;
int dx[4] {-1,+1, 0, 0};
int dy[4] { 0, 0,-1,+1};
int main()
{
  int h, w; cin >> h >> w;
  vecstr s(h);
  REP(i,h){
    cin >> s[i];
  }
  vecint l(h,0), r(h,w);
  REP(i,h){
    REP(j,w){
      if(s[i][j] == '#'){
	l[i] = j;
	break;
      }
    }
    for(int j = w - 1; j >= 0; j --){
      if(s[i][j] == '#'){
	r[i] = j;
	break;
      }
    }
  }
  REP(i, h - 1){
    if(l[i + 1] != r[i]){
      cout << "Impossible" << endl;
      return 0;
    }
  }
  cout << "Possible" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.LinkedHashMap;

class Main {
  public static final int WHITE = 0;
  public static final int GRAY  = 1;
  public static final int BLACK = 2;
  public static int SIZE;
  public static int TIME;

  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    SIZE = sc.nextInt();
    Map<Node, List<Integer>> graph = new LinkedHashMap<>(SIZE);

    Node node;
    int size;
    for (int i = 0; i < SIZE; i++) {
      node = new Node(sc.nextInt());
      size = sc.nextInt();
      List<Integer> elements = new ArrayList<>(size);
      for (int j = 0; j < size; j++) {
        elements.add(sc.nextInt());
      }
      graph.put(node, elements);
    }
    dfs(graph);
    print(graph);
  }

  public static void dfs(Map<Node, List<Integer>> graph) {
    for (Map.Entry<Node, List<Integer>> entry : graph.entrySet()) {
      if (entry.getKey().color == WHITE) {
        visit(entry.getKey(), graph);;
      }
    }
  }

  public static void visit(Node node, Map<Node, List<Integer>> graph) {
    node.color = GRAY;
    node.first = ++TIME;
    for (int addr : graph.get(node)) {
      Node connect = getNode(addr, graph);
      if (connect.color == WHITE) {
        visit(connect, graph);
      }
    }
    node.color = BLACK;
    node.second = ++TIME;
  }

  public static Node getNode(int value, Map<Node, List<Integer>> graph) {
    for (Map.Entry<Node, List<Integer>> entry : graph.entrySet()) {
      if (entry.getKey().value == value) {
        return entry.getKey();
      }
    }
    return null;
  }

  public static void print(Map<Node, List<Integer>> graph) {
    StringBuilder sb = new StringBuilder();
    for (Map.Entry<Node, List<Integer>> entry : graph.entrySet()) {
      Node node = entry.getKey();
      sb.append(node.value).append(' ');
      sb.append(node.first).append(' ');
      sb.append(node.second);
      System.out.println(sb);
      sb.setLength(0);
    }
  }
}

class Node {
  public int value;
  public int color;
  public int first;
  public int second;

  public Node() {
    this(0);
  }

  public Node(int value) {
    this.value = value;
  }
}



Measured memory_bytes: 28880
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	string s;
	cin >> s >> s;
	printf("A%cC\n", s[0]);
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
sw="1"
ans=1

for i in range(N-1):
    if sw=="1":
        if A[i]>A[i+1]:
            sw="2"
        if A[i]<A[i+1]:
            sw="3"
    elif sw=="2":
        if A[i]<A[i+1]:
            ans+=1
            sw="1"
    elif sw=="3":
        if A[i]>A[i+1]:
            ans+=1
            sw="1"

print(ans)


Measured memory_bytes: 20416
#if loc||local
#define _GLIBCXX_DEBUG
#endif

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

#define rep(i,n) for(ll i=0;i<ll(n);++i)
#define repr(i,n) for(ll i=ll(n);i-->0;)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>
std::tuple<T,T,T> ext_gcd(T a,T b){
  if(b==0){
    return {a,1,0};
  }
  auto [d,y,x] = ext_gcd(b,a%b);
  y -= a/b * x;
  return {d,x,y};
}

std::pair<int64_t,int64_t> crt1(int64_t b1,int64_t m1,int64_t b2,int64_t m2){
  auto [d,p,q] = ext_gcd(m1,m2);
  if((b2-b1)%d)return {0,-1};
  int64_t lcm_m = m1/d*m2;
  int64_t s = (b2-b1)/d;
  int64_t x = b1+s*m1*p;
  return {x,lcm_m};
}
std::vector<int64_t> divisor(int64_t n){
  std::vector<int64_t> div;
  for(int64_t p=1;p*p<=n;++p){
    if(n%p==0){
     div.push_back(p);
     if(p*p!=n)div.push_back(n/p);
    }
  }
  std::sort(div.begin(),div.end());
  return div;
}
signed main(){

  ll n;
  cin>>n;
  ll ans = INF;
  for(ll x:divisor(2*n)){
    ll y = 2*n/x;
    auto[k,mod] = crt1(0,x,-1,y);
    if(k>0)chmin(ans,k);
    if(k<0)chmin(ans,k+mod);
    dump(k,mod);
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 3752
#include<iostream>
#include<cstdio>
using namespace std;
int lcm(int a,int b);
int main(){
	for(;;){
		int a,b;
		if(scanf("%d %d",&a,&b) == EOF){break;}
		int x = lcm(a,b);
		int y = a/x*b;
		cout <<x<<" "<<y<<endl;
	}
	return 0;
}
int lcm(int a,int b){
	if (a == 0){return b;}
	return lcm(b%a,a);
}

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

int main()
{
    int arr[5];
    int k;
    for(int i=0; i<5; i++)
    {
        cin>>arr[i];
    }
    cin>>k;
    sort(arr,arr+5);
    if(arr[4]-arr[0]<=k)
    {
        cout<<"Yay!";
    }
    else
        cout<<":(";
            return 0;
}


Measured memory_bytes: 256
S = input()
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        print(i+1, i+2)
        break
else:
    for i in range(len(S)-2):
        if S[i] == S[i+2]:
            print(i+1, i+3)
            break
    else:
        print(-1, -1)

Measured memory_bytes: 3188
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,a[200111];
int main()
{
	get1(n);
	for(int i=1;i<=n;i++)
	{
		get1(a[i]);
		a[i]=i-a[i]-1;
		if(a[i]<0||a[i]>=i)
		{
			puts("-1");
			return 0;
		}
	}
	for(int i=1;i<n;i++)if(a[i]>a[i+1])
	{
		puts("-1");
		return 0;
	}
	LL ans=0;
	for(int i=1;i<=n;i++)
	{
		if(i==1||a[i]!=a[i-1])ans+=(i-a[i]-1);
		else ans++;
	}
	printendl(ans);
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(){
int n;
  scanf("%d",&n);
  int t[n],ans=0;
  for(int i=0;i<n;i++){
    scanf("%d",&t[i]);
    ans+=t[i];
  }
  int m,max=0;
  scanf("%d",&m);
  int p[m],x[m];
  for(int i=0;i<m;i++){
      scanf("%d%d",&p[i],&x[i]);
     printf("%d\n",ans-(t[p[i]-1]-x[i]));
  }
  
  
  return 0;
}


Measured memory_bytes: 128
//https://discuss.codechef.com/t/robagain-editorial/20734
#pragma GCC optimize("O3")
#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <iostream>
#include <stdio.h>
#include<bits/stdc++.h>


/*
#define x real()
#define y imag()
#define angle(a)                (atan2((a).imag(), (a).real()))
#define vec(a,b)                ((b)-(a))
#define same(p1,p2)             (dp(vec(p1,p2),vec(p1,p2)) < EPS)
#define dp(a,b)                 ( (conj(a)*(b)).real() )	// a*b cos(T), if zero -> prep
#define cp(a,b)                 ( (conj(a)*(b)).imag() )	// a*b sin(T), if zero -> parllel
#define length(a)               (hypot((a).imag(), (a).real()))
#define normalize(a)            (a)/length(a)
//#define polar(r,ang)            ((r)*exp(point(0,ang)))  ==> Already added in c++11
#define rotateO(p,ang)          ((p)*exp(point(0,ang)))
#define rotateA(p,ang,about)  (rotateO(vec(about,p),ang)+about)
#define reflectO(v,m)  (conj((v)/(m))*(m))
*/

//#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
#define NOT(x) (1^x)

const double PI  = acos(-1.0);
using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;

//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//const int N=500009,M=1000000;
const double EPS= 1e-9,eps=-1e9;
const int N =500005;

int n;
string s;
 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
//__builtin_popcount()
input;


      cin>>n;
      cin>>s;
      ll ans=0;

      stack<int>k;
      for(int i=0;i<n;i++)
      {
          if(k.size()==0)k.push(s[i]-'0');
          else if(k.top()!=s[i]-'0')k.push(s[i]-'0');
      }
      cout<<k.size();


return 0;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  char X, Y;
  cin >> X >> Y;
  if(X<Y){
    cout << "<";
  }else if(X==Y){
    cout << "=";
  }else{
    cout << ">";
  }

  return 0;
}


Measured memory_bytes: 3592
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    xy = sorted([list(map(int, input().split())) for i in range(N)], key=lambda x: (x[0], x[1]))
    
    dic = {}
    max_ = 0
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            p = xy[i][0] - xy[j][0]
            q = xy[i][1] - xy[j][1]
            if (p, q) in dic:
                dic[(p, q)] += 1
            else:
                dic[(p, q)] = 1
            max_ = max(max_, dic[(p, q)])
    
    print(N - max_)

if __name__ == "__main__":
    main()

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

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

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int f(int x) {
  int res = 0;
  while (x % 2 == 0) {
    ++res;
    x /= 2;
  }

  return res;
}

ll gcd(ll a, ll b) {
  if (a % b == 0) return b;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  rep(i, n) cin >> a[i];
  rep(i, n) {
    if (a[i] % 2 == 1) {
      cout << 0 << endl;
      return 0;
    }
    a[i] /= 2;
  }

  int t = f(a[0]);
  rep(i, n) {
    if (f(a[i]) != t) {
      cout << 0 << endl;
      return 0;
    }
    a[i] >>= t;
  }

  m >>= t;

  ll l = 1;
  rep(i, n) {
    l = lcm(l, a[i]);
    if (l > m) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = m / l;
  ans = (ans + 1) / 2;

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


Measured memory_bytes: 640
using System;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		public static void Main()
		{
			_loopNum = IO.ReadInt();
			IO.Write(_Run(0 , 0));
		}

		private static long _Run(long iGCD , int iLoopIndex)
		{
			if(iLoopIndex == 3) { return iGCD; }

			var sum = 0L;
			var nextIndex = iLoopIndex + 1;
			for(int iIndex = 1 ; iIndex <= _loopNum ; ++ iIndex)
			{
				sum += _Run(Util.Gcd(iGCD , iIndex) , nextIndex);
			}
			return sum;
		}
		private static int _loopNum = 0;
	}

	public static class IO
	{
		public static string   Read()							  { return Console.ReadLine(); }
		public static string[] ReadArray(char iSplitter = ' ')	  { return Read().Split(iSplitter); }
		public static int	   ReadInt()						  { return int.Parse(Read()); }
		public static int[]	   ReadIntArray(char iSplitter = ' ') { return ReadArray().Select(iText => int.Parse(iText)).ToArray(); }
		public static char[]   ReadCharArray()					  { return Read().ToCharArray(); }

		public static void Write(string iValue)  { Console.WriteLine(iValue); }
		public static void Write(int iValue)	 { Console.WriteLine(iValue); }
		public static void Write(long iValue)	 { Console.WriteLine(iValue); }
		public static void Write(decimal iValue) { Console.WriteLine(iValue); }
		public static void Write(bool iValue)	 { Console.WriteLine(iValue ? "Yes" : "No"); }
	}

	public static class Util
	{
		public static long Gcd(long i0 , long i1)	{ return (i0 > i1) ? _Gcd(i0 , i1) : _Gcd(i0 , i1); }
		private static long _Gcd(long i0 , long i1)	{ return (i1 == 0) ? i0 : _Gcd(i1 , i0 % i1); }
	}
}


Measured memory_bytes: 27512
n=int(input())
if n >= 64:
    print("64")
elif n >= 32:
    print("32")
elif n >= 16:
    print("16")
elif n >= 8:
    print("8")
elif n >= 4:
    print("4")
elif n >= 2:
    print("2")
else:
    print("1")

Measured memory_bytes: 3060
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
    int a[100000];
int main()
{
    int n=0;
    int b=0; 
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>b;
        a[b]++;
    }
    int mx=0;
    for (int i=1;i<=99999;i++)
        if (a[i-1]+a[i]+a[i+1]>mx) mx=a[i-1]+a[i]+a[i+1];
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=2e5+5;
int a[MN],n;
ll s[MN],tot[4],ans=0x3f3f3f3f3f3f3f3f;
int main(){
	scanf("%d",&n);
	for(reg int i=1;i<=n;i++)scanf("%d",a+i),s[i]=s[i-1]+a[i];
	reg int p1=1,p2=3;
	for(reg int i=2;i<n-1;i++){
		while(p1<i&&llabs(s[p1]+s[p1]-s[i])>=llabs(s[p1+1]+s[p1+1]-s[i]))p1++;
		while(p2<n&&llabs(s[p2]+s[p2]-s[i]-s[n])>=llabs(s[p2+1]+s[p2+1]-s[i]-s[n]))p2++;
		tot[0]=s[p1];tot[1]=s[i]-s[p1];tot[2]=s[p2]-s[i];tot[3]=s[n]-s[p2];
		sort(tot,tot+4);ans=min(ans,tot[3]-tot[0]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int n,m;
vector<int> to[200001];
int main(){
    cin>>n>>m;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    set<int> s1,s2;
    for(auto u : to[0]){
        s1.insert(u);
    }
    for(auto u : to[n-1]){
        s2.insert(u);
    }
    bool ok  = 0;
    for(auto u : s1){
        if(s2.find(u)!=s2.end()){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    double j = 0, b = 0;
    for(int i = 0; i < n; i++)
    {
        string u;
        double x;
        cin >> x >> u;
        if(u == "JPY")j += x;
        else b += x;
    }
    printf("%lf\n",j + b * 380000.0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;

int main(){

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

    vector<int> x(n);
    rep(i, n)cin >> x[i];

    x.push_back(133333);
    sort(all(x));

    vector<vector<int>> counts(m);
    int cnt = 0;
    rep(i, n){
        cnt++;
        if(x[i] < x[i + 1]){
            counts[x[i] % m].push_back(cnt);
            cnt = 0;
        }
    }

    auto getsum = [&](int i){
        int res = 0;
        for(int x : counts[i])res += x;
        return res;
    };

    auto oddcount = [&](int i){
        int res = 0;
        for(int x : counts[i])if(x % 2 == 1)res++;
        return res;
    };
    
    auto getsum_odd = [&](int i){
        int res = 0;
        for(int x : counts[i])res += x / 2;
        return res;
    };

    int ans = 0;
    rep(i, m / 2 + 1){
        if(i == 0 or i * 2 == m){
            ans += getsum(i) / 2;
        } else {
            int l = i, r = m - i;
            int lsum = getsum(l), rsum = getsum(r);
            if(lsum < rsum)swap(l, r), swap(lsum, rsum);
            int lodd = oddcount(l), lsumodd = getsum_odd(l);
            if(rsum <= lodd)ans += lsumodd + rsum;
            else ans += (lsum + rsum) / 2;
        }
    }

    cout << ans << endl;
    return 0;

}

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

int main(){
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(i%2==0&&(s[i]=='R'||s[i]=='U'||s[i]=='D')){
            continue;
        }else if(i%2!=0&&(s[i]=='L'||s[i]=='U'||s[i]=='D')){
            continue;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

map <int, int> M;
int minPrime[1000001];

void factorize(int n) {    
    while (n != 1) {
    	M[minPrime[n]]++;
        n /= minPrime[n];
    }
}


int main() {
	int n;
	cin >> n;
	
	for(int i = 2; i * i <= n; i++) {
	    if(minPrime[i] == 0) {  
	        for(int j = i * i; j <= n; j += i) {
	            if(minPrime[j] == 0) {
	                minPrime[j] = i;
	            }
	        }
	    }
	}

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

	ll Ans = 0;
	for(int i = 2; i < n; i++) {
		M.clear();
		factorize(i);	
		ll ans = 1LL;
		for(auto it = M.begin(); it != M.end(); it++) {
			ans = ans * ((it->second) + 1);
		}
		Ans += ans;
	}
	//cout << M.size() << endl;
	cout << Ans + 1 << endl;
	return 0;
}


Measured memory_bytes: 7440
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <deque>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}
const int INF=1e6;
const ll int MOD=998244353;

main(){
    int n=in();
    if(n==2)cout<<-1;
    else{
        if(n%3==0){
            vector<vector<char>> v(3,vector<char>(3,'.'));
            v[0][0]=v[1][0]=v[2][1]=v[2][2]='a';
            rep(i,n){
                rep(j,n){
                    cout<<v[i%3][j%3];
                }
                cout<<endl;
            }
        }
        else{
            int t=(n%4)+4;
            vector<string> a={"aacd","bbcd","efgg","efhh"},
            b={".aabc","dd.bc","e.ffg","e.h.g","iihjj"},
            c={"aa..gh","bb..gh","cc..ij","..ddij","..eekl","..ffkl"},
            d={"aabb..c",".d..eec",".dff..g","h...k.g","h...kl.","mnn..l.","m..qqpp"};
            vector<string> ans(n,string(n,'.'));
            for(int i=t;i<n;i+=4){
                rep2(j,i,i+3){
                    rep2(k,i,i+3){
                        ans[j][k]=a[j-i][k-i];
                    }
                }
            }
            rep(i,t){
                rep(j,t){
                    if(t==4)
                    ans[i][j]=a[i][j];
                    if(t==5)ans[i][j]=b[i][j];
                    if(t==6)ans[i][j]=c[i][j];
                    if(t==7)ans[i][j]=d[i][j];
                }
            }
            rep(i,n)cout<<ans[i]<<endl;
        }
    }
}

Measured memory_bytes: 2176