akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 29;
const int MOD = 1000000007;

int main() {
    // 右側から見ていくとかならずいいボールの入れ方が存在することが分かる
    // (i) iの倍数がないとき
    // a=1 => ボールを入れる
    // a=0 => ボールは入れない
    // (ii) iの倍数があるとき
    // 自身を除く倍数のボールの数が奇数個
    // & a=1 => ボールは入れない
    // & a=0 => ボールを入れる
    // 偶数個ならばボールを入れる入れないを逆転する

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a.at(i);
    }

    // ボールが入っているかどうか
    vector<bool> ball(n, false);
    // ボールを入れた箱の番号を記録
    vector<int> in_ball;
    long long ball_num = 0;

    // 後ろから見ていく(n~1)
    for (int i = n; i >= 1; i--) {
        // 自身を除く倍数のボールが何個かを数える
        int count = 0;
        for (int j = 2 * i; j <= n; j += i) {
            // indexは-1する
            if (ball.at(j - 1) == true) {
                count++;
            }
        }

        // 倍数なしのときも含む
        // 偶数個でa=1のときと奇数個でa=0のときボールを入れる
        if ((count % 2 == 0 && a.at(i - 1) == 1) || (count % 2 == 1 && a.at(i - 1) == 0)) {
            ball.at(i - 1) = true;
            // ボールを入れる場合その箱の番号を記録
            in_ball.push_back(i);
            ball_num++;
        }
    }

    cout << ball_num << endl;
    for (auto v : in_ball) {
        cout << v << " ";
    }
}


Measured memory_bytes: 4608
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

ll powmod(ll a, ll e) {
  ll sum = 1;
  ll cur = a;
  while (e > 0) {
    if (e % 2) {
      sum = sum * cur % mod;
    }
    cur = cur * cur % mod;
    e /= 2;
  }
  return sum;
}

const int DEBUG = 0;
const int N = 1010;
ll dp[N][N];
ll fact[N];
// dp[k]:= the number of way to do in the first k persons
int main(void){
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  fact[0] = 1;
  REP(i, 1, N) {
    fact[i] = fact[i - 1] * i % mod;
  }
  REP(i, a - 1, b) {
    dp[0][i] = 1;
  }
  REP(i, 1, n + 1) {
    dp[i][a - 1] = 0;
    REP(j, a - 1, b) {
      ll sum = 0;
      int u = j + 1;
      REP(f, c, d + 1) {
	if (u * f <= i) {
	  ll tmp = dp[i - u * f][u - 1];
	  // divide by (u!)^f * f!
	  ll tmp2 = fact[f];
	  tmp2 = tmp2 * fact[i - u * f] % mod;
	  // TLE
	  tmp2 = tmp2 * powmod(fact[u], f) % mod;
	  tmp2 = fact[i] * powmod(tmp2, mod - 2) % mod;
	  tmp = tmp * tmp2 % mod;
	  if (DEBUG) {
	    cout << "(u, f)=" << u << ", " << f << endl;
	    cout << "tmp=" << tmp << endl;
	    cout << "tmp2=" << tmp2 << endl;
	  }
	  sum += tmp;
	}
      }
      sum += dp[i][j];
      sum %= mod;
      dp[i][u] = sum;
      if (DEBUG) {
	cerr << "dp[" << i  << "," << u << "]=" << dp[i][u] << endl;
      }
    }
  }
  ll tmp = 0;
  cout << dp[n][b] << endl;
}


Measured memory_bytes: 8192
import math
x, k, d = map(int, input().split())
mx = x + k*d
mn = x - k*d
ans = min(abs(mx), abs(mn));
p = abs(x)//d
# print(p)
l = max(p-1, 0)
r = min(p+1, k)
for n in range(l, r+1):
	rem = k - n
	mx = x + n*d
	mn = x - n*d
	# print(n, rem, mx, mn)
	if rem % 2 == 0:
		# print("here", mn, " ", mx)
		ans = min(ans, abs(mx), abs(mn))
	else:
		ans = min(ans, abs(mx+d), abs(mn+d));
		ans = min(ans, abs(mx-d), abs(mn+d));
		ans = min(ans, abs(mx+d), abs(mn-d));
		ans = min(ans, abs(mx-d), abs(mn-d));

print(ans)


Measured memory_bytes: 9252
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << '\n'
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 998244353;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;

