akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;
    cout << (a*3+b)/2 << endl;

}

Measured memory_bytes: 256
s = input()

if len(s) == 2:
    if s[0] == s[1]:
        print('1 2')
    else:
        print('-1 -1')
else:
    for i in range(2, len(s)):
        if s[i-1] == s[i]:
            print('{} {}' . format(i, i+1))
            exit(0)
        elif s[i-2] == s[i]:
            print('{} {}' . format(i-1, i+1))
            exit(0)
    print('-1 -1')


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

#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define VPII vector<PII>
#define LD long double
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000 // array max range

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(11);
    cerr << fixed << setprecision(6);
    int n;
    cin >> n;
    int sum=0;
    FOR(i,1,n-1){
        if(n%i == 0){
            sum+=(n/i)-1;
        }else{
            sum+=(n/i);
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>
#include <stack>

using namespace std;

struct pa{
  int i, j;
  pa(int _i, int _j) : i(_i), j(_j) {}
};

long long search(vector<vector<int> >& v, int si, int sj){
  stack<pa> st = stack<pa>();
  st.push(pa(si, sj));
  v[si][sj] += 2;
  long long b = 0, w = 0;
  while(! st.empty()){
    stack<pa> st2 = stack<pa>();
    while(! st.empty()){
      pa pt = st.top();
      int i = pt.i, j = pt.j;
      st.pop();
      int nextcolor;
      if (v[i][j] == 2){
        nextcolor = 1;
        ++b;
      }else{
        nextcolor = 0;
        ++w;
      }
      if (i != 0 && v[i-1][j] == nextcolor){
        st2.push(pa(i-1, j));
        v[i-1][j] += 2;
      }
      if (j != 0 && v[i][j-1] == nextcolor){
        st2.push(pa(i, j-1));
        v[i][j-1] += 2;
      }
      if (i != v.size()-1 && v[i+1][j] == nextcolor){
        st2.push(pa(i+1, j));
        v[i+1][j] += 2;
      }
      if (j != v[0].size()-1 && v[i][j+1] == nextcolor){
        st2.push(pa(i, j+1));
        v[i][j+1] += 2;
      }
    }
    st = st2;
  }
  return b*w;
}

int main(void){
  int h, w;
  cin >> h >> w;
  vector<vector<int> > v = vector<vector<int> >();
  v.reserve(h);
  for(int i = 0; i < h; ++i){
    string str;
    cin >> str;
    vector<int> vv = vector<int>();
    vv.reserve(w);
    for(int j = 0; j < w; ++j){
      vv.push_back(str[j] == '#' ? 0 : 1);
    }
    v.push_back(vv);
  }
  long long sum = 0;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      if (v[i][j] == 0){
        sum += search(v, i, j);
      }
    }
  }
  cout << sum << endl;
  return 0;
}


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

//GCD,LCM
ll gcd(ll a, ll b){ return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){ return a/gcd(a,b)*b;}

