akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int calc(int x)
{
  int ret = 0;
  while (x % 100 == 0)
  {
    x /= 100;
    ++ret;
  }
  return ret;
}
int main()
{
  int D, N;
  cin >> D >> N;
  int cnt = 0, val = 0;
  while (cnt < N)
  {
    ++val;
    if (calc(val) == D)
      ++cnt;
  }
  cout << val << '\n';
  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
char t1[1510];
char t2[1510];
int main(){
	int i,j;
	int n1,n2;
	int	cnt=0;
	scanf("%s",t1);
	for(i=0;i<strlen(t1);i++){
		t1[i]=tolower(t1[i]);
	}
	while(scanf("%s",t2)){
		if(strcmp(t2,"END_OF_TEXT")==0) break;
		for(i=0;i<strlen(t2);i++){
			t2[i]=tolower(t2[i]);
		}
		if(strcmp(t1,t2)==0) cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 552
#include <iostream>
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
string ans[2][3010];
string a,b;
string comp(string l,string r){
	if(l.size()>r.size())return l;
	return r;
}
int main(){
	cin>>a>>b;
	for(int i=1;i<=a.size();i++){
		for(int j=1;j<=b.size();j++){
			ans[i%2][j]=comp(ans[(i-1)%2][j],ans[i%2][j-1]);
			if(a[i-1]==b[j-1])ans[i%2][j]=comp(ans[i%2][j],ans[(i-1)%2][j-1]+a[i-1]);
		}
	}
	cout<<ans[a.size()%2][b.size()]<<endl;
}


Measured memory_bytes: 16816
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    vector<pair<int,int>>vp;
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++)
    {
        int element=v[i];
        int count=0;
        bool inside=0;
        while(i<n&&v[i]==element){
            count++;
            i++;
            inside=true;
        }
        if(inside){
            i--;
        }
        vp.push_back({v[i],count});
    }
    int maxresult=0;
    for(int i=0;i<vp.size();i++){
        int result=0;
        result+=vp[i].second;
        if(i<vp.size()-1&&vp[i+1].first==vp[i].first+1){
            result+=vp[i+1].second;
        }
        if(i<vp.size()-1&&vp[i+2].first==vp[i].first+2){
            result+=vp[i+2].second;
        }
        if(result>maxresult){
            maxresult=result;
        }
    }
    cout<<maxresult;
}

Measured memory_bytes: 4208
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
K = int(input())
X, Y = map(int, input().split())
if K % 2 == 0 and (X + Y) % 2 == 1:
    print(-1)
    exit() 

def solve(x, y):
    if x < 0:
        dx, dy = solve(-x, y)
        return (-dx, dy)
    if y < 0:
        dx, dy = solve(x, -y)
        return (dx, -dy)
    if x > y:
        dx, dy = solve(y, x)
        return (dy, dx)

    l = x + y
    if l > 2 * K:
        dx = min(x, K)
        dy = K - dx
        return (dx, dy)
    if l == K:
        return x, y
    if l % 2 == 0:
        t = (y - x) // 2
        dx = K - t
        dy = t
        return (dx, dy)
    dx = min(x, K)
    dy = K - dx
    return dx, dy

ans = []
cur_x, cur_y = (0, 0)
while cur_x != X or cur_y != Y:
    dx, dy = solve(X - cur_x, Y - cur_y)
    cur_x += dx
    cur_y += dy
    ans.append((cur_x, cur_y))
print(len(ans))
for x, y in ans:
    print(x, y)

Measured memory_bytes: 32972
N=int(input())
H=list(map(int,input().split()))
ans=0
i = 0

while i < N-1:
  tmp=0
  for j in range(i,N-1):
    if H[j] >= H[j+1]:
      tmp += 1
    else:
      break
  ans = max(ans,tmp)
  i = i + tmp +1
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define fi first
#define se second
#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 rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    map<int, int> m;
    rep(i, 3) {
        int x;
        cin >> x;
        m[x]++;
    }
    cout << (m.size() == 2 ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define p_b push_back
#define pl pair<ll,ll>
#define m_p make_pair
#define MOD 1000000007
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,a,b) for(i=a;i>=b;i--)
#define nfs ios_base::sync_with_stdio(false);cin.tie(NULL)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll h[n];
    ll i;
    for(i=0;i<n;i++)
    {

        cin >> h[i] ;
    }
    ll dp[n];
    dp[n-1] = 0;
    ll maxi = 0;
    for(i=n-2;i>=0;i--)
    {

        if(h[i+1]<=h[i])
        {

            dp[i] = dp[i+1]+1;
        }
        else
        {

            dp[i] = 0;
        }
        maxi = max(maxi,dp[i]);
    }
    cout << maxi << endl;


    return 0;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	
	printf("%d %d %d\n", c, a, b);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define mod 1000000007
#define INF 1000000000000000000
/****************************/
ll a[200010];
ll c[200010];
ll n;
int main()
{
	cin>>n;
	zero(a);
	rep(i,n)
	{
		cin>>c[i];
		a[c[i]]++;
	}
	ll ans=0;
	rep(i,n+1)
	{
		ans+=(ll)(a[i]*(a[i]-1)/2);
	}
	rep(i,n)
	{
		cout<<(ll)(ans-(a[c[i]]-1))<<endl;
	}
	return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

ll ctdigits(ll n)
{
    ll ct=0;
    while(n!=0)
    {
        n=n/10;
        ct++;
    }
    return ct;
}


int main()
{

      ll n,i;
      cin>>n;
      string s;
      cin>>s;
      if(n%2!=0)
      {
          cout<<"No";
      }
      else
      {
          string str1="",str2="";
          for(i=0;i<n;i++)
          {
              if(i<n/2)
              {
                  str1+=s[i];
              }
              else
              {
                  str2+=s[i];
              }
          }
          if(str1==str2)
          {
              cout<<"Yes";
          }
          else
          {
              cout<<"No";
          }
      }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());

		int jpy = 0;
		double btc = 0.0;

		for(int i=0;i<N;i++) {
			String[] s = sc.nextLine().split(" ");
			double x = Double.parseDouble(s[0]);
			String u = s[1];

			if(u.equals("JPY")) {
				jpy += x;
			}else {
				btc += x;
			}
		}
		System.out.println(jpy + (btc * 380000));
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

int main() {
	long long n, a[100000];
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n, greater<long long>());
	long long j = 0, x = 0, y = 0;
	while (!(x > 0 && y > 0) && j < n) {
		if (a[j] == a[j + 1]) {
			if (x == 0)x = a[j];
			else if (y == 0) {
				y = a[j];
				break;
			}
			j += 2;
		}
		else j++;
	}
	cout << x*y << endl;
	return 0;
}

Measured memory_bytes: 1024
<?php
$n=intval(fgets(STDIN));
$list = new SplFixedArray($n+1);
for($i = 0; $i < $n + 1; $i++) {
  $list[$i] = 1000000;
}
$list[0] = 0;

$six_pow = new SplFixedArray(7);
for($i = 0; $i < 7; $i++) {
  $six_pow[$i] = 6 ** ($i + 1);
}

$nine_pow = new SplFixedArray(6);
for($i = 0; $i < 6; $i++) {
  $nine_pow[$i] = 9 ** ($i + 1);
}

for($i = 0; $i < $n; $i++) {
  $list[$i+1] = min($list[$i+1], $list[$i]+1);
  foreach($six_pow as $pow) {
    if ($i + $pow <= $n) {
       $list[$i+$pow] = min($list[$i+$pow], $list[$i]+1);
    }
  }
  foreach($nine_pow as $pow) {
    if ($i + $pow <= $n) {
       $list[$i+$pow] = min($list[$i+$pow], $list[$i]+1);
    }
  }
}
echo $list[$n];

Measured memory_bytes: 6648
n=int(input())
a= (list(map(int,input().split())))
sm1=sm2=0
cnt1=cnt2=0
for i ,num in enumerate(a):
	sm1+=num
	if sm1<=0 and i%2==0:
		cnt1+=1-sm1
		sm1=1
	elif sm1>=0 and i%2!=0:
		cnt1+=1+sm1
		sm1=-1
		
	sm2+=num
	if sm2<=0 and i%2!=0:
		cnt2+=1-sm2
		sm2=1
	elif sm2>=0 and i%2==0:
		cnt2+=1+sm2
		sm2=-1
print(min(cnt1,cnt2))

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  cout << 6 - a - b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<int> a(n), b(n);
	rep(i, 0, n - 1)
	{
		int x; cin >> x;
		a[i] = b[i] = x;
	}
	sort(all(b), greater<int>());
	if (b[0] == b[1])
	{
		rep(i, 0, n - 1)
		{
			cout << b[0] << endl;
		}
	}
	else
	{
		int f, s;
		f = b[0];
		s = b[1];
		rep(i, 0, n - 1)
		{
			if (a[i] == f)
			{
				cout << s << endl;
			}
			else
			{
				cout << f << endl;
			}
		}
	}
}

