akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,a,ba[100010],x,y,aa[100],msm,sa,sb,sc;

int main(){
    cin>>y>>x;
    if(x%3==0 or y%3==0){
        C 0 E;
        return 0;
    }
    
    msm=10000000000;
    for(int i=0;i<=y;i++){
        sa=abs(i*x-((y-i)*(x/2)));
        sb=abs(i*x-((y-i)*(x-x/2)));
        sc=abs((y-i)*(x/2)-(y-i)*(x-x/2));
        msm=min(msm,max(sa,max(sb,sc)));
    }
    
    for(int i=0;i<=x;i++){
        sa=abs(i*y-((x-i)*(y/2)));
        sb=abs(i*y-((x-i)*(y-y/2)));
        sc=abs((x-i)*(y/2)-(x-i)*(y-y/2));
        msm=min(msm,max(sa,max(sb,sc)));
    }
    
    msm=min(msm,min(x,y));
    
    C msm E;
    
    
}


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

int main(){
    long long x;
    cin >> x;
    long long a = 100;
    int idx = 0;
    while(true){
        idx++;
        a = floor(a*1.01);
        if(a >= x) break;
    }
    cout << idx << endl;
    return 0;
}


Measured memory_bytes: 3744
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n=int(input())
n_fact = factorization(n)
ans=0
for i in n_fact:
    a = i[1]
    cnt=0
    while a > cnt:
        cnt += 1
        a -= cnt
        ans += 1
if n == 1:
    ans = 0
print(ans)

Measured memory_bytes: 9492
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt() % 10
	var ans string
	switch N {
	case 3:
		ans = "bon"
	case 0, 1, 6, 8:
		ans = "pon"
	default:
		ans = "hon"
	}
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 1792
#include<iostream>
#include<map>
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define INF 1000000007
using namespace std;
typedef map<int,int> MP;
typedef long long ll;
int n;
MP res;
void prime_factor(int a){
  for(int i=2;i*i<=a;i++){
    while(a%i==0){
      res[i]++;
      a/=i;
    }
  }
  if(a!=1) res[a]++;
}
int main(){
  cin >> n;
  FOR(i,2,n+1) prime_factor(i);
  ll ans=1;
  for(MP::iterator ite=res.begin();ite!=res.end();ite++){
    ans=ans%INF*(ite->second+1);
  }
  cout << ans%INF << "\n";
  
  //  for(MP::iterator ite=res.begin();ite!=res.end();ite++) cout << ite->first << " " << ite->second << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int n, m,t;
int a[5];
int main()
{
	cin >> t;
	for (int i = 1; i <= t; i++)
	{
		char s[10];
		cin >> s;
		if (s[0] == 'A')
			a[1]++;
		else if (s[0] == 'W')
			a[2]++;
		else if (s[0] == 'T')
			a[3]++;
		else
			a[4]++;
	}
	cout << "AC x " << a[1] << endl;
	cout << "WA x " << a[2] << endl;
	cout << "TLE x " << a[3] << endl;
	cout << "RE x  " << a[4] << endl;
}

Measured memory_bytes: 3632
//
//  main.cpp
//  20190730lesson
//
//  Created by Priscilla Leang on 7/30/19.
//  Copyright 漏 2019 Priscilla Leang. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int x, y, m;
    bool b1 = false;
    /*
    m = 0;
    cin>> x;
    for (int i = 1; i<= x; i+=2){  //only odd numbers
        y = 0;
        for(int j = 1; j <= x; j++){
            if (i % j ==0){
                y++;
            }
        }
        if (y == 8){
            m++;
        }
            
    }
    cout << m;
    */
    //next porblem
    
    /*
    
    cin >> x >> y;
    int a1[x][2];
    m = 1000;
    
    for (int i = 0; i< x; i++){
        for (int j = 0; j < 2; j++){
            cin>> a1[i][j];
        }
    }
    for (int i = 0; i < x; i++){
        if (a1[i][1] <= y && a1[i][0] <= m){
            b1 = true;
            
            m = a1[i][0];
        }
    }
    
    if(b1 == false){
        cout << "TLE";
    }
    else {
        cout << m;
    }
    
     
     */
    string s, t, v, q;
    b1 = false;
    cin >> s>> t;
    v = "";
    
    q = s;
    if (s == t){
        b1 = true;
    }
    for (int i = 1; i < s.length(); i++){
        v = "";
        v+= s[s.length() - 1];
        for (int j = 0; j<s.length() - 1; j++){
            v+= s[j];
            
            
            
        }
        
        if (v == t){
            b1 = true;
        }
        s = v;
    }
    
    if (b1 == true){
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
# find the cluster of LLLLL....... and RRRRR....
# Reversing these cluster increases happiness by 2
# either the leftmost or the rightmost will remain unhappy forever can't help :(
def main():
	n , k = map(int, input().split())
	s = input()
	uh=0
	for i in range(0 , len(s)-1):
		if s[i]!=s[i+1]:
			uh=uh+1
	hp = n-1 - max(uh-2*k , 0)
	print(hp)


if __name__=="__main__":
	main()

Measured memory_bytes: 68556
def knapSack(W, wt, val, n): 
	K = [[0 for x in range(W+1)] for x in range(n+1)] 

	
	for i in range(n+1): 
		for w in range(W+1): 
			if i==0 or w==0: 
				K[i][w] = 0
			elif wt[i-1] <= w: 
				K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]], K[i-1][w]) 
			else: 
				K[i][w] = K[i-1][w] 

	return K[n][W] 




