akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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 vi = vector<int>;
using vvi = vector<vi>;
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1};
const vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0};
const vi d4y = {0, 1, 0, -1};

//---------------from here-----------------

int main(){
    int n; cin>>n;
    vector<pair<int,int>> xy(n);
    rep(i,n){
        cin>>xy[i].first>>xy[i].second;
    }

    vector<int> combi(n);
    rep(i,n) combi[i]=i;

    long double dist=0.0;
    int pat=0;
    do{
        rep(i,n-1){
            dist+=sqrt(pow(xy[combi[i]].first - xy[combi[i+1]].first,2)+ pow(xy[combi[i]].second - xy[combi[i+1]].second,2));
        }
        pat++;
    }while(next_permutation(combi.begin(),combi.end()));

    dist/=pat;
    cout<<fixed<<setprecision(10);
    cout<<dist<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)

int main(){
  ll n, k, ans, ans2;
  cin >> n >> k;
  ans = n%k;
  ans2 = abs(ans - k);
  ans = min(ans, ans2);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int[] A = new int[n];

            for (int i = 0; i < n; i++)
            {
                A[i] = int.Parse(Console.ReadLine());
            }

            Console.WriteLine(GetLIS(A));
        }

        static int GetLIS(int[] A)
        {
            int n = A.Length, length = 1;

            Nullable<int>[] L = new Nullable<int>[n];
            L[0] = A[0];

            for (int i = 1; i < n; i++)
            {
                if (L[length - 1] < A[i])
                {
                    L[length++] = A[i];
                }
                else
                {
                    for (int j = 0; j < length; j++)
                    {
                        if (L[j] >= A[i])
                        {
                            L[j] = A[i];
                            break;
                        }
                    }
                }
            }
            return length;
        }
    }
}

Measured memory_bytes: 10676
program main
implicit none
integer :: n, i, m, l
character :: s*100
read(*,*) n
read(*,*) s(1:n)

m = 0
do i = 1 , n
   if( s(i:i) == 'R' ) then
      m = m+1
   else
      l = l+1
   end if
end do

if( m>l) then
   write(*,*) 'Yes'
   stop
else
   write(*,*) 'No'
end if

end program main


Measured memory_bytes: 768
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<map>
using namespace std;
const int N=1e4+50;
const long long INF=0x3f3f3f3f3f3f3f3f;
typedef long long ll;
double length[N][N];
double d[N];
bool vis[N];
int n;
struct circular
{
   double x,y;
   double r=0;
}c[N];
void dijkstra(int s)
{
    for(int i=0;i<=n+1;i++)
        d[i]=INF;
    d[s]=0;
    while(1)
    {
        int v=-1;
        for(int i=0;i<=n+1;i++)
        {
            if(!vis[i]&&(v==-1||d[i]<d[v]))
                v=i;
        }
        if(v==-1)
         break;
        vis[v]=1;
        for(int i=0;i<=n+1;i++)
        d[i]=min(d[i],d[v]+length[v][i]);
    }
}
int main()
{
    double x1,y1;
    scanf("%lf%lf%lf%lf",&c[0].x,&c[0].y,&x1,&y1);
    scanf("%d",&n);
    c[n+1].x=x1;
    c[n+1].y=y1;
    for(int i=1;i<=n;i++)
    {
        scanf("%lf%lf%lf",&c[i].x,&c[i].y,&c[i].r);
    }
    for(int i=0;i<=n+1;i++)
    {
        for(int j=i+1;j<=n+1;j++)
        {
           length[i][j]=(double)sqrt((double)(c[i].x-c[j].x)*(c[i].x-c[j].x)+(long double)(c[i].y-c[j].y)*(c[i].y-c[j].y));
            length[i][j]-=c[i].r+c[j].r;
            if(length[i][j]<0)
             length[i][j]=0;
            length[j][i]=length[i][j];
        }
    }
    dijkstra(0);
    printf("%.9f\n",d[n+1]);
    return 0;
}

Measured memory_bytes: 78592
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a-1;i>=(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 1000000000000000000;
const char END = '\n';

ll a, b, c;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	cin >> a >> b >> c;

	if (b*c>= a)
		cout << "Yes" << END;
	else
		cout << "No" << END;
	return 0;
}


Measured memory_bytes: 3556
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'

const int N = 200005;

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	for(int i = 1 ; i <= s.size() ; i ++){
		if(i % 2 == 1) {
			if(s[i - 1] == 'L') return cout << "No",0;
		}
		else {
			if(s[i - 1] == 'R') return cout << "No",0;
		}
	}
	cout << "Yes";
}


Measured memory_bytes: 256
k = int(input())
if k % 2 == 0:
    print("-1")
    exit()
if k == 1 or k == 7:
    print("1")
    exit()

seven_i = 7
for i in range(1,10**6):
    seven_i = seven_i*10+7
    seven_mod = seven_i % k

    if seven_mod == 0:
        print(i+1)
        exit()
    seven_i = seven_mod