Measured memory_bytes: 3200
def change(before_tax,after_tax,previous_price):
    original_price = 0
    for i in range(1, previous_price+1):
        if i * (100 + before_tax) // 100 == previous_price:
            original_price = i
            break
        else:
            pass
    return original_price * (100 + after_tax) // 100

ans_list = []

while True:
    x,y,s = [int(x) for x in input().split()]
    if x == 0:
        break
    else:
        ans = 0
        for i in range(1,s):
            price1, price2 = i, s - i
            afterprice = change(x,y,price1) + change(x,y,price2)
            if afterprice > ans:
                ans = afterprice
            else:
                continue
        ans_list.append(ans)

for x in ans_list:
    print(x)


Measured memory_bytes: 5640
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
 

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


    ll ans = 0;
    //while(N > 0){
    //    if(M < 2) break;
    //    M -= 2;
    //    N--;
    //    ans++;
    //}
    ll add;
    add = min(M/2, N);
    ans += add;
    M -= add * 2;
    N -= add;

    //while(M >= 4){
    //    ans++;
    //    M -= 4; 
    //}
    ans += M/4;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner scan = new Scanner(System.in)) {

			String str = scan.next();
			long W = scan.nextLong();
			String[] split = str.split("");

			int sameNum = 1;
			long ans = 0;
			long headTail = 0;
			
			if(split.length == 1) {
				System.out.println(W/2);
				return;
			}
			for (int i = 1; i < split.length; i++) {
				if (split[i - 1].equals(split[i])) {
					sameNum++;
				} else {
					ans += sameNum / 2;
					sameNum = 1;
				}
			}
			ans += sameNum / 2;
			sameNum = 1;

			int headSame = 1;
			boolean changeHead = true;
			for (int i = 0; i < split.length - 1; i++) {
				if (split[i].equals(split[i + 1])) {
					headSame++;
				} else {
					break;
				}
			}
			if(headSame == split.length) {
				System.out.println(headSame*W/2);
				return;
			}
			if (headSame % 2 == 1) {
				changeHead = false;
			}
			int tailSame = 1;
			boolean changeTail = true;
			for (int i = split.length - 1; i > 0; i--) {
				if (split[i].equals(split[i - 1])) {
					tailSame++;
				} else {

					break;
				}
			}
			if (tailSame % 2 == 1) {
				changeTail = false;
			}

			if (split[0].equals(split[split.length - 1]) && !changeHead && !changeTail) {
				headTail = W - 1;
			}
			System.out.println(ans * W + headTail);
		}
	}
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s;
	cin>>n>>s;
	vector<int >r(n+1,0),b(n+1,0),g(n+1,0);
	long long count=0;
	for(int i=1;i<=n;i++){
		if(s[i-1]=='R')r[i]++;
		if(s[i-1]=='B')b[i]++;
		if(s[i-1]=='G')g[i]++;
		r[i]+=r[i-1];
		b[i]+=b[i-1];
		g[i]+=g[i-1];

	}
	for(int i=1;i<=n-2;i++){
		for(int j=i+1;j<=n-1;j++){
			if(s[i-1]==s[j-1])continue;
			int k = 2*j-i;
			if(k>n){
				if(s[i-1]=='R'){
					if(s[j-1]=='G'){
						count+=(b[n]-b[j]);
				}
					else{
						count+=(g[n]-g[j]);
					}
				}
				else if(s[i-1]=='G'){
					if(s[j-1]=='R'){
						count+=(b[n]-b[j]);
					}
					else count+=(r[n]-r[j]);
				}
				else if(s[i-1]=='B'){
					if(s[j-1]=='G'){
						count+=(r[n]-r[j]);
					}
					else count+=(g[n]-g[j]);
				}
				//cout<<i<<' '<<j<<' '<<k<<' '<<count<<'\n';

				continue;
			}
			if(s[i-1]=='R'){
				if(s[j-1]=='G'){
					count+=(b[n]-b[k]+b[k-1]-b[j]);
				}
				else{
					count+=(g[n]-g[k]+g[k-1]-g[j]);
				}
			}
			else if(s[i-1]=='G'){
				if(s[j-1]=='R'){
					count+=(b[n]-b[k]+b[k-1]-b[j]);
				}
				else count+=(r[n]-r[k]+r[k-1]-r[j]);
			}
			else if(s[i-1]=='B'){
				if(s[j-1]=='G'){
					count+=(r[n]-r[k]+r[k-1]-r[j]);
				}
				else count+=(g[n]-g[k]+g[k-1]-g[j]);
			}
			//cout<<i<<' '<<j<<' '<<count<<'\n';
		}
	}
	cout<<count;
}

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

