akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


void no()
{
  std::cout << -1 << std::endl;
      
  exit(0);
}


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

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, M, s, c, a[11];

  std::cin >> N >> M;

  if (M == 0) {
    if (N == 1) {
      std::cout << 0 << std::endl;
    }
    else {
      std::cout << 1;
      for (int i = 0; i < N - 1; i ++)
        std::cout << 0;
      std::cout << std::endl;
    }
    
    return 0;
  }

  memset(a, -1, sizeof(a));

  for (int i = 0; i < M; i ++) {
    std::cin >> s >> c;

    if (N > 1)
      if (s == 1 && c == 0)
        no();

    if (a[s - 1] != -1)
      if (a[s - 1] != c)
        no();

    a[s - 1] = c;
  }

  for (int i = 0; i < N; i ++)
    if (a[i] == -1)
      a[i] = i == 0 ? 1 : 0;

  for (int i = 0; i < N; i ++)
    std::cout << a[i];
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string s,t,u;
    int a,b;
    cin>>s>>t>>a>>b>>u;
    if(s==u) a--;
    else if(t==u) b--;
    cout<<a<<' '<<b;
}


Measured memory_bytes: 256
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

using namespace std;

int ans[500];

int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie();
	//cout.tie();		

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	ans[1] = 300000;
	ans[2] = 200000;
	ans[3] = 100000;
	int x, y;
	cin >> x >> y;
	int res = ans[x] + ans[y];
	if (x == 1 && y == 1)
		res += 400000;
	cout << res << endl;



	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace std;

int main(void) {
    double a,b,C;cin>>a>>b>>C;
    double h = b * sin(C * (2 * M_PI / 360));
    double S = a * h / 2.0;
    double L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(C * (2 * M_PI/ 360)));
    printf("%.6f\n", S);
    printf("%.6f\n", L);
    printf("%.6f\n", h);
    return 0;
}


Measured memory_bytes: 3360
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define VAR(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

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

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

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

int N;

inline i64 parent(i64 u) { return (u - 1) / N; }

inline i64 depth(i64 u) {
    i64 d = 0;
    while (u > 0) ++d, u = parent(u);
    return d;
}

inline i64 findLCA(i64 a, i64 b) {
    if (N == 1) {
        return min(a, b);
    }
    while (a != b) {
        const i64 depA = depth(a);
        const i64 depB = depth(b);
        if (depA > depB) {
            rep(i, 0, depA - depB) a = parent(a);
        } else if (depA < depB) {
            rep(i, 0, depB - depA) b = parent(b);
        } else {
            a = parent(a);
            b = parent(b);
        }
    }
    return a;
}

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

    int Q;
    read(N, Q);

    while (Q--) {
        VAR(int, a, b);
        --a, --b;
        print(findLCA(a, b) + 1);
    }

    return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j=0,v;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  for(i=2;i<=n;i++){
    v = A[i];
    j = i-1;
    while(j>=0&&A[j]>v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
      }
     
    
   trace(A,n);
  }
  
  return 0;
}

Measured memory_bytes: 608
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int a,b;
    scanf("%d %d", &a, &b);
    printf("%d", 6-a-b);
    
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
    ll n;
    cin>>n;
    
    ll i,j;
    ll res=0;
    for(i=1;i<=n;i++)
    {
        for(j=i;j<=n;j+=i)
        {
            res+=j;
        }
    }
    
    cout<<res<<"\n";
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3640
c = 0

def merge(a,l,m,r):
    global c
    n1 = m-l
    n2 = r-m
    L = a[l:m]
    R = a[m:r]
    L.append(1000000009)
    R.append(1000000009)
    i,j = 0,0
    for k in range(l,r):
        if L[i]<R[j]:
            a[k] = L[i]
            i += 1
        else :
            a[k] = R[j]
            j += 1
            c += n1-i

def mergeSort(a,l,r):
    if l+1<r:
        m = (l+r)//2
        mergeSort(a,l,m)
        mergeSort(a,m,r)
        merge(a,l,m,r)

def main():
    n = int(input())
    a = list(map(int,input().split()))
    mergeSort(a,0,n)
    print (c)

if __name__ == '__main__':
    main()




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

int n,a,tmp;
int s[10],w[10];
string f[10],temp;
int t[10];
vector<int>ans;

int get_weight(int);
void swap_data(int);
void sort_data();