int main()
{
    int N,t[100010]={},x[100010]={},y[100010]={};
    cin>>N;
    t[0]=0;
    x[0]=0;
    y[0]=0;

    for(int i=1;i<=N;i++){
        cin>>t[i]>>x[i]>>y[i];

        int td=t[i]-t[i-1];
        int d=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);

        if(td<d||(td-d)%2!=0){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll r; cin >> r;
    if(r<1200) cout << "ABC" << endl;
    else if(r<2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}

Measured memory_bytes: 256
while True:
    H, W = [int(x) for x in input().split(" ")]

    if H == 0 and W == 0: exit()

    fill = (["." for x in range(W)])
    fill[0] = "#"
    fill[len(fill) - 1] = "#"

    for i in (range(H - 1)):
        if i == 0:
            print("#"*W)
        elif i == H - 1:
            print("#"*W)
        else:
            print("".join(fill))

    print("#"*W)
    print("")
    

Measured memory_bytes: 7756
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define loop(x) for(int i=0;i<x;i++)
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define dd fflush(stdout)
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mt make_tuple //use tie
#define eb emplace_back
typedef tuple<int,int,int> State;//use in dijkstra
ll mod=1e9+7;
// ll power(ll x,ll y,ll mod){
//  ll ans=1;
//  while(y>0){
//   if(y&1){
//     ans=ans*x;
//   }
//   x=x*x;
//   y=y/2;
//  }
//  return ans;
// }
int n;
int a[100][100];
int dp[23][(1<<21)+3];
ll solve(int row,ll mask){
  ll ans=0;
  if(row==n && mask==((1<<n)-1)){
    return 1;
  }
  if(dp[row][mask]!=-1)
  return dp[row][mask];
  for(int i=0;i<n;i++){
    if(a[row][i]==1 && ((mask&(1<<i))==0))
      ans=(ans+solve(row+1,mask|(1<<i)))%mod;
  }
  return dp[row][mask]=ans;
} 
int main(){
    IOS;   
    // int n;
    memset(dp,-1,sizeof dp);
cin>>n;
loop(n){
  for(int j=0;j<n;j++)
    cin>>a[i][j];
}
cout<<solve(0,0)<<endl;
}

// https://atcoder.jp/contests/dp/tasks/dp_d
// https://codeforces.com/contest/1131/problem/C
 
//csjosh

Measured memory_bytes: 188672
import math

# 素数か否かを判定する関数
def is_prime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if n%i == 0:
            return False
    return True      

# nまでの素数を返す関数（エラトステネスの篩）
def getPrime(n):
    n_sqrt = int(math.sqrt(n))
    array = [True]*(n_sqrt+1)
    result = []
    for i in range(2, n_sqrt+1):
        if array[i]:
            array[i] = False
            result.append(i)
            for j in range(i*2, n_sqrt+1, i):
                array[j] = False
    return result

N = int(input())
n = N
prime = getPrime(n)
prime_exp = []
# print(prime)
for p in prime:
    cnt = 0
    while n%p == 0:
        n = int(n/p)
        # print(n)
        cnt += 1
    if cnt != 0:
        prime_exp.append([p, cnt])
if is_prime(n) and n != 1:
    prime_exp.append([n, 1])
ans = 0
for pe in prime_exp:
    ans += int((-1+math.sqrt(1+8*pe[1]))/2)
print(ans)

Measured memory_bytes: 19996
N, A = int(input()), list(map(int, input().split()))
print(' '.join([str(a) for a in A]))
for i in range(1, N):
    v= A[i]
    j= i - 1
    while j  >= 0 and A[j] > v:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
    print(' '.join([str(a) for a in A]))

Measured memory_bytes: 7720
N,K = map(int,input().split())
V = list(map(int,input().split()))
ans = []
for i in range(1,min(K,N)+1):
    for a in range(i+1):
        b = i-a
        AB = V[:a]
        if b > 0:
            AB += V[-b:]
        AB.sort(reverse = True)
        for j in range(K-i):
            if AB and AB[-1] < 0:
                AB.pop()
        ans.append(sum(AB))
print(max(ans))

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main() {
	int n = in(), m = in();
	vector<int>road(n);
	REP(i, m) {
		int a = in() - 1, b = in() - 1;
		++road[a];
		++road[b];
	}
	REPC(i, road) {
		cout << i << endl;
	}
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

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

void Main()
{
    ll n;
    cin >> n;
    vll t(n), v(n);
    rep(i, n)
    {
        cin >> t[i];
        t[i] *= 2;
    }
    rep(i, n)
    {
        cin >> v[i];
        v[i] *= 2;
    }

    vll max_v(200 * 105 * 2, 0);
    ll prev = 0;
    rep(i, n)
    {
        rep(j, t[i])
        {
            max_v[prev + j] = v[i];
        }
        prev += t[i];
    }

    vvll dp(200 * 105 * 2, vll(105 * 2, -LINF));
    dp[0][0] = 0;

    ll sum = accumulate(ALL(t), 0);
    rep(i, sum) rep(j, 202)
    {
        if (j <= min(max_v[i], max_v[i + 1]))
        {
            chmax(dp[i + 1][j], dp[i][j] + j * 2);
        }
        if (j + 1 <= min(max_v[i], max_v[i + 1]))
        {
            chmax(dp[i + 1][j + 1], dp[i][j] + j * 2 + 1);
        }
        if (j >= 1 && j - 1 <= min(max_v[i], max_v[i + 1]))
        {
            chmax(dp[i + 1][j - 1], dp[i][j] + j * 2 - 1);
        }
    }
    cout << dp[sum][0] / 8. << endl;
}

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


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

using namespace std;
using ll = long long;

ll a, b, c;

int main(){
	cin >> a >> b >> c;
	if(c-a-b > 0 && 4*a*b < (c-a-b)*(c-a-b)) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;


int main(void){
	int x; cin >> x;
	int count = x /100;
	x %= 100;
	if(count*5 >= x) cout << 1 << endl;
	else cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  vector<bool> exit(102, false);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    exit[p[i]] = true;
  }
  int diff = 10000, ans = 10000;
  for (int i = 0; i < 102; i++) {
    if (exit[i]) continue;
    int temp = abs(x - i);
    if (diff > temp) {
      diff = temp;
      ans = i;
    } else if (diff == temp && ans > i) {
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define int long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"

int32_t main()
{ 

	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]>=k)
			cnt++;
	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 1024
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
	int x,a,b;
	scanf("%d%d%d",&x,&a,&b);
	if(abs(x-a) < abs(x-b))
		printf("A\n");
		else printf("B\n");
		return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<string>

#define ll unsigned long long
using namespace std;
int solve()
{
	ll a;
	double b;
	cin >> a;
	cin >> b;
 	ll c = b*1000;
	
	ll d = a*c;
  	ll res = d/1000;
	cout << res << endl;
 
	return 0;
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 3736
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
char in[50000];
int main(){
	int a;scanf("%d",&a);
	scanf("%s",in);

	for(int i=0;in[i];i++){
		in[i]='A'+(in[i]-'A'+a)%26;
	}
	printf("%s\n",in);
}


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

using namespace std;

vector<vector<int> > node(10000);
vector<bool> used(10000, false);
vector<int> ans_c(10000, -1);


void disp(int index, int &c_index, int &index_c_l, vector<int> &c) {
	if (used[index] == true) return;
	used[index] = true;
	if (node[index].size() > 1) {
		ans_c[index] =c[index_c_l];
		index_c_l--;
	} else {
		ans_c[index] =c[c_index];
		c_index++;
	}


	for (int cur_node : node[index]) {
		disp(cur_node, c_index,index_c_l,c);
	}

}



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

	vector<int> a(n), b(n), c(n);



	for (int i = 0; i < n - 1; i++) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;

		node[a[i]].push_back(b[i]);
		node[b[i]].push_back(a[i]);
			
	}
	int max_c = 0;
	int total = 0;
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		if (c[i] > max_c) {
			max_c = c[i];
		}
		total += c[i];

	}
	cout << total - max_c << endl;
	sort(c.begin(), c.end());

	int index = 0;
	for (int i = 0; i < n; i ++) {
		if (node[i].size() == 1) {
			index = i;
			break;
		}
	}
	int index_c = 0;
	int index_c_l = n - 1;

	disp(index, index_c,index_c_l,c);
	for (int i = 0; i < n; i++) {
		cout << ans_c[i] << " ";
	}
	cout << endl;

	return 0;

}

Measured memory_bytes: 1536
#include<bits/stdc++.h> 
using namespace std; 
string sss; 
int main() 
{
    int i=0,x=0,y,ans; 
    cin>>sss; 
    int qaq=sss.length(); 
    while(i<qaq) 
    { 
        if(sss[i]=='p') x++; 
        i++; 
    } 
    y=i/2; 
    ans=y-x; 
    cout<<ans;
    return 0; 
} 

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


int main()
{
  int N, i; cin >> N >> i;
  cout << (N - i + 1) << endl;

	return 0;
}



Measured memory_bytes: 256
s = gets.chomp

if s == "SUN"
  puts 7
elsif s == "MON"
  puts 6
elsif s == "TUE"
  puts 5
elsif s == "WED"
  puts 4
elsif s == "THU"
  puts 3
elsif s == "FRI"
  puts 2
elsif s == "SAT"
  puts 1
end

Measured memory_bytes: 1788
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
m = 0
b = []
cnt = [[] for _ in range(n+1)]
for i in range(1, n+1):
    j = i
    c = 1
    while j*c <= n:
        cnt[j*c].append(i)
        c += 1

tmp = [0]*(n+1)
for i in range(n)[::-1]:
    if tmp[i+1] % 2 != a[i]:
        b.append(i+1)
        m += 1
        for j in cnt[i+1]:
            tmp[j] += 1

if m == 0:
    print(m)
else:
    print(m)
    print(*b[::-1])


Measured memory_bytes: 157472
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void dfs(int root, vector<vector<int>> nodes, vector<int>& preorder, vector<int>& inorder, vector<int>& postorder) {
    preorder.push_back(root);
    if (nodes[root][0] != -1) {
        dfs(nodes[root][0], nodes, preorder, inorder, postorder);
    }
    inorder.push_back(root);
    if (nodes[root][1] != -1) {
        dfs(nodes[root][1], nodes, preorder, inorder, postorder);
    }
    postorder.push_back(root);
}

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

    int n, root;
    cin>>n;
    vector<vector<int>> nodes(n, vector<int>(2));
    vector<bool> ischild(n);
    rep(i, n) {
        int id, left, right;
        cin>>id>>left>>right;
        nodes[id][0] = left;
        nodes[id][1] = right;
        if (nodes[id][0] != -1) {
            ischild[nodes[id][0]] = true;
        }
        if (nodes[id][1] != -1) {
            ischild[nodes[id][1]] = true;
        }
    }
    rep(i, n) {
        if (!ischild[i]) root = i;
    }

    vector<int> preorder, inorder, postorder;
    dfs(root, nodes, preorder, inorder, postorder);

    cout<<"Preorder"<<endl;
    rep(i, n) cout<<" "<<preorder[i];
    cout<<endl;

    cout<<"Inorder"<<endl;
    rep(i, n) cout<<" "<<inorder[i];
    cout<<endl;

    cout<<"Postorder"<<endl;
    rep(i, n) cout<<" "<<postorder[i];
    cout<<endl;
}


Measured memory_bytes: 3196
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 count = 0;

        while(N-- != 0) {
            int x = sc.nextInt();
            int y = sc.nextInt();

            long dist = (long)((long)x * (long)x + (long)y * (long)y);
            if(dist <=  ((long)D * (long)D)) {
                count++;
            }
        }

        System.out.println(count);
    }
}


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