MOD = pow(10, 9) + 7

def make_fact_list(n, MOD):
    # make factorial list from 0 to n
    fact = [0] * (n+1)
    inv = [0] * (n+1)
    factinv = [0] * (n+1)

    fact[0]=fact[1]=1
    inv[1]=1
    factinv[0]=factinv[1]=1

    for i in range(2,n+1):
        fact[i] = fact[i-1] * i % MOD
        inv[i] = MOD - (( inv[MOD % i] *  (MOD // i)) % MOD )
        factinv[i] = factinv[i-1] * inv[i] % MOD
    
    return fact, factinv

def cbn(n, k, MOD, fact = [], factinv = []):
    if len(fact) == 0 and len(factinv) == 0:
        fact, factinv = make_fact_list(n, MOD)
    return fact[n] * factinv[n-k] * factinv[k] % MOD

fact, factinv = make_fact_list(n, MOD)

for i in range(1, k+1):
    if i <= n - k + 1:
        c = cbn(k-1, i-1, MOD, fact, factinv) * cbn(n-k+1, i, MOD, fact, factinv) % MOD
        print(c % MOD)
    else:
        print(0)


Measured memory_bytes: 74612
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
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)]
mod = 1000000007


h, w = LI()
A = LIR(h)
B = LIR(h)
dp = [[0] * w for _ in range(h)]
m = 80 * 160
dp[0][0] = (1 << m) << abs(A[0][0] - B[0][0])
dp[0][0] |= (1 << m) >> abs(A[0][0] - B[0][0])
for y in range(h):
    for x in range(w):
        if y + 1 < h:
            dp[y + 1][x] |= dp[y][x] << abs(A[y + 1][x] - B[y + 1][x])
            dp[y + 1][x] |= dp[y][x] >> abs(A[y + 1][x] - B[y + 1][x])
        if x + 1 < w:
            dp[y][x + 1] |= dp[y][x] << abs(A[y][x + 1] - B[y][x + 1])
            dp[y][x + 1] |= dp[y][x] >> abs(A[y][x + 1] - B[y][x + 1])


ans = INF
for j in range(m * 2):
    if dp[h - 1][w - 1] >> j & 1:
        ans = min(ans, abs(j - m))


print(ans)





Measured memory_bytes: 65880
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
//
// using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a;
  cin >> n >> a;
  n %= 500;
  if(n <= a) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
N, M = map(int,input().split())

#N桁の数字
number = [-1 for _ in range(N)] 

for i in range(M):
    s,c = map(int,input().split())

    if number[s-1] == -1 or number[s-1] == c:
        number[s-1] = c
    else:
        #already exists
        print(-1)
        exit()

#1桁の場合
if N == 1:
    if number[0] == -1:
        print(0)
    else:
        print(number[0])
    exit()

#2桁以上の場合の最上位チェック
if number[0] == 0:
    print(-1)
    exit()

#最上位の-1は1に置換、それ以外は0に置換
if number[0] == -1:
    number[0] = 1    
for i in range(1,N):
    if number[i] == -1:
        number[i] = 0

if N == 2:
    print(number[0]*10+number[1])
    exit()
if N == 3:
    print(number[0]*100+number[1]*10+number[2])
    exit()


Measured memory_bytes: 38256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=305;
int f[N][N][N],n,m;
int main(){
	scanf("%d%d",&n,&m);
	f[0][1][1]=1;
	fp(i,0,m-1)fp(j,1,min(n,i+1))fp(k,1,j)if(f[i][j][k]){
		upd(f[i+1][j+1][k],mul(f[i][j][k],n-j));
		upd(f[i+1][j][k],mul(f[i][j][k],j-k));
		upd(f[i+1][j][j],mul(f[i][j][k],k));
	}
	printf("%d\n",f[m][n][n]);
	return 0;
}

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

class Program
{
    static void Main()
    {
        Scanner cin = new Scanner();
        int N = cin.Int();
        Console.WriteLine(N*N*N);
        Console.ReadLine();
    }

}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}



