akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string S;
    cin >> S;
    if(S[0]=='S')pr("Cloudy");
    else if(S[0]=='C')pr("Rainy");
    else pr("Sunny");
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll fc[225816]={1ll},nv[225816]={1ll},dp[3333];

ll rwpw(ll a, ll p){
	ll ret = 1ll;
	while(p){
		if(p&1){
			mul_mod(ret,a);
		}
		mul_mod(a,a);
		p >>= 1;
	}
	return ret;
}

ll comb(int n, int k){
	ll ret = fc[n];
	mul_mod(ret,nv[k]);
	mul_mod(ret,nv[n-k]);
	return ret;
}

vector<P> v;

int main(void){
	int h,w,n,i,j,r,c;
	ll ans;
	cin >> h >> w >> n;
	for(i=0; i<h+w; ++i){
		fc[i+1] = fc[i]*(i+1)%MOD;
		nv[i+1] = rwpw(fc[i+1],MOD-2);
	}
	for(i=0; i<n; ++i){
		cin >> r >> c;
		v.push_back(P(r,c));
	}
	sort(v.begin(),v.end());
	for(i=0; i<n; ++i){
		r = v[i].first - 1;
		c = v[i].second - 1;
		dp[i] = comb(r+c,r);
		for(j=0; j<i; ++j){
			r = v[i].first - v[j].first;
			c = v[i].second - v[j].second;
			if(r<0 || c<0){
				continue;
			}
			add_mod(dp[i],MOD-(dp[j]*comb(r+c,r))%MOD);
		}
	}
	ans = comb(h+w-2,h-1);
	for(i=0; i<n; ++i){
		r = h - v[i].first;
		c = w - v[i].second;
		add_mod(ans,MOD-(dp[i]*comb(r+c,r))%MOD);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3456
'use strict'

function main(s) {

  s = s.split('\n');
  const x = Number(s[0]);
  const a = Number(s[1]);
  const b = Number(s[2]);

  const ans = (x - a) % b;
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9420
N=int(input())
li=list(input())

W = [0] * (N + 1)
w = 0

for index, i in enumerate(li):
  if i == 'W':
    w += 1
  W[index + 1] = w

newLi = reversed(li)

E = list(reversed(W))
e = 0

for index, i in enumerate(newLi):
  if i == 'E':
    e += 1
  E[index + 1] += e

print(min(E))

Measured memory_bytes: 29368
#include <iostream>
using namespace std;
#define NUM 100
#define rep(i,a,n) for(i = a ; i < n; i++)
 
void trace(int[],int);
 
int main(void) {
 
  int i, j, a, N;
  int T[NUM] = {};
 
  cin >> a;
  rep(i,0,a) {
    cin >> T[i];
  }

  trace(T,a);

  rep(i,1,a) { 
    N = T[i];
    j = i - 1;
 
    while (j >= 0 && T[j] > N) {
      T[j + 1] = T[j];
      j--; 
    }

    T[j + 1] = N;
    trace(T,a);
  }
  return 0;
}
 
void trace(int T[],int n) {
 
  int i;
 
  rep(i,0,n) {
    if(i > 0) {
      cout << " ";
    } 
    cout << T[i];
  }
  cout << endl;
}

Measured memory_bytes: 1160
#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> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(),l.end());
    int ans = 0;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(l[i]==l[j]||l[j]==l[k]||l[i]==l[k]) continue;
                if(l[i]+l[j]>l[k]) ++ ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG=20;

ll n, m, k, u, v, x, y, t, a, b, ans;
ll dp[MAXN];
string S1, S2;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>S1>>S2;
	S1="#"+S1;
	S2="@"+S2;
	dp[0]=1;
	if (S1[1]==S2[1]) dp[1]=3;
	if (S1[2]!=S1[3]) dp[2]=6;
	for (int i=3; i<=n; i++){
		if (S1[i]==S2[i]){
			if (S1[i-1]==S2[i-1]) dp[i]=2*dp[i-1]%mod;
			else dp[i]=dp[i-1];
		}
		if (S1[i]==S1[i-1]){
			if (S1[i-2]!=S2[i-2]) dp[i]=3*dp[i-2]%mod;
			else dp[i]=2*dp[i-2]%mod;
		}
	}
	cout<<dp[n]<<'\n';
	
	return 0;
}
/*
52
RvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn
RLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn

*/

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>

typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for(ll i=init;i<(n);i++)

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

    if (s == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
        return 0;
    }

    bool c[26] = {false};
    int n = s.size();
    repi(i, n, 0) {
        c[s[i] - 'a'] = true;
    }
    if (n == 26) {
        for (int i = n - 1; i >= 0; i--) {
            bool flag = false;
            repi(j, 26, s[i] - 'a') {
                if (!c[j]) {
                    if (i + 1 != n) {
                        s.erase(i);
                    }
                    s.push_back('a' + j);
                    flag = true;
                    break;
                }
            }
            if (flag)break;
            c[s[i] - 'a'] = false;
            s.erase(i);
        }
    } else {
        for (int i = n - 1; i >= 0; i--) {
            bool flag = false;
            repi(j, 26, 0) {
                if (!c[j]) {
                    if (i + 1 != n) {
                        s.erase(i);
                    }
                    s.push_back('a' + j);
                    flag = true;
                    break;
                }
            }
            if (flag)break;
            c[s[i] - 'a'] = false;
            s.erase(i);
        }
    }

    cout << s << endl;
    return 0;
}

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

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;//998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template<class _T> static void getint(_T& a) {
	if (sizeof(_T) > sizeof(int)) {
		scanf("%lld", &a);
	}
	else {
		scanf("%d", &a);
	}
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}