ll g1(ll n, int p){
	if (n==0) return 0;
	return n/p + g1(n/p,p);
}

ll g2(ll n, int p){
	if(n%2) return 0;
	ll res = g1(n/2,p);
	if(p==2) res += n/2;
	return res;
}

int main(){
	ll N;
	cin >> N;
	ll ans = min(g2(N,2), g2(N,5));
	cout << ans << endl;
	return 0;
}


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

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

  int a = 0;
  int t = 0;

  for (int i = 0; i < N; i++) {
    int h;
    cin >> h;
    if (h >= t) {
      a++;
      t = h;
    }
  }

  cout << a << endl;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function modpow(x, n, p)
    ans = 1
    while(n!=0)
        if n&1 == 1
            ans = ans*x%p
        end
        x = x*x%p
        n = n>>1
    end
    return ans
end
function main()
    s = readline()
    s = reverse(s)
    p=2019
    d = Dict()


    i10 = 0
    now = 0
    for i in 1:length(s)
        t = parse(Int, s[i])
        now += (modpow(10, i10, p) * t)%p
        now%=p
        i10+=1
        if haskey(d, now)
            d[now]+=1
        else
            d[now]=1
        end
    end

    res = 0
    i10 = 0
    now = 0
    for i in 1:length(s)
        if haskey(d, now)
            res += d[now]
        end
        t = parse(Int, s[i])
        now += (modpow(10, i10, p) * t)%p
        now %= p

        d[now]-=1
        i10+=1
    end
    println(res)