using mint = static_modint<mod>;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    vi p(n);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }

    mint sum1 = 0;
    mint sum2 = 0;
    mint z = mint(k-1)/mint(k);
    mint zinv = z.inv();
    mint x = 1;
    mint xinv = 1;
    fenwick_tree<int> t(n);
    fenwick_tree<mint> tw(n);
    rep(i, n) {
        if (i>=k) {
            x *= z;
            xinv *= zinv;
        }
        sum1 += tw.sum(0, p[i])*x/mint(2);
        sum2 += t.sum(p[i]+1, n)-tw.sum(p[i]+1, n)*x/mint(2);
        t.add(p[i], 1);
        tw.add(p[i], xinv);
    }
    mint ans = sum1 + sum2;
    pr(ans.val());

    
    return 0;
}


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

typedef complex<double> P;
#define PI acos(-1)
#define EPS 1e-10
#define INF 1e9

int N;
P p[300];

int solve()
{
	int ans = 1;

	rep(i, 0, N) rep(j, i + 1, N)
	{
		double dd = abs(p[i] - p[j]);

		if (2.0 < dd - EPS) continue;

		P vec = p[i] - p[j];
		P m = p[i] + p[j]; m /= 2.0;
		P grad = P(-imag(vec), real(vec));
		grad /= abs(grad);

		P c = m + grad * sqrt(1 - abs(vec) * abs(vec) / 4.0);

		int cnt = 0;
		rep(k, 0, N)
		{
			double d = abs(p[k] - c);
			if (d <= 1.0 + EPS) cnt++;
		}
		ans = max(ans, cnt);

		c = m - grad * sqrt(1 - abs(vec) * abs(vec) / 4.0);

		cnt = 0;
		rep(k, 0, N)
		{
			double d = abs(p[k] - c);
			if (d <= 1.0 + EPS) cnt++;
		}
		ans = max(ans, cnt);
	}

	return ans;
}

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

	while (1)
	{
		cin >> N;
		if (N == 0) return 0;

		rep(i, 0, N)
		{
			double x, y; cin >> x >> y;
			p[i] = P(x, y);
		}

		cout << solve() << endl;
	}
}

Measured memory_bytes: 3268
N,M=map(int,input().split())
X=sorted(set(list(map(int,input().split()))))
s=[]
if M<N:
    print(0)
    exit()
for i in range(M-1):
    s.append(X[i+1]-X[i])
s=sorted(s)
print(sum(s[:M-N]))

Measured memory_bytes: 14936
import java.util.Scanner;
 public class Main{

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       while(true){
           int H = sc.nextInt();
           int W= sc.nextInt();
        for( int i = 0; i<H; i++ ){
            for( int n = 0; n<W; n++ ){
                if(i==0||i==H-1||n==0||n==W-1){
                 System.out.print("#");
                }else{
                 System.out.print(".");
                }
            }
        System.out.println();
       }
        if(H==0&&W==0)break;   
         System.out.println();

       }
	}
 }


Measured memory_bytes: 32284
#include <bits/stdc++.h>
#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
const int INF = 1e9 + 7;
const ll LINF = 1e18 + 14;

vector<vector<int> > G;
vector<int> used;

bool dfs(int v){
    used[v] = 1;
    for (int i = 0; i < G[v].size(); i++){
        int to = G[v][i];
        if (used[to] == 1)
            return true;
        else if (!used[to] && dfs(to))
                return true;
    }
    used[v] = 2;
    return false;
}

int main(){
    ios_base::sync_with_stdio(false); //cin.tie(nullptr); cout.tie(nullptr);
    int n, m;
    cin >> n >> m;
    G.resize(n);
    used.resize(n);
    for (int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].PB(b);
    }
    
    int ans = 0;
    vector<int> del(n, 0);

    bool f = 0;
    for (int j = 0; j < n; j++)
        if (!used[j])
            f = f || dfs(j);
    if (!f){
        cout << -1;
        return 0;
    }
    
    for (int i = 0; i < n; i++){
        del[i] = 2;
        for (int j = 0; j < n; j++)
            used[j] = del[j];
        bool b = 0;
        for (int j = 0; j < n; j++)
            if (!used[j])
                b = b || dfs(j);
        if (!b){
            del[i] = 0;
            ans++;
        }
    }

    cout << ans << endl;
    for (int i = 0; i < n; i++){
        if (!del[i])
            cout << i + 1 << endl;
    }
    return 0;
}  


Measured memory_bytes: 512
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

