akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  int k;cin>>k;
  vector<vector<vector<int>>>zeon(k,vector<vector<int>>(k,vector<int>(2,0)));
  rep(i,n)
  {
    int x,y;
    char c;
    cin>>x>>y>>c;
    x=x%(2*k);
    y=y%(2*k);
    int cc=c=='B';
    if((x>=k)^(y>=k))
    {
      cc=1-cc;
    }
    x%=k;
    y%=k;
    zeon[x][y][cc]++;
  }
  vector<vector<int>>sum1(k+1,vector<int>(k+1,0));
  auto sum2=sum1;
  rep(i,k)rep(j,k)sum1[i+1][j+1]=sum1[i+1][j]+sum1[i][j+1]-sum1[i][j]+zeon[i][j][0];
  rep(i,k)rep(j,k)sum2[i+1][j+1]=sum2[i+1][j]+sum2[i][j+1]-sum2[i][j]+zeon[i][j][1];

  int res=0;

  rep(i,k+1)rep(j,k+1)
  {
    int tres1=0,tres2=0;
    tres1=sum1[k][k]-sum1[k][j]-sum1[i][k]+2*sum1[i][j];
    tres1+=sum2[k][j]+sum2[i][k]-2*sum2[i][j];

    tres2=sum2[k][k]-sum2[k][j]-sum2[i][k]+2*sum2[i][j];
    tres2+=sum1[k][j]+sum1[i][k]-2*sum1[i][j];
    chmax(res,tres1);
    chmax(res,tres2);

  }
  //cout<<sum1[k][k]<<endl;
  cout<<res<<endl;


  return 0;

}


Measured memory_bytes: 62848
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <queue>
#include <map>
#include <stack>
#include <set>
#define ll long long
using namespace std;

int main(){
 //cout<<123<<endl;
  int N;
  cin>>N;
  int hen[N+1];
  int sum=0;
  for(int i=1;i<=N;i++){
    cin>>hen[i];
    sum=sum+hen[i];
  }
  bool ok = true;
  for( int i=1;i<=N;i++){
    if(hen[i]>=sum-hen[i]) ok=false;
    else continue;
    
  }
  string ans = ok ? "Yes":"No";
  cout<< ans <<endl;
  
  return 0;
}


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

int main(){
    string s, t;
    int count = 0, max = 0;
    cin >> s >> t;
    for (int i = 0; i < 1 + s.size() - t.size(); i++) {
        count = 0;
        for (int j = 0; j < t.size(); j++) {
            if (s.at(i+j) == t.at(j)) count++;
        }
        if(max < count) max = count;
    }
    cout << t.size() - max << endl;
}

Measured memory_bytes: 3592
#include<stdio.h>