int main(){
  while(cin>>n&&n!=0){
    ans.clear();
    for(int i=0;i<n;i++){
      cin>>f[i];
      cin>>w[i]>>s[i];
    }    
    sort_data();
    for(int i=0;i<n;i++){
      for(int j=0;j<n-1;j++){
	if(w[j]<w[j+1]){
	  swap_data(j);
	  a=get_weight(j+1);
	  if(a>s[j])swap_data(j);
	}
      }
    }
    for(int i=0;i<n;i++)cout<<f[i]<<endl;
  }
  return 0;
}

int get_weight(int x){
  int res=0;
  for(int i=x;i<n;i++)res+=w[i];
  return res;
}

void swap_data(int x){
  tmp=w[x];
  w[x]=w[x+1];
  w[x+1]=tmp;

  tmp=s[x];
  s[x]=s[x+1];
  s[x+1]=tmp;

  temp=f[x];
  f[x]=f[x+1];
  f[x+1]=temp;
}

void sort_data(){
  for(int i=n-1;i>0;i--){
    for(int j=0;j<i;j++){
      if(s[j]<s[j+1])swap_data(j);
      else if(s[j]==s[j+1]&&w[j]<w[j+1])swap_data(j);
    }
  }
}

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

using namespace std;
const int N=1e4+5;
int cum[N][30];
string RGB="RGB";
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;cin>>n;
    string s;cin>>s;
    for(int i=n-1;i>=0;i--)
    {
        cum[i][s[i]-'A']=1;
        for(auto c:RGB)
            cum[i][c-'A']+=cum[i+1][c-'A'];
    }
    long long ans=0;
    for(int i=0;i<n;i++)
        for(int j=i;j<n;j++)
        {
            if(s[i]==s[j]) continue;
            char t;
            for(auto c:RGB)
                if(c!=s[i]&&c!=s[j])
                    t=c;
            ans+=cum[j+1][t-'A'];
            int k=j+(j-i);
            if(k<n&&s[k]==t) ans--;
        }
    cout<<ans<<endl;
    return 0;
}


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


int main()
{
    int n;
    cin >> n;
    vector<ll> a, b;
    rep(i, n + 1){ ll tmp; cin >> tmp; a.push_back(tmp);}
    rep(i, n){ ll tmp; cin >> tmp; b.push_back(tmp);}

    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (b[i] >= a[i]){
            ans += a[i];
            b[i] -= a[i];
            a[i] = 0;
            if (b[i] >= a[i + 1]){
                ans += a[i + 1];
                b[i] -= a[i + 1];
                a[i + 1] = 0;
            } else {
                ans += b[i];
                a[i + 1] -=  b[i];
            }
        } else {
            ans += b[i];
            a[i] -= b[i];
        }
    }
    cout << ans << endl; 
}

Measured memory_bytes: 2548
a = [int(input()) for _ in range(5)]

m = 0#1の位が0以外で一番小さいもの(10との差が一番大きいもの)
sum_a = 0#10倍数にしたものの合計
for x in a:
    if x%10 != 0:
        t = 10 - x%10#10倍数との差
    else:
        t = 0
    sum_a += x+t
    m = max(m, t)

print(sum_a - m)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(int argc, const char *argv[]) {
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }

  vector<int>::iterator iter = max_element(p.begin(), p.end());
  size_t index = distance(p.begin(), iter);
  int sum = accumulate(p.begin(), p.end(), 0) - p[index];

  cout << sum + p[index] / 2 << endl;
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll MOD = 1e9+7;

ll N;
long double DP[305][305][305];

long double rec(ll i, ll j, ll k){
    if(i == 0 && j == 0 && k == 0) return DP[0][0][0];
    if(DP[i][j][k] != 0) return DP[i][j][k];
    
    long double res = 0.0;
    if(i > 0)res += rec(i-1, j, k) * i;
    if(j > 0)res += rec(i+1, j-1, k) * j;
    if(k > 0)res += rec(i, j+1, k-1) * k;

    res += (long double) N;
    res /= (long double) (i+j+k);
    DP[i][j][k] = res;
    return res;

}

int main() {
    cin >> N;
    ll one = 0, two = 0, three = 0;
    for(int i = 0; i < N; i++){
        ll x; cin >> x;
        if(x == 1) one++;
        else if(x == 2) two++;
        else three++;
    }
    memset(DP, 0, sizeof(DP));

    long double ans = rec(one, two, three);
    cout << setprecision(20) << ans << endl;
}