void solve(){
	string s;
	cin>>s;
	if(s== "AAA" or s == "BBB"){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
	return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll no;
	// cin>>no;
	no = 1;
	while(no--){
		solve();
	}
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int box[100001];
int main(void)
{
	int MIN,i,w,h,n,x,y,MAX,flg;
	scanf("%d %d %d",&w,&h,&n);
	for(i=0;i<w;i++){
		box[i]=0;
	}
	for(i=0;i<n;i++){
		scanf("%d %d",&x,&y);
		box[x]=max(y,box[x]);
		if(x!=0&&y!=0){
			flg=1;
			}
	}
	if(flg==0){
		printf("0\n");
	}
	else{
	MIN=10000001;
	MAX=0;
	for(i=w-1;i>=0;i--){
			MIN=min(MIN,MAX+i);
			MAX=max(MAX,box[i]);
	}
	}
	printf("%d\n",MIN);
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const long long INF = 9223372000000000000/2145;
//static const int INF = 1000010000;
//static const int NIL = -1;
//static const int MOD = 1000000007;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
//#define int ll

signed main(){
    int x,a,b;
    scanf("%d%d%d",&x,&a,&b);

    if(b-a<=0) puts("delicious");
    else if(b-a<=x) puts("safe");
    else puts("dangerous");
    return 0;
}

Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
xy=array(N)
N.times do|i|
    xy[i]=get_i
end
kind={}
N.times do|i|
    N.times do|j|
      next if i==j
      dx=xy[i][0]-xy[j][0]
      dy=xy[i][1]-xy[j][1]
      kind[dy]=Hash.new(0) if kind[dy].nil?
      kind[dy][dx]+=1
    end
end
ans=N
kind.each do|_,arr|
    arr.each do|k,v|
      ans=N-v if ans>N-v
    end
end
puts ans

Measured memory_bytes: 14560
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long co = 0;
		HashMap<String, Long> l = new HashMap<String, Long>();
		for (int i = 0; i < N; i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			String S = new String(c);
			if (l.containsKey(S)) {
				l.put(S, l.get(S) + 1);
				co += l.get(S);
			} else {
				l.put(S, (long) 0);
			}
		}
		sc.close();
		System.out.println(co);
	}

}

Measured memory_bytes: 68860
#include <stdio.h>

int main()
{
	int point[5];
	int k;

	for (int i = 0; i < 5; i++) {
		scanf("%d", &point[i]);
	}
	scanf("%d", &k);

	if (point[4] - point[0] > k) {
		printf(":(\n");
	}
	else {
		printf("Yay!\n");
	}

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
const int MAXN = 2005;
int n, k, q, ans = 1e9, x, y, val;
int A[MAXN];
vi V, current;

void input() {
	cin >> n >> k >> q;
	for (int i = 0; i < n; i++)
		cin >> A[i];
	A[n] = -1;
}

void solve() {
	for (int i = 0; i < n; i++) {
		x = A[i];
		for (int j = 0; j <= n; j++) {
			val = A[j];
			if (val < x) {
				sort(current.begin(), current.end());
				reverse(current.begin(), current.end());
				for (int pos = current.size() - 1; pos >= k - 1; pos--)
					V.PB(current[pos]);
				current.clear();
				current.shrink_to_fit();
			}
			else {
				current.PB(val);
			}
		}
		sort(V.begin(), V.end());
		if (V.size() >= q) {
			ans = min(ans, V[q - 1] - x);
		}
		V.clear();
		V.shrink_to_fit();
		current.clear();
		current.shrink_to_fit();
	}
	cout << ans << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);

	input();
	solve();
	
	return 0;
}


Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N, M;
    std::cin >> N >> M;

    struct C {
        int64_t x;
        int64_t y;
        int64_t z;
    };

    std::vector<C> cake;
    for (decltype(N) i = 0; i < N; ++i) {
        C t;
        std::cin >> t.x >> t.y >> t.z;
        cake.push_back(t);
    }

    std::vector<int64_t> ans;

    for (uint32_t i = 0; i < 8; ++i) {
        int64_t xop = ((i >> 2) & 1) ? 1 : -1;
        int64_t yop = ((i >> 1) & 1) ? 1 : -1;
        int64_t zop = ((i >> 0) & 1) ? 1 : -1;

        std::vector<int64_t> cak;
        for (size_t j = 0; j < N; ++j) {
            cak.push_back(cake[j].x * xop + cake[j].y * yop + cake[j].z * zop);
        }

        std::sort(std::begin(cak), std::end(cak),
                  [](const auto& a, const auto& b) {
                      return a > b;
                  });

        int64_t sum = 0;
        for (int64_t j = 0; j < M; ++j) {
            sum += cak[j];
        }
        ans.push_back(sum);
    }

    std::cout << *std::max_element(ans.begin(), ans.end()) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

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

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(S == T) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inp_ll;

const int MAXN = 100010;
const int INF = 1000000000;

ll gcd(ll a, ll b)
{
	return b ? gcd(b, a%b) : a;
}

bool solve(ll A, ll B, ll C, ll D)
{
	if (A < B) return false;
	if (D < B) return false;
	if (C >= B) return true;
	A %= B;
	if (C < A) return false;
	D %= B;
	if (D == 0) return true;
	ll step = gcd(B, D);
	ll tmp = A+(C-A)/step*step;
	tmp = (tmp+step)%B;
	if (0 <= tmp && tmp <= C) return true;
	return false;
}

int main()
{
	
	int T;
	cin >> T;
	while (T --)
	{
		ll A, B, C, D;
		cin >> A >> B >> C >> D;
		puts(solve(A, B, C, D) ? "Yes" : "No");
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
# define    all(a)              a.begin(), a.end()
#define forn(i, a, b) for (int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define MOD int(1e9+7)
using namespace std;

typedef long long int ll;

bool cmp(int a, int b) {
    return a < b;
}

void printV(vector<int> nums) {
    for (int i: nums) {
        printf("%d ", i);// << " ";
    }
    printf("\n");
}

// void printV(vector<ll> nums) {
//     for (ll i: nums) {
//         printf("%lld ", i);// << " ";
//     }
//     printf("\n");
// }



int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

bool valid(int i, int j, int n, int m) {
    if (i >= 0 && i < n && j >=0 && j < m)
        return true;
    else 
        return false;
}

vector<int> seive(int n) {
    vector<int> prime;
    vector<bool> flag(n+1);
    int cnt = 0;
    for (int i=2; i<=n+1; i++) {
        cnt++;
        if (!flag[i]) {
            for (int j=2; j*i<=n; j++) {
                flag[i*j] = true;
                cnt++;
            }
        }
    }
    // cout << cnt << endl;
    for (int i=2; i<=n; i++)
        if (!flag[i])
            prime.pb(i);
    return prime;
}


int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    // ios_base::sync_with_stdio(false);
    // cin.tie(0);cout.tie(0);
    // time_t start, end;
    // time(&start);
    string s;
    cin >> s;
    int n = s.length();
    int a,b;
    a = b = -1;
    for (int i=0; i<n; i++)
        if (s[i] == 'A' && a == -1)
            a = i;
        else if (s[i] == 'Z')
            b = i;
    cout << b-a+1 << endl;


    // printV(res);
    // time(&end); 
    // double time_taken = double(end - start);
    // cout << "Time Taken: " << fixed << time_taken << setprecision(5);
    // cout << " sec" << endl;
    return 0;
}      

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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll dp[2010][2010];
ll a[2010];
ll H;
ll n,l,r;



int main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // ll l,r;
    int p[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll n;
    cin >> n;
    cout<<p[n-1];

    return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int h,w; cin>>h>>w;
	vector<vector<char>>s(h+2,vector<char>(w+2));
	for(int i=0;i<w+2;++i)s.front().at(i)='#'; for(int i=0;i<w+2;++i)s.back().at(i)='#';
	for(int i=0;i<h+2;++i)s.at(i).front()='#'; for(int i=0;i<h+2;++i)s.at(i).back()='#';
	for(int i=1;i<h+1;++i){
		for(int j=1;j<w+1;++j){
			cin>>s.at(i).at(j);
		}
	}
	vector<vector<int>>L(h+2,vector<int>(w+2,0)),R(h+2,vector<int>(w+2,0)),
	U(h+2,vector<int>(w+2,0)),D(h+2,vector<int>(w+2,0));
	for(int i=1;i<h+1;++i){
		for(int j=1;j<w+1;++j){
			if(s.at(i).at(j)=='.'){
				L.at(i).at(j)=L.at(i).at(j-1)+1;
				U.at(i).at(j)=U.at(i-1).at(j)+1;
			}
		}
	}
	for(int i=h;i>=1;--i){
		for(int j=w;j>=1;--j){
			if(s.at(i).at(j)=='.'){
				R.at(i).at(j)=R.at(i).at(j+1)+1;
				D.at(i).at(j)=D.at(i+1).at(j)+1;
			}
		}
	}
	int ans=0;
	for(int i=1;i<h+1;++i){
		for(int j=1;j<w+1;++j){
			ans=max(ans,L.at(i).at(j)+R.at(i).at(j)+U.at(i).at(j)+D.at(i).at(j)-3);
		}
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 67200
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();
        int k = sc.nextInt();

        long ans = 0;
        long a = 1;

        while (true) {
            a *= k;
            ans++;
            if (n < a) {
                break;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
n = int(input())

d = {}

for k in range(97, 97+26):
  d[chr(k)] = 51
  
for i in range(n):
  s = str(input())
  for j in range(97,97+26):
    d[chr(j)] = min(d[chr(j)], s.count(chr(j)))

ans = ''
for k, v in d.items():
  ans += k*v
print(''.join(sorted(ans)))

Measured memory_bytes: 41964
#include<stdio.h>
#define N 100000

typedef struct{
  int pare,fstch,sibling;
}Node;

Node node[N];
int n,dep[N],he[N];

int sibling(int x){
    if(node[x].pare == -1)
        return -1;
    if(node[node[x].pare].fstch != x && node[node[x].pare].fstch != -1)
        return node[node[x].pare].fstch ;
    if(node[node[x].pare].sibling != x && node[node[x].pare].sibling != -1)
        return node[node[x].pare].sibling;
    return -1;
}

void print(int x){
    int d=0;
    
    printf("node %d: ",x);
    printf("parent = %d, ",node[x].pare);
    printf("sibling = %d, ",sibling(x));

    if(node[x].fstch != -1)
        d++;
    if(node[x].sibling != -1)
        d++;
    printf("degree = %d, ",d);
    printf("depth = %d, ",dep[x]);
    printf("height = %d, ",he[x]);

    if(node[x].pare == -1)
        printf("root\n");
    else if(node[x].fstch == -1 && node[x].sibling == -1)
        printf("leaf\n");
    else
        printf("internal node\n");
}

void depth(int x,int cnt){
  if(x==-1) return;
  
  dep[x]=cnt;
  depth(node[x].fstch,cnt+1);
  depth(node[x].sibling,cnt+1);
}

int height(int x){
    int h1=0,h2=0;
    if(node[x].fstch != -1)
        h1=height(node[x].fstch)+1;
    if(node[x].sibling != -1)
        h2=height(node[x].sibling)+1;
    return he[x]=(h1>h2?h1:h2);
}


int main(){

  int i,j,ch,v,left,right,root,k;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    node[i].pare = node[i].fstch = node[i].sibling = -1;

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&left,&right);

    node[v].fstch=left;
    node[v].sibling=right;
    
    if(left!=-1) node[left].pare=v;
    if(right!=-1) node[right].pare=v;
  }

  for(k=0;k<n;k++){
    if(node[k].pare==-1)
      root=k;
  }

  depth(root,0);
  height(root);

  for(i=0;i<n;i++) print(i);

  return 0;
}



Measured memory_bytes: 1996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1000000007;

int N, M;
int s[2020], t[2020];
ll sum[2020][2020];
ll dp[2020][2020];

int main(){
    cin >> N >> M;
    for(int i=1; i<=N; i++) cin >> s[i];
    for(int i=1; i<=M; i++) cin >> t[i];

    for(int i=1; i<=N; i++){
        for(int j=1; j<=M; j++){
            if(s[i] == t[j]){
                dp[i][j] = sum[i-1][j-1] + 1;
                dp[i][j] %= mod;

                sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + dp[i][j] + mod;
                sum[i][j] %= mod;
            } else {
                dp[i][j] = 0;

                sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + dp[i][j] + mod;
                sum[i][j] %= mod;
            }
        }
    }

    cout << (sum[N][M]+1) << endl;
}

Measured memory_bytes: 63744
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,a;
	int ans=0,i;
	s="CODEFESTIVAL2016";
	cin>>a;
	for(int i=0;i<s.size();i++)
	if(s[i]!=a[i]) ans++;
	cout<<ans;
	return 0;
}

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

#define int long long
using namespace std;

int a, b;

signed main()
{
	cin >> a >> b;
	if (a >= b * 2 - 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}


	return 0;

}




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

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        char[][] s = new char[N][10];
        int[] n = new int[N];
        for (int i = 0; i < N; i++) {
            n[i] = in.read(s[i]);
        }
        int ans = 0;
        int A = 0;
        int B = 0;
        int AB = 0;
        for (int i = 0; i < N; i++) {
            boolean a = s[i][n[i] - 1] == 'A';
            boolean b = s[i][0] == 'B';
            if (a && b) {
                AB++;
            } else if (a) {
                A++;
            } else if (b) {
                B++;
            }
            char[] si = s[i];
            boolean f = false;
            for (int j = 0; j < n[i]; j++) {
                if (si[j] == 'A') {
                    f = true;
                } else if (f && si[j] == 'B') {
                    ans++;
                    f = false;
                } else {
                    f = false;
                }
            }
        }
        if (AB > 0) {
            ans += AB - 1;
            if (A > 0 || B > 0) {
                A++;
                B++;
            }
        }
        ans += Math.min(A, B);
        System.out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


Measured memory_bytes: 34532
A, B = map(int, input().split())
list = [A, B]
list.sort()

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import collections
c = collections.Counter(prime_factorize(gcd(A, B)))

print(len(c)+1)

Measured memory_bytes: 3316
import java.io.*;
import java.util.*;

class Main {

    // Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long[] a = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                a[i] = sc.nextLong();
        }
        solve((int)N, a);
    }

    static long getSum(int l, int r, long[] a){
        long s = 0;
        for (int i = l; i <= r; i++){
            s += a[i];
        }
        return s;

    }
    static void solve(int N, long[] a){
        long[][] dp = new long[N][N];

        for (int l = N - 1; l >= 0; l--){
            for (int r = l; r < N; r++){
                if (l == r) {
                    dp[l][r] = 0;
                }else{
                    dp[l][r] = Long.MAX_VALUE;
                    for (int i = l; i <= r - 1; i++){
                        dp[l][r] = Math.min(dp[l][r], dp[l][i] + dp[i+1][r] + getSum(l, r, a));
                    }
            }
            }
        }
        System.out.print(dp[0][N-1]);

    }
}


Measured memory_bytes: 24532
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 1000000007

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll ans=0;
    ll r,g,b;
    r=0;g=0;b=0;
    rep(i,n){
        if(s[i]=='R'){
            r++;
        }else if(s[i]=='G'){
            g++;
        }else{
            b++;
        }
    }
    ans=r*g*b;
    //cout << ans ;

    rep(i,n-2){
        for(ll k=1;i+k+k<n;++k){
            if(s[i]!=s[i+k]&&s[i]!=s[i+2*k]&&s[i+k]!=s[i+2*k]){
                ans--;
            }
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

//π M_PI
//deg = rad*180/M_PI

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


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

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; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

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

    // input
    for(;;){
        ll N;
        cin >> N;

        if(N==0) return 0;

        ll count = 0;

        FOR(i, 0, 1001){
            FOR(j, i+2, 1001){
                ll j_sum = j * (j+1) / 2;
                ll i_sum = i * (i+1) / 2;
                if(j_sum - i_sum == N){
                    count++;
                }
            }
        }

        p(count);
    }
    
    return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;

ll MOD=1000000007;



int main(){
	string S;
	cin >> S;
	if(S=="Sunny")cout<<"Cloudy"<<endl;
	else if(S=="Cloudy")cout<<"Rainy"<<endl;
	else  cout<<"Sunny"<<endl;

return 0;
}  



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void fuk() { puts("No"); exit(0); }

const int MAXN = 300055;

int A[MAXN], B[MAXN];

int N;

int main() {
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i = 1; i <= N; i++) {
		cin >> A[i];
		if(i != A[i]) B[i] = i < A[i] ? 1 : -1;
	}

	for(int s = 1, e; s <= N;) {
		if(B[s]) {
			if(s == N || B[s+1]) fuk();
			e = s+1;
		} else e = s;
		for(; e < N && (!!B[e]) != (!!B[e+1]); e++);
		int mn = N+1, mx = -1;
		for(int i = s; i <= e; i++) {
			if(A[i] < mn) mn = A[i];
			if(mx < A[i]) mx = A[i];
		}
		if(mx != e || mn != s) fuk();
		mn = mx = -1;
		for(int i = s; i <= e; i++) {
			if(B[i] > 0) {
				if(A[i] < mx) fuk();
				mx = A[i];
			} else if(B[i] < 0) {
				if(A[i] < mn) fuk();
				mn = A[i];
			}
		}
		s = e+1;
	}

	puts("Yes");
	return 0;
}

Measured memory_bytes: 3196
#include<cstdio>

int main() {
    char s[100000];
    scanf("%s", s);

    bool checker[26];
    for (int i = 0; i < 26; i++) {
        checker[i] = false;
    }

    for (int i = 0; s[i] != '\0'; i++) {
        checker[s[i] - 'a'] = true;
    }

    for (int i = 0; i < 26; i++) {
        if (checker[i] == false) {
            printf("%c\n", (char)(i + 'a'));
            return 0;
        }
    }
    puts("None");
    return 0;
}

Measured memory_bytes: 888
using System;

namespace _0259
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string s = Console.ReadLine();
                if (s == "0000")
                {
                    break;
                }
                if (s[0] == s[1] && s[1] == s[2] && s[2] == s[3])
                {
                    Console.WriteLine("NA");
                }
                else
                {
                    int n = int.Parse(s);
                    int x = 0;
                    while (n != 6174)
                    {
                        string a = n.ToString();
                        int[] now = new int[4];
                        if (a.Length == 4)
                        {
                            now = new int[] { int.Parse(a[0].ToString()), int.Parse(a[1].ToString()), int.Parse(a[2].ToString()), int.Parse(a[3].ToString()) };
                        }
                        if (a.Length == 3)
                        {
                            now = new int[] { int.Parse(a[0].ToString()), int.Parse(a[1].ToString()), int.Parse(a[2].ToString()), 0 };
                        }
                        if (a.Length == 2)
                        {
                            now = new int[] { int.Parse(a[0].ToString()), int.Parse(a[1].ToString()), 0, 0 };
                        }
                        if (a.Length == 1)
                        {
                            now = new int[] { int.Parse(a[0].ToString()), 0, 0, 0 };
                        }
                        Array.Sort(now);
                        int min = now[0] * 1000 + now[1] * 100 + now[2] * 10 + now[3];
                        int max = now[3] * 1000 + now[2] * 100 + now[1] * 10 + now[0];
                        n = max - min;
                        x++;
                    }
                    Console.WriteLine(x);
                }
            }
        }
    }
}