Measured memory_bytes: 15940
class Array
    include Comparable
end

N, M = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

num = [-1,2,5,5,4,5,6,3,7,6]
mx = Array.new(8, -1)
as.each do |a|
    mx[num[a]] = [mx[num[a]], a].max
end

dp = Array.new(N+10, -10**9)
use = Array.new(N+10)
dp[0] = 0
use[0] = Array.new(10, 0)
(0..N).each do |i|
    next if dp[i] < 0
    (2..7).each do |n|
        next if mx[n] < 0
        d2 = dp[i] + 1
        use2 = use[i].dup
        use2[9-mx[n]] += 1
        if dp[i+n] < d2 || (dp[i+n] == d2 && use[i+n] < use2)
            dp[i+n] = d2
            use[i+n] = use2
        end
    end
end

ans = ""
(0..9).each do |i|
    use[N][i].times do
        ans << (9-i).to_s
    end
end
puts ans

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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))

vi ad[200009];
int dis[200009];
bool vis[200009];

void dfs(int x)
{
    vis[x] = 1;

    for(auto u : ad[x])
    {
        if(!vis[u] && dis[x]+1 < dis[u])
        {
            dis[u] = dis[x]+1;
            dfs(u);
        }
    }
}

int main()
{

    int n,m,i,j,k,l,u,v;

    cin >> n >> m;

    for(i=0;i<m;i++)
    {
        cin >> u >> v;

        ad[u].pb(v);
        ad[v].pb(u);
    }

   bool faltu = false;

   for(auto x : ad[1])
   {
       if(x == n)faltu = true;

       for(auto kk : ad[x])
       {
           if(kk == n)faltu = true;
       }
   }
    if(faltu)cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
//    ll i,j,k,n,x,m;
//
//    cin >> n>> x;
//ll ar[n+10];
//
//ll cnt = 0;
//    for(i=0;i<n;i++)
//    {
//        cin >> ar[i];
//    }
//
//    for(i=1;i<n;i++)
//    {
//        m = ar[i]+ar[i-1];
//        if(m>x)
//        {
//            ll baki = m-x;
//
//            ar[i] -= baki;
//            cnt += baki;
//        }
//    }
//
//    cout << cnt << endl;
}