Measured memory_bytes: 443648
#include <cstdio>

int main(void){
  int n;
  int com_cum[1001];
  com_cum[0] = 0;
  for(int i=1; i <= 1000; i++){
    com_cum[i] = com_cum[i-1] + i;
  }
  while(scanf("%d",&n), n){
    int ans = 0;
    for(int i=0; i < n; i++){
      for(int j=i+1; j < n; j++){
	if(n == com_cum[j] - com_cum[i])
	  ans++;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1028
// Last Change: 11/28/2019 18:56:57.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N, M;
  cin >> N >> M;
  vector<int> A(M);
  for (auto &&e : A) {
    cin >> e;
    --e;
  }
  vector<vector<int>> B(M, vector<int>(N));
  for (auto &&e : B) {
    for (auto &&f : e) {
      cin >> f;
      --f;
    }
  }

  vector<ll> score(N, 0);
  for (int i = 0; i < M; ++i) {
    int hit = 0, target = A[i];
    for (int j = 0; j < N; ++j) {
      if (B[i][j] == target) {
        ++score[j];
        ++hit;
      }
    }
    score[target] += N - hit;
  }

  for (auto &&e : score) {
    cout << e << endl;
  }
}



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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

int solve(vi &data)
{
    int ret = 0;
    int bef = 0, aft = data.size()-1;
    int now = data[bef] * 2;

    //cout << "call : " << endl;
    //rep(i, data.size()) cout << data[i] << " "; cout << endl;

    rep(i, data.size()) {
        //cout << "now = " << now << " bef = " << bef << " aft = " << aft << endl;
        if (i % 2) {
            if (bef+1 < aft) { // 2ko
                int tmp = data[bef+1] + data[bef+2];
                bef += 2;
                ret += (abs(now - tmp));
                now = tmp;
            } else if (bef < aft) {  // 1ko
                int tmp = data[bef+1];
                bef += 1;
                ret += max(abs(data[aft+2] - tmp), abs(data[aft+1] - tmp));
                break;
            } else {
                break;
            }
        } else {
            if (bef+1 < aft) { // 2ko
                int tmp = data[aft] + data[aft-1];
                aft -= 2;
                ret += (abs(now - tmp));
                now = tmp;
            } else if (bef < aft) {  // 1ko
                int tmp = data[aft];
                if (data.size() == 2) {
                    ret += abs(data[0] - tmp);
                } else {
                    ret += max(abs(data[bef] - tmp), abs(data[bef-1] - tmp));
                }
                now = tmp;
                break;
            } else {
                break;
            }
        }
        //cout << now << " " << ret << endl;
    }

    return ret;
}


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

    Int(n);
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }
    
    sort(all(data));
    int ans = solve(data);
    //cout << ans << endl;
    reverse(all(data));
    ans = max(ans, solve(data));

    cout << ans << endl;

    return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = ReadIntArray();
            var n = nums[0];
            var m = nums[1];
            var a = ReadIntArray().Select(x => new Price(x));
            var set = new SortedSet<Price>(a);
            for (int i = 0; i < m; i++)
            {
                var max = set.Max;
                set.Remove(max);
                max.Discount();
                set.Add(max);
            }
            var result = set.Sum(x => (long)x.Value);
            Console.WriteLine(result);
            ReadString();
        }

        public static string ReadString()
        {
            return Console.ReadLine();
        }

        public static string[] ReadStringArray()
        {
            return ReadString().Split(' ');
        }

        public static int[] ReadIntArray()
        {
            return ReadStringArray().Select(x => int.Parse(x)).ToArray();

        }

        public static int ReadInt()
        {
            return int.Parse(ReadString());
        }
    }

    class Price : IComparable<Price>
    {
        public double Value { get; private set; }
        public int Id = NewId();

        private static int _prevId;
        static int NewId()
        {
            return ++_prevId;
        }


        public Price(int value)
        {
            Value = value;
        }

        public void Discount()
        {
            Value /= 2;
        }

        public int CompareTo(Price other)
        {
            var result = Value.CompareTo(other.Value);
            if (result == 0)
            {
                return Id.CompareTo(other.Id);
            }
            else
            {
                return result;
            }
        }
    }
}