print("-1")


Measured memory_bytes: 9132
#include<stdio.h>
#define WHITE 2
#define GRAY 1
#define BLACK 0

int d[101],f[101],color[101],m,time;
int mat[101][101] = {{0}};

void visit(int u){
  int i;
  color[u] = GRAY;
  d[u] = ++time;
  for(i = 1; i <= m; i++){
    if(mat[u][i] == 1 && color[i] == WHITE) visit(i);
  }
  color[u] = BLACK;
  f[u] = ++time;
}


void dfs(void){
  int i;
  for(i = 1; i <= m; i++) color[i] = WHITE;
  time = 0;
  for(i = 1; i <= m; i++){
    if(color[i] == WHITE) visit(i);
  }
}


int main(){
  int next[100][100];
  int k,num,i,j;

  scanf("%d",&m);

  for(i = 1; i <= m; i++){
    scanf("%d %d",&num,&k);
    for(j = 1 ; j <= k; j++){
      scanf(" %d",&next[i][j]);
      mat[i][next[i][j]] = 1;
    }
  }
  

  dfs();

  for(i = 1; i <= m; i++){
    printf("%d %d %d\n",i,d[i],f[i]);
  } 
 
  return 0;
}



Measured memory_bytes: 2104
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next() + sc.next();
    int n = Integer.parseInt(s);
    boolean flag = true;
    for (int i = 0; i*i <= n; i++) {
      if (i*i == n) {
        flag = false;
      }
      if (i*i > n) {
        break;
      }
    }
    if (flag) System.out.println("No");
    else System.out.println("Yes");
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;
int main(void){
    ll N,L,T;
    cin >> N >> L >> T;
    vector<ll> X(N);
    vector<bool> W(N);//０なら時計回り,１なら反時計回り
    for(int i = 0; i < N; i++){
        cin >> X.at(i);
        int a;
        cin >> a;
        a--;
        W.at(i) = a;
    }
    
    vector<ll> afterX(N);
    for(int i = 0; i < N; i++){
        if(W.at(i)){//反時計回り
            afterX.at(i) = (((X.at(i) - T) % L) + L) % L;
        }else{
            afterX.at(i) = (X.at(i) + T) % L;
        }
    }
    
    ll through = 0;
    for(int i = 0; i < N; i++){
        if(W.at(0) != W.at(i)){
            
            ll sa;
            if(!W.at(0)){//時計回り
                sa =  X.at(i) - X.at(0);
            }
            else{//反時計回り
                sa =  X.at(0) + (L - X.at(i));
            }
            
            if(T * 2 >= sa){
                through += 1 + (2 * T - sa) / L;
            }
        }
    }
    
    ll position = 0;
    
    
    if(W.at(0)){//反時計回り
        position -= through;
    }else{//時計回り
        position += through;
        
    }
    
    position = ((position % N) + N) % N;
    //Pがposition番目に出力されたい
    
    ll P = afterX.at(0);
    
    
    sort(afterX.begin(), afterX.end());
    
    bool l = 0;
    ll I1;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(afterX.at(i) == P){
            cnt++;
            if(cnt == 1){
                I1 = i;
            }
            else if(cnt == 2){
                l = 1;
            }
        }
    }
    //I1はPの場所
    
    if(l){
        if( (W.at(0) + through) % 2 == 1){
            if(W.at(0))I1++;
        }
        else{
            if(!W.at(0))I1++;
            
        }
    }
    
    
    for(int i = 0; i < N; i++){
        cout << afterX.at((((I1 - position + i) % N) + N) % N) << endl;
    }
    
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define mod 1000000007
#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a;i<b;i++)

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main(){
    FASTIO
    int n;
    string s,ss;
    cin>>n>>s;
    if(s.size()>n){
        ss=s.substr(0,n);
        cout<<ss<<"...";
    }
    else cout<<s;
    return 0;
}


Measured memory_bytes: 3628
import java.util.*;
import java.math.*;

public class Main {