end
main()





Measured memory_bytes: 186812
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
const int N = 1e5 + 5;
ll n, m, out, arr[N], cum[N];
ll qry(int l, int r)
{
    if(r < l)   return 0;
    return cum[r] - (l ? cum[l - 1] : 0);
}
bool can(ll have, ll mn)
{
    for(int i = 0;i < n;++i)
        have -= (n - (lower_bound(arr, arr + n, mn - arr[i]) - arr));
    return have >= 0;
}
void calc(ll mn)
{
    for(int i = 0;i < n;++i)
    {
        int idx = lower_bound(arr, arr + n, mn - arr[i]) - arr;
        out += arr[i] * (n - idx) + qry(idx, n - 1);
        m -= (n - idx);
    }
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for(int i = 0;i < n;++i)
        cin >> arr[i];
    sort(arr, arr + n);
    for(int i = 0;i < n;++i)
        cum[i] = arr[i] + (i ? cum[i - 1] : 0);
    ll lo = 2, hi = 2e5 + 5, mid, ans = -1;
    while(lo <= hi)
    {
        mid = (lo + hi) >> 1;
        if(can(m, mid)) ans = mid, hi = mid - 1;
        else            lo = mid + 1;
    }
    calc(ans);
    ll mx = 0;
    for(int i = 0;i < n;++i)
    {
        int idx = lower_bound(arr, arr + n, ans - arr[i]) - arr;
        --idx;
        if(~idx)    mx = max(mx, arr[i] + arr[idx]);
    }
    cout << mx * m + out;
    return 0;
}



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