Measured memory_bytes: 34520
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();

        int[] taste = new int[n];
        for (int i = 1; i <= n; i++) {
            taste[i - 1] = l + i - 1;
        }

        int min = 105;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            min = Math.min(Math.abs(taste[i]), min);
            sum += taste[i];
        }

        if (sum > 0) {
            System.out.println(sum - min);
        } else {
            // 0の場合は均等なので最小値も0で加算しても変わらない
            System.out.println(sum + min);
        }
    }
}


Measured memory_bytes: 22996
S=gets.chomp
T=gets.chomp
leng = S.length

a={}
b={}

for i in 0..leng-1 do
  if a[T[i]] == nil
    a[T[i]] = S[i]
  end

  if b[S[i]] == nil
    b[S[i]] = T[i]
  end

  if b[S[i]] != T[i]
    puts "No"
    exit
  end

  if a[T[i]] != S[i]
    puts "No"
    exit
  end
end

puts "Yes"

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

int main()
{
    int n,y,i=0,k=0,z;
    long long sum=0;
    cin>>n>>y;
    int a[n], b[n];
    while(i<n)
    {
        cin>>a[i]>>b[i];
        i++;
    }
    sort(a,a+n);
    sort(b,b+n);
    i=n-1;
    for(int j=i; j>=0; j--)
    {
        if(a[i]<=b[j])
        {
            sum+=b[j];
            k++;
            if(sum>=y)
            {
                cout<<k;
                return 0;
            }
        }
        else
        {
            break;
        }
    }
    z=(y-sum)/a[i];
    sum+=z*a[i];
    if(sum>=y) cout<<k+z;
    else cout<<k+z+1;

    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()


const vector<int> che={6,9};

int main(){
    int n; cin>>n;
    int ans=0;
    vector<int> p(n+5,-1);
    p[0]=0;
    rep(i,n){
        vector<int> cnt;
        rep(j,2){
            int a=che[j];
            rep(k,8){
                if((i+1)<pow(a,(k+1))) break;
                if(p[i+1-pow(a,k+1)]!=-1) cnt.push_back(p[i+1-pow(a,k+1)]+1);
            }
        }
        if(p[i]!=-1) cnt.push_back(p[i]+1);
        if(!cnt.empty()){
            p[i+1]=*min_element(btoe(cnt));
        }
    }
    cout<<p[n]<<endl;
}

Measured memory_bytes: 4192
#include <iostream>
#include <iomanip>
#include <cmath>

int main(){
    long double n, k;
    std::cin >> n >> k;

    long double ans = 0;
    for(int i = 1; i <= n; ++i){
        if(k <= i){
            ans +=  1;
        }else{
            int bufInt = std::ceil(log2(k / i));
            ans +=  std::pow(0.5, bufInt);
        }
    }

    std::cout << std::setprecision(15) << ans / n << std::endl;

    return 0;
}


Measured memory_bytes: 384
use std::io::Read;
use std::cmp::{max, min};

fn main(){
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n:usize = iter.next().unwrap().parse().unwrap();
    let mut h = vec![];
    for _ in 0..n{
        let hi:i32 = iter.next().unwrap().parse().unwrap();
        h.push(hi);
    }
    h[0] -= 1;
    for i in 1..n{
        if h[i]-1 >= h[i-1]{
            h[i] -= 1;
        }
        else if h[i] < h[i-1]{
            println!("No");
            return;
        }
    }
    println!("Yes");
}


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

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

    if (a > b) {
        cout << 0 << endl;
        return 0;
    }

    if (n == 1) {
        if (a == b) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
        return 0;
    }

    long long mx = a + b;
    long long mn = a + b;
    for (int i = 0; i < n - 2; i++) {
        mx += b;
        mn += a;
    }

    cout << (mx - mn + 1) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main() {
	
	int N;
	float A[1000];
	float ans = 0.0;

	scanf("%d", &N);

	for (int i = 0; i < N; i++) {
		scanf("%f", &A[i]);
		ans += 1 / A[i];
	}

	ans = 1 / ans;

	printf("%f", ans);

	return 0;
}



Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var HW = ReadLine().Split().Select(int.Parse).ToArray();
        var H = HW[0];
        var W = HW[1];
        var S = new bool[H, W];
        for (int i = 0; i < H; i++)
        {
            var line = ReadLine();
            for (int j = 0; j < W; j++)
            {
                S[i, j] = line[j] == '.';
            }
        }
        var x = new int[H, W];
        var y = new int[H, W];
        for (int i = 0; i < H; i++)
        {
            var s = 0;
            var t = 0;
            for (int j = 0; j < W; j++)
            {
                if (S[i, j])
                {
                    t = j+1;
                }
                else 
                {
                    for (int k = s; k < t; k++)
                    {
                        x[i, k] = t-s;
                    }
                    s = j + 1;
                }
            }
            if (S[i, W - 1])
            {
                for (int k = s; k < t; k++)
                {
                    x[i, k] = t - s;
                }
            }
        }

        for (int j = 0; j < W; j++)
        {
            var s = 0;
            var t = 0;
            for (int i = 0; i < H; i++)
            {
                if (S[i, j])
                {
                    t = i+1;
                }
                else
                {
                    for (int k = s; k < t ; k++)
                    {
                        y[k, j] = t-s;
                    }
                    s = i + 1;
                }
            }
            if (S[H-1, j])
            {
                for (int k = s; k < t; k++)
                {
                    y[k,j ] = t - s;
                }
            }
        }
        //Show(x);
       // Show(y);
        var ans = 0;
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                ans = Max(ans, x[i, j] + y[i, j] - 1);
            }
        }
        WriteLine(ans);
    }

    static void Show(int [,]m )
    {
        for (int i = 0; i < m.GetLength(0); i++)
        {
            for (int j = 0; j < m.GetLength(1); j++)
            {
                Write(m[i,j].ToString()+" ");
            }
            WriteLine();
        }
        WriteLine();
    }
}