Measured memory_bytes: 9380
N, W = map(int, input().split())
w, v = [0]*N, [0]*N
total_v = 0
for i in range(N):
  w[i], v[i] = map(int, input().split())
  total_v += v[i]

dp = [[float('inf') for _ in range(total_v+1)] for _ in range(N+1)]
dp[0][0] = 0

for i in range(1, N+1):
  for j in range(total_v+1):
    if j < v[i-1]:
      dp[i][j] = dp[i-1][j]
    else:
      dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i-1]] + w[i-1])
for i in range(total_v, -1, -1):
  if dp[N][i] <= W:
    print(i)
    break

Measured memory_bytes: 319124
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
 
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
   
using namespace std;
   
typedef long long ll;
typedef pair <double,double> P;
typedef pair <int,P> PP;
   
static const double EPS = 1e-12;
   
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

class Player {
public:
  int frame;
  int back_number;
  int team;
  int x,y;
  Player(int frame, int back_number, int team, int x, int y)
    : frame(frame), back_number(back_number), team(team), x(x), y(y) {}
};

bool equals(double lhs,double rhs){
  return (lhs <= rhs + EPS && lhs >= rhs - EPS);
}

P calc(vector<Player> players,int target_team){
  int time = INF;
  int distance = -1;
  for(int player_i = 0; player_i + 1 < players.size(); player_i++){
    if(players[player_i].team != target_team) continue;
    if(players[player_i].team != players[player_i + 1].team) continue;
    if(players[player_i].back_number == players[player_i + 1].back_number) continue;
    int tmp;
    if((tmp = ((players[player_i].x - players[player_i + 1].x) * (players[player_i].x - players[player_i + 1].x)
               + (players[player_i].y - players[player_i + 1].y) * (players[player_i].y - players[player_i + 1].y))) < distance) continue;
    
    // equal
    if(tmp == distance){
      if(time > (players[player_i + 1].frame - players[player_i].frame)){
        time = players[player_i + 1].frame - players[player_i].frame;
      }
    }
    // larger
    else {
      time = players[player_i + 1].frame - players[player_i].frame;
      distance = tmp;
    }
  }

  if(time == INF){
    return P(-1, -1);
  }
  else{
    return P(sqrt((double)distance),(double)time/60.0);
  }
}