Measured memory_bytes: 15048
// #pragma GCC optimize "trapv" Uncomment when dealing with huge numbers
/*<----------PBDS---------->

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
template <typename T>
using order_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

order_set<datatype>oset;
Kth smallest : *oset.find_by_order(k-1); // 0 based index
No of elements less than k : oset.order_of_key(k);
Erase X : oset.erase(x)
<----------PBDS---------->*/
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
	int x,y,z;
	cin >> x >> y >> z;
	int a = x;
	int b = y;
	int c = z;
	swap(a,b);
	swap(a,c);
	cout << a << " " << b << " " << c;
}





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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b,c; cin>>a>>b>>c;
    cout<<a[0]<<b[1]<<c[2]<<endl;;
}

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


int main(){
      map<string, int> x;
      int N;cin >> N;
      int Max=0;
      string S[N];

      for(int i=0;i<N;i++){
            cin >> S[i];
            x[S[i]] ++;
            Max = max(x[S[i]], Max);
      }
      
      for(auto i=x.begin();i != x.end();i++){
            if(i->second == Max)cout << i->first << endl;
      }
}


Measured memory_bytes: 26752
N = int(input())
arr = [list(map(int,input().split())) for i in range(N)]
arr = sorted(arr, key=lambda x: x[0])
F = [True]*N
P = [0]*N
for i in range(N):
  P[i] = [arr[i][0]-arr[i][1], arr[i][0]+arr[i][1]]
P = sorted(P,key=lambda x:x[1])
ind = 0
for i in range(1,N):
  if P[i][0] < P[ind][1]:
    F[i] = False
  else:
    ind = i
print(F.count(True))

Measured memory_bytes: 43828
from bisect import *
while 1:
    n, lmt = map(int, raw_input().split())
    if n == 0: break
    p = [input() for i in range(n)] + [0]
    p = sorted(set(i + j for i in p for j in p))
    s = bisect(p, lmt)
    print max(i + p[bisect(p, lmt - i) - 1] for i in p[:s])

Measured memory_bytes: 50664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int a = 0;
		int b = 0;
		int n = 0;
		String c;
		char d[] = new char[] {'S', 'H', 'C', 'D'};
		boolean cards[][] = new boolean[4][13];

		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();

		for(int i=0; i<n; i++) {
			c = sc.next();  //マークの読み込み
			b = sc.nextInt() - 1;  //数字の読み込み

			switch(c) {
				case "S":
					a = 0;
					break;
				case "H":
					a = 1;
					break;
				case "C":
					a = 2;
					break;
				case "D":
					a = 3;
					break;
			}

			for(int j=0; j<4; j++) {
				for(int k=0; k<13; k++) {
					if(j == a && k == b) {
						cards[j][k] = true;
					}
				}
			}
		}

		for(int i=0; i<4; i++) {
			for(int j=0; j<13; j++) {
				if(cards[i][j] == false) {
					System.out.print(d[i] + " ");
					System.out.println(String.format("%d",j+1));
				}
			}
		}

	}
}



Measured memory_bytes: 26460
# 解答
N, K  = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

def check(L):
  count = 0
  for a in A:
    if a <= L:
      break      
    count += (a-1)//L
    if count > K:
      return False

  return True

l = 0
r = A[0]

while r-l > 1:
  c = (r+l)//2
  if check(c):
    r = c
  else:
    l = c
print(r)

Measured memory_bytes: 30716
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
const int MAXN = 1e5+5,MAXM = 2e5+5,MOD = 20130427,INF = 0x3f3f3f3f,N=100050;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const db eps = 1e-9;
#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define mid l + ((r-l)>>1)
#define rep(i,a,b) for(register int i=(a);i<=(b);i++)
#define vii vector<pair<int,int>>
#define vi vector<int>
using namespace std;

int A,B,C;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    //freopen("../A.in","r",stdin);
    //freopen("../A.out","w",stdout);
    cin>>A>>B>>C;
    int ans=0;
    int t= min(C,A);
    C-=t;A-=t;
    ans=t;
    t=min(C,B);
    ans+=t*2;
    C-=t;B-=t;
    if(C)ans++;
    else ans+=B;
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>
 