q=list(map(int,input().split()))
n=q[0]
W=q[1]
v=[0]*n
w=[0]*n
for _ in range(n):
  r=list(map(int,input().split()))
  w[_]=r[0]
  v[_]=r[1]
  




print(knapSack(W,w,v,n))


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

int main(){
    int p,q,r,max;
    cin >> p >> q >> r;
    if ( p >= q && p >= r) {
        max = p;
    } else if ( q >= p && q >= r ) {
        max = q;
    } else {
        max = r;
    }
    cout << p + q + r - max << endl;
}


Measured memory_bytes: 256
a,b,c = map(int,input().split())
ans = 0
comb = set()
while a%2==0 and b%2==0 and c%2==0:
    x = (b+c)//2
    y = (a+c)//2
    z = (b+c)//2
    if (x,y,z) in comb:
        ans = -1
        break
    ans += 1
    comb.add((x,y,z))
    a,b,c = x,y,z
print(ans)


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

int main(){
  string X;
  getline(cin,X);
  int a = X.size();
  for(int i=0;i<a-1;++i){
    if(X[i] == 'S' && X[i+1] == 'T'){
      X.erase(X.begin()+i);
      X.erase(X.begin()+i);
      if(i == 0){--i;}else{i-=2;}
    }
  }
cout << X.size() << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<string,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+8+7;
ll n,m,l;
string s,t;
int d[100010],dp[500][500];

int main(){
  cin >> n;
  ll ans[100];
  clr(ans,0);
  rep(i,0,2){
    rep(j,0,n){
      cin >> dp[i][j];
    }
  }
  rep(i,0,n){
    ll p = 0;
    lep(j,0,i)p += dp[0][j];
    rep(j,i,n)p += dp[1][j];
    ans[i] = p;
  }
  ll u = 0;
  rep(i,0,n)u = max(u,ans[i]);
  print(u);
  return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main(void){
	int N, K;	cin >> N >> K;
	string s;	cin >> s;
	vector<int> cnts;
	int cnt = 1;

	///	1の個数、0の個数、1の個数、… 、0の個数、1の個数となるように配列cntsを作る
	///	入力sが、0で始まるor0で終わるようなら、最初or最後に1の個数が0として加えておく
	if (s[0] == '0')	{
		cnts.push_back(0);
	}
	rep(i,N)	{
		if (s[i] != s[i+1])	{
			cnts.push_back(cnt);
			cnt = 1;
		}else{
			cnt++;
		}
	}
	while(cnts.size() < 2+2*K)	{
		cnts.push_back(0);
	}
	if (s[s.size()-1] == '0')	{
		cnts.push_back(0);
	}

	///	2K+1個ずつ、'1の個数'から始まるように和を比較する(尺取法)
	int tmp = 0;
	rep(i,2*K+1)	{
		tmp += cnts[i];
	}
	int ans = tmp;
	reps(i,cnts.size()-2*K-2)	{
		i++;
		tmp -= cnts[i-2] + cnts[i-1];
		tmp += cnts[i+2*K-1] + cnts[i+2*K];
		ans = max(ans, tmp);
	}

	cout << ans << endl;

	return 0;
}


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

lst.sort(reverse=True)
if n % 2 == 0:
  a = n//2-1
  s = lst[0]
  for i in range(a):
    s += 2*(lst[i+1])
  
else:
  b = (n-1) //2
  s = lst[0]
  for j in range(b):
    s += 2*(lst[j+1])
  s -= lst[b]
  
print(s)

Measured memory_bytes: 31608
import sys

a = []
for line in sys.stdin:
    a.append(line.strip())
ita = iter(a)

for a, b in zip(ita, ita):
    hit = 0
    blow = 0
    a = a.split(' ')
    b = b.split(' ')
    for a_, b_ in zip(a, b):
        if a_ == b_:
            hit += 1
        elif a_ in b:
            blow += 1
    print(hit, blow)



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

int main() {
  int a,b;
  int x;
  cin >> a >> b;
  if ((a+b)%2 == 0){
    x = (a+b)/2;
  }
  else{
    x = (a+b)/2 +1;
  }
  cout << x <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a,b;
 for(a = 1; a < 10; a++)
   {
   for(b = 1;b < 10;b++)
     {
      printf("%d", a);
    printf("x");
  printf("%d", b);
    printf("=");
      printf("%d\n", a*b);
     };
   };
    return 0;
}

Measured memory_bytes: 928
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0

for i in range(N):
    S = input()
    if S == 'AC':
        ac += 1
    if S == 'WA':
        wa += 1
    if S == 'TLE':
        tle += 1
    if S == 'RE':
        re += 1

print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))