int N, K, d[11], ans=1<<30, pw[6]={1}, i, x;
void rec(int n,int res){
    if(n==-1){
        if(res>=N)ans=min(ans,res);
    }
    else{
        for(int i=0;i<10;i++){
            if(!d[i]){
                rec(n-1,res+pw[n]*i);
            }
        }
    }
}
int main(){
    for(i=1;i<6;i++) pw[i]=pw[i-1]*10;
    for(scanf("%d%d",&N,&K),i=1;i<=K;i++)
        scanf("%d",&x), d[x]=1;
    for(i=5;i>=0;i--) rec(i,0);
    printf("%d\n",ans);
    return 0;
}


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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  vector<int> digit_mod(s.size());
  int mult_digit = 1;
  for(int i = 0; i < s.size(); ++i){
    int digit = s[i] - '0';
    digit *= mult_digit;
    digit_mod[i] = digit % 2019;
    mult_digit *= 10;
    mult_digit %= 2019;
  }

  vector<int> cumsum(s.size()+1, 0);
  for(int i = 0; i < s.size(); ++i){
    cumsum[i + 1] = (cumsum[i] + digit_mod[i]) % 2019;
  }

  map<int, int> mp;
  for(int i = 0; i < cumsum.size(); ++i){
    mp[cumsum[i]]++;
  }

  ll ans = 0;
  for(auto itr : mp){
    ans += itr.second * (itr.second - 1) / 2;
  }

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

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  ll x, result;
  cin >> x;
  if (x <= 6) {
    result = 1;
  } else if (x <= 11) {
    result = 2;
  } else {
    result = x / 11;
    result *= 2;
    if (x % 11 != 0) {
      if (x % 11 <= 6) {
        result += 1;
      } else {
        result += 2;
      }
    }
  }
  cout << result << endl;
  return 0;
}


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