const int64_t cc = pow( 10, 9 );
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< std::string, int64_t > origin, std::pair< std::string, int64_t > another )
{
    return origin.second  > another.second;
}
 
int main()
{
    std::string word = "aa";
    int64_t a,b,c,d,e;
    std::cin>> a;
    std::vector< int64_t > list9;
    std::vector< int64_t > list6;
    b = 9;
    c = 0;
    e = -1;

    while( a >= b )
    {
        list9.push_back( b );
        b *= 9;
    }

    b = 6;

    while( a >= b )
    {
        list6.push_back( b );
        b *= 6;
    }

    list6.push_back( 1 );
    list9.push_back( 1 );
    std::sort( list6.begin(), list6.end() );
    std::sort( list9.begin(), list9.end() );
    int64_t min = 100000;
    
    for( int i = 0; i <= a; i++ )
    {
        b = 1;
        c = 0;
        e = list9.size() - 1;
        int64_t cc = i;

        while( cc != 0 )
        {
            if( list9[e] <= cc )
            {
                cc -= list9[e];
                c += 1;
            }
            else
            {
                e -= 1;
            }
        }

        cc = a - i;
        e = list6.size() - 1;
        
        while( cc != 0 )
        {
            if( list6[e] <= cc )
            {
                cc -= list6[e];
                c += 1;
            }
            else
            {
                e -= 1;
            }
        }

        min = std::min( c, min );
    }
    
    std::cout<< min <<"\n";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 1000

int top, new_num[MAX];
void push(int);
int pop(void);
int isEmpty(void);
int isFull(void);

int main(){
  int x, y, X;
  char num[MAX];

  /*スタックポインタを表す整数型変数*/
  top = 0;
  while( scanf("%s", num) != EOF ){

    if ( num[0] == '+' ){
      x = pop();
      y = pop();
      push(x + y);
    }

    else if ( num[0] == '-' ){
      x = pop();
      y = pop();
      push(y - x);
    }

    else if ( num[0] == '*' ){
      x = pop();
      y = pop();
      push(x * y);
    }

    else {
      X = atoi(num);
      push(X);
    }
  }
  printf("%d\n", pop());

  return 0;
}


/*top を 1 つ増やし、S[top] に x を代入します。*/
void push(int x){
 
  if(isFull()){
printf("overflow\n");
 exit(1);
}
  top++;
  new_num[top] = x;
}


/*S[top] の値を返し、top を１つ減らします。*/
int pop(){

  if(isEmpty()){
printf("underflow");
 exit(1);
}

top--;
return new_num[top+1];
}

int isEmpty(){
  return top==0;
}

int isFull(){
  return top >= MAX -1;
}

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

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

int main() {
  int a[3];
  rep(i, 3) cin >> a[i];
  sort(a, a + 3);
  cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
  return 0;
}



Measured memory_bytes: 3116
#include <iostream>

using namespace std;

int main(int argc, const char *argv[])
{
  using ll = long long;
  ll n, k;
  cin >> n >> k;
  ll d = n / k;
  ll ans = min(n - d * k, abs(n - (d + 1) * k));
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))

i_ai_list = []
for index, a in enumerate(a_list):
    i_ai_list.append((index + 1, a))

i_ai_list_sorted = sorted(i_ai_list, key=lambda  x: x[1])
output_list = [i[0] for i in i_ai_list_sorted]
#print(output_list)
print(' '.join(list(map(str, output_list))))

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main() {
  string s; cin >> s;
  sort(ALL(s));
  if (s == "abc") cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int x,y,an,fc,dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};

void fill(int (*d)[10],int c,int cr,int fx,int fy) {
	int i;
	for (i=0;i<4;i++) {
      if (fx+dx[i]>=0 && fx+dx[i]<x && fy+dy[i]>=0 && fy+dy[i]<y) {
		  if (d[fy+dy[i]][fx+dx[i]]==c) {
			   fc++; d[fy+dy[i]][fx+dx[i]]=cr; fill(d,c,cr,fx+dx[i],fy+dy[i]);
		   }
	   }
   }
 } 		 

int ans(int (*s)[10],int cr,int g) {
	int i,j,k,d[10][10];
	for (i=1;i<3;i++) {
		 fc=1;
		 for (j=0;j<y;j++) for (k=0;k<x;k++) d[j][k]=s[j][k];
		 d[0][0]=(cr+i) % 3; fill(d,cr,(cr+i) % 3,0,0); if (fc==x*y) { an=g; return 1;}
		 if (g<an) ans(d,(cr+i) % 3,g+1);
	 } 
	 return 0;
}

int main() {
	char c;
	int i,j,s[10][10];
	while(cin >> x >> y && x+y>0) {
		for (i=0;i<y;i++) for (j=0;j<x;j++) { cin >> c; if (c=='R') s[i][j]=0;	 if (c=='G') s[i][j]=1;	 if (c=='B') s[i][j]=2;}
		an=100; ans(s,s[0][0],0);
		cout << an << endl;		
	}
	
	return 0;
} 