int main()
{
  int num_of_frames;
  while(~scanf("%d",&num_of_frames)){
    vector<Player> players;
    for(int frame_i = 0; frame_i < num_of_frames; frame_i++){
      int frame;
      int back_number;
      int team;
      int x,y;
      scanf("%d %d %d %d %d",&frame,&back_number,&team,&x,&y);
      players.push_back(Player(frame,back_number,team,x,y));
    }
    P team_A = calc(players,0);
    P team_B = calc(players,1);
    if(equals(team_A.first,-1)){
      printf("%d %d\n",-1,-1);
    }
    else{
      printf("%.12lf %.12lf\n",team_A.first,team_A.second);
    }
    if(equals(team_B.first,-1)){
      printf("%d %d\n",-1,-1);
    }
    else{
      printf("%.12lf %.12lf\n",team_B.first,team_B.second);
    }
  }
}

Measured memory_bytes: 1228
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
int D;
string S;
void solve(){
    int N[S.size()];
    for(int i = 0; i < S.size(); i++){
        N[i] = S.at(i) - '0';
    }
    ll dp[2][D][2];
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    for(int i = 0; i < S.size(); i++){
        int d = N[i];
        for(int j = 0; j < D; j++){
            if(d == 0){
                dp[1][j][0] += dp[0][j][0];
                for(int k = 0; k < 10; k++){
                    dp[1][j][1] += dp[0][(((j-k)+D)%D+D)%D][1];
                    dp[1][j][1] %= MOD;
                }
            }
            else{
                for(int k = 0; k < 10; k++){
                    dp[1][j][1] += dp[0][(((j-k)+D)%D+D)%D][1];
                    dp[1][j][1] %= MOD;
                }
                for(int k = 0; k < d; k++){
                    dp[1][j][1] += dp[0][(((j-k)+D)%D+D)%D][0];
                    dp[1][j][1] %= MOD;
                }
                dp[1][j][0] += dp[0][(((j-d)+D)%D+D)%D][0];
                dp[1][j][0] %= MOD;
            }
            
        }
        for(int j = 0; j < D; j++){
            for(int k = 0; k < 2; k++){
                dp[0][j][k] = dp[1][j][k];
            }
        }
        
        for(int j = 0; j < D; j++){
            for(int k = 0; k < 2; k++){
                dp[1][j][k] = 0;
            }
        }
        
    }
    cout << (((dp[0][0][0] + dp[0][0][1] - 1) % MOD) + MOD) % MOD << endl;
}
int main(void){
    cin >> S >> D;
    solve();
    
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        int A = Integer.parseInt(sc.nextLine());

        boolean isCan = false;
        int amari = N % 500;

        if (A - amari >= 0) {
            isCan = true;
        }

        if (isCan) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21716
#include<stdio.h>
#define N 10


int main() {
		int ary[N];
		int i, j, temp;

		for(i=0; i<N; i++) {
				scanf("%d", &ary[i]);
		}

		// sort
		for(i=0; i<N; i++) {
				for(j=0; j<N-1; j++) {
						if(ary[j] < ary[j+1]) {
							temp = ary[j];
							ary[j] = ary[j+1];
							ary[j+1] = temp;
						}
				}
		}
		printf("%d\n%d\n%d\n", ary[0], ary[1], ary[2]);

		return 0;
}

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

int main() {
    int L, R, d;
    cin >> L >> R >> d;
    int count = 0;
    for(int i = L; i <= R; i++){
        if(i % d == 0) count++;
    }
    cout << count << endl;
}

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

int main(void) {
  int n, m, c, i, j, ans, count=0;
  int *b;
  int **a;
  scanf("%d", &n); scanf("%d", &m); scanf("%d", &c);
  b = (int*)malloc(m*sizeof(int));
  a = (int**)malloc(n*sizeof(int*));
  for(i=0; i<n; i++) {
    a[i] = (int*)malloc(m*sizeof(int));
  }
  for(i=0; i<m; i++) {
    scanf("%d", &b[i]);
  }
  for(i=0; i<n; i++) {
    for(j=0; j<m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  for(i=0; i<n; i++) {
    ans = 0;
    for(j=0; j<m; j++) {
      ans += a[i][j] * b[j];
    }
    if(ans + c > 0) {
      count++;
    }
  }
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

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

using namespace std;

int main() {
    int cnt=0;
    string w,t;

    cin>>w;

    for(int i=0;i<w.size();i++) w[i]=tolower(w[i]);

    while(1){
        cin>>t;
        if(t=="END_OF_TEXT")    break;
        for(int i=0;i<(int)t.size();i++){
            t[i] = tolower(t[i]);
        }
        if(t==w)    cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3152
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    map<int, int> mp;
    rep(i, N) {
        int D; cin >> D;
        mp[D]++;
    }
    int M; cin >> M;
    rep(i, M) {
        int T; cin >> T;
        mp[T]--;
        if (mp[T] < 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;


    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc099/tasks/abc099_b

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

    int n = b - a;
    int h = n * (n+1) / 2;
    cout << h - b << "\n";

    return 0;
}


Measured memory_bytes: 256