Measured memory_bytes: 50376
#include <bits/stdc++.h>
#define INF 1023456789
#define sacnf scanf
#define scnf scanf
#define scnaf scanf
#define CRLF <<'\n';
#define ALL(v) v.begin,v.end()
#define SIZE(v) (int)v.size()
#define PRPAIR(x) x.first << x.second
#define DEBUG(x) do { std::cerr <<(x)<<'\n'; } while (0)
#define rep(i,a,b) for(int i=(a);i!=(int)b-((a)>(b));(a)>(b)?--i:++i)
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> pip;
typedef vector<int> vi;
typedef long long ll;

int main(){
    ll n,d;
    scanf("%lld%lld",&n,&d);
    int c=0;
    rep(i,0,n){
        ll a,b;
        scanf("%lld%lld",&a,&b);
        if (a*a + b*b <= d*d)
            c++;
    }
    cout << c;

}


Measured memory_bytes: 3756
n = gets.chomp.to_i
input = gets.chomp
wlist = input.split.collect{ |item| item.to_i}
sum = 0
wlist.each { |i| sum += i}
leftsum = 0
result = sum
wlist.each do |ni|
  leftsum += ni
  dif = (sum - leftsum*2).abs
  if result > dif
    result = dif
  else
    break
  end
end
puts result

Measured memory_bytes: 1788
function Main(input){
    i=input.split(" ").map(Number);
    a=i[0]>i[1]?i[0]*2-1:i[1]*2-1;
    if(i[0]==i[1])a=i[0]*2;
    console.log(a);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)
        {
            var abck = Input3();
            var ans = 0l;

            if (abck[3] <= abck[0]) ans = abck[3];
            else if (abck[3] <= abck[0] + abck[1]) ans = abck[0];
            else ans = abck[0] - (abck[3] - abck[0] - abck[1]);
            
            
            Console.WriteLine(ans);



        }






    





        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }
        
        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }
    }
}


Measured memory_bytes: 27548
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int x = (a + b + 1) / 2;
		
		System.out.println(x);

		}
}

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