Measured memory_bytes: 1176
S = input()
T = input()

ans = len(T)
for i in range(len(S)-len(T)+1):
    cnt = 0
    for j in range(len(T)):
        if T[j] != S[i:i+len(T)][j]:
            cnt += 1
    ans = min(ans, cnt)

print(ans)


Measured memory_bytes: 8976
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int a=0,sum=0;
int main(void){
	for(int i=0;i<4;i++){
		cin>>a;
		sum+=a;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3096
e=enumerate
h,w=map(int,input().split())
a=[list(map(int,input().split()))for _ in range(h)]
b=[list(map(int,input().split()))for _ in range(h)]
dp=[0]*w
c=13000
for i,(a,b)in e(zip(a,b)):
  for j,(x,y)in e(zip(a,b)):
    x=abs(x-y)
    if i==j==0:
      dp[j]=2**c<<x
      continue
    t=0
    if j:
      t|=dp[j-1]<<x
      t|=dp[j-1]>>x
    if i:
      t|=dp[j]<<x
      t|=dp[j]>>x
    dp[j]=t
*a,=map(int,(bin(dp[w-1])[2:]).zfill(26001))
print(min([i for i,f in e(a[13000:])if f]+[i for i,f in e(a[13000::-1])if f]))

Measured memory_bytes: 4644
#include <string>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <cmath>
#include <cassert>
#include <queue>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>

#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()

using namespace std;

typedef long long int64;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef __int128 int128;

const int L = 20;
const int mod = 998244353;

int d[1 << (L + 1)];
map<int128, int> D;

int d0[1 << (L + 1)];
map<int128, int> D0;

int128 encode(const string& s) {
  int128 res = 0;
  for (int i = 0; i < sz(s); ++i)
    if (s[i] == '1') res |= (((int128) 1) << (int128) i);
  res |= (((int128) 1) << (int128) sz(s));
  return res;
}

int encode_short(const string& s) {
  int res = 0;
  for (int i = 0; i < sz(s); ++i)
    if (s[i] == '1') res |= (1 << i);
  res |= (1 << sz(s));
  return res;
}

int calc(string s);
int calc0(string s);

int calc(string s) {
  if (sz(s) == 1) return s[0] == '1' ? 2 : 1;
  int ikey;
  int128 lkey;
  if (sz(s) < L) {
    ikey = encode_short(s);
    if (d[ikey] != -1) return d[ikey];
  } else {
    lkey = encode(s);
    auto it = D.find(lkey);
    if (it != D.end())
      return it->second;
  }

  int res = calc0(s);
//  if (s == "0000") cerr << "step 0: " << res << "\n";
  for (int i = 1; i < sz(s); ++i) {
    int64 cur = (int64) calc0(s.substr(0, i)) * (int64) calc(s.substr(i));
//    if (s == "0000") cerr << "step " << i << ": " << cur << "\n";
//    if (s == "0000" && i == 2) cerr << calc0(s.substr(0, i)) << " " << calc(s.substr(i)) << "\n";
    res += (int) (cur % mod);
    res %= mod;
  }
//  cerr << s << " " << res << "\n";
  if (sz(s) < L) {
    d[ikey] = res;
  } else {
    D[lkey] = res;
  }
  return res;
}

int calc0(string s) {
  if (sz(s) == 1) return s[0] == '1' ? 2 : 1;
  int ikey;
  int128 lkey;
  if (sz(s) < L) {
    ikey = encode_short(s);
    if (d0[ikey] != -1) return d0[ikey];
  } else {
    lkey = encode(s);
    auto it = D0.find(lkey);
    if (it != D0.end())
      return it->second;
  }

  int res = 0;
  for (int i = 1; i < sz(s); ++i) if (sz(s) % i == 0) {
    string ns(i, '1');
    for (int j = 0; j < sz(s); ++j)
      if (s[j] == '0') ns[j % i] = '0';
    res += calc(ns);
    res %= mod;
  }

//  cerr << "0: " << s << " " << res << "\n";

  if (sz(s) < L) {
    d0[ikey] = res;
  } else {
    D0[lkey] = res;
  }
  return res;
}

int main() {
  memset(d, -1, sizeof(d));
  memset(d0, -1, sizeof(d0));
  string s;
  cin >> s;
  cout << calc(s) << "\n";
  return 0;
}

Measured memory_bytes: 19328
#include <iostream>

int main(int argc, char *argv[]) {
  std::string s, t;
  std::cin >> s >> t;
  int count = 0;
  for (int i = 0; i < (int)s.size(); ++i) {
    if (s.at(i) != t.at(i))
      count++;
  }
  std::cout << count << std::endl;
}


Measured memory_bytes: 3472
a, b, c, k = map(int, input().split())

ans = 0
if a >= k:
    print(k)
    exit()
else:
    ans += a
    k -= a

if b >= k:
    print(ans)
    exit()
else:
    k -= b

if c >= k:
    ans -= k
    print(ans)
    exit()
else:
    ans -= k
    print(ans)


Measured memory_bytes: 9188
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/

ll ans(ll k){
   if(k==1) return 2;
   return ans(k-1)*2%MOD;
}
ll Ans(ll k){
    ll b=1;
    repf(i,1,k+1){
        b*=2;
        b%=MOD;
    }
    return b;
}

int main(){
    string s;
    string s1,s2,s3,s4;
    s1="dream";
    s2="draeamer";
    s3="erase";
    s4="eraser";
    cin>>s;
    while(1){
        if(s.size()>=5){
            if(s.substr(s.size()-5,5)=="dream"){
                s.erase(s.size()-5,5);
            }else if(s.substr(s.size()-5,5)=="erase"){
                s.erase(s.size()-5,5);
            }else if(s.size()>=6){
                if(s.substr(s.size()-6,6)=="eraser"){
                    s.erase(s.size()-6,6);
                }else if(s.size()>=7){
                    if(s.substr(s.size()-7,7)=="dreamer"){
                        s.erase(s.size()-7,7);
                    }else{
                        cout<<"NO"<<endl;
                        return 0;
                    }
                }
            }
        }else if(s.size()==0){
            break;
        }else {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

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

namespace ConsoleApplication
{
    class Program
    {
        static void Main()
        {
            new Solution().process();
        }
    }

    class Solution
    {
        string input;
        public Solution()
        {
            input = Console.ReadLine();
        }

        public void process()
        {
            string right, left;
            int len, answer;
            input = input.Substring(0, input.Length - 1);
  
            if (input.Length % 2 == 1) { input = input.Substring(0, input.Length - 1); }
            len = input.Substring(0, input.Length / 2).Length;

            int i;

            if (input.Length < 2)
            {
                Console.WriteLine(0);
            }
            else
            {
                for (i = 0; i <= len; i++)
                {
                    left = input.Substring(0, input.Length / 2);
                    right = input.Substring(input.Length / 2, input.Length / 2);
                    if (left == right)
                    {
                        answer = left.Length + right.Length;
                        i = len + 1;
                        Console.WriteLine(answer);
                    }
                    else
                    {
                        input = input.Substring(0, input.Length - 2);
                    }
                }

            }
        }
    }
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

class UnionFind {
public:
  UnionFind(int n) {
    r.resize(n, 0);
    s.resize(n, 1);
    p.resize(n);
    for (int i = 0; i < n; ++i) {
      p[i] = i;
    }
  }
  void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if (a == b) {
      return ;
    }
    int c = s[a] + s[b];
    s[a] = s[b] = c;
    if (r[a] > r[b]) {
      p[b] = a;
    } else {
      p[a] = b;
      if(r[a] == r[b]) r[b]++;
    }
    return ;
  }
  int find(int a) {
    return (a == p[a]) ? a : p[a] = find(p[a]);
  }
  bool same(int a, int b) {
    return find(a) == find(b);
  }
  size_t size(int n) {
    return s[find(n)];
  }
private:
  vector<int> r, p, s;
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n, m;
  while (cin >> n >> m) {
    vector<pair<int, int>> v(m);
    cin >> v;
    reverse(v.begin(), v.end());

    UnionFind uf(n + 1);

    vector<lli> u;
    lli x = (n - 1) * n / 2;
    each (e, v) {
      u.push_back(x);
      if (uf.same(e.first, e.second)) {
        continue;
      }
      
      x += (uf.size(e.first) - 1LL) * uf.size(e.first) / 2;
      x += (uf.size(e.second) - 1LL) * uf.size(e.second) / 2;

      uf.unite(e.first, e.second);

      x -= (uf.size(e.first) - 1LL) * uf.size(e.first) / 2;
    }
    reverse(u.begin(), u.end());
    each (i, u) cout << i << endl;
  }

  return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int count_str(string str1, string str2)
{
    int ans = 0;
    for(char c = 'a'; c <= 'z'; c++)
    {
        bool found_left = false;
        bool found_right = false;

        REP(i, str1.length())
        {
            if (str1[i] == c)
            {
                found_left = true;
            }
        }

        REP(i, str2.length())
        {
            if (str2[i] == c)
            {
                found_right = true;
            }
        }

        if (found_left && found_right)
        {
            ans++;
        }
    }

    return ans;
}

int main()
{
    int n = 0;

    cin >> n;
    ll ans = 1;
    for (int i = 1; i <= n; i++)
    {
        ans *= i;
        if (ans > 100000)
        {
            ans %= MOD;
        }
    }


    COUT(ans % MOD);

    return 0;
}

Measured memory_bytes: 256