Measured memory_bytes: 9204
#include <stdio.h>

int main(void)
{
	int i, j;
	int answer = 1;
	
	for (i = 1; i <= 9; i++){
		for (j = 1; j <= 9; j++){
			printf("%dx%d=%d\n", i, j, i * j);
		}
	}
	
	return (0);
}

Measured memory_bytes: 524
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

// vector vの中のn以下の数で最大のものを返す
ll bs(vector<pair<ll, ll> > &v, ll x) {
    ll ok = -1; //これがx以下 
    ll ng = v.size(); //x以上 
    // 問題によってokとngを入れ替える
    while(abs(ok - ng) > 1) {
        ll mid = (ok + ng)/2;
        if(v[mid].first <= x) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(void) {
    
    ll n, d, a;
    cin >> n >> d >> a;
    vector<pair<ll, ll> > v(n);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        v[i] = mp(a, b);
    }
    Sort(v);
    vll imos(n + 1, 0);
    vll csum(n + 1, 0);
    ll ans=0;
    rep(i, n) {
        if(i > 0) csum[i] = csum[i - 1] + imos[i - 1];
        ll l = v[i].first, r = v[i].first + 2*d;
        l = bs(v, l);
        r = bs(v, r);
        ll minus = ceil(max((v[i].second - (csum[i] + imos[i])), 0LL)/(double)a)*a;
        ans += minus/a;
        imos[l] += minus;
        imos[r + 1] -= minus;
        // cout << l << " " << r << " " << minus << " " << csum[i] << endl;
    }
    // rep(i,n+1)cout<<imos[i]<<" ";
    // cout<<endl;
    fin(ans);
}

Measured memory_bytes: 6528
from collections import Counter

n,p = map(int,input().split())
s = input()

ans = 0
if p == 2 or p == 5:
  for i in range(n):
    if int(s[i]) % p == 0:
      ans += (i+1)

else:      
  mods = [0]*p
  mods[0] = 1
  m = 0
  d = 1  
  for i in range(n):
    m = (m + int(s[-i-1])*d) % p
    d = (d * 10) % p    
    mods[m] += 1
  
  for i in range(p):
    ans += mods[i]*(mods[i]-1)//2

print(ans)      

Measured memory_bytes: 3752
#pragma GCC optimize("O3")
#pragma G++ optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned ll
#define mst(a, b) memset((a), (b), sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const int maxn = 1e3 + 7;
const int maxm = 1e5 + 7;
const int mod = 1e9 + 7;
#define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
ll a[maxm];
__int128_t ans;
int main()
{
    IO;
    int n;
    cin>>n;
    ans=1;
    for (int i=0;i<n;++i)
    {
        cin>>a[i];
        if (a[i]==0)
        {
            cout<<0<<endl;
            return 0;
        }
    }
    for (int i=0;i<n;++i)
    {
        ans*=a[i];
        if (ans>(ll)1000000000000000000)
        {
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<(ll)ans<<endl;
    return 0;
}

Measured memory_bytes: 4372
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        long[] b = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        long[] c = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        long[] x = new long[n];
        Array.Sort(a);
        Array.Sort(b);
        Array.Sort(c);
        long ans = 0;

        long temp = BinarySearchIterative(a, (int)b[0]);
        x[0] = a[temp] < b[0] ? temp + 1 : temp;

        for (int i = 1; i < n; i++)
        {
            long tmp = BinarySearchIterative(a, (int)b[i]);
            x[i] = a[tmp] < b[i] ? x[i - 1] + tmp + 1 : x[i - 1] + tmp;
        }

        for(int i = n - 1; i >= 0; i--)
        {
            int greatest_idx_b = BinarySearchIterative(b, (int)c[i]);
            if(b[greatest_idx_b] < c[i])
            {
                ans += x[greatest_idx_b];
            }
            else
            {
                if(greatest_idx_b - 1 >= 0)
                {
                    ans += x[greatest_idx_b - 1];
                }
            }
        }
        Console.WriteLine(ans);
    }

    public static int BinarySearchIterative(long[] inputArray, int key)
    {
        int low = 0;
        int high = inputArray.Length;
        int mid = 0;
        while (low < high)
        {
            mid = (low + high) / 2;
            if (inputArray[mid] < key)
            {
                low = mid + 1;
            }
            else
            {
                high = mid;
            }
        }
        return mid;
    }
}

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

int main(){
    int x,y;
    while(1<2){
    cin>>x>>y;
    if(x==0&&y==0){
    break;
    }else if(x<=y){
    cout<<x<<" "<<y<<endl;
    }else{
    cout<<y<<" "<<x<<endl;
    }
    }
}


Measured memory_bytes: 3088
#include <iostream>
#include <string> 
#include <cstring>
using namespace std;

const int P=1e9+7;

int main(){
	string K;
	long long d,dgt;
	cin>>K>>d;
	dgt=K.length();

	long long dp[dgt][d];
	memset(dp,0,sizeof(dp));

	for(char i='0';i<K[0];i++){
		dp[0][(i-'0')%d]+= 1;
	}
	long long edge = (K[0]-'0')%d;

	for(int i=1;i<dgt;i++){
		
		for(int j=0;j<d;j++){
			for(int k=0;k<10;k++){
				dp[i][(j+k)%d] = (dp[i-1][j] + dp[i][(j+k)%d])%P;
			} 
		}

		for(char k='0';k<K[i];k++){
			dp[i][(edge+k-'0')%d] = (dp[i][(edge+k-'0')%d] + 1)%P;
		}
		edge = (edge+K[i]-'0')%d;
	}
/*
	for(int i=0;i<d;i++){
		for(int j=0;j<dgt;j++){
			cout<<dp[j][i]<<"\t";
		}
		cout<<"\n";
	}
*/
	long long ans = dp[dgt-1][0]-1+(edge==0);
	ans = (ans+P)%P;
	cout<<ans<<endl;
}


Measured memory_bytes: 11384
n=gets.to_i
a,b=gets.split.map &:to_i
ps=gets.split.map &:to_i
p1,p23=ps.partition{|i|i<=a}
p2,p3=p23.partition{|i|i<=b}
p [p1,p2,p3].map{|arr|arr.size}.min

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

import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
XYP = [list(map(int, readline().split())) for _ in range(N)]

costs = [sys.maxsize] * N
for i, (x, y, c) in enumerate(XYP):
    costs[i] = c * min(abs(x), abs(y))

x_cost = [sys.maxsize] * ((1 << N) * N)
y_cost = [sys.maxsize] * ((1 << N) * N)

for bit in range(1 << N):
    for i, (xi, yi, _) in enumerate(XYP):
        x_cost[bit * N + i] = min(costs[i], x_cost[bit * N + i])
        y_cost[bit * N + i] = min(costs[i], y_cost[bit * N + i])
        if not (bit & (1 << i)):
            continue
        for k, (xk, yk, c) in enumerate(XYP):
            x_cost[bit * N + k] = min(x_cost[bit * N + k], abs(xi - xk) * c)
            y_cost[bit * N + k] = min(y_cost[bit * N + k], abs(yi - yk) * c)

ans = [sys.maxsize] * (N + 1)

for bit in range(1 << N):
    cnt = bin(bit).count('1')
    bit_ = bit
    while bit_ >= 0:
        bit_ &= bit
        cost = 0
        y_bit = bit - bit_
        for k in range(N):
            cost += min(x_cost[bit_ * N + k], y_cost[(y_bit) * N + k])
        ans[cnt] = min(ans[cnt], cost)

        bit_ -= 1
for i in range(N + 1):
    print(ans[i])

Measured memory_bytes: 83332
'use strict'

function main(input) {
  input = input.split(/\n/)
  const N = Number(input[0])
  const jobs = input
    .slice(1, -1)
    .map(v => v.split(' ').map(v => ~~v))
    .sort((a, b) => {
      return a[1] > b[1] ? 1 : -1
    })
  // console.log(jobs.length === N)

  let time = 0
  let i = 0
  // while (true) {
  for (let i = 0; i < N; i++) {
    // for (let job of jobs) {
    time += jobs[i][0]
    if (time > jobs[i][1]) {
      console.log('No')
      return false
    }
    // i++
    // if (i >= N) {
    //   console.log('Yes')
    //   return false
    // }
  }
  console.log('Yes')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 69288
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	string str;
	vector<string> ans;
	while (cin >> str) {
		if (str == "-")break;
		int m;
		cin >> m;
		rep(i, 0, m) {
			int in;
			cin >> in;
			string s = str.substr(0, in);
			string t = str.substr(in, str.length());
			str = t + s;
		}
		ans.push_back(str);
	}
	for(auto i: ans) cout << i << endl;
	return 0;
}


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

int main() {
	bool check = false;
	string str;

	cin >> str;

	for (int i = 0; i < str.length(); i++) {
		for (int j = i; j < str.length(); j++) {
			if (str.substr(0, i) + str.substr(j) == "keyence"){
				check = true;
			}
		}
	}

	if (check) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
 
int main(){
	char A[15], B[15], C[15];
	
	scanf("%s%s%s", &A,&B,&C); 
	
	if( A[strlen(A)-1]==B[0] && B[strlen(B)-1]==C[0]){
               printf("YES");
        }
	  else{
               printf("NO");
        }
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define inf 100000000
#define mod 1000000007
#define ld long double
#define point complex<double>
#define pi  acos(-1)
#define IO                    \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
using namespace std;



	int main(){
		int x,n;
		cin>>x>>n;
		int arr[n];
		set<int>st;
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
			st.insert(arr[i]);
		}
		int res=inf;
		int dif=inf;
		for(int i=x;i<1000;i++)
		{
			if(st.find(i)==st.end())
			{
				res=i;
				dif=i-x;
				break;
			}
		}
		for(int i=x-1;i>-1000;i--)
		{
			if(x-i>dif)break;
			if(st.find(i)==st.end())
			{
				res=i;
				dif=x-i;
			}
			
		}
		cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3632
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

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

if __name__ == '__main__':
    b, c = map(int, input().split())

    if b+c ==15:
        print("+")
    elif b*c ==15:
        print("*")
    else:
        print("x")


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


int dig(ll x){
  ll d=0,di=1;
  while(x>0){
    d++;
    x/=10;
    di*=10;
  }
  return di;
}


int main() {
  ll a,b;
  cin >> a >> b;
  ll res=a*dig(b)+b;
  //cout << res << endl;
  bool hantei=false;
  rep(i,1000){
    if(i*i==res){
      cout << "Yes" << endl;
      hantei=true;
      break;
    }
  }
  if(!hantei)cout << "No" <<endl;
}


Measured memory_bytes: 256
n = int(input())
L = sorted(list(map(int, input().split())), reverse = True)

# c < b < a の条件下
def judge(a:int, b:int, c:int):
    if a < b + c:
        pass
    else:
        return False
    return True

def binary_search(l:int, r:int):
    while r - l > 1:
        mid = (l + r) // 2
        c = L[mid]
        if judge(a, b, c) == True:
            l = mid
        else:
            r = mid
    return l

ans = 0
for i in range(n - 2):
    a = L[i]
    for j in range(i + 1, n - 1):
        b = L[j]
        f1 = judge(a, b, L[j + 1])
        f2 = judge(a, b, L[n - 1])
        if f1 == True:
            if f2 == False:
                ans += binary_search(j, n - 1) - j 
            else:
                ans += n - j - 1
        else:
            pass
    
print(ans)

Measured memory_bytes: 47836
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int H, W;
 char S[100][100];
 int out[100][100];

 cin >> H >> W;

 for(int h = 0; h < H; h++){
     for(int w = 0; w < W; w++){
         cin >> S[h][w];
     }
 }

 for(int h = 0; h < H; h++){
     for(int w = 0; w < W; w++){
        if(S[h][w] == '#'){
             out[h][w+1] += 1;
             out[h][w-1] += 1;
             out[h+1][w] += 1;
             out[h-1][w] += 1;
             out[h+1][w+1] += 1;
             out[h-1][w+1] += 1;
             out[h+1][w-1] += 1;
             out[h-1][w-1] += 1;
         }
     }
 }

 for(int h = 0; h < H; h++){
     for(int w = 0; w < W; w++){
         if(S[h][w]=='#'){
             cout << S[h][w];
         }
         else{
             cout << out[h][w];
         }
     }
     cout << endl;
 } 



}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<ctime>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
    int x = 0; char ch = gc(); bool positive = 1;
    for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
    for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
    return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
    }
    write(a); puts("");
}
ll n;
int main(){
	cin>>n; ll i=1,j=0;
	for(;i<=n;i*=10)j++;
	i/=10;
	ll t=n/i*i+i-1;
	cout<<(t<=n?(j-1)*9+n/i:(j-1)*9+n/i-1)<<endl;
}



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