    static long MOD = 1000000007;



    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean hoge = false;  
        for(int i = 0; i < s.length() - 1; i++) {
            if(s.charAt(i) == s.charAt(i + 1)) hoge = true;
        }
        System.out.println(hoge?"Bad":"Good");

    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;

struct node {
    std::vector<int> nextnode;
    std::vector<int> nextcost;
};

void seeker(std::vector<int>& colors, std::vector<node>& nodelist, int now)
{
    for (int i = 0; i < nodelist[now].nextnode.size(); i++) {
        int next = nodelist[now].nextnode[i];
        if (colors[next] != -1) {
            continue;
        }
        if (nodelist[now].nextcost[i] % 2 == 1) {
            colors[next] = (colors[now] ^ 1);
        } else {
            colors[next] = colors[now];
        }
        seeker(colors, nodelist, next);
    }
}


signed main()
{
    int n;
    cin >> n;
    std::vector<node> nodelist(n);
    for (int i = 0; i < n - 1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        nodelist[u].nextnode.pb(v);
        nodelist[v].nextnode.pb(u);
        nodelist[u].nextcost.pb(w);
        nodelist[v].nextcost.pb(w);
    }
    std::vector<int> colors(n, -1);
    colors[0] = 0;
    seeker(colors, nodelist, 0);
    for (int i = 0; i < n; i++) {
        cout << colors[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 13696
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

int main() {
    int N, M;
    std::cin >> N >> M;
    
    std::vector<std::pair<long, long>> D(N);
    long A, B;
    for (int i = 0; i < N; i++) {
        std::cin >> A >> B;
        D[i] = std::make_pair(A, B);
    }

    std::sort(D.begin(), D.end(), [] (const auto &lhs, const auto &rhs) {
        return lhs.first < rhs.first;
    });

    int res = M;
    long price = 0;
    
    for (auto && drink : D) {
        if (res <= drink.second) {
            price += res * drink.first;
            break;
        }
        price += drink.first * drink.second;
        res -= drink.second;
    }

    std::cout << price << std::endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
	char s[10];int f=0;
    scanf("%s",s);
	for(int i=1;s[i]!='\0';i++)
	
		if(s[i]=='C'&&s[i-1]=='A')
		{f=1;
		break;}
	if(f)
	printf("Yes\n");
		else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>

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

typedef long long int64;

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	int x, y, z;
	cin >> x >> y >> z;
	if (x + y + z >= 22) {
	    cout << "bust" << endl;
	} else {
	    cout << "win" << endl;
	}

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 500000
#define INFTY 1000000000
void merge(int* ,int, int,int);
void mergeSort(int* ,int, int);
int count;

int main(){
  int s,i,A[N];
  
  scanf("%d",&s);
  for(i = 0 ; i < s ; i++) scanf("%d",&A[i]);
  mergeSort(A,0,s);
  for(i = 0 ; i < s-1 ; i++) printf("%d ",A[i]);
  printf("%d\n",A[i]);
  printf("%d\n",count);
  return 0;
}


void merge(int A[],int left,int mid,int right){
  int n1,n2,i,j,k;
  n1 = mid - left;
  n2 = right - mid;
  int L[n1+1], R[n2+1];
  for(i = 0 ; i < n1 ; i++) L[i] = A[left + i];
  for(i = 0 ; i < n2 ; i++) R[i] = A[mid + i];
  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;
  for(k = left ;k < right ; k++){
    count++;
    if( L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{ 
      A[k] = R[j];
      j++;
    }
  }
}
void mergeSort(int A[],int left,int right){
  int mid;
  if (left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

Measured memory_bytes: 4504
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    string s;
    cin >> s;

    int n = s.length();
    vbool d(4, false);
    rep(i, n) {
        if (s[i] == 'N') d[0] = true;
        if (s[i] == 'W') d[1] = true;
        if (s[i] == 'S') d[2] = true;
        if (s[i] == 'E') d[3] = true;
    }

    int e = 0;
    rep(i, 4) if (d[i]) e += 1 << i;

    yns(e == 15 || e == 10 || e == 5);
    return 0;
}

Measured memory_bytes: 256
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, 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 each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; 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; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  vector<ll> v;
  ll sum = 0;
  rep(i, n) {
    ll a, b; cin >> a >> b;
    sum += a;
    v.eb(a + b);
  }
  sort(all(v), greater<ll>());
  rep(i, n) {
    if (i % 2 == 1) {
      sum -= v[i];
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 1396
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cassert>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

#define read_int(X) \
    ll X;           \
    scanf("%lld\n", &X);

#define read_two_int(X, Y) \
    ll X, Y;               \
    scanf("%lld %lld\n", &X, &Y);

#define read_three_int(X, Y, Z) \
    ll X, Y, Z;                 \
    scanf("%lld %lld %lld\n", &X, &Y, &Z);

#define read_four_int(X, Y, Z, W) \
    ll X, Y, Z, W;                \
    scanf("%lld %lld %lld %lld\n", &X, &Y, &Z, &W);

vector<vector<ll>> dp(2000, vector<ll>(2000, -1));
ll search(ll rest, ll n)
{
    if (dp[rest][n] != -1)
        return dp[rest][n];

    if (n == 1)
    {
        dp[rest][n] = 1;
        return 1;
    }

    if (n == 2)
    {
        dp[rest][n] = rest + 1;
        return rest + 1;
    }

    ll ans = 0;
    ll left = n / 2;
    for (ll i = 0; i <= rest; i++)
    {
        ans += search(rest - i, left) * search(i, n - left);
        ans %= mod;
    }
    dp[rest][n] = ans;
    return ans;
}

int main()
{
    ll S;
    scanf("%lld", &S);

    ll ans = 0;
    for (ll i = 1; i <= S / 3; i++)
    {
        ll rest = S - i * 3;
        ans += search(rest, i);
        ans %= mod;
    }

    printf("%lld\n", ans);
}


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

const int MOD = 1000000007;

int64_t modpow(int64_t x, int64_t n) {
  x = x % MOD;
  if (n == 0)
    return 1;  //再帰の終了条件

  else if (n % 2 == 1) {
    return (x * modpow(x, n - 1)) % MOD;  // nが奇数ならnを1ずらす
  } else
    return modpow((x * x) % MOD, n / 2) % MOD;  // nが偶数ならnが半分になる
}

int64_t comb(int64_t n, int64_t k) {
  int64_t x = 1;
  for (int i = n - k + 1; i <= n; i++) {
    x = x * i % MOD;
  }

  int64_t y = 1;
  for (int i = 1; i <= k; i++) {
    y = y * i % MOD;
  }
  y = modpow(y, MOD - 2);

  return x * y % MOD;
}

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

  int all = modpow(2, n) - 1;
  int muri = comb(n, a) + comb(n, b);

  int ans = all - muri;
  while (ans < 0) {
    ans += MOD;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    //ios::sync_with_stdio(false);
    //freopen("data.txt", "r", stdin);
    int n;
    string s;
    cin>>n;
    cin>>s;

    int x=0,maxx = 0;
    for(auto itr=s.begin();itr!=s.end();++itr){
        if(*itr=='I'){
            ++x;
            if(x>maxx){
                maxx = x;
            }
        }else{
            --x;
        }
    }
    cout<<maxx<<endl;
    return 0;
}


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

#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
#define repinv(i, st, n) for (int i = ((n)-1); i >= (st); --i)
#define MEM(a, b) memset(a, b, sizeof(a));
#ifdef LOCAL
#define debug(x) std::cerr << #x << ": " << x << endl
#else
#define debug(x) 860111
#endif
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileIO(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

//mt19937 mrand(random_device{}());
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
pii operator+(const pii&x, const pii&y) { return mp(x.X+y.X, x.Y+y.Y);}
pii operator-(const pii&x, const pii&y) { return mp(x.X-y.X, x.Y-y.Y);}
//INT_MAX, ULLONG_MAX, LLONG_MAX or numeric_limits<int>::min()

inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}

//------------------------------------------------------------------------//
int T;
const int maxn = 2e5+7;
ll n, m;
//ll a[maxn];

//check T
void solve()
{
	cin >> n >> m; //rep(i, 0, n) cin >> a[i];
	//cout << ((n*m)+1)/2 << endl;
	if(n == 1) cout << 1 << endl;
	else if(m ==1) cout << 1 << endl;
	else cout << m*(n/2ll) + (n%2ll)*((m+1ll)/2ll) << endl;
  return;
}


signed main()
{
  fastIO();
  T = 1;
  //cin >> T; //this
  while(T--) solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int p[1005];
int x[1005];
int su[1005];//sum
bool t[1005][5005];

int main(){
	int n;
	int i,j,k;
	int a,b,c;
	bool s=true;
	cin>>n;
	p[0]=-1;
	for(i=0;i<n;i++)t[i][0]=true;
	for(i=1;i<n;i++){
		cin>>p[i];
		p[i]--;
	}
	for(i=0;i<n;i++){
		cin>>x[i];
	}
	for(i=n-1;i>=0;i--){
		for(j=x[i];j>=0;j--){
			if(t[i][j])break;
		}
		if(j==-1){
			s=false;
			break;
		}
		if(i!=0){
			k=p[i];
			su[k]+=su[i]+x[i]-j;
			a=x[i],b=su[i]-j;
			for(j=x[k];j>=0;j--){
				if(!t[k][j])continue;
				t[k][j]=false;
				if(j+a<=x[k])t[k][j+a]=true;
				if(j+b<=x[k])t[k][j+b]=true;
			}
		}
	}
	print_POSSIBLE_IMPOSSIBLE(s);
	return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int m, n;
  cin >> n >> m;
  vector<int> x(m), y(m);
  for (int i = 0; i < m; i++){
    cin >> x[i];
  }
  if(n >= m){
    cout << 0 << "\n";
    return 0;
  }
  sort(x.begin(), x.end());
  for (int i = 0; i<m-1 ; i++){
    y[i] = x[i + 1] - x[i];
  }
  
  sort(y.begin(), y.end());
  reverse(y.begin(), y.end());
  int ans = 0;
  for (int i = 0; i < n - 1; i++)
  {
    ans += y[i];
  }
  cout << x[m-1] - x[0] - ans << "\n";
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fe first
#define se second
#define pii pair<int,int>
#define PI  3.14159265358979323846
const int N=1e5+10;
const int INF=1e9+10;

ll v,wei,n,sub,val,maxi;
vector<ll> dp(N);

void solve()
{ int n,w;
	cin>>n>>wei;
	for(int i=0;i<n;i++)
     {  cin>>w>>val;
     	for(int j=wei-w;j>=0;--j)
     		 { dp[j+w]=max(dp[j+w],dp[j]+val);
     		 }
     }
     for(int i=0;i<=wei;i++)
     	  maxi=max(dp[i],maxi);

     	cout<<maxi;
}


int main()
{  cool;
   int t=1;
   while(t--)   
     solve(); 

  return 0; 
}






Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    ll A;
    string B;
    io.read(A, B);
    B.erase(B.begin() + B.find('.'));
    int _B = stoi(B);
    ll ans = A * _B;
    ans /= 100;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const ll inf = 1e18;
using namespace std;

int N,W;
ll w[maxn],v[maxn];
ll dp[maxn];
int main(){
    // debug;
    ios;

    cin>>N>>W;
    for(int i = 1;i<=N;i++) cin>>w[i]>>v[i];
    for(int i = 1;i<=N;i++){
        for(int j = 100000;j>=v[i];j--){
            if(dp[j] == 0){
                if(dp[j-v[i]] != 0) dp[j] = dp[j-v[i]] + w[i];
                else if(j - v[i] == 0) dp[j] = w[i]; 
            }else{
                if(dp[j-v[i]] != 0) dp[j] = min(dp[j],dp[j-v[i]] + w[i]);
                else if (j - v[i] == 0) dp[j] = min(dp[j],w[i]); 
            }
        }
    }
    for(int i = 100000;i>=0;i--){
        if(dp[i] != 0 && dp[i] <= W){
            cout<<i<<'\n';
            return 0;
        }
    }
    cout<<0<<'\n';
    
    return 0;
}


Measured memory_bytes: 5120
#include<iostream>

using namespace std;

int main(void){

    int x1, x2, y1, y2;

    cin >> x1 >> y1 >> x2 >> y2;

    int x = x2 - x1;
    int y = y2 - y1;

    cout << x2 - y << " " << y2 + x << " "
         << x1 - y << " " << y1 + x << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define rep(i, n) for (int i = 0; i < (int)n; i++)
typedef long long ll;
const ll MOD = 1e9+7;
const int inf = 1000000;
const int minf = -1000000;
const ll lnf = 1e9;
const ll mlnf = -1e9;

void debug_vector(vector<int>& v){
    int n = v.size();
    for (int i = 0; i < n; i++){
        cout << v[i] << " ";
    }
    cout << endl;
}

void solve();
int main(void){

    solve();
    return 0;
}

void solve(){
    // 入力

    int H, N;
    cin >> H >> N;

    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];

    
    // dp[i][d]:= i 番目の魔法で d ダメージ与える時の使う魔力の最小値
    // ans = dp[N][D]
    vector<vector<ll>> dp(N+10, vector<ll>(H+10, lnf));
    dp[0][0] = 0;

    for (int i = 0; i < N; i++){
        for (int d = 0; d <= H; d++){
            // 選ぶ時
            if (d - A[i] >= 0){
                dp[i+1][d] = min(dp[i][d], dp[i+1][d-A[i]] + B[i]);
            }
            else{// 与えるダメージの方が大きい時でも魔力を使う
                dp[i+1][d] = min(dp[i][0] + B[i], dp[i][d]);
            }
        }
    }
    cout << dp[N][H] << endl;

}


Measured memory_bytes: 79360
#include <iostream>
#include <complex>
#include <vector>
#include <cmath>
#define EPS 1.0e-10
using namespace std;

#define X real()
#define Y imag()
typedef complex<double> P;
 
vector<P> p;
int check(P a){
	int ret=0;
	for(int i=0;i<p.size();i++) if(abs(a-p[i]) < 1+EPS) ret ++;
	return ret;
}

int adjcircle(P a, P b){
	P dir = a-b, pos=(a+b)*0.5;
	dir = P(dir.Y, -dir.X);
	dir = dir*(1/abs(dir))*sqrt(1-abs(pos-a)*abs(pos-a));
	return max(check(pos+dir), check(pos-dir));
}

main(){
	int i,j,N;
	while(cin >> N, N){
		p = vector<P>(N);
		int ans = 1;
		for(i=0;i<N;i++) cin >> p[i].X >> p[i].Y;
		for(i=1;i<N;i++)
			for(j=0;j<i;j++)
				if(abs(p[i]-p[j])<=2.0) ans = max(ans, adjcircle(p[i], p[j]));
		cout << ans << endl;
	}
}

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

int main()
{
    int k, n, a[10]={0}, x, f=0;
    cin>>n>>k;
    for(int i=0;i<k;++i)
    {
        cin>>x;
        a[x] = 1;
    }
    for(int i=n;;++i)
    {
        f=0;
        string temp = to_string(i);
        for(int j=0;j<temp.length();++j)
        {
            if(a[temp[j]-'0'])
            {
                f=1;
                break;
            }
        }
        if(f==0)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<n<<endl;
    return 0;
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long

#define for(i,a,b) for (i=a; i<b; i++)
#define forb(i,a,b) for (i=a; i>b; i--)
#define all(S) S.begin(),S.end()
//#define sort(S) sort(all(S))

const int inf = 1e9;
const ll INF = 1e18;

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    int x,y,a,b,c,i;
    ll S=0;
    cin >> x >> y >> a >> b >> c;
    vector <int> A(a),B(b),C(c);
    for (i,0,a)
        cin >> A[i];
    for (i,0,b)
        cin >> B[i];
    for (i,0,c)
        cin >> C[i];
    sort(all(A),greater<int>()),sort(all(B),greater<int>());
    for (i,0,x)
    C.pb(A[i]);
    for (i,0,y)
    C.pb(B[i]);
    sort(all(C),greater<int>());
    for (i,0,x+y)
        S+=C[i];
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 5576
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
			Scanner sc = new Scanner(System.in);
			int a = sc.nextInt();
			int b = sc.nextInt();
			double c = sc.nextInt();
			double d,e,f;
			c = c * Math.PI / 180;
			d = a * b * Math.sin(c) / 2;
			e = a + b + Math.sqrt(Math.pow(a*Math.sin(c),2)+Math.pow(b-a*Math.cos(c), 2));
			f = b * Math.sin(c);
			System.out.println(d);
			System.out.println(e);
			System.out.println(f);
	}

}

Measured memory_bytes: 26292
#include <bits/stdc++.h>
  
using namespace std;
  
#define MAX 21
#define EPS 1e-9
#define INF 1e9
 
struct Point{
    double x, y;
}; 
 
int N;
Point h, d, crystal[MAX];
  
double dist(Point a, Point b){
    return sqrt(pow(a.x-b.x,2) + pow(a.y-b.y,2));
}
 
bool rec(int S, int v, double total_dist){
    if(S == (1 << N) - 1){
	return true;
    }
    for(int u = 0 ; u < N ; u++){
	if(!(S >> u & 1)){
	    if(total_dist + dist(crystal[v],crystal[u]) >= dist(d, crystal[u])){
		return false;
	    }
	}
    }
    for(int u = 0 ; u < N ; u++){
	if(!(S >> u & 1)){
	    if(rec(S | 1 << u, u, total_dist + dist(crystal[v],crystal[u]))){
		return true;
	    }
	}
    }
}
 
bool solve(){
    for(int i = 0 ; i < N ; i++){
	if(rec(0,i,dist(h,crystal[i]))){
	    return true;
	}
    }  
    return false;
}
  
int main(){
    while(cin >> N >> h.x >> h.y >> d.x >> d.y, (N + h.x + h.y + d.x + d.y)){
	for(int i = 0 ; i < N ; i++){
	    cin >> crystal[i].x >> crystal[i].y;
	}
	cout << (solve() ? "YES" : "NO") << endl;
    }
    return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define all(a) a.begin(),a.end()
using namespace std;

int main(){
	int n;
	cin>>n;
	rep(i,0,n){
		string s1,s2;
		cin>>s1>>s2;

		if(s1.size()<s2.size()) swap(s1,s2);

		for(int j=s1.size()-1,k=s2.size()-1;j>=0;j--,k--){
			if(k>=0) s1[j]+=s2[k]-'0';
			if(s1[j]>'9'){
				s1[j]-=10;
				if(j==0) s1="1"+s1;
				else s1[j-1]++;
			}
		}
		if(s1.size()>80){
			cout<<"overflow"<<endl; continue;
		}
		cout<<s1<<endl;
	}
}

/*int main(){
    int n;
    cin>>n;
    rep(i,0,n){
        int ans[85]={};
        vector<int> n1(80,0),n2(80,0);
        //rep(j,0,81)cout<<n1[j]<<" "<<n2[j]<<endl;
        string s1,s2; 
        cin>>s1>>s2;
        //cout<<s1<<" "<<s2<<endl;
        int sz1=s1.size(),sz2=s2.size();
 
        //rep(j,0,sz1) n1[j]=s1[sz1-1-j]-'0';
        //rep(j,0,sz2) n2[j]=s2[sz2-1-j]-'0';
 		
 		reverse(all(s1));
 		reverse(all(s2));

        rep(j,0,min((int)s1.size(),79)) n1[j]=s1[j]-'0';
        rep(j,0,min((int)s2.size(),79)) n2[j]=s2[j]-'0';

        reverse(all(n1));
        reverse(all(n2));

        for(int j=79;j>=0;j--){
           // cout<<"  "<<j<<" "<<n1[j]<<" "<<n2[j]<<endl;
            ans[j]+=n1[j]+n2[j];
            if(ans[j]>9){
            	if(j>0) {
            		ans[j-1]=1;
            		ans[j]-=10;
            	}
            }
            //cout<<" "<<j<<" "<<ans[j]<<endl;
        }
        if(ans[0]>9){
            cout<<"overflow"<<endl; break;
        }
        bool f=0;
        for(int j=0;j<80;j++){
            if(f==0 && ans[j]>0){
                f=1; cout<<ans[j];
            }else if(f||j==79) cout<<ans[j];
        }
        cout<<endl;
    }
}*/

Measured memory_bytes: 1212
from collections import defaultdict

d, g = map(int, input().split())

scores = []

for i in range(1, d + 1):
    p, c = map(int, input().split())
    scores.append([100 * i, p, c])


result = 10 ** 9
#print(scores)
n = 2 ** d
for i in range(n):
    #print(bin(i))
    cnt = 0
    point = 0
    memo = -1
    for j in range(d):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            point += scores[j][0] * scores[j][1] + scores[j][2]
            cnt += scores[j][1]
        else:
            memo = j

    #print(memo)
    if point >= g:
        result = min(result, cnt)
    else:
        if memo > -1:
            for k in range(scores[memo][1] - 1):
                cnt += 1
                point += scores[memo][0]
                if point >= g:
                    result = min(result, cnt)
                    break

print(result)


Measured memory_bytes: 40304
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define N 100005
const int mod=998244353;
LL f_pow(LL a,LL b){
    LL res=1,temp=a;
    while(b){
        if(b&1)res=res*temp%mod;
        temp=temp*temp%mod;
        b>>=1;
    }
    return res;
}
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    bitset<300> b[305];
    for(int i = 0;i<n;i++){
        for(int j = 0;j<m;j++){
            int x;
            scanf("%d",&x);
            b[i][j]=x;
        }
    }
    vector<bitset<300> > v;
    int tot=n;
    for(int i = 0;i<n;i++){
        for(auto &it:v){
            for(int k = 0;k<m;k++){
                if(it[k]||b[i][k]){
                    if(it[k]&&b[i][k]){
                        b[i]^=it;
                    }
                    else if(it[k]){

                    }
                    else{
                        swap(b[i],it);
                    }
                    break;
                }
            }
        }
        if(b[i].count()!=0){
            v.pb(b[i]);
            tot--;
        }
    }
    LL ans=(f_pow(2,n)-f_pow(2,tot))*f_pow(2,m-1)%mod;
    ans=((ans+mod)%mod);
    printf("%lld\n",ans);
}
/*


     0   
     1   1
     2   3
     3 5  1 0 0
    4*/

Measured memory_bytes: 256
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
typedef long long ll;

const int N = 10005, D = 100;
const int Mod = 1e9 + 7;

string s;
int d, n;
int dp[2][D][2];

int main()
{
  cin >> s >> d;
  n = sz(s);
  dp[0][0][0] = 1;
  int cur = 0;
  for(int i = 0; i < n; i++) {
    int nxt = cur ^ 1;
    int c = s[i] - '0';
    for(int r = 0; r < d; r++)
      dp[nxt][r][0] = dp[nxt][r][1] = 0;
    for(int r = 0; r < d; r++) {
      dp[nxt][r][0] = dp[cur][((r - c) % d + d) % d][0];
      dp[nxt][r][1] = 0;
      for(int di = 0; di < 10; di++) {
        int p = ((r - di) % d + d) % d;
        dp[nxt][r][1] = (dp[nxt][r][1] + dp[cur][p][1]) % Mod;
        if(c > di)
          dp[nxt][r][1] = (dp[nxt][r][1] + dp[cur][p][0]) % Mod;
      }
    }
    cur ^= 1, nxt ^= 1;
  }
  int ans = (dp[cur][0][0] + dp[cur][0][1] + Mod - 1) % Mod;
  cout << ans << endl;
  return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}

ll BinarySearch(ll ng, ll ok, function<bool(ll)> judge){
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(judge(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}


signed main(){
    int n;
    cin >> n;
    string str;
    cin >> str;

    auto fn = [&](ll len){
        map<string, set<int>> mp;

        REP(i, n - len + 1){
            string s = str.substr(i, len);
            mp[s].insert(i);
        }

        bool res = false;

        for(auto i : mp){
            int mi = *(i.second.begin()), ma = *(i.second.rbegin());
            res |= (ma - mi >= len);
        }
        
        return res;
    };

    ll ans = BinarySearch(n/2 + 1, 0, fn);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6784
import sys

input = sys.stdin.readline


def main():
    A, B, C, D = [s for s in input().rstrip()]

    ops = ["+", "-"]
    for op1 in ops:
        for op2 in ops:
            for op3 in ops:
                eq = "".join([A, op1, B, op2, C, op3, D])
                res = eval(eq)
                if res == 7:
                    ans = eq + "=7"

    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

int A[105];

int main() {
	int n, sum = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", A + i);
		sum += A[i];
	}
	int m;
	scanf("%d", &m);
	while(m--) {
		int p,x;
		scanf("%d %d", &p, &x);
		int aux = sum - A[p] + x;
		printf("%d\n", aux);
	}
}

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

#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
int main(){
    string s; cin >> s;
    if(s=="SUN") cout<<7<<endl;
    else if(s=="SAT") cout<<1<<endl;
    else if(s=="MON") cout<<6<<endl;
    else if(s=="TUE") cout<<5<<endl;
    else if(s=="WED") cout<<4<<endl;
    else if(s=="THU") cout<<3<<endl;
    else if(s=="FRI") cout<<2<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#define REP(i,a) for(int i = 0; i < (a); i++)
using namespace std;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a == b && b == c && c == a)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n,k;
  cin>>n>>k;
  map<Int,int> m;
  for(Int i=0;i<n;i++){
    Int a;
    cin>>a;
    m[a]++;
  }
  vector<Int> v;
  for(auto p:m) v.emplace_back(p.second);
  sort(v.begin(),v.end());
  if((Int)v.size()<=k){
    cout<<0<<endl;
    return 0;
  }
  cout<<accumulate(v.begin(),v.begin()+(v.size()-k),Int(0))<<endl;
  return 0;
}


Measured memory_bytes: 14964
/**
 *    author:  Sarfaraz
 *    created: 19.04.2020 17:51:34
**/

#include <bits/stdc++.h>
#define ll long long
using namespace std;

void solve(){

     float r;
     cin >> r;
     float pi=3.14;
     float c;
     c=2*pi*r;
     cout<<fixed<<setprecision(6)<<c<<endl;

}

int main(){


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();

return 0;
}



Measured memory_bytes: 3804
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    s=input()
    t=input()
    cnt=0
    for i in range(len(s)):
        if s[i]!=t[i]:
            cnt+=1
    print(cnt)
    
resolve()

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    int left = 0;
    int right = 0;
    int ans = 0;
    int remain = K;

    while (left < N) {
        while (right < N) {
            if (S[right] == '0') {
                if (remain > 0) {
                    if (right + 1 < N && S[right + 1] == '1') {
                        remain--;
                    }
                }else{
                    break;
                }
            }
            right++;
        }
        ans = max(ans, right - left);
        if (left == right) {
            right++;
        }
        if (S[left] == '0' && S[left + 1] == '1') {
            remain++;
        }
        left++;
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  a += b, c += d;
  
  if(a > c) cout << "Left" << endl;
  else if(a == c) cout << "Balanced" << endl;
  else cout << "Right" << endl;
}

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

int main() {
	int n;
  	cin>>n;
  
  	ll h[n];
  	rep(i,n)cin>>h[i];
  
  	bool ans=true;

  	for(int j=1;j<n;j++){
      	if(h[j-1]<h[j]){
        h[j]--;
        }
    	if(h[j-1]>h[j]){
        	ans=false;
          	break;
        }
      

    
    }
  
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 4320
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int a[10];
int b[10];
int c;
c=0;
while(c<10){
cin >>a[c];
c=c+1;}
c=0;
while(c<10){
cin >>b[c];
c=c+1;}
sort(a,a+10);
sort(b,b+10);
int d;
d=a[9]+a[8]+a[7];
int e;
e=b[9]+b[8]+b[7];
cout <<d <<" "<<e<<endl;}

Measured memory_bytes: 1180
var
n,i,j,cnt,t:Longint;
a,b:array[1..10000]of Byte;
begin
read(n);
t:=n+1-n mod 2;
for i:=1 to n do begin
for j:=i+1 to t-i-1 do begin
inc(cnt);
a[cnt]:=i;
b[cnt]:=j;
end;
if(j=t-i-1)or(j=t-i)then j:=t-i+1;
for j:=j to n do begin
inc(cnt);
a[cnt]:=i;
b[cnt]:=j;
end;
end;
writeln(cnt);
for i:=1 to cnt do writeln(a[i],' ',b[i]);
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int mn=100001,n,i,j,a[1000],k,x,y,mx=0;
double sum=0.0,tes;
int main(void)
{
	cin>>n;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(a[j]-a[i]<mn) mn=a[j]-a[i],y=j;
		}
		//cout<<"mn"<<" "<<y<<endl;
		for(j=n-1;j>=0;j--){
			if(j!=i&&j!=y){
				for(k=j-1;k>=0;k--){
					if(k!=y&&k!=i){
						tes=(double)(a[j]+a[k])/mn;
						if(sum<tes){
							sum=tes;
							break;
						}
					}
				}
				//cout<<j<<" "<<sum<<endl;;
				break;
			}
		}
	}
	printf("%.6f\n",sum);
	return 0;
}


Measured memory_bytes: 3244