int main()
{
    ll a, b, k;
    cin >> a >> b >> k;
    rep(i, k) {
        if(i % 2 == 0) {
            if(a % 2 == 1) {
                a--;
            }
            a /= 2;
            b += a;
        }
        else{
            if(b % 2 == 1) {
                b--;
            }
            b /= 2;
            a += b;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n,k;
	cin>>n>>k;
	int a[n],f[n];
	forci(0,n)	cin>>a[i];
	forci(0,n)	cin>>f[i];
	sort(a,a+n);
	sort(f,f+n,greater<int>());
	int l=0,r=1e12+18;
	int mn=r;
	while(l<=r){
		int m=l+(r-l)/2LL;
		int sum=0;
		for(int i=0;i<n;i++){
			sum+=max(0LL,a[i]-m/f[i]);
		}
		if(sum<=k)
		{
			r=m-1;
			mn=min(mn,m);
		}
		else
			l=m+1;
	}
	cout<<mn<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}






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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int n;
int m;

vector<bool> is_reached(51);

vector<vector<bool>> g(50, vector<bool>(50, false));
VI a, b;

void dfs(int v){
	is_reached[v] = true;

	REP(i, n){
		if (!g[v][i]) continue;
		if (is_reached[i]) continue;
		DEBUGP(make_pair(v, i));
		dfs(i);
	}
}

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

	REP(i, m){
		int x, y;
		cin >> x >> y;
		x--; y--;
		a.push_back(x);
		b.push_back(y);
		g[y][x] = true;
		g[x][y] = true;
	}

	int res = 0;

	REP(i, m){
		g[a[i]][b[i]] = false, g[b[i]][a[i]] = false;
		REP(j, n){ is_reached[j] = false; }
		dfs(0);
		bool flag = false;
		REP(j, n){
			if (is_reached[j] == false) flag = true;
		}
		if (flag) res++;
		g[a[i]][b[i]] = true, g[b[i]][a[i]] = true;
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    int x;
    cin >> x;

    cout << ((x >= 1200) ? "ARC" : "ABC") << endl;
    return 0;
}

Measured memory_bytes: 256
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>

int main()
{
    int r = 0;
    
    scanf("%d",&r);
    
    printf("%d",r*r);
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
    int n; cin >> n;
    vector<pair<pair<int, int>, bool> > a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first.first >> a[i].first.second;
        a[i].second = 0;
    }
    vector<pair<int, int> > c(n);
    for (int i = 0; i < n; ++i) {
        cin >> c[i].first >> c[i].second;
    }
    sort(c.begin(), c.end());
    int cnt = 0;
    using pii = pair<int, int>;
    for (int i = 0; i < n; ++i) { //c
        int ymax = -1;
        int key = -1;
        for (int j = 0; j < n; ++j) {
            if (c[i].first > a[j].first.first && c[i].second > a[j].first.second && a[j].second == 0) {
                if (a[j].first.second > ymax) {
                    ymax = a[j].first.second;
                    key = j;
                }
            }
        }
        if (key != -1) {
            cnt++;
            a[key].second = 1;
        }
        /*
        cout << endl;
        for (int j = 0; j < n; ++j) {
            cout << a[j].first.first << " " << a[j].first.second << " " << a[j].second << endl;
        }*/
    }
    cout << cnt << endl;
}


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

int a[1000],n,cnt,L,R,M,p;

int main(){
	while(true){
		cin>>n;
		if(n==0){break;}
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		cin>>p;
		L=0;R=n-1;cnt=0;
		while(R>=L){
			cnt++;
			M=(R+L)/2;
			if(p==a[M]){break;}
			if(p>a[M]){L=M+1;}
			if(p<a[M]){R=M-1;}
		}
		cout<<cnt<<endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair< int, int > P;
typedef pair< int, P > iP;
typedef long long LL;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const int MOD = (10^9 + 7);

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int a[m + 1] = {};
    for(int i = 0; i < n; ++i ) {
        int k;
        cin >> k;
        for(int j = 0; j < k; ++j) {
            int b;
            cin >> b;
            a[b]++;
        }
    }
    int ans = 0;
    for(int i = 1; i <= m; ++i) {
        if( a[i] == n ) ++ans;
    }
    cout << ans << endl;
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct BinaryIndexedTree{
	int n;
	vector<int>dat;
	BinaryIndexedTree(int n=0):n(n){
		dat.resize(n+1);
	}
	void add(int k,int x){
		for(k++;k<=n;k+=k&-k)dat[k]+=x;
	}
	int sum(int k){
		int ret=0;
		for(k++;k;k-=k&-k)ret+=dat[k];
		return ret;
	}
};

int N;
int A[111111];

int S[111111];

// a<x    num(a)<=N/2
bool check(int x){
    int K=(N*(N+1)/2)/2;

    for(int i=0;i<N;i++){
        S[i+1]=S[i];
        if(A[i]<x)S[i+1]++;
        else S[i+1]--;
    }

    vector<int>vs;
    rep(i,N+1)vs.pb(S[i]);
    sort(all(vs));vs.erase(unique(all(vs)),vs.end());
    rep(i,N+1)S[i]=lower_bound(all(vs),S[i])-vs.begin();

    int cnt=0;
    BinaryIndexedTree bit(N+114);

    rep(i,N){
        bit.add(S[i],1);
        cnt+=bit.sum(S[i+1]-1);
    }

    return cnt<=K;
}

signed main(){
    cin>>N;
    rep(i,N)cin>>A[i];

    int lb=0,ub=1001001001;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(check(mid))lb=mid;
        else ub=mid;
    }
    cout<<lb<<endl;
    return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int xtime(int x){
    return (x+9)/10*10;
}

int ytime(int x){
    return xtime(x)-x;
}

int main(){
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    int sum=xtime(a)+xtime(b)+xtime(c)+xtime(d)+xtime(e);
    sum-=max({ytime(a),ytime(b),ytime(c),ytime(d),ytime(e)});
    cout << sum << endl;
}


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

int main() {
  string s;
  cin>>s;
  if(s=="SUN")cout<<7<<endl;
  if(s=="MON")cout<<6<<endl;
  if(s=="TUE")cout<<5<<endl; 
  if(s=="WED")cout<<4<<endl;
  if(s=="THU")cout<<3<<endl;
  if(s=="FRI")cout<<2<<endl;
  if(s=="SAT")cout<<1<<endl;
}


Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_6_A-in9.txt"));

		int n = scan.nextInt();
		boolean[][] a = new boolean[n + 1][n + 1];

		for (int i = 0; i < n; i++) {
			int u = scan.nextInt();
			int k = scan.nextInt();
			for (int j = 0; j < k; j++) {
				int v = scan.nextInt();
				a[u][v] = true;
			}
		}

		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if (j > 1)
					System.out.print(" ");
				if (a[i][j])
					System.out.print("1");
				else
					System.out.print("0");
			}
			System.out.println();
		}

		scan.close();
		System.exit(0);
	}
}

Measured memory_bytes: 34144
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;

const int64 INF = 1e18;
const int MOD = 1000000007;

struct Edge {
    int to;
    int64 cost;
    Edge(int _to, int64 _cost) : to(_to), cost(_cost) {}
};

template<class T>
vector<T> Dijkstra(const vector<vector<Edge>> &G, int s, T def, vector<int64> &path) {
    using P = pair<T, int>;
    priority_queue<P, vector<P>, greater<P>> que;
    vector<T> dist((int)G.size(), def);
    que.emplace(0, s);
    dist[s] = 0;
    path[s] = 1;
    while(!que.empty()) {
        auto p = que.top(); que.pop();
        int cur = p.second;
        if(dist[cur] < p.first) continue;
        for(auto &e : G[cur]) {
            if(dist[e.to] > dist[cur] + e.cost) {
                dist[e.to] = dist[cur] + e.cost;
                que.emplace(dist[e.to], e.to);
                path[e.to] = path[cur];
            } else if(dist[e.to] == dist[cur] + e.cost) {
                path[e.to] += path[cur];
                path[e.to] %= MOD;
            }
        }
    }
    return dist;
}