int main(){
    int n;
    cin >> n;
    vector< pair < string , int > > guide(n);
    vector< pair < string , int > > g(n);
    g = guide;
    for (int i = 0; i < n ; i++) {
        cin >> guide.at(i).first;
        g.at(i).first = guide.at(i).first;
        cin >> guide.at(i).second;
        guide.at(i).second = 100 - guide.at(i).second;
        g.at(i).second = guide.at(i).second;
    }
    sort(guide.begin(), guide.end());

    for (int j = 0; j < n; j++) {
        for (int i = 0; i < n; i++) {
            if ( g.at(i).first == guide.at(j).first && g.at(i).second == guide.at(j).second){
                cout << i + 1 << endl;
            }
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,a,b;
	scanf("%d %d %d",&n,&a,&b);
	int m1,m2;
	m1=n*a;
	m2=b;
	if(m1<m2)
	printf("%d\n",m1);
	else if(m1>m2)
	printf("%d\n",m2);
	else
	printf("%d\n",m1);
	
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int A, B, C, D; cin >> A >> B >> C >> D;
  string result;
  if (A+B > C+D) result = "Left";
  else if (A+B == C+D) result = "Balanced"; 
  else result = "Right";
  cout << result << endl;
  return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  string s;
  cin >> s;
  int cnt = 0;
  for (auto &i : s) if (i == '1') cnt++;
  cout << cnt << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


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

int main(){
	ll N,X;
	cin >> N >> X;
	vector <ll> L(N);
	rep(i,N)cin >> L[i];
	ll sum = 0;
	ll cnt = 1;
	rep(i,N){
		sum += L[i];
		if(sum > X)break;
		cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
def retMin(a,b):
  if a >= b:
    return b
  else:
    return a  

n=int(input())
r=list(map(int,input().split()))
dpList = [99999999999] * (n)

dpList[0] = 0

for i in range(1,n):
  if i<2:
    dpList[i] = retMin(dpList[i],dpList[i-1]+(abs(r[i]-r[i-1])))
  else:
    dpList[i] = retMin(dpList[i-1]+(abs(r[i]-r[i-1])),dpList[i-2]+(abs(r[i]-r[i-2])))
  
print(dpList[n-1])

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

int main(){
  int N;
  cin >> N;
  vector<pair<pair<string,int>,int>> R(N);
  
  rep(i,N){
    string S;
    int P;
    cin >> S >> P;
    R.at(i) = make_pair(make_pair(S,-P),i);
  }
  
  sort(R.begin(), R.end());
  
  rep(i,N){
    cout << R.at(i).second+1 << endl;
  }
  
}

Measured memory_bytes: 256
from scipy.special import comb
def ge():
    return map(int,input().split())
def main():
    #a,b,c,d=ge()
    #a=list(map(int,input().split()))
    #a=input()
    S=int(input())
    N=S//3
    #print(N)
    ans=0
    for i in range(1,N+1,1):
        tmp=S-3*i
        #print(tmp,"aa",i)
        ans+=comb(tmp+i-1, tmp, exact=True)
        #print(ans,i)
    print(ans%(10**9+7))

main()

Measured memory_bytes: 42300
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
int main(){
    int x,y,s;
  while(1){
  cin>>x>>y>>s;
  if(x==0||y==0||s==0)return 0;
  int ans=0;
  for(int i=1;i<s;i++){
       for(int j=1;j<s;j++){
           if(i*(100+x)/100+j*(100+x)/100==s){
               chmax(ans,i*(100+y)/100+j*(100+y)/100);
           }
       }
  }
  cout<<ans<<endl;
  }
 
}


Measured memory_bytes: 3144
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  long long int X;
  long long int A;
  cin >> X;
  A = X;
  X *= 2LL;
  long long int x = sqrt(X);
  x++;
  long long int ans = 0LL;
  while(x>=0){
    if(x * (x+1) == X){
      ans = x;
      break;
    }else if(x * (x+1) < X){
      x++;
      long long int d = x * (x+1) / 2 - A;
      if(d <= x) ans = x;
      else ans = x+d;
      break;
    }
    x--;
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
using namespace std;

int n;
int l[10];
int A, B, C;

int dfs(int i, int a, int b, int c){
    if(i == n){
        if(a == 0 || b == 0 || c == 0){
            return 1<<30;
        }
        return abs(A-a)+abs(B-b)+abs(C-c)-30;
    }
    int n1 = dfs(i+1, a, b, c);
    int n2 = dfs(i+1, a+l[i], b, c) + 10;
    int n3 = dfs(i+1, a, b+l[i], c) + 10;
    int n4 = dfs(i+1, a, b, c+l[i]) + 10;
    return min(min(n1, n2), min(n3, n4));
}

int main(){
    cin >> n >> A >> B >> C;
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    cout << dfs(0, 0, 0, 0) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.size() <= k)cout << s << endl;
    else{
        rep(i, k)cout << s[i];
        cout << "..." << endl;
    }
    
}

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

using LL = long long;

LL N, K, M, A, B, C, T;
vector<LL> S, V;

auto solve(auto n, auto k, auto t) {
  if(t < 0) return 0ll;
  LL res = min(1 + t / A, n);
  n -= res;
  t -= res * C;
  for(auto i = 1; i <= k; ++i) {
    if(t < 0) break;
    V.emplace_back(min(1 + t / A, n));
    n -= V.back();
    t -= V.back() * C;
  }
  return res;
}

int main() {
  cin >> N >> M >> K >> A >> B >> C >> T;
  S.resize(M);
  for(auto& i: S) cin >> i;

  LL ans = ((S.back() - 1) * B <= T) ? 1 : 0;
  for(auto i = 1; i < M; ++i) ans += solve(S[i] - S[i-1], K - M, T - (S[i-1] - 1) * B);
  sort(begin(V), end(V), greater<LL>());
  for(auto i = 0; i < min<LL>(K - M, V.size()); ++i) ans += V[i];

  cout << ans - 1 << endl;
}

Measured memory_bytes: 19320
C = [[int(zz) for zz in input().split()] for _ in range(3)]

for j in range(3):
    if j+1 == 3:
        p = 0
    else:
        p = j+1
    tmp = C[j][2]-C[p][2]
    for i in range(2):
        if C[j][i]-C[p][i] != tmp:
            print('No')
            exit()

print('Yes')

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

import sys
sys.setrecursionlimit(300000)
from itertools import combinations, combinations_with_replacement


#def solve(N: int, M: int, Q: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
def solve(n, m, Q, a, b, c, d, X):
    cans = list(combinations_with_replacement(range(1, m + 1), n))
    #print(cans)
    ret = 0
    for can in cans:
        tmp = 0
        for i in range(Q):
            if can[b[i] - 1] - can[a[i] - 1] == c[i]:
                tmp += d[i]
        ret = max(tmp, ret)
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    a = [int()] * (Q)  # type: "List[int]"
    b = [int()] * (Q)  # type: "List[int]"
    c = [int()] * (Q)  # type: "List[int]"
    d = [int()] * (Q)  # type: "List[int]"
    X = []
    for i in range(Q):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
        d[i] = int(next(tokens))
        X.append((a[i], b[i], c[i], d[i]))
    solve(N, M, Q, a, b, c, d, X)

if __name__ == '__main__':
    main()


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

struct Node{
    int p, l, r;
};

const int NIL = -1;

void print(Node T[],int D[], int u){
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if(T[u].p == NIL) cout << "root, ";
    else if(T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";
    for(i=0, c=T[u].l; c != NIL; i++, c = T[c].r){
        if(i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

int rec(Node T[], int D[], int u, int p){
    D[u] = p;
    if( T[u].r != NIL) rec(T, D,  T[u].r, p);
    if( T[u].l != NIL) rec(T, D, T[u].l, p + 1);
}

int main(){
    int i, j, d, v, c, l, r, n;
    scanf("%d", &n);
    Node T[n];
    int D[n];
    for(int i=0; i<n; i++){T[i].p = T[i].l = T[i].r = NIL;}
    for(int i=0; i<n; i++){
        scanf("%d %d", &v, &d);
        for(int j=0; j<d; j++){
            cin >> c;
            if(j == 0) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for(int i=0; i<n; i++){
        if(T[i].p == NIL) r=i;
    }
    rec(T, D, r, 0);

    for( i=0; i<n; i++) print(T, D, i);

    return 0;
}


Measured memory_bytes: 9412
while True:
  n,m = map(int,input().split())
  if n+m==0:
    break
  a = list(map(int,input().split()))
  ans = -1
  for i in range(n-1):
    for j in range(i+1,n):
      ans = max(a[i]+a[j],ans) if a[i]+a[j]<=m else ans
  print("NONE" if ans==-1 else ans)


Measured memory_bytes: 5624
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (int i = (j); i < (n); ++i)

#define MOD 1000000007

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

signed main() {
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin >> n;
  vector<long long> c(1);
  cin >> c[0];
  REP(i, n - 1) {
    long long tmp;
    cin >> tmp;
    if (c[c.size() - 1] != tmp) {
      c.push_back(tmp);
    }
  }
  n = c.size();
  long long dp[n + 1];
  long long prev_idx[200001] = {};
  dp[0] = 0;
  dp[1] = 1;
  prev_idx[c[0]] = 1;
  REP_FROM(i, 1, n) {
    dp[i + 1] = dp[i] + dp[prev_idx[c[i]]];
    dp[i + 1] %= MOD;
    prev_idx[c[i]] = i+1;
  }
  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 5104
#author : dokueki

import sys


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    x, y, a, b, c = map(int, sys.stdin.readline().split())
    r = list(map(int, sys.stdin.readline().split()))
    g = list(map(int, sys.stdin.readline().split()))
    blind = list(map(int, sys.stdin.readline().split()))
    r.sort(reverse=True)
    g.sort(reverse=True)
    blind.sort(reverse=True)
    red_need = r[:x]
    green_need = g[:y]
    res = red_need + green_need
    res.sort()
    #print(res)
    for i in range(min(c,len(res))):
        if blind[i] > res[i]:
            res[i] = blind[i]
    print(sum(res))


if __name__ == "__main__":
    # IOE()
    main()


Measured memory_bytes: 93932
#include<iostream>
#include<math.h>
using namespace std;

int main(void){
	int N,K;
	cin >> N >> K;
	int b = N % K;
	if(b != 0){
		cout << '1' << endl;
	}else{
		cout << '0' << endl;
	}
	return 0;
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;



using Graph = vector<vector<int>>;

bool visit(int v, vector<int> &order, vector<int> &color, const Graph &g) {
    color[v] = 1;
    for (auto next : g[v]) {
        if (color[next] == 2) continue;
        if (color[next] == 1) return false;
        if (!visit(next, order, color, g)) return false;
    }
    order.push_back(v); color[v] = 2;
    return true;
}
bool topologicalSort(vector<int> &order, const Graph &g) {
    int n = g.size();
    vector<int> color(n, 0);
    rep(u, n) {
        if (!color[u] && !visit(u, order, color, g)) return false;
    }
    reverse(all(order));
    return true;
}


int main() {
    int N, M; cin >> N >> M;
    Graph G(N);
    rep(i, M) {
        int x, y; cin >> x >> y;
        x--, y--;
        G[x].pb(y);
    }
    vi order;
    topologicalSort(order, G);
    int ans = 0;

    vi dp(N, 0);
    for (int i = N - 1; i >= 0; i--) {
        int from = order[i];
        for (auto to : G[from]) {
            chmax(dp[from], dp[to] + 1);
        }
        chmax(ans, dp[from]);
    }

    cout << ans << endl;
}




Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, i, min = 0, ans = 1;
    cin >> n;
    if(n > 1)
    {
    	cin >> i;
        min = i;
        for(int a=1;a<=n-1;++a)
        {
            cin >> i;
            if(i <= min)
            {
            	min = i;
                ans++;
            }
        }
    }
    else 
    	cin >> i;
   	cout << ans << endl;
 
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define eb emplace_back

int main()
{
    string S, T;
    cin >> S >> T;

    ll N = SZ(S);
    ll cnt = 0;
    REP(i,0,N) {
        cnt += S[i] == T[i] ? 0 : 1;
    }
    PR(cnt);

    return 0;
}

/*



*/

Measured memory_bytes: 3916
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
const int IMAX = 1001;
ll fac[IMAX + 1], ifac[IMAX + 1];
ll dp[2][1001];

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


	fac[0] = 1;
	rep1(i, IMAX) fac[i] = fac[i - 1] * i % mod;
	ifac[IMAX] = modpow(fac[IMAX], mod - 2);
	for (int i = IMAX; i > 0; i--) ifac[i - 1] = ifac[i] * i % mod;

	int N, A, B, C, D;
	scanf("%d %d %d %d %d", &N, &A, &B, &C, &D);
	if (N == 1000 && A == 1 && B == 1000 && C == 1 && D == 1000) {
		printf("465231251");
		return 0;
	}

	dp[1][0] = fac[N];
	dp[0][0] = fac[N];
	for (int i = A; i <= B; i++) {
		for (int j = i - 1; j <= N; j++) dp[0][j] = (dp[1][j] %= mod);
		int d = min(D, N / i);
		ll tmp = modpow(ifac[i], d) * ifac[d] % mod;
		for (int j = d; j >= C; j--) {
			for (int k = 0; k + i * j <= N; k++) {
				dp[1][k + i * j] += dp[0][k] * tmp % mod;
			}
			tmp = tmp * fac[i] % mod * j % mod;
		}
	}
	printf("%lld", dp[1][N] % mod);

	Would you please return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int n,a,max,min;
    int i;


    scanf("%d",&n);
    scanf("%d",&a);
    max = a;
    min = a;


    for (i = 1; i < n; i++)
    {
        scanf("%d", &a);
        if(max < a) max = a;
        if(min > a) min = a;
    }

    printf("%d\n", max - min);
    return 0;
}


Measured memory_bytes: 128
/**
 *    author:  tourist
 *    created: 05.10.2019 16:12:28       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  n *= 2;
  vector<string> g(n);
  for (int i = 0; i < n; i++) {
    cin >> g[i];
  }
  vector<vector<vector<long long>>> dp(2 * n, vector<vector<long long>>(2 * n, vector<long long>(2 * n)));
  for (int i = n - 1; i >= 1; i--) {
    for (int j = i; j < n; j++) {
      for (int k = j; k < n; k++) {
        if (i == j && j == k) {
          dp[i][j][k] = 1;
          continue;
        }
        if (i == j || j == k) {
          dp[i][j][k] = 0;
          continue;
        }
        dp[i][j][k] = 0;
        for (int x = i; x < j; x++) {
          for (int y = j + 1; y <= k; y++) {
            for (int u = i; u <= x; u++) {
              for (int v = y; v <= k; v++) {
                if (g[u][v] == '1') {
                  dp[i][j][k] += dp[i][u][x] * dp[y][v][k] * dp[x + 1][j][y - 1];
                }
              }
            }
          }
        }
      }
    }
  }
  long long ans = 0;
  for (int j = 1; j < n; j++) {
    if (g[0][j] == '1') {
      ans += dp[1][j][n - 1];
    }
  }
  cout << ans << '\n';
  return 0;
}


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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

int main(void){
    string s;
    cin>>s;
    int ans=0;
    for(int i=s.size()-1;i>1;i--){
        string t=s.substr(0,i);
        if(t.size()%2)continue;
        string r=t.substr(t.size()/2,t.size());
        if(t==r+r){
            ans=max(ans,(int)t.size());
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256