akhauriyash/Code-Regression huggingface dataset:
a,b=map(int,input().split())
count=0
for i in range(a,b+1):
    S=str(i)
    m=int(len(S)/2)
    flag=0
    if len(S)%2==0:
        for j in range(m):
            if S[j]==S[len(S)-1-j]:
                continue
            else:
                flag=1
                break
    else:
        for j in range(m):
            if S[j]==S[len(S)-1-j]:
                continue
            else:
                flag=1
                break
    if flag==0:
        count+=1
    else:
        continue
print(count)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args){
		//入力値を受け取る
		Scanner scanner = new Scanner(System.in);
		String input = scanner.nextLine();
		//inputのなかで"1"に一致する数をカウント
		int count = 0;
		for(char x: input.toCharArray()){
			if(x == '1'){
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21716
#include<stdio.h>

int main(void)
{ 
  int d,n,i,j,k,cnt,dis;
  double distance;
  int za[10][10]={0};
  scanf("%d %d",&n,&d);
 k=cnt=dis=0;
 distance=0;
 for(i=0;i<n;i++){
   for(k=0;k<d;k++){
     scanf("%d",&j);
     za[i][k]=j;
   }
 }
for(i=0;i<n;i++)
 for(k=i+1;k<n;k++){
   dis=distance=0;
   for(j=0;j<d;j++)
    dis+=(za[i][j]-za[k][j])*(za[i][j]-za[k][j]);
    distance=sqrt((double)dis);
    dis=sqrt(dis);
    if(distance==dis)cnt++;
 }
 printf("%d",cnt);
  return 0;
}

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

static const int MAX = 200000;

int main()
{
	int R[MAX], n;

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> R[i];

	int maxv = -1000000000;
	int minv = R[0];

	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}

	cout << maxv << endl;

	return 0;
}



Measured memory_bytes: 3884
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  int i,j;
  #define MAX 10000
  int num[MAX]={1,1,0};
 
  for(i=3;i<MAX;i+=2){
    if(num[i]==1)
      continue;
    for(j=3*i;j<MAX;j+=i*2)
      num[j]=1;
  }
  int n;
  while(cin>>n,n){
    n+=n%2-1;
    for(i=n;i>2;i-=2)if((!num[i])&&(!num[i-2]))break;
	cout<<i-2<<" "<<i<<endl;
  }
}

Measured memory_bytes: 1204
module fast_prime_sieve
  implicit none
contains
  subroutine primes(p, m, n)
    integer, allocatable, intent(inout) :: p(:)
    integer, intent(inout) :: m
    integer, intent(in) :: n
    integer :: lp(n), pr(n), i, j
    lp(n) = 0
    m = 0
    do i = 2, n
      if (lp(i) == 0) then
        lp(i) = i
        m = m + 1
        pr(m) = i
      end if
      j = 1
      do j = 1, m
        if (pr(j) > lp(i) .or. i * pr(j) > n) exit
        lp(i * pr(j)) = pr(j)
      end do
    end do
    allocate(p(m))
    p = pr(1:m)
  end
end module fast_prime_sieve
module bisection
  implicit none
  integer, private, parameter :: intkind = 4
contains
  integer function lower_bound(a, b) result(res)
    integer(intkind), intent(in) :: a(:), b
    integer :: l, r, m
    l = 0
    r = size(a) + 1
    do while (r - l > 1)
      m = (l + r) / 2
      if (a(m) < b) then
        l = m
      else
        r = m
      end if
    end do
    res = r
  end
  integer function upper_bound(a, b) result(res)
    integer(intkind), intent(in) :: a(:), b
    integer :: l, r, m
    l = 0
    r = size(a) + 1
    do while (r - l > 1)
      m = (l + r) / 2
      if (a(m) > b) then
        r = m
      else
        l = m
      end if
    end do
    res = l
  end
end module bisection
module gcd_lcm
  implicit none
  integer, private, parameter :: intkind = 4
contains
  integer(intkind) function gcd(x, y) result(res)
    integer(intkind), intent(in) :: x, y
    integer(intkind) :: a, b
    a = max(abs(x), abs(y))
    b = min(abs(x), abs(y))
    res = a
    do while (b > 0)
      res = b
      b = mod(a, b)
      a = res
    end do
  end
  integer(intkind) function lcm(x, y) result(res)
    integer(intkind), intent(in) :: x, y
    res = x / gcd(x, y) * y
  end
end module gcd_lcm
program coprime
  use fast_prime_sieve
  use bisection
  use gcd_lcm
  implicit none
  integer :: n, m, d, q, i, j
  integer, allocatable :: a(:), p(:)
  logical, allocatable :: b(:)
  read(*,*) n
  allocate(a(n))
  read(*,*) a
  d = a(1)
  do i = 2, n
    d = gcd(d, a(i))
  end do
  if (d /= 1) then
    write(*,'(a)') 'not coprime'
    stop
  end if
  call primes(p, m, maxval(a(1:n)))
  allocate(b(m))
  b = .false.
  do i = 1, n
    d = a(i)
    do j = 1, m
      q = p(j)
      if (q * q > d) exit
      if (mod(d, q) == 0) then
        if (b(j)) then
          write(*,'(a)') 'setwise coprime'
          stop
        end if
        b(j) = .true.
        do while (mod(d, q) == 0)
          d = d / q
        end do
      end if
    end do
    if (d /= 1) then
      j = lower_bound(p, d)
      if (b(j)) then
        write(*,'(a)') 'setwise coprime'
        stop
      end if
      b(j) = .true.
    end if
  end do
  write(*,'(a)') 'pairwise coprime'
end program coprime

Measured memory_bytes: 11604
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/20/20 21:00:19
// -----------------------------------

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using ll = long long;

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

  ll n; cin>>n;
  ll ans = 2*n-1;
  auto check = [&](ll x) {
    ll y = 2*n/x;
    auto [a,b] = atcoder::crt({0, y-1}, {x, y});
    if (b == 0) return;
    ans = min(ans, a);
  };
//  check(1);
//  check(2*n);
  for (int x = 2, sqrt2n = sqrt(2*n); x <= sqrt2n; ++x) {
    if ((2*n) % x == 0) {
      check(x);
      check(2*n/x);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3708
import java.util.*;
import java.lang.*;
class Main{




    public static void main(String args[]){
	Scanner in = new Scanner(System.in);
	int N,s;
	while(true){
	    N = in.nextInt();
	    s = in.nextInt();
	    assert (0<=N && N<=9 && 0<=s && s<=45);
	    if(N+s == 0)break;
	    int cnt=0;
	    for(int i=0;i<=9;i++){
		if(N <= 0)break;
		if(i == s && N == 1)cnt++;
		for(int j=0;j<=9;j++){
		    if(N <= 1)break;
		    if(i == j)continue;
		    if(i+j == s && N == 2)cnt++;
		    for(int k=0;k<=9;k++){
			if(N <= 2)break;
			if(k==i||k==j)continue;
			if(i+j+k == s && N == 3)cnt++;
			for(int l=0;l<=9;l++){
			    if(N <= 3)break;
			    if(l==i||l==j||l==k)continue;
			    if(i+j+k+l == s && N == 4)cnt++;
			    for(int m=0;m<=9;m++){
				if(N <=4 )break;
				if(m==i||m==j||m==k||m==l)continue;
				if(i+j+k+l+m == s && N== 5)cnt++;
				for(int n=0;n<=9;n++){
				    if(N <=5 )break;
				    if(n==i||n==j||n==k||n==l||n==m)continue;
				    if(i+j+k+l+m+n == s && N == 6)cnt++;
				    for(int o=0;o<=9;o++){
					if(N <=6 )break;
					if(o==i||o==j||o==k||o==l||o==m||o==n)continue;
					if(i+j+k+l+m+n+o == s && N == 7)cnt++;
					for(int p=0;p<=9;p++){
					    if(N <=7 )break;
					    if(p==i||p==j||p==k||p==l||p==m||p==n||p==o)continue;
					    if(i+j+k+l+m+n+o+p == s & N == 8)cnt++;
					    for(int q=0;q<=9;q++){
						if(N <=8 )break;
						if(q==i||q==j||q==k||q==l||q==m||q==n||q==o||q==p)continue;
						if(i+j+k+l+m+n+o+p+q == s & N == 9)cnt++;
					    }
					}
				    }
				}
			    }
			}
		    }
		}
	    }
	    int div=1;
	    for(int i=2;i<=N;i++)div*=i;
	    System.out.println(cnt/div);
	}

    }
    //funny
}

Measured memory_bytes: 12000
h,w=gets.split.map &:to_i
s=Array.new(h){gets.chomp.chars}
h.times{|y|
  count=0
  w.times{|j|
    count=1 if s[y][j]=="#"
  }
  s[y]=nil if count==0
}
s.compact!
s=s.transpose
w.times{|i|
  count=0
  s[i].each{|j|
  count=1 if j=="#"
  }
  s[i]=nil  if count==0
}
s.compact!
s=s.transpose
s.each{|i|puts i.join}


Measured memory_bytes: 14928
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
 
int main() {
  int n,x,t;
  cin >> n >> x >> t;
  if(n%x==0) cout << n/x*t << endl;
  else cout << (n/x+1)*t << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <limits>
#include <set>
#include <map>
 
int main()
{
    int n{};
    std::cin >> n;
    std::vector<int> staff(n);
    int a{};
    for (int i = 1; i < n; i++) {
        std::cin >> a;
        staff[a - 1]++;
    }
    for (int i = 0; i < n; i++) {
        std::cout << staff[i] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3972
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

int N, A, B, C;
vector<int> l;

int dfs(int idx, int lenA, int lenB, int lenC) {
    if (idx == N) {
        if (!lenA || !lenB || !lenC) {
            return INF;
        } else {
            return abs(lenA - A) + abs(lenB - B) + abs(lenC - C) - 30;
        }
    }

    return min({
            dfs(idx + 1, lenA, lenB, lenC),
            dfs(idx + 1, lenA + l[idx], lenB, lenC) + 10,
            dfs(idx + 1, lenA, lenB + l[idx], lenC) + 10,
            dfs(idx + 1, lenA, lenB, lenC + l[idx]) + 10
            });
}

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

    cin >> N >> A >> B >> C;
    l.resize(N);

    for (auto &li: l) cin >> li;

    cout << dfs(0, 0, 0, 0) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

string s;
int n;

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    cin >> s;
    n = s.length();
    s = " " + s;
    FOR(i,1,n) {
        if (i + 1 <= n && s[i] == s[i+1]) {
            cout << i << " "  << i+1;
            return 0;
        }
        if (i + 2 <= n && s[i] == s[i+2]) {
            cout << i << " " << i+2;
            return 0;
        }
    }
    cout << "-1 -1";
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  long ans(0);
  for (int i = 1; i <= n; ++i) {
    if (i % 3 && i % 5) ans += i;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n;
  cin >> n;

  cout << "ABC" << n << endl;

  return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
vc<ll> ans;
inline int S(ll x)
{
    int ret=0;
    while(x)
    {
        ret+=x%10;
        x/=10;
    }
    return ret;
}
int main()
{
    /*for(int i=1;i<10*maxn;i++)
    {
        int tt=i;
        int s=0;
        while(tt)
        {
            s+=tt%10;
            tt/=10;
        }
        bool ok=1;
        for(int j=i+1;j<i*2;j++)
        {
            tt=j;
            int sj=0;
            while(tt)
            {
                sj+=tt%10;
                tt/=10;
            }
            if(1LL*i*sj>1LL*j*s)
            {
                ok=0;
                break;
            }
            //else break;
        }
        if(ok) dbg(i);
    }*/
    for(int i=1;i<1000;i++)
    {
        ll cur=i;
        for(int j=0;j<15;j++)
        {
            ans.push_back(cur);
            cur=cur*10+9;
        }
    }
    mkuni(ans);
    vc<ll> op;
    for(auto u:ans)
    {
        if(!op.size()) op.push_back(u);
        else{
            while(op.back()*S(u)>S(op.back())*u) op.pop_back();
            op.push_back(u);
        }
    }
    //dbg(op.size());
    int k;
    cin>>k;
    for(int i=0;i<k;i++) print(op[i]);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
	int n,ans;
	cin >> n;
	vector<int> vec(n);
	
	for (int i = 0; i < n; i++) {
		cin >> vec.at(i);
	}

	sort(vec.begin(), vec.end());
	ans = 0;
	for (int i = 0; i < n-1; i++) {
		if (vec.at(i)-vec.at(i+1)==0) {
			ans = 1;
		}
	}

	if (ans==1) {
		cout << "NO" << endl;
	}
	else if(ans==0) {
		cout << "YES" << endl; }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cmath>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
#include <functional>
#include <stack>
#include <map>
#include <utility>
#define REP(i,n) for(int i=0;i<n;++i)
using namespace std;

int main() {
  string s;
  cin >> s;
  if (s[s.size()-1] == 's') {
    cout << s << "es" << endl;
  } else {
    cout << s << "s" << endl;
  }
}


Measured memory_bytes: 3628
import java.util.*;

public class Main {

    static class UnionFind {
        int[] size;
        int[] id;

        public UnionFind(int n) {
            size = new int[n];
            id = new int[n];

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

        void unify(int p, int q) {
            int root1 = find(p);
            int root2 = find(q);

            if (size[root1] > size[root2]) {
                size[root1] += size[root2];
                id[root2] = root1;
            } else {
                size[root2] += size[root1];
                id[root1] = root2;
            }
        }

        int find(int p) {
            int root = p;
            while (root != id[root]) root = id[root];
            while (p != root) {
                int next = id[p];
                id[p] = root;
                p = next;
            }
            return root;
        }

        boolean connected(int p, int q) {
            return find(p) == find(q);
        }
    }

    static class Edge implements Comparable<Edge> {
        int from, to, cost;

        public Edge(int from, int to, int cost) {
            this.from = from;
            this.to = to;
            this.cost = cost;
        }

        @Override
        public int compareTo(Edge o) {
            return cost - o.cost;
        }
    }

    static class Pair implements Comparable<Pair> {
        int id, pos;

        public Pair(int id, int pos) {
            this.id = id;
            this.pos = pos;
        }

        @Override
        public int compareTo(Pair o) {
            return pos - o.pos;
        }
    }

    static long kruskal() {
        long mstCost = 0;
        UnionFind uf = new UnionFind(N);
        PriorityQueue<Edge> pq = new PriorityQueue<>(edges);

        while (!pq.isEmpty()) {
            Edge edge = pq.poll();
            if (uf.connected(edge.from, edge.to)) continue;

            uf.unify(edge.from, edge.to);
            mstCost += edge.cost;

            if (uf.size[uf.find(0)] == N) break;
        }
        return mstCost;
    }

    static int N;
    static List<Edge> edges;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        edges = new ArrayList<>();
        List<Pair> X = new ArrayList<>();
        List<Pair> Y = new ArrayList<>();
        for (int i = 0; i < N; ++i) {
            X.add(new Pair(i, sc.nextInt()));
            Y.add(new Pair(i, sc.nextInt()));
        }

        Collections.sort(X);
        for (int i = 0; i+1 < X.size(); ++i) {
            int from = X.get(i).id;
            int to = X.get(i+1).id;
            edges.add(new Edge(from, to, X.get(i+1).pos - X.get(i).pos));
        }

        Collections.sort(Y);
        for (int i = 0; i+1 < Y.size(); ++i) {
            int from = Y.get(i).id;
            int to = Y.get(i+1).id;
            edges.add(new Edge(from, to, Y.get(i+1).pos - Y.get(i).pos));
        }

        System.out.println(kruskal());
    }
}

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

int main() {
int x,a,b;
  cin>>x>>a>>b;
int c = abs(a-x);
int d = abs(b-x);
  if(c>d){
    cout<<'B'<<endl;
}
     else if (d>c){
       cout<<'A'<<endl;
}
}


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

Measured memory_bytes: 2692
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a, b = map(int, input().split())
    print(max(0, a-b*2))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

int main() {
    long long int x;
    cin >> x;
    long long int base = 100;
    long long int res = 0;
    while (base < x) {
        res++;
        base = base + base / 100;
    }
    cout << res << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod) { a %= _mod; b %= _mod; ll res = 1; switch(op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break; } if (res < 0) res += _mod; return res; }


int main()
{
        ll R, G, B, N;
        cin >> R >> G >> B >> N;
        ll ans = 0;
        rep(i, 0, N+1) {
                rep(j, 0, N+1) {
                        ll k = N - i*R - j*G;
                        if (k < 0) continue;
                        if (k%B == 0) ++ans;
                }
        } 

        cout << ans << endl;
}


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(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 VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

string S;
vector<char> s;

int main() {
    cin >> S;
    int bidx = S.length() - 1;
    ll cnt = 0;
    REPR(i, S.length() - 1) {
        if(S[i] == 'B') {
            cnt += bidx - i;
            bidx--;
        }
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int a;
    cin >> a;
    printf("%d\n", a+a*a+a*a*a);   
}

Measured memory_bytes: 3600
a = int(input())
case = 0
# r = 部屋数　f = 階数　ｂ　＝　棟数 
list1 = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]

for i in range(a):
    x = input()
    c = x.split()
    list1[int(c[0])-1][int(c[1])-1][int(c[2])-1] += int(c[3])

aa ="{:2}"*10
q = "#"*20
for b in range(4):
    for f in range(3):
        print(aa.format(*list1[b][f]))
    if b != 3:
        print(q)


Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  string S;
  cin >> S;
  set<string> s;
  int n = S.length();
  if (n == 1) {
    cout << "1\n";
    return 0;
  }
  if (n == 2) {
    if (S[0] == S[1]) {
      cout << "1\n";
    } else {
      cout << "2\n";
    }
    return 0;
  }

  int dp[n + 1][2]{};
  dp[0][0] = 1;
  dp[0][1] = 0;
  if (S[0] == S[1]) {
    dp[1][0] = 1;
    dp[1][1] = 1;
  } else {
    dp[1][0] = 2;
    dp[1][1] = 1;
  }

  for (int i = 2; i < n; i++) {
    if(S[i] != S[i - 1]) {
      dp[i][0] = max(dp[i - 1][0] + 1, dp[i - 2][0] + 1); 
      dp[i][1] = dp[i - 2][0] + 1;
    } else {
      dp[i][0] = max(dp[i - 1][1] + 1, dp[i - 2][1] + 1);
      dp[i][1] = dp[i - 2][0] + 1;
    }
  }
  cout << max(dp[n -1][0], dp[n - 1][1]) << "\n";
  // for (int i = 0; i < n; i++) {
  //   cout << dp[i][0] << " " << dp[i][1] << "\n";
  // }
  return 0;
}

Measured memory_bytes: 2180
import java.util.*;

class Main {
  public static void main(String[] args) {
	Scanner scanner = new Scanner(System.in);
    
    int N = scanner.nextInt(); //next(文字列), nextDouble, nextLine(1行)とか
	int S = scanner.nextInt();
    
    int ans = 0;
    for (int i = 0; i <= N; i++){
      for (int j = 0; j <= N; j++){
        if (0 <= S - i - j && S - i - j <= N ){
          ans++;
        }
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23124
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def modInverse(a, p):
    return pow(a, p - 2, p)


def modBinomial(n, k, p):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n - i)) % p

    denominator = 1
    for i in range(1, k + 1):
        denominator = (denominator * i) % p

    return (numerator * modInverse(denominator, p)) % p


def main():
    N, A, B = [int(x) for x in input().split()]

    MOD = 10 ** 9 + 7

    ans = pow(2, N - 1, MOD)
    ans = ans * 2
    a = modBinomial(N, A, MOD)
    b = modBinomial(N, B, MOD)
    print((ans - a - b) % MOD - 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

int main()
{
	ll A;
	cin >> A;

	string B;
	cin >> B;

	ll tmp = 0;
	rep(i, B.size())
	{
		if (B[i] == '.') continue;
		tmp = 10 * tmp + (B[i] - '0');
	}

	cout << (A * tmp) / 100 << endl;

	return 0;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String a = br.readLine();
		int l = a.length();
		char[] c = new char [l];
		for(int i = 0; i < l; i++){
			c[i] = a.charAt(i);
			//a:97 - z:122
		}
		int n = Integer.parseInt(br.readLine());
		while(n>0){
			boolean check = false;
			for(int i = 0; i < l; i++){
				if(c[i]!='a'){
					int v = 123-c[i];
					if(v<=n){
						check = true;
						n -= v;
						c[i] = 'a';
					}
				}
			}
			if(!check){
				n%=26;
				c[l-1] += n;
				n = 0;
			}
		}
		for(int i = 0; i < l; i++){
			sb.append(c[i]);
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 11988
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m,c;
	cin>>n>>m>>c;
	ll ans=0;
	vl b(m);
	cin>>b;
	rep(i,n){
		vl a(m);
		cin>>a;
		ll v=c;
		rep(j,m){
			v+=b[j]*a[j];
		}
		if(v>0)ans++;
	}
	puta(ans);
	return 0;
}

Measured memory_bytes: 256
def resolve():
    N = int(input())
    d = {}
    for i in range(2, N+1):
        for j in prime_factors(i):
            d[j] = d[j] + 1 if j in d else 1
    res = 1
    for v in d.values():
        res *= (v+1)
    print(res%(10**9+7))

def prime_factors(n):
    i = 2
    factors = []
    while i**2 <= n:
        if n % i != 0:
            i += 1
        else:
            factors.append(i)
            n = n // i
    if n > 1:
        factors.append(n)
    return factors

if '__main__' == __name__:
    resolve()



Measured memory_bytes: 39792
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
int main() {
	string s;
	while (cin >> s) {
		if (s == "#")break;
		char board[10][10];
		int cnth = 0; int cntw = 0;
		int len = s.length();
		rep(i, len) {
			if (s[i] == '/') {
				cnth++; cntw = 0;
			}
			else if (s[i] == 'b') {
				board[cnth][cntw] = 'b'; cntw++;
			}
			else {
				rep(j, (s[i] - '0')) {
					board[cnth][cntw] = '.';
					cntw++;
				}
			}
		}
		cnth++;
		int a, b, c, d;
		cin >> a >> b >> c >> d; a--; b--; c--; d--;
		swap(board[a][b], board[c][d]);
		rep(i, cnth) {
			int cnt = 0;
			rep(j, cntw) {
				if (board[i][j] == '.') {
					cnt++;
				}
				else {
					if (cnt > 0) {
						cout << cnt;
					}
					cout << 'b';
					cnt = 0;
				}
			}
			if (cnt > 0)cout << cnt;
			if (i < cnth - 1) {
				cout << '/';
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3184
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long N, long long D){
  long long t = 2 * D + 1;
  std::cout << (N-1+t)/t << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long D;
  scanf("%lld",&D);
  solve(N, D);
  return 0;
}


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


typedef unsigned int uint;
typedef unsigned long int lu;
typedef unsigned long long llu;
typedef long int ld;
typedef long long lld;
typedef vector<int> vint;
typedef vector<unsigned int> vuint;
typedef vector<unsigned long int> vlu;
typedef vector<unsigned long long> vllu;
typedef vector<long int> vld;
typedef vector<long long> vlld;
typedef priority_queue<int> p_qd;
typedef vector<char> vchar;

static const llu bv = (int)'a' -1;

void name(llu num)
{
    if(num==0)
        return ;
    name((num-1)/26);
    cout<<(char)(((num-1)%26) + bv+1);
    //cout<<(((num-1)%26) + bv+1)<<endl;

}

int main()          
{
    llu num;
    cin>>num;
    //cout<<num<<endl;
    name(num);
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3588
X, N = map(int, input().split())
if N > 0:
    p = list(map(int, input().split()))
elif N == 0:
    print(X)
    exit()
else :
    p = [int(input())]
if N == 100:
    if X <= 50:
        print(0)
    else:
        print(101)
    exit()

for i in range(X+1):
    if not i in p:
        x = i

for i in range(X,101):
    if not i in p:
        y = i
        break
    elif i == 100:
        y = 101

if (X-x) == (y-X):
    print(x)
elif (X-x) > (y-X):
    print(y)
else:
    print(x)

Measured memory_bytes: 62092
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
int n,d,x;
int t[20][20];
int dp[20][110001];
const int INF=0;

int getMoney(int day,int x){
rep(i,20)rep(j,110001)dp[i][j]=INF;

dp[0][x]=x;
int ret=x;

for(int i=0;i<n;i++){//i品目目
	if(t[day][i]>t[day+1][i]){
		for(int j=0;j<=x;j++)dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
		continue;//下がる品目は買わない
	}
	
	for(int j=x;j>=0;j--){
		if(dp[i][j]!=INF){

			for(int k=0;k<=x;k++){
				if(j-k*t[day][i]<0)break;
				dp[i+1][j-k*t[day][i]]=max(dp[i+1][j-k*t[day][i]],dp[i][j]+k*(t[day+1][i]-t[day][i]));
			}
		}
	}
}

rep(i,n+1){
	rep(j,x+1)if(dp[i][j]!=INF)ret=max(ret,dp[i][j]);
}
	return ret;
}


int main(){
cin>>n>>d>>x;
rep(i,d)rep(j,n)cin>>t[i][j];

int nx=x;
 
for(int i=0;i<d-1;i++){
    nx=getMoney(i,nx);//i日目とi+1日目から最大の金額を返す
}
cout<<nx<<endl;

	return 0;
}



Measured memory_bytes: 11704
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int H, W;
  cin >> H >> W;
  int h, w;
  cin >> h >> w;

  cout << (H - h) * (W - w) << endl;

  return 0;
}


Measured memory_bytes: 256
n,a,b,c,d=map(int,input().split())
s=list(input())
def check(a,c,s):
  if s[a-1]=="#"or"#"==s[c-1]:return False
  for i in range(c-a):
    if s[a-1+i]==s[a+i]=="#":return False
  return True
if c<d:
  if check(a,c,s)and check(b,d,s):print("Yes")
  else:print("No")
else:
  if not(check(b,d,s)):print("No");exit()
  f=False
  for i in range(d-b+1):
    if s[b-2+i:b+1+i]==[".",".","."]:f=True
  if f and check(a,c,s):print("Yes")
  else:print("No")

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

int main(){
	
	int n,m,k;
	cin >> n;
	vector<int> v;
	for(int i=0;i<n;i++){
		cin >> k;
		v.push_back(k);
	}
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> k;
		v.push_back(k);
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()),v.end());
	for(auto x:v){
		cout << x << "\n";
	}

}



Measured memory_bytes: 4884
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
#define repi(i,a,b) for (int i=a;i<(b);i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;
typedef long long ll;
  
  int main(void){
    cin.tie(0); //cin高速化
    ios::sync_with_stdio(false); //cin高速化
	int a,b,ans=0;
    cin >> a >> b;
    string s,t;
    repi(i,a,b+1){
      s = to_string(i);
      t = to_string(i);
      reverse(t.begin(),t.end());
      if(s==t){
      	ans++;
      }
    }
    cout << ans << endl;
    return 0;
  } 

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.awt.Point;
import java.util.*;
    
class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str;
while(!(str=br.readLine()).equals("0 0")){
String[] value=str.split(" ");
int h=Integer.parseInt(value[0]);
int w=Integer.parseInt(value[1]);
char[][] map=new char[h][w];
for(int i=0;i<h;i++){
map[i]=br.readLine().toCharArray();
}
Deque <Point> que=new  ArrayDeque<Point>();
int ans=0;
for(int m=0;m<h;m++){
for(int n=0;n<w;n++){
if(map[m][n]!='.'){
ans++;
Point p = new Point(n,m);
que.addLast(p);
while(que.peekFirst()!=null){
p=que.pollFirst();
int x=p.x;
int y=p.y;
char crop = map[y][x];
map[y][x]='.';
int [] dx ={0,1,0,-1};
int [] dy ={1,0,-1,0};                   
for(int i=0;i<4;i++){
int nx =x+dx[i];
int ny =y+dy[i];
if(nx>=0&&nx<w&&ny>=0&&ny<h&&map[ny][nx]!='.'&&map[ny][nx]==crop){
Point np = new Point(nx,ny);
que.addLast(np);                       
}
}
}
}
}
}System.out.println(ans);
}
}
}

Measured memory_bytes: 26704
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

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



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


    return 0;
}

Measured memory_bytes: 3632
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []
for i in range(N):
    Ai = list(map(int, input().split()))
    A.append(Ai)
CA = 0

for i in range(N):
    sum = 0
    for j in range(M):
        sum += A[i][j] * B[j]
    sum += C
    if sum > 0:
        CA += 1

print(CA)

Measured memory_bytes: 3064
n = int(raw_input())

for i in range(n):
    x1,y1,x2,y2,x3,y3,x4,y4 = map(float, raw_input().split())
    if abs((y4-y3)*(x2-x1)-(y2-y1)*(x4-x3)) < 1e-10:
        print "YES"
    else:
        print "NO"

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

string s;
int ans;
signed main(){
	while (cin >> s && s > "0"){
		ans = 0;
		for (int i = 0; i < s.length(); i++){
			ans += s[i] - '0';
		}
		cout << ans << endl;
	}
	return 0;
}
	



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

int main(){
        int rot = 0;
        char *s,*ans;
        char c;
        int i = 0;
        s = malloc(10002);
        ans = malloc(10002);
        scanf("%d\n",&rot);
        fgets(s,10002,stdin);
        while(s[i] != '\n'){
                c = s[i] + rot;
                if(c > 'Z'){
                        c -= 26;
                }
                ans[i] = c;
                i++;
        }
        printf("%s\n",ans);
        return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

map<string, int> s, t;

signed main()
{
    int N, D, X;
    int ans = 0;
    cin >> N >> D >> X;
    REP(i, N) {
        int A;
        cin >> A;
        for(int i = 1; i <= D; ++i) {
            if((i - 1) % A == 0) { ans++; }
        }
    }
    printf("%lld\n", ans + X);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

int main()
{
  string s;
  cin >> s;
  
  int res = INT_MAX;
  for (int i = 0; i < 2; i++) {
    int cnt = 0;
    for (int j = 0; j < s.size(); j++) {
      if ((j % 2 == 0) && (s[j] == (char) ('0' + i))) {
        cnt++;
      }
      if ((j % 2 == 1) && (s[j] != (char) ('0' + i))) {
        cnt++;
      }
    }
    res = min(res, cnt);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    if(n == 1 && m == 0){
      System.out.println(0);
      return;
    }
    String s[] = new String[3];
    s[0] = "1";
    s[1] = "0";
    s[2] = "0";
    int count[] = new int[3];
    String ss[] = new String[3];
    for(int i = 0;i<3;i++){
      ss[i] = "";
    }
    for(int i = 0;i<m;i++){
      int si = sc.nextInt();
      String ci = sc.next();
      if(si == 1){
        if(ci.equals("0") && !(n == 1)){
          System.out.println(-1);
          return;
        }
        count[0]++;
        ss[0] = ss[0] + ci;
      }else if(si == 2){
        count[1]++;
        ss[1] = ss[1] + ci;
      }else if(si == 3){
        count[2]++;
        ss[2] = ss[2] + ci;
      }
    }
    for(int i = 0;i<3;i++){
      if(count[i] == 0){
        continue;
      }else if(count[i] == 1){
        s[i] = ss[i];
      }else{
        String kiri = ss[i].substring(0,1);
        ss[i] = ss[i].replace(kiri,"");
        if(ss[i].length() == 0){
          s[i] = kiri;
        }else{
          System.out.println(-1);
          return;
        }
      }
    }
    for(int i = 0;i<n;i++){
      System.out.print(s[i]);
    }
  }
}


Measured memory_bytes: 23252
class Point
  attr_reader :x, :y
  def initialize(x, y)
    @x = x
    @y = y
  end
end
class Line
  attr_reader :p1, :p2, :maxx, :minx, :maxy, :miny, :x, :y
  def initialize(x1, y1, x2, y2)
    @p1 = Point.new(x1, y1)
    @p2 = Point.new(x2, y2)
    @maxx = (x1 > x2)? x1 : x2
    @minx = (x1 > x2)? x2 : x1
    @maxy = (y1 > y2)? y1 : y2
    @miny = (y1 > y2)? y2 : y1
    @x = x1 - x2
    @y = y1 - y2
  end
  def parallel?(other)
    return (x * other.y) == (y * other.x)
  end
  def over_x?(other)
    return (x ** 2 + other.x ** 2 >= (maxx - other.maxx) ** 2 + (minx - other.minx) ** 2)
  end
  def over_y?(other)
    return (y ** 2 + other.y ** 2 >= (maxy - other.maxy) ** 2 + (miny - other.miny) ** 2)
  end
  def get_xy(other)
    return (y * other + (x * p2.y - y * p2.x))
  end
  def get_yx(other)
    return (x * other + (y * p2.x - x * p2.y))
  end
  def cross_x?(other)
    return (other.x * p1.y - other.get_xy(p1.x)) * (other.x * p2.y - other.get_xy(p2.x)) <= 0
  end
  def cross_y?(other)
    return (other.y * p1.x - other.get_yx(p1.y)) * (other.y * p2.x - other.get_yx(p2.y)) <= 0
  end
  def intersection?(other)
    if (parallel?(other))
      if (x * y == 0)
        if (x == 0)
          return ((p1.x == other.p1.x) and (over_y?(other)))
        else
          return ((p1.y == other.p1.y) and (over_x?(other)))
        end
      else
        return (cross_x?(other) and over_x?(other))
      end
    else
      if (y == 0 or other.y == 0)
        return (cross_x?(other) and other.cross_x?(self))
      else
        return (cross_y?(other) and other.cross_y?(self))
      end
    end
  end
end

def main(input = STDIN, output = nil)
  q = input.gets.to_i
  q.times do |i|
    arg = input.gets.split(" ").map(&:to_i)
    l1 = Line.new(*arg[0...4])
    l2 = Line.new(*arg[4..-1])
    if (l1.intersection?(l2))
      puts "1"
    else
      puts "0"
    end
  end
end
main

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

int x[110];

int main(){

    int n;
    cin >> n;

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

    int min = 1e9;
    for(int i=1;i<100;i++){
        int spend = 0;
        for(int j=0;j<n;j++){
            spend+=(i-x[j])*(i-x[j]);
        }
        if(spend<min)
            min = spend;
    }

    cout << min << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, m, i, j;
    string s, t;
    cin >> s >> t;
    n = s.size(), m = t.size();
    ll dp[n + 1][m + 1];
    memset(dp, 0, sizeof dp);
    for(i = 1; i <= n; i++)
    {
        for(j = 1; j <= m; j++)
        {
            if(s[i - 1] == t[j - 1])
                dp[i][j] = 1 + dp[i - 1][j - 1];
            dp[i][j] = max({dp[i][j], dp[i - 1][j], dp[i][j - 1]});
            // cout << i << ", " << j << ": " << dp[i][j] << ' ';
        }
        // cout << '\n';
    }
    ll x = dp[n][m];
    string ans;
    for(i = n; i > 0 && x; i--)
    {
        for(j = m; j > 0 && x; j--)
        {
            if(dp[i][j] == x && s[i - 1] == t[j - 1])
            {
                ans += s[i - 1];
                x--;
                break;
            }
        }
    }
    reverse(all(ans));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70656