static void exec()
{
	LLONG N;
	get(N);

	LLONG ans = 0;
	LLONG mod = 1;
	LLONG div = 2;
	while (div * mod <= N) {
		if (((N - mod) % mod) == 0) {
			div = (N - mod) / mod;
			if (N % div == mod) {
				ans += div;
			}
		}
		mod++;
		div = mod + 1LL;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 3764
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var n=Arr.shift()-0;
for(var I=0;I<n;I++){
   var str=Arr.shift();
   var obj={};
   for(var i=1;i<str.length;i++){
      var A=str.slice(0,i);
      var B=str.slice(i,str.length);
      var a=A.split("").reverse().join("");
      var b=B.split("").reverse().join("");
      obj[A+B]=true;
      obj[A+b]=true;
      obj[a+B]=true;
      obj[a+b]=true;
      obj[B+A]=true;
      obj[B+a]=true;
      obj[b+A]=true;
      obj[b+a]=true;
   }
   console.log(Object.keys(obj).length);
}

Measured memory_bytes: 12824
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>
#include <math.h>

using namespace std;
const long long INF = (long long) (1e18)+1;

int main() {
  int s, w;
  cin >> s >> w;
  if (s > w) {
    cout << "safe" << endl;
  } else {
    cout << "unsafe" << endl;

  }
  return 0;
}

Measured memory_bytes: 3620
function Main(input){
  var tmp = input.split(' ');
  var count = 0;
  for(var i=Number(tmp[0]);i<=Number(tmp[1]);i++){
    count += check(i);
  }
  function check(num){
    var str = String(num);
    var cut = str.substr(Math.ceil(str.length/2)).split('').reverse().join('');
    for(var i=0;i<cut.length;i++){
      if(str[i]!=cut[i]){
        return 0;
      }
    }
    return 1;
  }
  console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 13592
#include <stdio.h>
#include <vector>
#include <tuple>

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

using lli = long long int;
using info = std::pair<lli, lli>;
// DP[i][j] = (v, c) := 品物 1, ..., i から j 個選んだ時の価値の総和v, その方法数 c 
std::vector<std::vector<info>> DP;

int main(void){
    int n, a, b; scanf("%d%d%d", &n, &a, &b);
    DP.resize(n+1, std::vector<info>(n+1, info(0, 0)));
    DP[0][0] = {0, 1};
    REP(i, n){
        lli v; scanf("%lld", &v);
        for(int j = 0; j <= i; ++j){
            // not chosen
            if(DP[i+1][j].first < DP[i][j].first) 
                    DP[i+1][j] = DP[i][j];
            else if(DP[i+1][j].first == DP[i][j].first)
                    DP[i+1][j].second += DP[i][j].second;

            // chosen
            if(DP[i+1][j+1].first < DP[i][j].first + v)
                    DP[i+1][j+1] = {DP[i][j].first + v, DP[i][j].second};
            else if(DP[i+1][j+1].first == DP[i][j].first + v)
                    DP[i+1][j+1].second += DP[i][j].second;
        }
    }

    lli average[2], cnt; average[0] = 0; average[1] = 1;
    for(int x = a; x <= b; ++x){
        lli v1 = average[0] * x,
            v2 = average[1] * DP[n][x].first;
        if(v1 == v2){
            cnt += DP[n][x].second;
        }
        else if(v1 < v2){
            average[0] = DP[n][x].first;
            average[1] = x;
            cnt = DP[n][x].second;
        }
    }
    long double res = average[0]; res /= average[1];
    printf("%.16Lf\n%lld\n", res, cnt);
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    char[] s = scanner.next().toCharArray();
    char[] t = scanner.next().toCharArray();
    if (solve(s, t)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

  private static boolean solve(char[] s, char[] t) {
    for (int i = 0; i < s.length; i++) {
      boolean ans = true;
      for (int j = 0; j < s.length; j++) {
        if (s[j] != t[(j + i) % t.length]) {
          ans = false;
          break;
        }
      }
      if (ans) return true;
    }
    return false;
  }
}


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

using namespace std;

//#define LOG(...) fprintf(stderr,__VA_ARGS__)
#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ull term(string& e, int& idx);
ull expr(string& e, int& idx);

ull number(string& e, int& idx) {
    ull number = 0;
    for (; idx < e.size(); idx++) {
        if (!isdigit(e[idx])) {
            break;
        }
        number *= 10;
        number += e[idx] - '0';
    }
    LOG("--> number %d\n", number);
    return number;
}

ull term(string& e, int& idx) {
    switch (e[idx]) {
    case '(': {
        idx++; // (
        ull n = expr(e, idx);
        ull val = (n * n) % 1000000007;
        LOG("--> pow %d = %d\n", n, val);
        idx++; // )
        return val;
    }
    default:
        return number(e, idx);
    }
    assert(0);
}

ull expr(string& e, int& idx) {
    ull val = term(e, idx);
    for (; idx < e.size(); idx++) {
        switch (e[idx]) {
        case '>': {
            idx++;
            ull n = term(e, idx);
            LOG("--> shift %d %d = ", val, n);
            for (int i = n; i > 0 && val != 0; i--) {
                val >>= 1;
            }
            LOG("%d\n", val);
            idx--;
            break;
        }
        case ')':
            return val;
        }
    }
    return val;
}

int main() {
    string s;
    while (getline(cin, s), s != "#") {
        stringstream ss;
        REP(i, s.size()) {
            if (s[i] != ' ') {
                ss << s[i];
            }
        }
        s = ss.str();
        stringstream ss2;
        REP(i, s.size()) {
            switch (s[i]) {
            case 'S':
                i++;
                ss2 << '(';
                break;
            case '>':
                if (i+2 < s.size() && (isdigit(s[i+2]) || s[i+2] == 'S')) {
                    ss2 << '>';
                    i += 1;
                } else {
                    ss2 << ')';
                }
                break;
            case ' ':
                break;
            default:
                ss2 << s[i];
            }
        }

        string e = ss2.str();
        LOG("%s\n", e.c_str());

        int idx = 0;
        cout << expr(e, idx) << endl;
    }
}

Measured memory_bytes: 6044
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        
        while(true){
            int num ;
            int sum = 0;
            double ave = 0;
            int count = 0;
            num = in.nextInt();
            if(num == 0) break;
            int [] a = new int [num];
            for(int i = 0; i < a.length; i++){
                a[i] = in.nextInt();
                sum += a[i];
            }
            ave = sum/num;
    
            for(int i = 0; i < a.length ;i++){
                if(a[i] <= ave) count++;
            }
            System.out.println(count);
        }
    }
}


Measured memory_bytes: 59284
#include<bits/stdc++.h>
typedef long long ll;
#define pair<int,int> P
#define sc(N) scanf("%lld",&N);
using namespace std;
ll A[505];
ll B[505];

ll K;ll N;
bool check(ll x)
{
    ll t=0;
    for(int i=1;i<=N;i++){
        B[i]=(A[i-1])%x;
    }
    sort(B+1,B+N+1);
    for(int i=1;i<=N;i++){
        B[i]+=B[i-1];
    }
    for(int i=0;i<=N;i++){
        if(B[i]==x*(N-i)-B[N]+B[i]){
            if(B[i]<=K)return true;
        }
        if(B[i]>K)return false;
    }
    return false;
}
int main()
{

    sc(N);
    sc(K);
    ll t=0;
    for(int i=0; i<N; i++)
    {
        sc(A[i]);
        t+=A[i];
    }
    sort(A,A+N);
    ll ans=1;
    ll x;
    for(ll i=1; i*i<=t; i++)
    {
        if(t%i==0)
        {
            x=t/i;
            if(check(x))
            {
                ans=x;
                break;
            }
            else if(check(i))
            {
                ans=i;
            }

        }
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    int n,k;
    char s[100010];
    scanf("%s",s);
    scanf("%d",&k);
    n=strlen(s);
    for(int i=0;i<n;i++){
        if(i==n-1){
            printf("%c\n",'a'+(s[i]-'a'+k)%26);
        }
        else if(s[i]!='a'&&k>='z'-s[i]+1){
            printf("a");
            k-='z'-s[i]+1;
        }
        else{
            printf("%c",s[i]);
        }
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VI x;
VVI gp;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,l,q;
  cin>>n;
  gp.resize(n,VI(18));
  x.resize(n);
  forn(i,n)
    cin>>x[i];
  cin>>l>>q;
  in cn=0;
  forn(i,n){
    while(cn<n && x[cn]<=x[i]+l)
      ++cn;
    gp[i][0]=cn-1;
  }
  for(in i=1;i<18;++i){
    forn(j,n)
      gp[j][i]=gp[gp[j][i-1]][i-1];
  }
  in a,b;
  forn(z,q){
    cin>>a>>b;
    --a;
    --b;
    if(a>b)
      swap(a,b);
    in sm=0;
    for(in i=17;i>=0;--i){
      if(gp[a][i]<b){
	sm+=(1LL<<i);
	a=gp[a][i];
      }
    }
    if(a!=b)
      ++sm;
    cout<<sm<<endl;
  }
  return 0;
}


Measured memory_bytes: 19584
N = int(input())
A = list(map(int, input().split()))
kabu = 0
money = 1000
for i in range(N):
  money += kabu*A[i]
  kabu = 0
  if i!=N-1:
    if A[i]<=A[i+1]:
      kabu += money//A[i]
      money %= A[i]
    else:
      pass
print(money)

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

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

    sort(p.begin(), p.end());

    long long cnt = 0;
    long long mon = 0;
    for(int i = 0; i < N; ++i) {
        if(cnt + p[i].second <= M) {
            mon += p[i].first * p[i].second;
            cnt += p[i].second;
        } else if(cnt + p[i].second > M) {
            while(cnt < M) {
                cnt++;
                mon += p[i].first;
            }
        }

        if(cnt == M) {
            break;
        }
    }

    cout << mon << endl;
}

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

int main() {
    int n, k, now = 1;
    cin >> n >> k;
    rep(i,n) {
        if (now * 2 > now + k) {
            now += k;
        } else {
            now *= 2;
        }
    }
    cout << now << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io;

macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    let (a, b) = get!(u32, u32);

    let mut ans = a - 1;

    if a <= b {
        ans += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	vd a(n),x(n);
	for(auto &i:a) cin>>i;
	x[0]=a[0];
	double res=2*a[0];
	for(int i=1;i<n;i++){
		x[i]=a[i];
		for(int j=0;j<i;j++){
			x[i]=max(x[i],x[j]+sqrt((a[i]+a[j])*(a[i]+a[j])-(a[i]-a[j])*(a[i]-a[j])));
		}
		res=max(res,x[i]+a[i]);
	}
	cout<<syosu(9)<<res<<endl;
//	for(auto i:x) cout<<i<<' ';cout<<endl;
}


Measured memory_bytes: 3312
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int count = 0;
        for (int i = 0; i < n; i++) {
            for (int day = 1; day <= d; day += a[i]) {
                count++;
            }
        }
        System.out.println(count + x);
    }
}

Measured memory_bytes: 21844
MAX = 10 ** 5 + 1
MOD = 10 ** 9 + 7

# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1

# Inverse
inv = [0] * (MAX + 1)
inv[1] = 1

# Inverse factorial
finv = [0] * (MAX + 1)
finv[0] = 1
finv[1] = 1

for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD


def comb(n, k):
    if n < k or k < 0:
        return 0
    return (fac[n] * finv[k] * finv[n - k]) % MOD


N, K = map(int, input().split())
X = list(map(int, input().split()))
X.sort()

ans = 0
for i in range(N):
    # Max
    ans += X[i] * comb(i, K - 1) % MOD
    ans %= MOD

    # Min
    ans -= X[i] * comb(N - i - 1, K - 1) % MOD
    ans %= MOD

print(ans)


Measured memory_bytes: 91620
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define X first
#define Y second
#define pb push_back
#define CL(x) (x << 1)
#define CR(x) ((x << 1) + 1)
#define sqr(x) ((x) * (x))
#define Task ""

typedef long long cc;
typedef long double ld;
typedef pair <int, int> pii;
const int N = 100005;
vector <int> e[N];
bool le[N], chan[N];
int n, m;
int res;
bool was[N];
int odd, even;
bool ok;
void dfs(int u, int p) {
    was[u] = true;
    if (le[u]) odd++;
    if (chan[u]) even++;
    if (le[u] && chan[u]) ok = true;
    for (auto v: e[u])
        if (v != u) {
            le[v] = le[v] | (chan[u] & 1);
            chan[v] = chan[v] | (le[u] & 1);
            if (!was[v]) dfs(v, u);
        }
}
int main() {
    std :: ios_base :: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //freopen("input.inp", "r", stdin);
    //-------------------------------------------------------------------------------------------------------
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        e[u].pb(v);
        e[v].pb(u);
    }
    le[1] = 1;
    dfs(1, -1);
    for (int i = 1; i <= n; i++)
        ok = ok | (le[i] && chan[i]);
    if (ok) cout << 1ll * n * (n - 1) / 2 - m;
    else {
        cc tmp = 0;
        tmp = 1ll * even * (even - 1) / 2;
tmp += 1ll * odd * (odd - 1) / 2;
        cout << max(0ll, 1ll * n * (n - 1) / 2 - m - tmp);
    }
    //-------------------------------------------------------------------------------------------------------
    return 0;
}


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

char map[10][10];

void bomb(int x, int y);

int main()
{
	int n;
	int x, y;

	cin >> n;

	for (int i = 0; i < n; i++){
		for (int j = 0; j < 8; j++){
			cin >> map[j];
		}
		cin >> x >> y;
		bomb(x - 1, y - 1); // (1,1) -> map[0][0]

		cout << "Data " << i + 1 << ":" << endl;
		for (int j = 0; j < 8; j++){
			cout << map[j] << endl;
		}
	}

	return (0);
}

void bomb(int x, int y)
{
	map[y][x] = '0';

	for (int i = 1; i <= 3; i++){
		if (y + i <= 7 && map[y + i][x] == '1'){
			bomb(x, y + i);
		}
		if (y - i >= 0 && map[y - i][x] == '1'){
			bomb(x, y - i);
		}
		if (x + i <= 7 && map[y][x + i] == '1'){
			bomb(x + i, y);
		}
		if (x - i >= 0 && map[y][x - i] == '1'){
			bomb(x - i, y);
		}
	}
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll inf = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/


int main(){
    fIO

    int n;
    cin >> n;

    set<pair<int, int>> st;
    int a;
    for(int i = 0; i < n; i++){
        cin >> a;
        st.insert({a, i});
    }

    for(auto it : st) cout << it.second + 1 << " ";


}









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

using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    
    string s;
    cin >> s;
    
    if (s[0] == 'R')
    {
        if (s[1] == 'R')
        {
            if (s[2] == 'R')
            {
                cout << 3;
                return 0;
            }
            else
            {
                cout << 2;
                return 0;
            }
        }
        else {
            cout << 1;
            return 0;
        }
    }
    else
    {
        if (s[1] == 'R')
        {
            if (s[2] == 'R')
            {
                cout << 2;
                return 0;
            }
            else
            {
                cout <<1;
                return 0;
            }
        }
        else {
            if (s[2] == 'R')
            {
                cout << 1;
                return 0;
            }
            else
            {
                cout <<0;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3608
#include <iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

int retl(int K,int L){
    int tmp=0;
    while(pow(2,tmp) * L < K){
        tmp++;
    }
    return tmp;
}
int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}
struct A{
    string s;
    int p;
    int order;
};
long long c(long long N,long long mod1,long long mod2){
     long long tmp=(N/mod1)+(N/mod2)-(N/((mod1*mod2)/gcd(mod1,mod2)));
 

     return N-tmp;
}

int main(){
    long long A,B,C,D;

    cin >>A>>B>>C>>D;
    
    cout<< c(B,C,D)-c(A-1,C,D) << endl;

    return 0;
}

Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T& v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  string s; in(s);
  int n = s.size();
  int p = 0;
  loop(i,0,n) p += s[i] == 'p';
  // nが偶数の時n/2
  // nが奇数ｎ時n/2 (切り捨て)
  print(n/2 - p);
  return 0;
}


Measured memory_bytes: 3732
$str = <STDIN>;
chomp($str);
@chars = split(//, $str);
$len = @chars;
$sum = 0;


for (my $i=0; $i<$len; $i++) {
    if ($i == $len-1) {
        $sum++;
        last;
    }
    if ($chars[$i] eq $chars[$i+1]) {
        if ($i == $len-2) {
            $sum++;
            last;
        } else {
            $i += 2;
            $sum += 2;
            next;
        }
    } else {
        $sum++;
    }
}

print "$sum\n";

Measured memory_bytes: 16460
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int dp[105][10005]={};
    int n; cin>>n;
    int W; cin>>W;
    int v[105],w[105];
    for(int i=0;i<n;i++){
        cin>>v[i]>>w[i];
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=W;j++){
            if(j<w[i]){
                dp[i+1][j]=dp[i][j];
            }else{
                dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
            }
        }
    }
    cout<<dp[n][W]<<endl;
    
}



Measured memory_bytes: 7220
a, b, n = gets.split.map(&:to_i)
x = n
if b <= x
  x = b - 1
end
puts (a * x / b).floor - a * (x / b).floor
# n.downto(0) do |x|
#   puts "#{x} の時: #{(a * x / b).floor - a * (x / b).floor}"
# end


Measured memory_bytes: 14332
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

const int N = 4010, M = 200010;
const int Mod = 1e9 + 7;

int Pow(int x, int e){
	int ret = 1;
	while(e){
		if(e & 1) ret = 1ll * ret * x % Mod;
		x = 1ll * x * x % Mod;
		e >>= 1;
	}
	return ret;
}

int dp[N][N], fac[N << 1], rfac[N << 1];
int Px[M], Py[M], n;

void init(){
	fac[0] = 1;
	int m = 8005;
	For(i, 1, m) fac[i] = 1ll * fac[i - 1] * i % Mod;
	rfac[m] = Pow(fac[m], Mod - 2);
	Forr(i, m - 1, 0) rfac[i] = 1ll * rfac[i + 1] * (i + 1) % Mod;
}

inline int C(int a, int b){
	return 1ll * fac[a] * rfac[b] % Mod * rfac[a - b] % Mod;
}

int main(){
	scanf("%d", &n);
	init();
	int ans = 0;

	For(i, 1, n){
		scanf("%d%d", &Px[i], &Py[i]);
		ans = (ans - C((Px[i] + Py[i]) << 1, Px[i] << 1) + Mod) % Mod;
		dp[2000 - Px[i]][2000 - Py[i]]++;
		Px[i] += 2000, Py[i] += 2000;
	}

	For(i, 0, 4000) For(j, 0, 4000){
		if(i) dp[i][j] = (dp[i][j] + dp[i - 1][j]) % Mod;
		if(j) dp[i][j] = (dp[i][j] + dp[i][j - 1]) % Mod;
	}

	For(i, 1, n) ans = (ans + dp[Px[i]][Py[i]]) % Mod;
	printf("%lld\n", 1ll * ans * rfac[2] % Mod);
	return 0;
}

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

int main(){
    int n;
    cin >> n; 
    int count =0;
    for (int i=1;i<=n;i++){
        if (i < 10){
            count++;
        }else if((i>99)&&(i<1000)){
            count++;
        }else if((i>9999)&&(i<100000)){
            count++;
        }
    }
    cout << count << endl;
}   

Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
int main(void){
    set< long long > s;
    long long n;
    cin >> n;
    for(long long i=1;i*i<=n;i++){
        if(n%i > 0) continue;
        long long k = i;
        long long m = n/i-1;
        if(k < m) s.insert(m);
        k = n / i;
        m = i-1;
        if(k < m) s.insert(m);
    }
    long long ans = 0;
    for(long long m : s) ans += m;
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

int main(void){  
  int n;
  cin >> n;
  int a[n];
  int sum = 0;
  rep(i,n){
    cin >> a[i];
    sum ^= a[i];
  }

  rep(i,n){
    cout << (sum^a[i]) << endl;
  }
  return 0;
}


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

int judge(char x){
    if(x == 'A' || x == 'T' || x == 'G' || x == 'C'){
        return 1;
    }else{
        return 0;
    }
}

int main(){
    string S;
    cin >> S;
    int cnt=0,max=0;
    for(int i = 0; i < S.size(); i++){
        if(judge(S[i]) == 1){
            cnt++;
             if(max < cnt){
                max = cnt;
            }
        }else{
            cnt = 0;
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #define      mp(x,y)          make_pair(x,y)
// #define      pb(x)            push_back(x)
// #define      eb(x)            emplace_back(x)
// #define      each(it,s)       for(auto it = s.begin(); it != s.end(); ++it)
// #define      forn(i, n)       for(int i = 0; i < (n); ++i)
// #define      sortA(v)         sort(v.begin(), v.end())
// #define      f                first
// #define      s                second
// #define      PQ priority_queue
// #define      eps 10e-6
// #define      PI 3.14159265359
// #define      MOD 1000000007
// #define      INF 2LL*MOD
// #define      N 1005
using namespace std;
typedef long long ll;
// typedef vector<int> vi ;
// typedef std::vector<vi> vvi;
// typedef pair<int,int> ii ;
// typedef pair<int,ii> iii;
// int dp[N][N];
//**************_____Global Variables______******************
//************------Main function---------*********************
int main()
{
    //freopen("output.txt","w",stdout);
    //freopen("input.txt","r",stdin);
    //ios::sync_with_stdio(false);cin.tie(0);
    char c;
    cin>>c;
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')cout<<"vowel";
    else cout<<"consonant";
    return 0; 
}  
// Taskkill /IM test.exe /F


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;

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

ll min=N-1;
for(ll i=1;i*i<=N;i++){
  if(N%i==0){
    ll tmp = i-1+(N/i)-1;
    if(min>tmp){
      min=tmp;
    }
  }
}
cout<<min<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;

int main() {
  int a[3][3];
  bool appear[3][3];

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

  int n;
  cin >> n;

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

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      appear[i][j] = false;
      for (int k = 0; k < n; k++) {
        if (a[i][j] == b[k]) {
          appear[i][j] = true;
        }
      }
    }
  }

  string ans = "No";
  for (int i = 0; i < 3; i++) {
    if (appear[i][0] and appear[i][1] and appear[i][2]) {
      ans = "Yes";
    }
    if (appear[0][i] and appear[1][i] and appear[2][i]) {
      ans = "Yes";
    }
  }
  if (appear[0][0] and appear[1][1] and appear[2][2]) {
    ans = "Yes";
  }
  if (appear[0][2] and appear[1][1] and appear[2][0]) {
    ans = "Yes";
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    a,b,c = map(int,input().split())

    list = []
    count = 1
    while True:
        d = count * a % b
        if  d==c:
            print("YES")
            break
        else:
            if d in list:
                print("NO")
                break
            else:
                list.append(d)
                count+=1

Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vvi a(n, vi(m));
    rep(i, n) rep(j, m) {
        cin >> a[i][j];
        a[i][j]--;
    }
    auto check = [&](int b) {
        vector<queue<int> > q(n);
        vector<bool> used(m);
        rep(i, n) rep(j, m) {
            q[i].push(a[i][j]);
        }
        rep(i, m) {
            vi cnt(m);
            int ma = 0;
            int j = 0;
            rep(i, n) {
                while(used[q[i].front()]) q[i].pop();
                cnt[q[i].front()]++;
                if(chmax(ma, cnt[q[i].front()])) j = q[i].front();
            }
            if(ma <= b) return true;
            used[j] = true;
        }
        return false;
    };
    int aa = 0, b, c = 300;
    while(c-aa > 1) {
        b = (aa+c)/2;
        if(check(b)) {
            c = b;
        } else {
            aa = b;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 4300
#include <stdio.h>

int main(){
long int a,b,aa,bb;
long int x,y,i;

while(scanf("%ld %ld",&a,&b) != EOF){
aa=a;
bb=b;
while((x=a%b)!=0){
a=b;
b=x;
}
y=aa*bb/b;
printf("%ld %ld\n",b,y);
}
return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 2019
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
inline int add(int x, int y, int mod) {
   if (y >= mod) y %= mod;
   if (x >= mod) x %= mod;
   x  += y;
   return (x >= mod ? x - mod : x);
} 
inline int mul(int x, int y, int mod) {
  if (x >= mod) x %= mod;
  if (y >= mod) y %= mod;
  return (x*y) % mod;
}
inline int sub(int x, int y, int mod) {
  x -= y;
  if (x + mod <= 0) {
	x %= mod;
  }
  return (x < 0 ? x+mod : x);
}
int PowerMod(int x, int n, int mod) {
  int res = 1;
  for (;n > 0;) {
	if (n & 1) {
	  res 	= mul(res, x, mod);
	}
	x = mul(x, x, mod);
	n /= 2;
  }
  return res;
}
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		string s;
		cin >> s;
		int n = s.size();
		map<int,int>mp;
		mp[0]=1;
		int ans =0 ;
		int last =0 ,cur =0 ;
		for(int i =n-1;i>=0;i--){
			int d= s[i]-'0';
			cur = mul(d,PowerMod(10,n-1-i,MOD),MOD);
			last=add(last,cur,MOD);
			// trace(cur);
			ans+=mp[last];
			mp[last]++;
		}
		cout << ans <<'\n';
	
	
	}
	return 0;
}

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

int main(void){
  string S;
  cin >> S;
  if(S == "Sunny")
    cout << "Cloudy" << "\n";
  else if(S == "Cloudy")
    cout << "Rainy" << "\n";
  else if(S == "Rainy")
    cout << "Sunny" << "\n";
  return 0;
}


Measured memory_bytes: 3576
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_LEN (100000)

int main(int argc, char *argv[]) {
  // read inputs
  char cs[MAX_LEN + 1];
  scanf("%s", cs);
  const int N = strlen(cs);

  // solve
  int nums[MAX_LEN] = {};
  char prev = 'R';
  int num_l = 0, num_r = 0, k;
  for (int i = 0; i < N; i++) {
    const char c = cs[i];
    if (c == 'R') {
      if (prev == 'L') {
        nums[k - 1] = (num_r + 1) / 2 + (num_l - (num_l + 1) / 2);
        nums[k] = (num_l + 1) / 2 + (num_r - (num_r + 1) / 2);
        num_r = 0;
        num_l = 0;
      }
      num_r++;
    } else {
      if (prev == 'R') {
        k = i;
      }
      num_l++;
    }
    prev = c;
  }
  nums[k - 1] = (num_r + 1) / 2 + (num_l - (num_l + 1) / 2);
  nums[k] = (num_l + 1) / 2 + (num_r - (num_r + 1) / 2);

  // print answers
  for (int i = 0; i < N; i++) {
    printf("%d ", nums[i]);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 896
n,x=map(int,input().split())
a=list(map(int,input().split()))
b=0
a.sort()
for i in range(0,n):
    x-=a[i]
    b+=1
    if x<=0:
        break
    
if x==0:
    print(b)
else:
    print(b-1)

Measured memory_bytes: 9076
def main():
  import sys
  input = sys.stdin.readline
  
  H,N = map(int,input().split())
  AB = [tuple(map(int,input().split())) for _ in range(N)]

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

  for i in range(N):
    a,b = AB[i]
    for j in range(H+1):
      if i == 0:
        dp[i][j] = ((j+a-1)//a)*b
      else:
        if j < a:
          dp[i][j] = min(b,dp[i-1][j])
        else:
          dp[i][j] = min(dp[i][j-a]+b,dp[i-1][j])

  #print(dp)
  print(dp[N-1][H])

if __name__ == '__main__':
  main()

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) ;
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

int dx[4]{0, 1, 0, -1};
int dy[4]{1, 0, -1, 0};

ll N;
vector<ll> L;

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N;
	L.resize(N);
	REP(i, N) cin >> L[i];
	sort(ALL(L));

	ll res{0};
	for (ll a = 0; a < N-2; ++a)
	{
		for (ll b = a+1; b < N-1; ++b)
		{
			for (ll c = b+1; c < N; ++c)
			{
				if (L[a] == L[b]) continue;
				if (L[a] == L[c]) continue;
				if (L[b] == L[c]) continue;
				vector<ll> v {L[a], L[b], L[c]};
				sort(ALL(v));
				if (v[2] < v[0] + v[1])
					++res;
			}
		}
	}

	std::cout << res << std::endl;
	
	return 0;
}


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

using namespace std;

int main() {
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> B(M);
	for(auto &x: B) cin >> x;

	int out = 0;
	for(int i = 0; i < N; i++) {
		vector<int> A(M);
	       for(auto &x: A) cin >> x;	
		int res = inner_product(
				A.begin(),
				A.end(),
				B.begin(),
				C);
		if(res > 0) out++;

	}

	cout << out << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

ll dp[100][2];

int main(){
	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	memset(dp,-1,sizeof(dp));
	dp[60][0] = 0;
	for(int i = 59; i >= 0; i--){
		ll mask = 1ll<<i,cnt = 0;
		for(int j = 0; j < n; j++) if(a[j]&mask) cnt++;
		if(dp[i+1][1] != -1){
			dp[i][1] = max(dp[i][1],dp[i+1][1]+mask*max(cnt,n-cnt));
		}
		if(dp[i+1][0] != -1){
			if(k&mask){
				dp[i][0] = max(dp[i][0],dp[i+1][0]+mask*(n-cnt));
				dp[i][1] = max(dp[i][1],dp[i+1][0]+mask*cnt);
			}else{
				dp[i][0] = max(dp[i][0],dp[i+1][0]+mask*cnt);
			}
		}
	}
	cout << max(dp[0][0],dp[0][1]) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define rv(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int M = 120000;
typedef long long ll;
int n,m,k;
int main(){
    string s,t,u;
    int a,b;
    cin>>s>>t>>a>>b>>u;
    if(s==u) --a;
    if(t==u) --b;
    cout<<a<<' '<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
#入力取得
N = int(input())

p = []

for j in range(N):
    S, P = input().split()
    p.append((S, int(P), j))




sorted_items = sorted(
  p,
  key = lambda x: (x[0], -x[1])
)




for (s,p,j) in sorted_items:
    print(j+1)

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

int euclid(int a, int b)
{
    if (a < b)
        euclid(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int m;
    cin >> m;

    cout << 24 - m + 24;
}


Measured memory_bytes: 256