int main() {
    int N, M, S, T;
    cin >> N >> M >> S >> T;
    --S, --T;
    vector<vector<Edge>> G(N);
    for(int i = 0; i < M; ++i) {
        int a, b;
        int64 c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].emplace_back(b, c);
        G[b].emplace_back(a, c);
    }
    vector<int64> path_s(N);
    vector<int64> path_t(N);
    auto dist_s = Dijkstra(G, S, INF, path_s);
    auto dist_t = Dijkstra(G, T, INF, path_t);
    int64 ans = path_s[T] * path_t[S] % MOD;
    for(int i = 0; i < N; ++i) {
        if(dist_s[i] + dist_t[i] == dist_s[T] && dist_s[i] == dist_t[i]) {
            int64 n = path_s[i] * path_t[i] % MOD;
            n = n * n % MOD;
            ans -= n;
            if(ans < 0) ans += MOD;
        }
    }
    for(int i = 0; i < N; ++i) {
        for(auto &e : G[i]) {
            int j = e.to;
            if(dist_s[i] + dist_t[j] + e.cost == dist_s[T] && 2 * dist_s[i] < dist_s[T] && 2 * dist_t[j] < dist_s[T]) {
                int64 n = path_s[i] * path_t[j] % MOD;
                n = n * n % MOD;
                ans -= n;
                if(ans < 0) ans += MOD;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


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

int GetDigit(int num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main(){
    int N,sum=0;
    cin >> N;
    if(GetDigit(N)%2==0){
        for (int i=1; GetDigit(N)-1>=i; i=i+2){
            sum+= 9*pow(10,i-1);
        }
        cout << sum;
    }
    else {
        for (int i=1; GetDigit(N)-2>=i; i=i+2){
            sum+= 9*pow(10,i-1);
        }
        sum+=N-pow(10,GetDigit(N)-1)+1;
        cout << sum;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))
x = sorted(x)

ans = x[-1]**2 *n
for _n in range(x[0], x[-1]+1):
    _ans = sum([(_x - _n)**2 for _x in x])
    ans = min(_ans, ans)

print(ans)


Measured memory_bytes: 38640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    vector<int> R(N), m(N), M(N);
    for (auto &i : R) cin >> i;
    m[0] = R[0];
    M[N - 1] = R[N - 1];
    for (int i = 1; i < N; i++) m[i] = min(R[i], m[i - 1]);
    for (int i = N - 2; i >= 0; i--) M[i] = max(R[i], M[i + 1]);
    int ans = -1000000000;
    for (int i = 1; i < N; i++) ans = max(M[i] - m[i - 1], ans);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;

int main(){
  int n;
  cin >> n;
  vector<vector<P>> vn(n);
  for(int i=0; i<n-1; ++i){
    int u, v, w;
    cin >> u >> v >> w;
    --u; --v;
    vn[u].push_back(make_pair(v,w));
    vn[v].push_back(make_pair(u,w));
  }
  vector<int> ans(n,-1);
  queue<int> que;
  que.push(0);
  ans[0] = 0;
  while(!que.empty()){
    int x = que.front();
    que.pop();
    for(auto pi: vn[x]){
      if(ans[pi.first] != -1) continue;
      if(pi.second %2 == ans[x]) ans[pi.first] = 0;
      else ans[pi.first] = 1;
      que.push(pi.first);
    }
  }
  for(int i=0; i<n; ++i) cout << ans[i] << endl;
}

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

int main() {
  char a, b;
  cin >> a >> b;
  
  char ans;
  if(a == 'H'){
    if(b == 'H') ans = 'H';
    else ans = 'D';
  }
  else{
    if(b == 'H') ans = 'D';
    else ans = 'H';
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define Rep(i,x) for(int i=head[x];i+1;i=nxt[i])
#define rep2(i,a,b) for(int i=(a);i<(b);i++)
#define ff first
#define ss second
using namespace std;
const int N=200005;
const int inf=1e9+7;
typedef long long ll;
//------------------------------------------head---------------------------------------------------//
char s[15];
inline int query(int x)
{
	printf("%d\n",x);fflush(stdout);
	scanf("%s",s+1);fflush(stdout);
	if(s[1]=='F')return 0;else if(s[1]=='M')return 1;else return 2;	
}
int main()
{
	int n;scanf("%d",&n);
	int left=0,right=n-1;int tp=query(0);
	while(left<=right)
	{
		int mid=(left+right)>>1;
		int p=query(mid);if(p==2)return 0;
		if(((mid&1)^tp)!=p)right=mid-1;
		else left=mid+1;
	}return 0;
}

Measured memory_bytes: 760
N,M,Q=map(int,input().split())
x=[[0]*N for i in range(N)]
for i in range(M):
    L,R=map(lambda x:int(x)-1,input().split())
    x[L][R]+=1
cum=[[0]*(N+1) for i in range(N+1)]
for l in range(N):
    for r in range(N):
        cum[l][r+1]=cum[l][r]+x[l][r]
for i in range(Q):
    p,q=map(lambda x:int(x)-1,input().split())
    res=0
    for l in range(p,q+1):
        res+=cum[l][q+1]-cum[l][p]
    print(res)

Measured memory_bytes: 58088
#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 n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	vector<int> ans(n);
	rep(i,n){
		ans[a[i]-1] = i + 1;
	}
	rep(i,n) cout << ans[i] << endl;
}

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

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

  int mx = 0;
  int J = 0, O = 0, I = 0;

  for(int i=0; i<s.size(); i++) {
    //cout << J << " " << O << " " << I << endl;
    if( s[i] == 'J' ) {
      if( O > 0 ) {
	J = 1; O = I = 0;
      }
      else J++;
    }

    else if( s[i] == 'O' ) {
      if( J <= O ) {
	J = O = I = 0;
      }
      else if( I > 0 ) J = O = I = 0;
      else if( J > 0 ) O++;
    }

    else if( s[i] == 'I' ) {
      if( J > 0 && O > 0 ) {
	I++;
	if( O == I ) {
	  mx = max( mx, min( J, min( O, I ) ) );
	  J = O = I = 0;
	}
      }
      else { J = 0; O = 0; }
    }
  }

  cout << mx << endl;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
// =======================
#define gc getchar_unlocked
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long int
#define ull unsigned long long int
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ss second
#define setbits(x) _builtin_popcount(x)
#define parity(x) _builtin_parity(x)
#define leadzero(x) __builtin_clz(x)
#define trailzero(x) __builtin_ctz(x)
#define endl "\n"
#define elif else if
// =======================
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef map<int, int> mii;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim)
{
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
int mpow(int base, int exp);
void yes() { cout << "YES\n"; }
void no() { cout << "NO\n"; }
ll maxv(ll a, ll b);
const int mod = 1'000'000'007;
const int N = 3e5, M = N;
// =======================
int n, c;
void solve()
{
  cin >> n >> c;
  int v[n + 1], w[n + 1];
  ll dp[n + 1][c + 1];
  Fo(i, 1, n + 1) cin >> w[i] >> v[i];
  fo(i, n + 1) dp[i][0] = 0;
  fo(i, c + 1) dp[0][i] = 0;
  Fo(i, 1, n + 1)
  {
    Fo(j, 1, c + 1)
    {
      dp[i][j] = dp[i - 1][j];
      if (j >= w[i] && (dp[i - 1][j - w[i]] + v[i] * 1LL > dp[i][j]))
      {
        dp[i][j] = dp[i - 1][j - w[i]] + v[i] * 1LL;
      }
    }
  }
  cout << dp[n][c];
}

int main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());

  int t = 1;
  //cin >> t;
  while (t--)
  {
    solve();
  }

  return 0;
}

int mpow(int base, int exp)
{
  base %= mod;
  int result = 1;
  while (exp > 0)
  {
    if (exp & 1)
      result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

ll maxv(ll a, ll b)
{
  if (a >= b)
    return a;
  else
    return b;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
    string s,ss;
    cin >> s;
    ss = s.substr(0, 4) + s.substr(5, 2) + s.substr(8, 2);
    int day = stoi(ss);
    int v = 20190430;
    if (v >= day)cout << "Heisei" << endl;
    else cout << "TBD" << endl;
    return 0;
}

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

int main(){
    int N,ans=0;
    cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
    }

    for(int i=0;i<N;i++){
        if((i+1)%2==1&&a.at(i)%2==1){
            ++ans;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3628
i = list(map(int, input().split()))
A = i[0]
B = i[1]

count = 0
for i in range (A,B+1,1):
    I = str(i)
    if int(I[-1]) == int(I[-5]) and int(I[-2]) == int(I[-4]):
        count = count + 1
    else :
        pass

print(count)

Measured memory_bytes: 3064