int main() {
	int N;
	int Ascore, Bscore;
	int Ainp, Binp;

	while (1) {
		scanf("%d", &N);
		if (!N)break;
		Ascore = 0; Bscore = 0;
		for (int i = 0; i < N; i++) {
			scanf("%d %d", &Ainp, &Binp);
			if (Ainp == Binp) {
				Ascore += Ainp; Bscore += Binp;
			}
			else if (Ainp > Binp) {
				Ascore += Ainp += Binp;
			}
			else {
				Bscore += Binp += Ainp;
			}
		}
		printf("%d %d\n", Ascore, Bscore);
	}

	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back

int main() {
    ios
    int dp[110000][3];
    int N; cin >> N;
    rep(i,0,N)
    {
        int a,b,c;
        cin >> a >> b >> c;
        if(i==0)
        {
            dp[i][0]=a;
            dp[i][1]=b;
            dp[i][2]=c;
        }
        else
        {
            rep(j,0,3)
                rep(k,0,3)
            {
                if(j==k) continue;
                else if(j==0)
                    dp[i][j]=max(dp[i][j],a+dp[i-1][k]);
                else if(j==1)
                dp[i][j]=max(dp[i][j],b+dp[i-1][k]);
                else
                dp[i][j]=max(dp[i][j],c+dp[i-1][k]);
            }
        }
    }
    int i=N-1,res=-1;
    rep(j,0,3)
        res=max(res,dp[i][j]);
    cout << res;
    return 0;
}


Measured memory_bytes: 1408
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e18;

int main(){
    ll n;
    cin >> n;
    while(n){
        ll r=n%10;
        n/=10;
        if(r==9){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace _20170409_AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            for (;;)
            {
                int[] iArr = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                int n = iArr[0];
                int x = iArr[1];

                if (n == 0 && x == 0)
                {
                    break;
                }

                int count = 0;
                int li = Math.Max(1, x - (2 * n - 1));
                int ui = Math.Min(x / 3, n - 1);
                for (int i = li; i < ui; i++)
                {
                    int lj = Math.Max(i + 1, x - i - n);
                    int uj = Math.Min((x - i - 1) / 2, n);

                    count += uj - lj + 1;
                }

                Console.WriteLine(count);
            }

            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9516
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll N,M;
vector<ll> A, dif;

int main() {
	cin >> M >> N;
	A.resize(N);
	for (ll n = 0; n < N; n++)cin >> A[n];
	sort(A.begin(), A.end(), [](ll a, ll b) {return a < b; });
	dif.resize(N - 1);
	for (ll n = 1; n < N; n++)dif[n - 1] = A[n] - A[n - 1];
	sort(dif.begin(), dif.end(), [](ll a, ll b) {return a < b; });
	ll ans = 0;
	for (ll n = 0; n < N - M; n++)ans += dif[n];
	cout << ans << endl;
	return 0;
}

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

int main()
{
    int n, ans = 0;
    string s;
    cin >> n >> s;
    int m = count(s.begin(), s.end(), 'R');
    for(int i = 0; i < m; i++) {
        if(s[i] == 'W') ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3740
import math
a, b, h, m = map(int, input().split())
w_m = m*(360/60)*(math.pi/180)
w_h = (h + m/60)*(360/12)*(math.pi/180)

d = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(w_h - w_m))
print(d)


Measured memory_bytes: 9496
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

int main() {
	makei(a);
	makei(b);
	int dif = b - a;
	int preans = 0;
	rep(dif)preans += i;
	say(preans - a);
}

Measured memory_bytes: 256
<?php
$number = fgets(STDIN);
$numbers = explode(" " , $number);

$num1 = trim($numbers[0]);
$num2 = trim($numbers[1]);

$min_num = min($num1, $num2);

if ($num1 < $num2) {
	$hoge = $num1;
	$num1 = $num2;
	$num2 = $hoge;
}

while ($num2 > 0):
	$r = $num1 % $num2;
	$num1 = $num2;
	$num2 = $r;
endwhile;

echo $num1 . PHP_EOL;



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

const int nmax=100010;
vector<int> graph[nmax];
int parent[nmax][20];
int depth[nmax];

void init(int n){
	function<void (int,int,int)> dfs=[&dfs](int v,int p,int d){
		parent[v][0]=p;
		depth[v]=d;
		for(auto &v2:graph[v]) if(v2!=p) dfs(v2,v,d+1);
	};
	dfs(0,-1,0);
	rep(j,19)rep(i,n){
		if(parent[i][j]==-1)
			parent[i][j+1]=-1;
		else
			parent[i][j+1]=parent[parent[i][j]][j];
	}
}

int lca(int u,int v){
	if(depth[u] < depth[v]) swap(u,v);
	for(int i=19;i>=0;--i) if((depth[u]-depth[v])>>i&1) u=parent[u][i];
	if(u==v) return u;
	for(int i=19;i>=0;--i){
		if(parent[u][i]!=parent[v][i]){
			u=parent[u][i];
			v=parent[v][i];
		}
	}
	return parent[u][0];
}

int main(void){
	int n; cin >> n;
	rep(i,n){
		int k; cin >> k;
		rep(j,k){
			int v; cin >> v;
			graph[i].push_back(v);
		}
	}
	init(n);
	int q; cin >> q;
	rep(i,q){
		int u,v; cin >> u >> v;
		cout << lca(u,v) << endl;
	}
	return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a >= 13) cout << b;
    else if(a >= 6) cout << b/2;
    else cout << 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    int ac,wa,tl,re;
    ac=wa=tl=re=0;
    while(t--)
    {
        string s;
        cin>>s;
        if(s=="AC")
            ac++;
        else if(s=="WA")
            wa++;
        else if(s=="TLE")
            tl++;
        else if(s=="RE")
            re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tl<<endl;
    cout<<"RE x "<<re<<endl;

}


Measured memory_bytes: 3628
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
red = N-K
mod = 10**9+7

pos = [1]*(N+1)
neg = [1]*(N+1)
s = 1
for i in range(1, N+1):
    s *= i
    s %= mod
    pos[i] = s
    neg[i] = pow(s, mod-2, mod)

# val = 0
# for i in range(1, K+1):
#     now = (pos[red+i]*neg[red]*neg[i]-val)*pos[K-1]*neg[i-1]*neg[K-i]%mod
#     print(now)
#     val = (now + val)%mod

for i in range(1, K+1):
    if N+1<K+i:
        print(0)
        continue
    ans = pos[red+1]*neg[i]*neg[red+1-i]*pos[K-1]*neg[i-1]*neg[K-i]
    print(ans%mod)

Measured memory_bytes: 74748
#include<cstdio>
using namespace std;
int main(){
    bool check[1000000]={0};
    int flg = 1;
    check[2] = 1;
    for(int i = 3;i <= 1000000; i += 2){
        flg = 1;
        for(int j = 2;j*j <= i; j++){
            if(i%j == 0){
                flg = 0;
                break;
            }
        }
        if(flg == 1){
            check[i] = 1;
        }
    }
    int n;
    while(scanf("%d",&n),n){
        int ans = 0;
        int cnt = 0;
        for(int i = 2;;i++){
            if(check[i] == 1){
                ans += i;
                cnt++;
            }
            if(cnt == n)break;
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 2008
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

template<typename T>
struct rerooting{
    using F=function<T(T,int)>;//集合，頂点番号
    using M=function<T(T,T)>;

    int V;
    vector<vector<int>> G;
    vector<vector<T>> dp;
    vector<T> ans;
    // dp_v = g(merge(f(dp_c1,c1),...,f(dp_ck,ck)),v)
    F f,g;  // TxN->T
    M merge;// TxT->T，子を集約する関数，モノイド
    T gen;
    //gen: mergeの元
    rerooting(int V,F f,M merge,T gen,F g=[](T a,int b){return a;})
        :V(V),f(f),merge(merge),gen(gen),g(g),G(V),dp(V),ans(V,gen){}
    
    //bidirectional
    void add_edge(int a,int b){
        G[a].push_back(b);
        G[b].push_back(a);
    }
    T dfs1(int pre,int now){
        T ret=gen;
        for(int i=0;i<G[now].size();i++)if(G[now][i]!=pre){
            dp[now][i]=dfs1(now,G[now][i]);
            ret=merge(ret,f(dp[now][i],G[now][i]));
        }
        return g(ret,now);
    }
    void dfs2(int pre,int now,T frompar){
        for(int i=0;i<G[now].size();i++){
            if(G[now][i]==pre){
                dp[now][i]=frompar;
                break;
            }
        }
        vector<T> lsum(G[now].size()+1),rsum(G[now].size()+1);//親も混ぜて累積
        lsum[0]=gen;rsum[G[now].size()]=gen;
        for(int i=0;i<G[now].size();i++) lsum[i+1]=merge(lsum[i],f(dp[now][i],G[now][i]));
        for(int i=G[now].size();i>0;i--) rsum[i-1]=merge(rsum[i],f(dp[now][i-1],G[now][i-1]));
        for(int i=0;i<G[now].size();i++)if(G[now][i]!=pre){
            T fromme=merge(lsum[i],rsum[i+1]);
            dfs2(now,G[now][i],g(fromme,now));
        }
    }
    void build(int root=0){
        for(int i=0;i<V;i++) dp[i].resize(G[i].size());
        dfs1(-1,root);
        dfs2(-1,root,gen);
        for(int i=0;i<V;i++){
            for(int j=0;j<G[i].size();j++) ans[i]=merge(ans[i],f(dp[i][j],G[i][j]));
            ans[i]=g(ans[i],i);
        }
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    auto f=[&](pair<int,int> ch,int v){return make_pair(ch.second-ch.first+1,ch.second+2);};
    auto merge=[&](pair<int,int> l,pair<int,int> r){return make_pair(max(l.first,r.first),l.second+r.second);};
    auto g=[&](pair<int,int> mg,int v){return make_pair(mg.second-mg.first,mg.second);};

    int n;cin>>n;
    rerooting<pair<int,int>> R(n,f,merge,make_pair(0,0),g);
    rep(i,n-1){
        int u,v;cin>>u>>v;u--,v--;
        R.add_edge(u,v);
    }
    R.build();
    rep(i,n)cout<<R.ans[i].first<<endl;
    return 0;
}



Measured memory_bytes: 48900
#include<iostream>
#include<algorithm>
using namespace std;
long long int cara(long long int x);
//long long int a[200000];
int main() {


	//B
	int h, n;
	cin >> h >> n;
	int i, a;
	for (i = 0; i < n; i++) {

		cin >> a;
		h = h - a;
		if (h <= 0) {
			cout << "Yes" << endl;
			return 0;
		}


	}
	cout << "No" << endl;
	return 0;
	//C
	/*int n, k;
	int i;
	cin >> n >> k;

	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	long long int sum = 0;
	if (k >= n) {
		cout << 0 << endl;
		return 0;
	}
	for (i = 0; i <= n - k - 1; i++) {
		sum = sum + a[i];
	}
	cout << sum << endl;
	return 0;
	*/

	//E
	/*int h, n;
	int a[1000], b[1000];
	int i, j, k;
	cin >> h >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}

	//体力hに対して使用する最小の魔力を求めるDP
	int DP[10001];
	DP[0] = 0;
	int min;
	for (i = 1; i <= h; i++) {
		min = 100000000;
		for (j = 0; j < n; j++) {
			if (a[j] >= i) {
				if (min > b[j]) {
					min = b[j];
				}
			}
			else {
				if (DP[i - a[j]] + b[j] < min) {
					min = DP[i - a[j]] + b[j];
				}
			}
		}
		DP[i] = min;
	}
	cout << DP[h] << endl;
	return 0;
	*/

	//D


	/*long long int n;
	cin >> n;
	cout << cara(n) << endl;
	return 0;*/

}
long long int cara(long long int x) {

	int i = 0;
	if (x == 1) {
		return 1;
	}
	else {
		return 1  + 2 * cara((long long int)(x / 2));
	}

}

Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const double BODER[4] = {1.1, 0.6, 0.2, 0.0};

int main(void){
    int res[4][2], cnt = 0;
    MEMSET(res, 0);
    
    for(double in; cin >> in; cnt ++)
        rep(i, 4) if(BODER[i] <= in){
            res[i][cnt % 2] ++;
            break;
        }

    rep(i, 4){ rep(j, 2) cout << (j ? " ":"") << res[i][j]; cout << endl; }
    
    return 0;
}

Measured memory_bytes: 1224
;;(declaim (optimize (speed 0) (safety 3) (debug 3)))
(declaim (optimize (speed 3) (safety 0) (debug 0)))

(defvar *n* (read))
(defvar arr (make-array *n*))
(dotimes (i *n*) (setf (aref arr i) (read)))

(let ((i 0) (p 1))
  (loop for j from 0 below *n*
	for a = (aref arr j)
	when (> p 1000000000000000000) do (return)
	do (setf p (* p a)) (incf i))
  (loop for j from i below *n*
	for a = (aref arr j)
	when (= a 0) do (setf p 0))
  (princ (if (> p 1000000000000000000) -1 p)))


Measured memory_bytes: 77016
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;
int main()
{
    ll x;
    cin>>x;
    ll n=1;
    ll p=100;
    while(true)
    {
        //double a=100*pow(1.01,n);
        double ci=p/100;
        p+=ci;
        if(p>=x)
        {
            cout<<n<<endl;
            break;
        }
        n+=1;
    }
}


Measured memory_bytes: 3636
def main():
    n = int(input())
    R, B = [], []
    for i in range(n):
        R.append(list(map(int, input().split())) + [0, i])
    for _ in range(n):
        B.append(list(map(int, input().split())))
    B.sort(key = lambda x: x[0])
    ans = 0
    for b in B:
        f = list(filter(lambda x: x[0] < b[0] and x[1] < b[1] and x[2] == 0, R))
        if len(f) != 0:
            f.sort(key = lambda x: x[1], reverse = True)
            p = f[0]
            ans += 1
            R[p[3]][2] = 1
    print(ans)        

if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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 fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, P;
	string S;
	cin >> S;
	N = S.size();
	P = 2019;

	reverse(S.begin(), S.end());
	int ten = 1;
	map<int, int>mp;
	int ans = 0;
	int sum = 0;
	mp[0]++;
	REP(i, N) {

		int a = S[i] - '0';
		a *= ten;
		a %= P;
		sum += a;
		sum %= P;

		ans += mp[sum];
		mp[sum]++;






		ten *= 10;
		ten %= P;
	}


	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 3776
def main():
    import sys
    from math import sqrt, hypot
    input = sys.stdin.readline

    def dist(p1, p2):
        x1, y1 = p1
        x2, y2 = p2
        return hypot(x2-x1, y2-y1)

    def CP(x1, y1, r1, x2, y2, r2):
        rr0 = (x2 - x1) ** 2 + (y2 - y1) ** 2
        xd = x2 - x1
        yd = y2 - y1
        rr1 = r1 ** 2
        rr2 = r2 ** 2
        cv = (rr0 + rr1 - rr2)
        sv = sqrt(4 * rr0 * rr1 - cv ** 2)
        return (
            (x1 + (cv * xd - sv * yd) / (2. * rr0), y1 + (cv * yd + sv * xd) / (2. * rr0)),
            (x1 + (cv * xd + sv * yd) / (2. * rr0), y1 + (cv * yd - sv * xd) / (2. * rr0)),
        )

    N = int(input())
    P = []
    for _ in range(N):
        x, y = map(int, input().split())
        P.append((x, y))

    dmax = 0
    for i in range(N):
        for j in range(i+1, N):
            dmax = max(dmax, dist(P[i], P[j]))

    eps = 10**-8
    ok = 1000.
    ng = dmax / 2
    mid = (ok+ng)/2
    while ok - ng > 10**-7:
        cp_list = []
        for i in range(N-1):
            x1, y1 = P[i]
            for j in range(i+1, N):
                x2, y2 = P[j]
                cp1, cp2 = CP(x1, y1, mid, x2, y2, mid)
                cp_list.append(cp1)
                cp_list.append(cp2)
        flg = 0
        for p0 in cp_list:
            tmp = 1
            for p in P:
                if dist(p0, p) > mid + eps:
                    tmp = 0
            if tmp:
                flg = 1
                break
        if flg:
            ok = mid
        else:
            ng = mid
        mid = (ok+ng)/2
    print(ok)


if __name__ == '__main__':
    main()


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

int main()
{
  int n, h;
  cin >> n >> h;
  int a[100007], b[100007];
  int amax = 0;
  for(int i = 0; i < n; i++)
  {
    cin >> a[i] >> b[i];
    amax = max(amax, a[i]);
  }
  sort(b, b + n, greater<int>());
  b[n] = 0;
  int ans = 0, sum = 0;
  for(; ans <= n; ans++)
  {
    if(sum >= h)
    {
      cout << ans << endl;
      return 0;
    }
    if(amax >= b[ans])
    {
      cout << ans + (h - sum - 1) / amax + 1 << endl;
      return 0;
    }
    sum += b[ans];
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;                     
using namespace __gnu_pbds;



int main()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.flush();
	ll t=1;
	ll CaseN=1; 
	//cin>>t;
	while(t--)
	{
		ll n,k,l=0;
		cin>>n>>k;
		ll a[n+1];
		for(ll i=1;i<=n;i++)
		{
		cin>>a[i];	
		}
		ll c[n+1] ; // cycle;
		bool vis[n+1];
		// set false;
		for(ll i=0;i<=n;i++)
		{
		vis[i]=false;	
		}
		
		
		
		
		ll p =1; // start
		ll lp =0;
		while(1)
		{
			//cout<<p<<" ::"<<endl;
		if(vis[p]==false)
		{
		//cout<<"++"<<endl;	
		c[l]=p;
		l++;
		//cout<<"--"<<endl;
		vis[p]=true;
		p = a[p];
			
		}
		else
		{
			lp = p ;
		break;	
		}
		}
		
	//	cout<<lp<<endl;
	//	for(ll i=0;i<l;i++)
	//	{
		//	cout<<c[i]<<" ";
	//		}
		//	cout<<endl;
		
		ll ans =0;
		// p  in
		ll sz=0;
	 for(ll i=0;i<l;i++)
	 {
		 if(c[i]!=lp)
		 {
			 sz++;
			 }
			 else
			 {
				 break;
				 }
		 }
		// cout<<"----"<<sz<<endl;
		 
	 if(k<=sz)
	 {
		 if(k-1>=0)
		 ans = a[c[k-1]];
		 
		}
	    else
	    {
		k = k-sz;	
		// l
		
		ll st=sz;
		ll en = l-1;	
		l = l-sz;
		//cout<<"+++"<<l<<endl;
		ll in = (k%l);
		if(in==0)
		{
			in=l;
			}
		//in--;
		//cout<<"in "<<in<<endl;
		//in =in + sz;
		
		ans = c[in];
		ll d=0;	
		for(ll i=st;i<=en;i++)
		{
			d++;
			if(d==in)
			{
			ans = a[c[i]];
			break;	
			}
		}	
			
			
			
		}
	
	
		//cout<<"Case #"<<CaseN<<": ";
		CaseN++;
		// print your ans below;
		cout<<ans<<endl;
	}

return 0;
}

//if(ans)
//{ cout<<"YES"<<endl;  }
//else
//{cout<<"NO"<<endl;}


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

int main() {
  int n;
  cin >> n;
  vector<int> pi(n);
  for (int i = 0; i < n; i++) cin >> pi.at(i);
  
  int ans = 0;
  for (int i = 0; i < n-2; i++) {
    if (pi.at(i) < pi.at(i+1) && pi.at(i+1) < pi.at(i+2)) ans++;
    if (pi.at(i) > pi.at(i+1) && pi.at(i+1) > pi.at(i+2)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,A,B;
  cin>>n>>A>>B;
  if(n*A<=B)
  {n=A*n;
    cout<<n<<endl;
  }
  else{
    cout<<B<<endl;
  }
  





return 0;
}

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

Int n;
vector<vector<Int>> a;
vector<Int> v;

Int rec(Int p){
	if(v[p] != -1) return v[p];
	if(a[p].size() == 0) return v[p] = 0;
	vector<Int> w(a[p].size());
	for(size_t i=0; i<a[p].size(); ++i)
		w[i] = rec(a[p][i]);
	sort(w.begin(), w.end());
	Int res = 0;
	for(size_t i=0; i<w.size(); ++i)
		res = max<Int>(res, w[i]+w.size()-i);
	return v[p] = res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	a.resize(n);
	for(Int i=0; i<n-1; ++i){
		Int t;
		cin >> t;
		a[t-1].push_back(i+1);
	}
	v.resize(n, -1);
	for(Int i=0; i<n; ++i)
		v[i] = rec(i);
	cout << v[0] << "\n";
}

Measured memory_bytes: 15872
#include <stdio.h>
int main(void)
{
int n;
int i;
  long sum=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        if( i%3!=0 && i%5!=0 ){
            sum=sum+i;
        }
    }
    printf("%ld\n",sum);
    return 0;
}

Measured memory_bytes: 1736
#include<stdio.h>

int main(void){
   int n[100],x[300],i,j,k,cnt[300]={0},a=0,b,c=0;
while(c<1000){
      scanf("%d %d",&n[a],&x[a]);
      if(n[a]==0 && x[a]==0){
      break;
    }
    a=a+1;
      c=c+1;
}



 for(a=0;a<c;a++){
    for(i=1;i<=n[a];i++){
       for(j=1;j<=n[a];j++){
          for(k=1;k<=n[a];k++){
			b=i+j+k;
             if(b==x[a] && i!=j && j!=k && k!=i)
                cnt[a]=cnt[a]+1;
          }
       }
    }
     printf("%d\n",cnt[a]/6);
}
 return 0;
}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


int main(){FIN
    
    ll H,W;cin>>H>>W;
    ll h,w;cin>>h>>w;
    cout<<W*H-(W*h+H*w-h*w)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h,w;
  cin >> h >> w;
  string s[h];
  rep(i,h) cin >> s[i];
  rep(i,w+2) cout << "#";
  cout << "" << endl;
  rep(i,h){
    cout << "#";
    rep(j,w)cout <<s[i][j];
    cout << "#" << endl;    
  }
  rep(i,w+2) cout << "#";
  cout <<""<<endl;
  
  return 0;
    

}


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

#define MAX 100000
#define INFTY (1 << 30)

class Edge {
public:
    int t, w;
    Edge(){}
    Edge(int t, int w): t(t), w(w) {}
};

vector<Edge> G[MAX];
int n, d[MAX];

bool vis[MAX];
int cnt;

void bfs(int s){
    for(int i=0; i<n; i++) d[i] = INFTY;
    queue<int> Q;
    Q.push(s);
    d[s] = 0;
    int u;
    while(!Q.empty()){
        u = Q.front(); Q.pop();
        for(int i=0; i<G[u].size(); i++){
            Edge e = G[u][i];
            if(d[e.t] == INFTY){
                d[e.t] = d[u] + e.w;
                Q.push(e.t);
            }
        }
    }
}

void solve(){
    // 適当な視点 s から最も遠い節点 tgt を求める
    bfs(0);
    int maxv = 0;
    int tgt = 0;
    for(int i=0; i<n; i++){
        if(d[i] == INFTY) continue;
        if(maxv < d[i]){
            maxv = d[i];
            tgt = i;
        }
    }
    
    // tgt から最も遠い節点の距離 maxv を求める
    bfs(tgt);
    maxv = 0;
    for(int i=0; i<n; i++){
        if(d[i] == INFTY) continue;
        maxv = max(maxv, d[i]);
    }
    
    cout << maxv << endl;
}



int main(){
    int s, t, w;
    cin >> n;
    
    for(int i=0; i<n-1; i++){
        cin >> s >> t >> w;
        
        G[s].push_back(Edge(t,w));
        G[t].push_back(Edge(s,w));
    }
    solve();
}



Measured memory_bytes: 9844
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	static class Team {
		int number;
		int score;
		int rank;
		
		Team(Integer number, Integer score) {
			this.number = number;
			this.score = score;
		}

		public String toString() {
			return "{number: " + number + "score: " + score + "rank: " + rank + "}";
		}
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String str[];
		ArrayList<Team> team = new ArrayList<Team>();
		int count;
		
		count = 0;
		while (true) {
			str = sc.next().split(",");
			if (str[0].equals("0") && str[1].equals("0")) {
				break;
			}
			team.add(new Team(Integer.valueOf(str[0]), Integer.valueOf(str[1])));
			count++;
		}
		quickSort(team, 0, count - 1);
		team.get(0).rank = 1;
		for (int i = 1; i < team.size(); i++) {
			if (team.get(i).score == team.get(i - 1).score) {
				team.get(i).rank = team.get(i - 1).rank;
			} else {
				team.get(i).rank = team.get(i - 1).rank + 1;
			}
		}
		while (sc.hasNext()) {
			int a = sc.nextInt();
			for (int i = 0; i < team.size(); i++) {
				if (team.get(i).number == a) {
					System.out.println(team.get(i).rank);
				}
			}
		}
	}
	
	public static void quickSort(ArrayList<Team> team, int low, int high) {
		if (high <= low) {
			return ;
		}
		int i = low;
		int j = high;
		int x = team.get((low + high) / 2).score;
		while (i <= j) {
			while (x < team.get(i).score) {
				i++;
			}
			while (team.get(j).score < x) {
				j--;
			}
			if (i <= j) {
				Team swap = new Team(team.get(i).number, team.get(i).score);
				team.get(i).score = team.get(j).score;
				team.get(i).number = team.get(j).number;
				team.get(j).score = swap.score;
				team.get(j).number = swap.number;
				i++;
				j--;
			}
		}
		quickSort(team, low, j);
		quickSort(team, i, high);
	}
}

Measured memory_bytes: 12000
def m():
    A = []
    for _ in range(5):
        a = int(input())
        A.append(a)

    amari = 10
    tmp = 0
    for i in range(5):
        if A[i] % 10 == 0:
            continue
        if (A[i] % 10) < amari:
            tmp = i
            amari = A[i] % 10
    if amari == 10:
        return sum(A)
    ans = []
    for i in range(5):
        if i == tmp:
            ans.append(A[tmp])
            continue
        if A[i] % 10 == 0:
            ans.append(A[i])
            continue
        ans.append(A[i] + (10 - A[i]%10))
    return sum(ans)
print(m())

Measured memory_bytes: 3064
k = list(input())
q = [i for i in range(len(k)) if k[i] == "?"]
p = [i for i in range(len(k)) if k[i] == "P"]
d = [i for i in range(len(k)) if k[i] == "D"]

for i in q:
  if i == 0 or i == len(k) - 1:
    k[i] = "D"
  else:
    if k[i -1] == "D" and k[i + 1] == "D":
      k[i] = "P"
    else:
      k[i] = "D"
print("".join(k))

Measured memory_bytes: 18552
n, a, b = map(int, input().split())

MOD = 1000000007

def comb(n, r):
    x = 1
    y = 1
    for i in range(r):
        x = x * (n - i) % MOD
        y = y * (i + 1) % MOD
    return x * pow(y, MOD - 2, MOD) % MOD

ans = pow(2, n, MOD)
ans -= 1
ans -= comb(n, a)
ans -= comb(n, b)
while ans < 0:
    ans += MOD
print(ans)

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif
	int a,b;
	cin>>a>>b;
	for(int i=1;i<=1250;i++){
		int a1=(i*8)/100;
		int b1=(i*10)/100;
		if(a1==a && b1==b ){
			cout<<i<<endl; return 0;
		}
	}
	cout<<"-1\n";
	return 0;
}

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

int main()
{
    int n , m;
    cin >> n >> m;
    vector<int>arr(m);
    for(auto & i : arr)
        cin >> i;
    long long val = accumulate(arr.begin(),arr.end(),0) ;
    if( val > n)
        cout << -1 << endl;
    else
        cout << n - val << endl;
    return 0;
}


Measured memory_bytes: 3668
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        m: u64
    }
    println!("{}", 48 - m);
}

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



long long int solve(long long int x, long long int y){
	if (x == y)return 0;
	if (-x == y)return 1;
	if (x == 0){
		return LLONG_MAX-1;
	}
	long long int ans = LLONG_MAX-1;
	if (x < y){
		ans = min(ans, y - x);
	}
	if (x > 0 && abs(x) < abs(y)){
		long long int tmp= abs(y) - abs(x);
		if (y!=0&&x / abs(x) != y / abs(y)){
			tmp++;
		}
		ans = min(ans, tmp);
	}
	if (x<0 && abs(x)>abs(y)){
		long long int tmp = abs(x) - abs(y);
		if (y!=0&&x / abs(x) != y / abs(y)){
			tmp++;
		}
		ans = min(ans, tmp);
	}
	return ans;
}
int main(){
	long long int  x, y;
	scanf("%lld%lld", &x, &y);
	long long int ans = solve(x, y);
	ans = min(ans, solve(x + 1, y)+1);
	ans = min(ans, solve(-x, y)+1);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;
int K;
vector<int> A = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> K;
    cout << A[K - 1] << endl;


    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int	main(void)
{
	int	h = 0;
	int	w = 0;

	while (1)
	{
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0)
			break ;
		int i;
		int j;
		j = 0;
		while (j < h)
		{
			i = 0;
			while (i < w)
			{
				printf("%c", '#');
				i++;
			}
			printf("%c", '\n');
			j++;
		}
		printf("%c", '\n');
	}
	return (0);
}




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

using namespace std;

template <class T>
using lim = numeric_limits<T>;

typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int maxN = 100000;
const int maxF = 200001;

ll fact[maxF+1];
vector<ll> primes;

// sieving primes
void sieve(){
	for (int i = 2; i <= maxN; i++){
		bool isPrime = true;
		for (ll p : primes){
			if (p*p > i) break;
			if (i%p == 0){
				isPrime = false;
				break;
			}
		}
		
		if (!isPrime) continue;
		primes.push_back(i);
	}
}

// computing fact
void compute(){
	memset(fact, 0, sizeof fact);
	fact[0] = 1;
	for (ll i = 1; i <= maxF; i++){
		fact[i] = fact[i-1]*i;
		fact[i] %= MOD;
	}
}

// modular power
ll modPow(ll b, ll e)
{
	if (e == 0) return 1;
	if (e&1) return (b*modPow(b,e-1))%MOD;
	else return modPow((b*b)%MOD, e/2);
}

// permutaitons
ll perm(ll n, ll r){
	return (fact[n] * modPow(fact[n-r], MOD-2))%MOD;
}

// combinations
ll combi(ll n, ll r){
	return (perm(n, r) * modPow(fact[r], MOD-2))%MOD;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	sieve();
	compute();

	unordered_map<int, int> multis;
	
	int n, m; cin >> n >> m;
	
	int temp = m;
	// computing multipicities
	for (ll p : primes) {
		while(temp%p==0){
			multis[p]++;
			temp /= p;
		}
	}
	// large primes
	if (temp > 1) multis[temp]++;
	
	
	ll ans = 1;
	for (auto it = multis.begin(); it != multis.end(); it++){
		if (it->second > 0){
			// stars and bars
			ans = (ans*combi(it->second+n-1, it->second))%MOD;
		}
	}
	
	cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
ll a[N];

void print_1() {
    cout << "First\n";
}

void print_2() {
    cout << "Second\n";
}

int solve(int n) {
    ll sum = 0;
    ll odd_num = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        odd_num += (a[i] & 1);
    }
    if ((sum + n) % 2 == 0) {
        if (odd_num != 1)
            return 2;
        int u;
        for (int i = 0; i < n; i++) {
            if (a[i] & 1) {
                u = i;
                break;
            }
        }
        if (a[u] == 1)
            return 2;
        a[u]--;
        ll g = 0;
        for (int i = 0; i < n; i++) {
            g = __gcd(g, a[i]);
        }
        for (int i = 0; i < n; i++) {
            a[i] /= g;
        }
        return 3 - solve(n);
    }
    return 1;

}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (n == 1) {
        if (a[0] == 1) {
            print_2();
        } else {
            print_1();
        }
        return 0;
    }
    if (solve(n) == 1)
        print_1();
    else
        print_2();
    return 0;
}


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

int main() {

  string s_;
  string q;
  cin >> s_ >> q;

  string s = s_ + s_;
  
  if (s.find(q) == -1) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;

}


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

#ifdef HOME
#define db(x) cerr << #x << " = " << x << endl
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")" << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
#define dbv(a) cerr << #a << " = "; for (auto xxx: a) cerr << xxx  << " "; cerr << endl
#else
#define db(x) ;
#define db3(x, y, z) ;
#define db2(x, y) ;
#define dbv(a) ;
#endif

using namespace std;
typedef long long ll;
typedef double dbl;


const int INF = 1.01e9;



int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif

    string s;
    while (cin >> s) {
        ll ans = 0;
        int cnt = 0;
        for (char c : s) {
            if (c == 'W') {
                ans += cnt;
            } else {
                cnt++;
            }
        }
        cout << ans << endl;
    }

#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

ll diff(ll a, ll b, ll c) { return max({a, b, c}) - min({a, b, c}); }

int main() {
  ll H, W;
  cin >> H >> W;
  ll res = H * W;
  for (ll h = 1; h <= H; h++) {
    ll rem = H - h;
    if (rem >= 2) {
      ll h1 = rem / 2;
      ll h2 = rem - h1;
      res = min(res, diff(h * W, h1 * W, h2 * W));
    }
    if (rem >= 1) {
      ll w1 = W / 2;
      ll w2 = W - w1;
      res = min(res, diff(h * W, w1 * rem, w2 * rem));
    }
  }
  for (ll w = 1; w <= W; w++) {
    ll rem = W - w;
    if (rem >= 2) {
      ll w1 = rem / 2;
      ll w2 = rem - w1;
      res = min(res, diff(w * H, w1 * H, w2 * H));
    }
    if (rem >= 1) {
      ll h1 = H / 2;
      ll h2 = H - h1;
      res = min(res, diff(w * H, h1 * rem, h2 * rem));
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
  a, b, c, d = map(int, input().split())

  takahashi_hp = a
  aoki_hp = c
  while True:
    aoki_hp -= b
    if aoki_hp <= 0:
      print('Yes')
      break

    takahashi_hp -= d
    if takahashi_hp <= 0:
      print('No')
      break



if __name__ == '__main__':
  main()


Measured memory_bytes: 9168
s=input()
s=s[:len(s)-1]
while True:
    if len(s)%2!=0:
        s=s[:len(s)-1]
    else:
        if s[:len(s)//2]==s[len(s)//2:]:
            print(len(s))
            break
        else:
            s=s[:len(s)-1]

Measured memory_bytes: 3060
def checkPalindrome(str)
  strArray = str.split(//)
  (strArray.size / 2).times do
    return false    if  strArray.shift != strArray.pop
  end
  return true
end

numPalindrome = 0
while input = gets
  numPalindrome += 1  if  checkPalindrome(input.chomp)
end
puts numPalindrome

Measured memory_bytes: 6100
#include <iostream>
#include <vector>

using namespace std;
typedef vector<long long int> Row;
typedef vector<Row> Matrix;

Matrix ScanMatrix(int n, int m)
{
    Matrix matrix(n, Row(m));
    for(int r = 0; r < n; ++r){
        for(int c = 0; c < m; ++c){
            cin >> matrix[r][c];
        }
    }
    return matrix;
}
long long int GetElement(Matrix a, Matrix b, int r, int c)
{
    int s = a[r].size();
    long long int result = 0;
    for(int i = 0; i < s; ++i){
        result += a[r][i] * b[i][c];
    }
    return result;
}
Matrix ProductMatrix(Matrix a, Matrix b)
{
    int n = a.size();
    int m = b[0].size();
    Matrix matrix(n, Row(m));
    for(int r = 0; r < n; ++r){
        for(int c = 0; c < m; ++c){
            matrix[r][c] = GetElement(a, b, r, c);
        }
    }
    return matrix;
}
void PrintMatrix(Matrix a)
{
    int n = a.size();
    for(int r = 0; r < n; ++r){
        int m = a[r].size();
        for(int c = 0; c < m; ++c){
            if(c){
                cout << " ";
            }
            cout << a[r][c];
        }
        cout << endl;
    }
}
int main()
{
    int n, m, l;
    cin >> n >> m >> l;
    Matrix A = ScanMatrix(n, m);
    Matrix B = ScanMatrix(m, l);
    Matrix C = ProductMatrix(A, B);
    PrintMatrix(C);
    return 0;
}

Measured memory_bytes: 3500
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int n,a[200200];
map<int,int> mp;

int main()
{
    n=read();
    rep(i,1,n) a[i]=read();
    ll ans=0;
    rep(i,1,n)
    {
        ans+=mp[i-a[i]];
        mp[i+a[i]]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 21252