int main() {
    int x;
    cin >> x;

    for (int i = x; true; i++) {
        bool prime = true;
        for (int n = 2; n <= sqrt(i); n++) {
            if (i % n == 0) {
                prime = false;
                break;
            }
        }
        if (prime) {
            cout << i << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
        int H,W;

        cin >> H >> W;
        int i,j;
        vector<string> a(H);

        for(i=0;i<H;i++){
                cin >> a[i];
        }

        vector<bool> row(H,false);
        vector<bool> col(W,false);

        for(i=0;i<H;i++){
                for(j=0;j<W;j++){
                        if(a[i][j]=='#'){
                        row[i]=true;
                        col[j]=true;
                        }
                }
        }

        for(i=0;i<H;i++){
                if(row[i]){
                        for(j=0;j<W;j++){
                                if(col[j]){
                                cout << a[i][j];
                                }
                        }
                cout << endl;
                }
        }

        return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a;
  scanf("%d",&a);
  int i,x[101];
  for(i=1;i<=a;i++){
    scanf("%d",&x[i]);
  }
  int e,j,y,u=0,q=0,z,t;
  for(i=1;i<=a;i++){
    for(j=1;j<=a;j++){
      y=x[i]*x[j];
      u=u+y;
    }
  }
  for(i=1;i<=a;i++){
    z=x[i]*x[i];
    q=q+z;
  }

  t=u-q;
  e=t/2;

  printf("%d",e);

  return 0;
}






Measured memory_bytes: 128
n = int(input())
var = list(map(int, input().split()))
var_max = 0
alice = 0
bob = 0
for y in range(n):
    var_max = 0
    for x in var:
        if(var_max <= x):
            var_max = x
    var.remove(var_max)
    if(y % 2 == 0):
        alice += var_max
    else:
        bob += var_max
print(alice - bob)


Measured memory_bytes: 3060
lmod = []
l = []
for i in range(5):
    l.append(int(input()))
    if l[i]%10 != 0:
        lmod.append(10 - l[i]%10)
    else:
        lmod.append(0)
lmod.pop(lmod.index(max(lmod)))
s = sum(l) + sum(lmod)
print(s)

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n, k;
	vector<ll> v;
	ll ans = 1LL << 60;

	cin >> n;

	REP(i, n) {
		ll a;
		cin >> a;
		if (i == 0) {
			v.push_back(a);
		}
		else {
			v.push_back(a + v[i - 1]);
		}
	}

	REP(i, n - 1) {
		if (abs(v[n - 1] - v[i] * 2) < ans) {
			ans = abs(v[n - 1] - v[i] * 2);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define V vector<int>
#define VP vector<pair<int, int> >
#define FASTIO ios_base::sync_with_stdio(0)
using namespace std;
#ifdef _WIN32
#include <windows.h>
#define print(x) PRINT(x, #x)
template<typename T> inline const void PRINT(T VARIABLE, string NAME)
{
#ifndef ONLINE_JUDGE /// ONLINE_JUDGE IS DEFINED ON CODEFORCES
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hConsole, 10);
    cerr << NAME << " = " << VARIABLE << '\n';
    SetConsoleTextAttribute(hConsole, 7);
#endif
}
#else
#define print(x) 0
#endif
struct pair_hash
{
    template<typename T1, typename T2>
    size_t operator () (const pair<T1, T2> &p) const
    {
        auto h1 = hash<T1>{}(p.first);
        auto h2 = hash<T2>{}(p.second);
        return h1 ^ h2;
    }
};
typedef long long ll;
typedef unsigned long long ull;
const ll INFLL = 2 * (ll)1e18 + 100;
const int INFINT = 2 * (int)1e9 + 100;
//ifstream fin(".in");
//ofstream fout(".out");
void die()
{
    cout << "NO";
    exit(0);
}
const int NMAX = 2 * 1e5 + 5;
const int MOD = 1e9 + 7; /// careful here (7 or 9, 66.. etc)
const double PI = atan(1) * 4;
const double EPS = 1e-12;

int n, m;
V graf[NMAX];
bool trecut[NMAX];
int cost[NMAX];

void bfs(int nod)
{
    for1(i, n) cost[i] = INFINT;
    cost[1] = 0;
    queue<int> coada;
    coada.push(nod);
    while(!coada.empty())
    {
        nod = coada.front();
        coada.pop();
        for(auto i: graf[nod])
            if(cost[i] > cost[nod] + 1)
            {
                cost[i] = cost[nod] + 1;
                coada.push(i);
            }
    }
}

int main()
{
    FASTIO;
    cin >> n >> m;
    for1(i, m)
    {
        int a, b;
        cin >> a >> b;
        graf[a].pb(b);
        graf[b].pb(a);
    }
    bfs(1);
    if(cost[n] == 2) cout << "POSSIBLE";
    else cout << "IMPOSSIBLE";


    return 0;
}


Measured memory_bytes: 13168
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt(), x = in.nextInt(), t = in.nextInt();
            out.println((long) Math.ceil(((double) n) / x) * t);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32440
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;
int main() {
    abdelrahman010
    ll a , b , c , d;
    cin >> a >> b >> c >> d;
    ll cnt = b / c - a / c + (a % c == 0);
    cnt += b / d - a / d + (a % d == 0);
    ll lcm = c * d / __gcd(c , d);
    cnt -= b / lcm - a / lcm + (a % lcm == 0);
    cout << (b - a + 1) - cnt;
    return 0;
}

Measured memory_bytes: 256
import math

input1= input()
A = int(input1.split()[0])
B = int(input1.split()[1])


C = A * B
C_sqrt_int = int(math.sqrt(C))

for i in range(C_sqrt_int):
    while A%(i+2) == 0 and B%(i+2) == 0:
        C = C / (i+2)
        A = A / (i+2)
        B = B / (i+2)


print(int(C))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main() 
{
  int n;
  cin >> n;
 
  vector<int> w(110);
  for (int i = 0; i < n; i++) {
    cin >> w[i];
  }
  int sum = 0;

  for (int i = 0; i < n; i++) {
    sum += w[i];
  }
  int minDiff = 9999;

  for (int i = 0; i < n; i++) {
    int diff = sum;
    for (int j = 0; j <= i; j++) {
      diff -= w[j] * 2;
    }
    if (minDiff > abs(diff)) minDiff = abs(diff);
  }

  cout << minDiff << endl;
}

Measured memory_bytes: 256
N, K = [int(s) for s in input().split()]

def main():
    k = K
    a = {}
    for i in range(N):
        n, i = [int(s) for s in input().split()]
        if n not in a:
            a[n] = 0
        a[n] += i
    for n, i in sorted(a.items()):
        k -= i
        if k <= 0:
            ans = n
            break
    print(ans)

if __name__ == '__main__':
    main()


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

int main() {

  int A, B;
  cin >> A >> B;

  if(A % 3 == 0) cout << "Possible" << endl;
  else if(B % 3 == 0) cout << "Possible" << endl;
  else if((A + B) % 3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}


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

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

int main(void) {
    int h, n, a;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> n;
    REP(i, n) {
        cin >> a;
        h -= a;
    }

    cout << (h <= 0? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string cof;
  cin >> cof;
  char a = cof.at(2),b = cof.at(3),c = cof.at(4),d = cof.at(5); 
  if(a == b && c == d)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int h, w, n; cin >> h >> w >> n;
  if (h < w) swap(h, w);
  int op = (n + h - 1) / h;
  cout << op << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
long long n,ans;
int main(void)
{
    scanf("%lld",&n);
    for(long long i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)ans+=i;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 3824
# -*- coding: utf-8 -*-

import sys
N,T=map(int, sys.stdin.readline().split())
AB=[ map(int, sys.stdin.readline().split()) for _ in range(N) ]

AB.sort()

N=6005
dp=[ None for _ in range(N) ]
dp[0]=0

for a,b in AB:
    for i in range(N-1,-1,-1):
        if dp[i] is not None and i<T:
                dp[i+a]=max(dp[i+a],dp[i]+b)

print max(dp)


Measured memory_bytes: 33640
#include <iostream>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <numeric>
#include <cctype>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define pb push_back
#define mp make_pair

typedef unsigned uint;
typedef long long ll;
typedef unsigned long ulong;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;

typedef double Real;
const Real eps = 1e-9;
const Real inf = 1e20;

int main(){
    int n;
    int k,m;
    m = 100000;
    cin >> n;

    for(int i = 0;i < n;i++){
        m = m*1.05;
        k = m%1000;
        if(k > 0){
            m = 1000+m - k;
        }
    }
    cout << m << endl;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

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

    int cntAC=0, cntWA=0, cntTLE=0, cntRE=0;

    rep(i,n){
        string s;
        cin >> s;
        if(s == "AC") cntAC++;
        if(s == "WA") cntWA++;
        if(s == "TLE") cntTLE++;
        if(s == "RE") cntRE++;
    }

    cout << "AC x " << cntAC << endl << "WA x " << cntWA << endl << "TLE x " << cntTLE << endl << "RE x " << cntRE << endl;

    return 0;
    
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
typedef long long ll;
/**
 * Uncomment the #define below if problem contains multiple test cases
 */
// #define MULTIPLE_TESTS 1

void solve() {
  int n;
  cin >> n;
  ll x;
  vector<ll> arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  vector<ll> brr(n);
  ll xori = 0;
  for (int i = 0; i < n / 2; ++i) {
    brr[i] = arr[i] ^ arr[n - i - 1];
    xori ^= brr[i];
    brr[n - i - 1] = brr[i];
  }
  vector<ll> ans(n);
  for (int i = 0; i < n; ++i) {
    ans[i] = arr[i] ^ xori ^ brr[i];
  }
  reverse(ans.begin(), ans.end());
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << " ";
  }
  cout << endl;
}

int main() {
  FAST_IO;
  int t = 1;
#ifdef MULTIPLE_TESTS
  cin >> t;
#endif

  while (t--) {
    solve();
  }

  return 0;
}

Measured memory_bytes: 7920
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using namespace std;


long long MOD = 1e9 + 7;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    long long t=s.size();
    long long dp[s.size()+1][13];
    long long i,j,k,g;
    for(i=0;i<t+1;i++)for(j=0;j<13;j++)dp[i][j]=0;
    dp[0][0] = 1;
    for(i=0;i<t;i++)
    {
        for(j=0;j<13;j++)
        {
            if (s[i] == '?')
            {
                for(k=0;k<10;k++)
                {
                    g=(j*10 + k)%13;
                    dp[i + 1][g] += dp[i][j];
                    if(dp[i + 1][g]>=MOD)dp[i + 1][g]-=MOD;
                }
            }
            else
            {
                g=(j * 10 + (s[i] - '0'))%13;
                dp[i + 1][g] += dp[i][j];
                if(dp[i + 1][g]>=MOD)dp[i + 1][g]-=MOD;
            }
        }
    }
    cout << dp[t][5] << endl;
}


Measured memory_bytes: 10704
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define repi(i, a, b) for (long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    a %= 500;
    if (a <= b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

void resetArray(int x[], int n) {
  int i;
  for (i = 0; i < n; i++)
    x[i] = 0;
}

int main(void) {
  char as[100], bs[100];
  int a[100], b[100], c[100];
  int n, ch, i, an, bn, abn, cn;

  while (scanf("%d", &n) != EOF) {
    while (n--) {
      resetArray(a, 100);
      resetArray(b, 100);
      resetArray(c, 100);
      
      scanf("%s", as);
      scanf("%s", bs);

      an = strlen(as);
      bn = strlen(bs);
      
      for (i = 0; i < an; i++)
	a[i] = as[an-i-1] - '0';
      
      for (i = 0; i < bn; i++)
	b[i] = bs[bn-i-1] - '0';
      
      abn = (an > bn) ? an : bn;
      
      for (i = 0; i < abn; i++) {
	c[i+1] = (a[i] + b[i] + c[i]) / 10;
	c[i] = (a[i] + b[i] + c[i]) % 10;
      }
      if (c[i]) cn = i + 1;
      else cn = i;
      
      if (cn > 80) 
	printf("overflow\n");
      else {
	for (i = 0; i < cn; i++)
	  printf("%d", c[cn-i-1]);
	putchar('\n');
      }
    }
  }
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define REP(i, N) for (int i = 0; i < N; i++)
#define REP1(i, N) for (int i = 1; i < N; i++)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ANS(a) cout << a << endl;
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())

#define DBG(V) for (auto v : V) cout << v << " "; cout << endl

int N;
vector<pair<int, int>> BA;

int
main()
{
  cin >> N;
  REP(i, N) { int a, b; cin >> a >> b; BA.emplace_back(make_pair(b, a)); }
  SORT(BA);

  ll time = 0;
  REP(i, N) { 
    time += BA[i].second;
    if (BA[i].first < time) {
      ANS("No");
      return 0;
    }
  }

  ANS("Yes");
  
  return 0;
}


Measured memory_bytes: 2420
import sys

N, M = list(map(int, input().split()))
A = set()

sys.setrecursionlimit(N * 10)

Z = 1000000007

for _ in range(M):
    a = int(input())
    A.add(a)


B = [-1] * (N + 1)
B[0] = 0


def d(n):
    if n < 1:
        return 0
    if n in A:
        B[n] = 0
        return 0

    if B[n] != -1:
        return B[n]
    if n == 1:
        return 1
    if n == 2:
        if 1 in A:
            return 1
        return 2

    if n - 1 in A and n - 2 in A:
        return 0

    if n - 1 in A:
        B[n] = d(n-2)
        return B[n]

    if n - 2 in A:
        B[n] = d(n-1)
        return B[n]

    B[n] = (d(n-2) + d(n-1)) % Z
    return B[n]


print(d(N))


Measured memory_bytes: 51480