akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	O := nextString()
	E := nextString() + " "

	var pw []byte
	for i := 0; i < len(O); i++ {
		pw = append(pw, O[i], E[i])
	}

	fmt.Printf("%s\n", pw)
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

// ---------- Util.


Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

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

    int ans = 0;
    for (int i = s.size() - 1; i != 0; --i) {
        if (i % 2 != 0) continue;

        bool ok = true;
        rep(j, i / 2) {
            if (s[j] != s[j + i / 2]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
flag=True
check=True
cnt=sum(A)-1
f=1
ans=1
dis=0
for i in range(n+1):
    if A[i]<=f:
        dis+=A[i]*(n-i)
        if check:
            if cnt==0:
                ans+=n
                check=False
            elif cnt>f-A[i]:
                ans+=(f-A[i])*(n-i)
                cnt=cnt-(f-A[i])
            else:
                ans+=cnt*(n-i)
                cnt=0
        f=2*(f-A[i])
    else :
        flag=False
        break
if not flag:
    print(-1)
else:
    print(ans-dis)

Measured memory_bytes: 83480
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

h, w = map(int,input().split())

c = []
for i in range(10):
    c.append(list(map(int, input().split())))

csr = csr_matrix(c)

a = []
for i in range(h):
    a.append(list(map(int, input().split())))

cost = floyd_warshall(csr)[:,1]

ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] > -1:
            ans += int(cost[a[i][j]])
print(ans)

Measured memory_bytes: 38388
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((int)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define eps 1e-9
typedef pair<int, int> II;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI 2 * acos(0)

#define maxn 600006

ll f[maxn][6];
string s;

void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
}

int main(){
	srand(1412);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);

    ms(f, 0);
    cin >> s;
    if(s[0] == '?'){
    	f[0][0] = 1;
    	f[0][1] = 1;
    } else{
    	f[0][s[0] - '0'] = 1;
    }

    int n = sz(s);
    for(int i = 1; i < n; i++){
    	if(s[i] == '0' || s[i] == '?'){
    		add(f[i][2], f[i - 1][0]);
    		add(f[i][4], f[i - 1][1]);
    		add(f[i][0], f[i - 1][2]);
    		add(f[i][0], f[i - 1][3]);
    		add(f[i][5], f[i - 1][4]);
    		add(f[i][4], f[i - 1][5]);
    	}
    	if(s[i] == '1' || s[i] == '?'){
    		add(f[i][3], f[i - 1][0]);
    		add(f[i][0], f[i - 1][2]);
    		add(f[i][1], f[i - 1][3]);
    		add(f[i][1], f[i - 1][4]);
    		add(f[i][4], f[i - 1][5]);
    	}
    }

    ll res = 1;
    Rep(i, n) if(s[i] == '?'){
    	res = res * 2 % mod;
    }
//    cout << res << endl;
    Rep(i, 6) if(i != 1){
//    	cout << i << " " << f[n - 1][i] << endl;
    	res = (res - f[n - 1][i] + mod) % mod;
//    	cout << res << endl;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 28880
#include<stdio.h>
int main()
{
  int n,i;
  double x,sum=0;
  char u[4];
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%lf",&x); scanf("%s",u);
    if(u[0]=='J')
      sum=sum+x;
    else
      sum=sum+x*380000.0;
  }
 
  printf("%f\n",sum);
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n,x;
	cin>>n>>x;
	vector<long long int>a(n);
	vector<long long int>sum(n-1);
	for(int i=0;i<n;i++) cin>>a[i];
	long long int times=0;
	if(a[0]>x){
		times+=a[0]-x;
		a[0]=x;
	}
	for(int i=0;i<n-1;i++){
		sum[i]=a[i]+a[i+1]-x;
		sum[i]=(sum[i]<0)?0:sum[i];
	}

	for(int i=0;i<sum.size()-1;i++){
		if(sum[i]<sum[i+1]){
			times+=sum[i];
			sum[i+1]-=sum[i];
			sum[i]=0;
		}else{
			times+=sum[i+1];
			sum[i]-=sum[i+1];
			sum[i+1]=0;
			i++;
		}
	}
	for(int i=0;i<sum.size();i++){
		times+=sum[i];
	}
	cout<<times<<endl;
	return 0;
}

Measured memory_bytes: 1792
def main():
    N=int(input())
    A=list(map(int,input().split()))
    Q=int(input())
    B=[]
    C=[]

    for i in range(Q):
        b,c=map(int,input().split())
        B.append(b)
        C.append(c)

    maxA=max(A)
    maxC=max(C)
    if maxA>=maxC:
        m=maxA
    else:
        m=maxC
    dp=[0 for i in range(m+1)]

    for i in range(N):
        dp[A[i]]+=1

    res=sum(A)


    for _ in range(Q):
        i=B[_]
        j=C[_]

        res-=dp[i]*i
        dp[j] += dp[i]
        res+=j*dp[i]
        dp[i]=0
        print(res)

if __name__=="__main__":
    main()


Measured memory_bytes: 96820
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t+1) out("Case #" << i << ": " << solve());
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define printv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j << ' '; ln}
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ' '; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1               // check ith bit
#define bitcount __builtin_popcount               // count set bits
#define firstbitindex __builtin_ctz               // count trailing zeros
#define lastbitindex __builtin_clz                // count leading zeros
#define bitparity __builtin_parity                // check set bits are even or odd
#define findv(v, x) (find(all(v), x) != v.end())
#define findsm(u, x) (u.find(x) != u.end())
#define findstr(s, x) (s.find(x) != string::npos)
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll MAXN = 1e7 + 5, MOD = 998244353, SIZE = 2e7;//, INF = 0x7f7f7f7f7f7f7f7f;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
ll n, m, i, k, ans;

//<<-----Implement Functions Here---->>//
void solve()
{
	in(n >> m >> k)
	vll a(n + 1), b(m + 1);
	FOR(i, 1, n + 1)
		in(a[i])
	FOR(i, 1, m + 1)
		in(b[i])
	FOR(i, 2, n + 1)
		a[i] += a[i - 1];
	FOR(i, 2, m + 1)
		b[i] += b[i - 1];
	ans = 0;
	i = n;
	FOR(j, 0, m + 1)
	{
		if (b[j] > k)
			break;
		while (a[i] > k - b[j])
			--i;
		ans = max(ans, i + j);
	}
	out(ans)
}

//<<----------Start of Main---------->>//
int main()
{
	fastio
    //ts
    solve();
    return 0;
}

Measured memory_bytes: 6348
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    int n,W;
    cin>>n>>W;
    int v[n],w[n];
    for(int i=0;i<n;i++)cin>>w[i]>>v[i];
    long long a[n][100001];
    for(int i=0;i<n;i++){
        for(int j=0;j<100001;j++)a[i][j]=-1;
    }
    for(int j=0;j<100001;j++)if(j==v[0])a[0][j]=w[0];
    else a[0][j]=-1;
    a[0][0]=0;
    for(int i=1;i<n;i++){
        a[i][0]=0;
        for(int j=1;j<100001;j++){
            if(j<v[i])a[i][j]=a[i-1][j];
            else{
                if(a[i-1][j-v[i]]!=-1){
                    long long m=a[i-1][j-v[i]]+w[i];
                    if(m<W+1){
                        if(a[i-1][j]!=-1)a[i][j]=a[i-1][j]<m?a[i-1][j]:m;
                        else a[i][j]=m;
                    }
                    else a[i][j]=a[i-1][j];
                }
                else a[i][j]=a[i-1][j];
            }
        }
    }
    int t=0;
   /* for(int i=0;i<n;i++){
        for(int j=0;j<29;j++)cout<<a[i][j]<<" ";
        cout<<endl;
    }*/
    for(int i=100000;i>=0&&t<1;i--){
        if(a[n-1][i]!=-1&&a[n-1][i]<=W){
            t++;cout<<i;
        }
    }
	return 0;
}

Measured memory_bytes: 78464
#include <iostream>
#include <string.h>
#include <map>
#include <iomanip>
#include <vector>
#include <set>
#include <queue>
#include <cmath>
#include <algorithm>
#define pb push_back
#define mk make_pair
#define ll long long
#define fast ios_base::sync_with_stdio(false);
using namespace std;
int main()
{
	ll int a,h;
	cin>>a>>h;
	if(a%h==0)
	{
		cout<<a/h;
	}
	else
	{
		cout<<a/h+1;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> c(n);
    vector<int> s(n);
    vector<int> f(n);
    for(int i = 0; i < n; i++)
    {
        cin >> c[i] >> s[i] >> f[i];
    }

    for(int i = 0; i < n; i++)
    {
        int j = i;
        int now = s[i];
        while(j != n-1)
        {
            now = max(now, s[j]);
            if(now % f[j] != 0) now = (now/f[j] + 1) * f[j];
            now += c[j];
            j++;
        }
        cout << now << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int n, i, j, temp, min, count=0, A[100];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }

  for(i = 0; i <= n-1; i++){
    min = i;
    for(j = i; j <= n-1; j++){
      if(A[j] < A[min]){
	min = j;
      }
    }
    if(A[min] < A[i]){
      temp = A[i];
      A[i] = A[min];
      A[min] = temp;
      count++;
    }
  }
  
  for(i = 0; i < n-1; i++){
    printf("%d ", A[i]);
  }
  printf("%d\n", A[n-1]);

  printf("%d\n", count);
  
  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

void maxHeapify(int,int,int *);
void buildMaxHeap(int,int *);

int main(){
  int H,i,n;
  int *key;

  scanf("%d",&H);
  key=(int *)malloc(sizeof(int)*H);

  for(i=0;i<H;i++){
    scanf("%d",&key[i]);
  }

  buildMaxHeap(H,key);

  for(i=0;i<H;i++) printf(" %d",key[i]);
  printf("\n");

  free(key);
			       

  return 0;
}


void maxHeapify(int i,int H,int *key){
  int l,r,large,tmp;

  l=2*(i+1)-1;
  r=2*(i+1);

  if(l<=H && key[l]>key[i]){
    large=l;
  } 
  else large=i;

  if(r<=H && key[r]>key[large]){
    large=r;
  } 
  if(large!=i){
    tmp=key[i];
    key[i]=key[large];
    key[large]=tmp;
    maxHeapify(large,H,key);
  }
}

void buildMaxHeap(int H,int *key){
  int i;

  for(i=H/2-1;i>=0;i--){
    maxHeapify(i,H,key);
  }
}

Measured memory_bytes: 2472
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long a = sc.nextLong();
		Long b = sc.nextLong();
		Long c = sc.nextLong();
		Long d = c - a - b;//これがマイナスになったら
		//全てを整数にする
		/*
		double s = 2*Math.sqrt(a)*Math.sqrt(b);
		double s1 = s+a+b;
		if(s < c) {
			System.out.print("Yes");
		}else {
			System.out.print("No");
		}
		*/
		if( d > 0 && 4*a*b < d*d ) {
			System.out.print("Yes");
		}else {
			System.out.print("No");
		}
		
	
	}
}
			

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll a, b, c;
  cin >> a >> b >> c;

  cout << (a + b + c) - max(a, max(b, c)) << endl;
  
  return 0;
}


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


int main(){
  int A,B,X;
  cin>>A>>B>>X;
  if(A>B*2){A=B*2;}
  if(B>A){B=A;}
  int ans=X/1000*A;
  if(X%1000<=500 && X%1000>0){ans+=B;}
  else if(X%1000>500){ans+=A;}
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 3088
str = input()
q = int(input())

for _ in range(q):
    line = input().split()
    c = line[0]
    a = int(line[1])
    b = int(line[2]) + 1

    if c == 'replace':
        str = str[:a] + line[3] + str[b:]
    elif c == 'reverse':
        str = str[:a] + str[a:b][::-1] + str[b:]
    else:
        print(str[a:b])

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	VI p(n), c(n);
	rep(i, n){ cin >>p[i]; p[i]--;}
	rep(i, n) cin >>c[i];
	
	vector<VI> hsu(n, VI(n));
	vector<VL> pt(n, VL(n));
	VI vc(n, -1);
	rep(i, n){
		ll cr=1, cr2=0;
		int z=p[i];
		cr2 = c[z];
		if(vc[z]==-1)  vc[z] = i;
		hsu[i][z]=cr; pt[i][z]=cr2;
		rep(j, n){
			z = p[z];
			cr++; cr2 +=c[z];
			if(hsu[i][z] !=0) break;
			hsu[i][z]=cr; pt[i][z]=cr2;
			if(vc[z]==-1) vc[z] = i;
		}
	}
	
	VI lp(n); VL sk(n+3);
	rep(i, n){
		lp[vc[i]]++;
		sk[vc[i]] += c[i];
	}
	//for(auto xl: hsu){for(auto x :xl) cerr<<x<<" ";dbg("hsu");}
	//for(auto xl: pt){for(auto x :xl) cerr<<x<<" ";dbg("pt");}
	//for(auto x :sk) cerr<<x<<" "; dbg("sk");
	//for(auto x :vc) cerr<<x<<" "; dbg("lp");
	ll ans = -1LL<<55;
	rep(s,n) rep(e,n){
		if(hsu[s][e] > k || hsu[s][e]==0)continue;
		ll cnd = pt[s][e];
		ll z =(k-hsu[s][e] ) / lp[vc[e]];
		cnd += max(0LL, sk[vc[e]]) * z;
		ans = max(cnd, ans);
		
	}
	cout <<ans <<"\n";

	return 0;
}



Measured memory_bytes: 296776
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  int k,x;cin>>k>>x;
  if(k*500>=x) p("Yes");
  else p("No");
  return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ans = 0;
    int count = 0;
    if(n < 105){
      System.out.println(0);
      return;
    }
    for(int i = 105;i<=n;i++){
      if(i % 2 == 0){
        continue;
      }
      count = 0;
      for(int j = 1;j<=i;j++){
        if(i % j == 0){
          count++;
        }
      }
      if(count == 8){
        ans++;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21076
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

#define MAX 200005
#define INF (1<<26)

int segN=1000000;
struct data{
    int value;
    data* ch[2];
    
    void init(){
        value=INF;
        ch[0]=new data;
        ch[1]=new data;
        ch[0]->ch[0]=NULL;
        ch[1]->ch[0]=NULL;
    }
    
    void set(int i,int x,int l,int r){
        int m=(l+r)/2;
        if(ch[0]==NULL)init();
        if(i<l || r<=i)return;
        if(x<value)value=x;
        if(r-l==1)return;
        ch[0]->set(i,x,l,m);
        ch[1]->set(i,x,m,r);
    }
    
    void set(int i,int x){
        set(i,x,0,segN);
    }
    
    int min(int a,int b,int l,int r){
        int m=(l+r)/2;
        if(ch[0]==NULL)init();
        if(b<=l || r<=a)return INF;
        if(a<=l && r<=b)return value;
        int lc=ch[0]->min(a,b,l,m);
        int rc=ch[1]->min(a,b,m,r);
        return (lc<rc?lc:rc);
    }
    
    int min(int a,int b){
        if(0<=a&&a<b)return min(a,b,0,segN);
        else return INF;
    }
};

int rak[MAX+1];
int tmp[MAX+1];
int n,k;

bool compare_sa(int i,int j){
    if(rak[i]!=rak[j])return (rak[i]<rak[j]);
    else{
        int ri=(i+k<=n?rak[i+k]:-1);
        int rj=(j+k<=n?rak[j+k]:-1);
        return ri < rj;
    }
}

void construct_sa(string s,int *sa){
    n=s.size();
    for(int i=0;i<=n;i++){
        sa[i]=i;
        rak[i]=(i<n?s[i]:-1);
    }
    for(k=1;k<=n;k*=2){
        sort(sa,sa+n+1, compare_sa );
        tmp[sa[0]]=0;
        for(int i=1;i<=n;i++){
            tmp[sa[i]]=tmp[sa[i-1]]+
            (compare_sa(sa[i-1],sa[i])?1:0);
        }
        for(int i=0;i<=n;i++)rak[i]=tmp[i];
    }
}


int search(string &target,int *sa,string &s){
    int l=0,r=n,m;
    int size=target.size(),res;
    while(l<r){
        m=(l+r)/2;
        res=s.compare(sa[m],size,target);
        if(res>=0)r=m;
        else l=m+1;
    }
    if(s.compare(sa[l],size,target)<0)return n+1;
    return l;
}

int search2(string &target,int *sa,string &s){
    int l=0,r=n,m;
    int size=target.size(),res;
    while(l<r){
        m=(l+r)/2;
        res=s.compare(sa[m],size,target);
        if(res>0)r=m;
        else l=m+1;
    }
    if(s.compare(sa[l],size,target)<=0)return n+1;
    return l;
}

data T,T2;
string s,s2;
string x,y;
int m;
int sa[MAX+1];
int sa2[MAX+1];

int main(){
    T.init();
    T2.init();
    
    cin>>s;
    s2=s;
    reverse(s2.begin(),s2.end());
    
    construct_sa(s2,sa2);
    construct_sa(s,sa);
    
    for(int i=0;i<=n;i++){
        T.set(i,sa[i]);
        T2.set(i,sa2[i]);
    }
    
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>x>>y;
        reverse(y.begin(),y.end());
        int xl=search(x,sa,s),xr=search2(x,sa,s);
        int yl=search(y,sa2,s2),yr=search2(y,sa2,s2);
        int xs=x.size();
        int X=T.min(xl,xr);
        int Y=T2.min(yl,yr);
        if(Y!=INF)Y=n-Y;
        
        if(Y<X+xs)cout<<0<<endl;
        else if(X==INF||Y==INF)cout<<0<<endl;
        else cout<<Y-X<<'\n';
        
    }
    
    return 0;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n, m;
    cin >> n >> m;
    vector<i64> cnt(n, 1), contain(n);
    contain[0] = 1;
    for (i64 i = 0; i < m; i++) {
        i64 x, y;
        cin >> x >> y, x--, y--;
        cnt[x]--, cnt[y]++;
        if (!contain[x]) continue;
        contain[y] = 1;
        if (cnt[x] == 0) contain[x] = 0;
    }
    cout << accumulate(all(contain), 0l) << endl;
}

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


Measured memory_bytes: 1792
using System;
using System.Linq;

class A
{
	static void Main()
	{
		var d = Console.ReadLine().GroupBy(c => c).ToDictionary(g => g.Key, g => g.ToArray());
		Console.WriteLine(d.Count == 2 && d.First().Value.Length == 2 ? "Yes" : "No");
	}
}


Measured memory_bytes: 13408
#include<iostream>

int main(){
  int N,K,op;
  while(std::cin >> N >> K && N && K){
    int S[K],B[K];
    for(int i=0;i<K;i++){
      std::cin >> S[i];
      B[i] = 0;
    }
    for(int j=0;j<N;j++){
      for(int i=0;i<K;i++){
	std::cin >> op;
	B[i] += op;	
      }
    }
    bool iscan = true;
    for(int i=0;i<K;i++){
      if(B[i] > S[i]){
	iscan = false;
	break;
      }
    }
    iscan?std::cout << "Yes" << std::endl:std::cout << "No" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 852
#include<stdio.h>
#include<string.h>
int N,M,K,A,B,C,D,i,j,k,dp[1000][1000][3]={0};
char W[1001][1001],T[4]="JOI";
int main()
{
	scanf("%d%d%d\n",&M,&N,&K);
	for(i=0;i<M;i++)
		gets(W[i]);
	for(i=M-1;i>=0;i--)
		for(j=N-1;j>=0;j--)
			for(k=0;k<3;k++)
				dp[i][j][k]=(W[i][j]==T[k]?1:0)+(i+1<N?dp[i+1][j][k]:0)+(j+1<N?dp[i][j+1][k]:0)-(i+1<N&&j+1<N?dp[i+1][j+1][k]:0);
	for(i=0;i<K;i++)
	{
		scanf("%d%d%d%d",&A,&B,&C,&D);
		A--;B--;C--;D--;
		for(k=0;k<3;k++)
			printf("%d%s",dp[A][B][k]-(C+1<N?dp[C+1][B][k]:0)-(D+1<N?dp[A][D+1][k]:0)+(C+1<N&&D+1<N?dp[C+1][D+1][k]:0),k==2?"\n":" ");
	}
	return 0;
}

Measured memory_bytes: 13288
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
            b[i] = scan.nextInt();
        }
        boolean ans = false;
        for (int i = 0; i + 2 < n; i++) {
            if (a[i] == b[i] && a[i + 1] == b[i + 1] && a[i + 2] == b[i + 2]) ans = true;
        }
        System.out.println(ans ? "Yes" : "No");
    }
}


Measured memory_bytes: 35964
from itertools import groupby

S = input()
K = int(input())
A = []
for s in S:
  A.append(s)

def cont(A):
  B = []
  b = 0
  for key, value in groupby(A):
    B.append([key, list(value)])
  for i in range(len(B)):
    b += len(B[i][1]) // 2
  return b

def plus1(A):
  plu1 = 0
  for i in range(1,len(A)):
    if A[0] == A[i]:
      plu1 += 1
    else:
      break
  return plu1

def plus2(A):
  plu2 = 0
  for j in range(1,len(A)):
    if A[0] == A[-j]:
      plu2 += 1
    else:
      break
  return plu2

X = len(S) - len(list(set(A)))
if len(list(set(A))) == 1:
  an = len(S)*K
  ans = an // 2
elif X == 0:
  ans = 0
elif A[0] != A[-1]:
  ans = cont(A) * K
else:
  if plus1(A)%2 == 0 and plus2(A)%2 == 1:
    ans = cont(A)*K + (K-1)
  else:
    ans = cont(A) * K
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, m;

int main()
{
    cin>>n>>m;
    if(n == 1 || m == 1) cout<<1<<endl;
    else cout<<(n * m + 1) / 2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int main(){
  int n,a,b;cin>>n>>a>>b;int p[100];rep(i,n)cin>>p[i];
  int aa = 0, bb = 0, cc = 0;
  rep(i,n){
    if(p[i] <= a)aa++;
    else if(p[i] <= b)bb++;
    else cc++;
  }
  cout << min(aa,min(bb,cc)) << endl;
}


Measured memory_bytes: 256
using System;

namespace B___Break_Number
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = new int[] { 64, 32, 16, 8, 4, 2, 1 };
            for (var i = 0; i < a.Length; i++)
            {
                if (n >= a[i])
                {
                    Console.WriteLine(a[i]);
                    return;
                }
            }
        }
    }
}

Measured memory_bytes: 13140
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1154&lang=jp

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

#define MAX 300000

int factorization(int value, int num)
{
	while(true)
	{
		if(value % num != 0) { break; }
		value = value / num; 
	}

	return value;
}

int main()
{
	int N;

	bool is_prime[MAX];
	is_prime[0] = false;
	is_prime[1] = false;
	REP(i,2,MAX) is_prime[i] = false;
	REP(i,2,MAX){
		if(i%7==1 || i%7==6) { is_prime[i]=true; }
	}
	REP(i,2,MAX) {
		if (is_prime[i]) {
				for (int j=i+i; j<MAX; j+=i) is_prime[j] = false;
		}
	}


	while(cin >> N)
	{
		if(N == 1){ break; }
		cout << N << ":";
		int tmp=N;
		REP(i,2,N+1)
		{
			if(is_prime[i])
			{
				N = factorization(N,i);
				if(tmp != N){ cout << " " << i; }
				N = tmp;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1452
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#define log(args...)
#else
#define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
void logf(istream_iterator<string> it) {
}
template<typename T, typename ... Args>
void logf(istream_iterator<string> it, T a, Args ... args) {
	cout << *it << " = " << a << endl;
	logf(++it, args...);
}
#endif

#define forn(i,k,n) for(ll i=(k); i<(n); i++)

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

const int INF = 1e9;

void solve() {
	cini(n);
	cini(x);
	cini(y);
	x--;
	y--;

	vvi adj(n);
	for (int i = 0; i < n - 1; i++) {
		adj[i].push_back(i + 1);
		adj[i + 1].push_back(i);
	}
	if (abs(x - y) > 1) {
		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	vi dist(n);

	vi f(n);
	for (int i = 0; i < n; i++) {
		dist.assign(n, INF);
		dist[i] = 0;
		queue<int> q;
		q.push(i);

		while (q.size()) {
			int node = q.front();
			q.pop();
			for (int chl : adj[node]) {
				if (dist[node] + 1 < dist[chl]) {
					dist[chl] = dist[node] + 1;
					q.push(chl);
				}
			}
		}

		for (int j = i + 1; j < n; j++)
			f[dist[j]]++;
	}

	for (int i = 1; i <= n - 1; i++) {
		cout << f[i] << endl;
	}

}

int main() {
	cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	solve();
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int X;
    cin >> X;
    if(X>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
using namespace std;
ll n,k,s;
int main(){
	ll i;
	cin>>n>>k>>s;
	for(i=0;i<k;i++)
	{
		cout<<s<<" ";
	}
	for(;i<n;i++)
	{
		if(s==1000000000)
		{
			cout<<s-1<<" ";
		}
		else
		{
			cout<<1000000000<<" ";
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1280
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

ans = -float("INF")
for bit in range(1, 1 << 10):
    tmp = 0
    for i in range(N):
        c = 0
        for k in range(10):
            if (bit >> k) & 1:
                if F[i][k] == 1:
                    c += 1
        tmp += P[i][c]
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 3064
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,3);
  var H = myconv(input[0],4)[0];
  var W = myconv(input[0],4)[1];
  var N = myconv(input[1],1);
  var list = myconv(input[2],4);
  
  var output = new Array(H);
  for(var i = 0; i < H; i++){
    output[i] = new Array(W);
  }
  
  var getNo = 1;
  for(var i = 0; i < H; i++){
    if(i % 2 == 0){
    for(var j = 0; j < W; j++){
      if(list[getNo-1] == 0){
        getNo++;
      }
      list[getNo-1]--;
      output[i][j] = getNo;
    }
  	}else{
    for(var j = W-1; j >= 0; j--){
      if(list[getNo-1] == 0){
        getNo++;
      }
      list[getNo-1]--;
      output[i][j] = getNo;
    }  
    }
  }
  for(var i = 0; i < H; i++){
    output[i] = output[i].join(" ");
  }
  myout(output.join("\n"));
}

Main(myin());


Measured memory_bytes: 11468
#include<bits/stdc++.h>
using namespace std;
char x[1000];
int main(){
	scanf(" %s", x);
	for(int i = 0; x[i] && x[i+1]; i ++ ){
		if ( x[i] == 'A' && x[i+1] == 'C' ){ puts("Yes"); return 0;}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define mp make_pair
#define ins insert
#define sz size
#define whoami(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); whi(_it, args); }

void whi(istream_iterator<string> it) { cerr<<"\n"; }

template<typename T, typename... Args>
void whi(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<" "<<a<<" "; whi(++it, args...); }

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;
const ll INF = 4e18;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	string s;
	cin>>s;
	cout<<s.substr(0, 3)<<"\n";
	return;
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

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

int main() {
  int n,y,a=-1,b=-1,c=-1;
  cin>>n>>y;
  y/=1000;
  for(int i=0;i<=n;i++){
    if((y-n-9*i)%4==0 && y-n-9*i>=0 &&4*(n-i)>=y-n-9*i){
      a=i,b=(y-n-9*i)/4,c=n-a-b;
      break;
    }
  }
  cout<<a<<" "<<b<<" "<<c;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int k,x;
	cin >> k >> x;
	if (500 * k >= x){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll n,c,k;cin>>n>>c>>k;
  ll t[n];rep(i,0,n)cin>>t[i];
  sort(t,t+n);
  ll sum=0;
  bool e=true;
  ll num=0;
  ll ans=0;

  rep(i,0,n){
    if(e){
      e=false;
      num=t[i];
      sum++;
      if(sum==c){
        ans++;
        e=true;
        sum=0;
      }
    }else{
      if(t[i]<=num+k){
        sum++;
        if(sum==c){
          ans++;
          e=true;
          sum=0;
        }
      }
      else{
        ans++;
        num=t[i];
        sum=1;
      }
    }
  }
  ans+=(sum!=0?1:0);
  out(ans);



  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int M = 1e6+10;
    vector<int> nums;
    int x = 1;
    while (true) {
        int y = (x*(x+1)*(x+2))/6;
        if (y > M) break;
        nums.push_back(y);
        ++x;
    }
    vector<int> dp(M, INF);
    vector<int> odd_dp(M, INF);
    dp[0] = odd_dp[0] = 0;
    for (int i = 1; i < M; ++i) {
        for (auto &&e: nums) {
            if (i-e < 0) continue;
            dp[i] = min(dp[i], dp[i-e]+1);
            if (e%2 == 1) odd_dp[i] = min(odd_dp[i], odd_dp[i-e]+1);
        }
    }
    while (true) {
        int N;
        cin >> N;
        if (N == 0) break;
        
        printf("%d %d\n",dp[N], odd_dp[N]);
    }

    return 0;
}


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

int main(){
	
	int s,ans = 0;
	for( int i=0 ; i<4 ; i++ ){
		cin >> s ;
		ans += s ;
	}
	cout << ans/60 << endl ;
	ans -= ans/60*60 ;
	cout << ans    << endl ;
	
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    
    int64_t l_1 = 0, l_2 = 0;
    for (int i = 0; i < N - 1; i++){
        if (A.at(i) == A.at(i + 1)){
            if (l_1 == 0) l_1 = A.at(i);
            else if (l_2 == 0) l_2 = A.at(i);
            i++;
            //cout << l_1 << " " << l_2 << endl;
        }
    }
    int64_t ans = l_1 * l_2;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N, K;
  cin >> N >> K;
  vi A(N);
  cin >> A;

  vvi dp(N+1,vi(K+1,0));
  dp[0][0]=1;

  rep(i,1,N+1) {
    dp[i][0] = 1;
    rep(j,1,K+1){
      dp[i][j] = dp[i][j-1] + dp[i-1][j];
      dp[i][j] %= MOD;
      if(j-A[i-1]>0){
        dp[i][j] -= dp[i-1][j-A[i-1]-1];
        if(dp[i][j]<0) dp[i][j] += MOD;
      }
    }
  }

  cout << dp[N][K] << "\n";

}

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

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define oo 2000000000
const int N = 400;
int vis[N] , vi ,grid[N][N] , n  , m; 
vector< vector< pair<int,int > > > g;

int djikstra(int s,int e){
	vi++;
	priority_queue < pair<int,int> > q;
	q.push(make_pair(0,s));
	while(!q.empty()){
		int cost = q.top().first;
		int node = q.top().second;
		q.pop();
		if(vis[node] == vi || cost < -1000000100) continue;
		vis[node] =vi;
		if(node == e) return -cost;
		for(int i=0;i<g[node].size();i++){
			int newnode = g[node][i].first;
			if(vis[newnode] != vi) q.push(make_pair(cost-g[node][i].second,newnode));
		}
	}
	return oo;
} 

int main(){
	//freopen("in.txt","r",stdin);
	scanf("%d",&n);
	g.resize(n+2);
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) scanf("%d",&grid[i][j]);
	vector< pair<int,pair<int,int> > > vv;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(i == j){
				if(grid[i][j] != 0){
					puts("-1");
					return 0;
				}
				continue;
			}
			if(grid[i][j] != grid[j][i]){
				puts("-1");
				return 0;
			}
			vv.push_back(make_pair(grid[i][j],make_pair(i,j)));
		}
	}
	sort(vv.begin(),vv.end());
	long long ans = 0;
	for(int i=0;i<vv.size();i++){
		int u = vv[i].second.first;
		int v = vv[i].second.second;
		int w = vv[i].first;
		int cur = djikstra(u,v);
		if(cur < w){
			puts("-1");
			return 0;
		}
		else if(cur > w){
			g[u].push_back(make_pair(v,w));
			g[v].push_back(make_pair(u,w));
			ans+=w;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=300010;
int n,x[N],y;
string s;
int main()
{
	cin>>y>>n;
	int ans=0;
	for(int i=0;i<n;i++)
	{
	 	cin>>x[i];
	 	ans=max(ans,x[i]-x[i-1]);
	}
	ans=max(ans,y+x[0]-x[n-1]);
	cout<<y-ans; 
	return 0; 
}

Measured memory_bytes: 1024
import sys
from collections import deque

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = [deque(lr()) for _ in range(N)]
candidate = list(range(N))
match = 0
day = 0

while True:
    day += 1
    used = set()
    next = set()
    bool = False
    for c in candidate:
        if len(A[c]) == 0:
            continue
        op = A[c][0] - 1
        if c in used or op in used:
            continue
        if A[op][0] - 1 == c:
            bool = True
            A[c].popleft()
            A[op].popleft()
            match += 1
            next |= {c, op}
            used |= {c, op}
    if match == N * (N-1) // 2:
        break
    if not bool:
        print(-1)
        exit()
    candidate = next

print(day)
    

Measured memory_bytes: 36092
from itertools import count
import math

def gen_prime():
    yield 2
    for i in count(3, 2):
        isPrime = True
        for j in range(3, int(math.sqrt(i)+1), 2):
            if i % j == 0:
                isPrime = False
                break
        if isPrime:
            yield i


n = int(input())
cn = 0

for p in gen_prime():
    if(p > 55555):
        break
    if(str(p)[-1] == '1'):
        print(p, end='')
        cn += 1
        if n == cn:
            print()
            break
        else:
            print(' ', end='')


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

int main(){
	long long a,b,p,r,gcd,lum;
	cin>>a>>b;
	p=a*b;
	do{
		r=a%b;
		a=b;
		b=r;
	}while(r!=0);
	lum=p/a;
	cout<<lum;
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

/* 基本要素 */
typedef complex<double> Point;
typedef pair<Point, Point> Line;
typedef vector<Point> VP;
const double PI = acos(-1);
const double EPS = 1e-9; // 許容誤差^2
const double INF = 1e9;
#define X real()
#define Y imag()
#define LE(n,m) ((n) - (m) < EPS)
#define GE(n,m) (EPS > (m) - (n))
#define EQ(n,m) (abs((n)-(m)) < EPS)

bool compX(const Point a, const Point b) {
  return (a.X!=b.X ? a.X<b.X : a.Y<b.Y);
}

bool compY(const Point a, const Point b) {
  return (a.Y!=b.Y ? a.Y<b.Y : a.X<b.X);
}

double closestPair(VP& a,int l,int r) {
  if(r-l<=1) return INF;
  int m = (l+r)/2;
  double x = a[m].X;
  double d = min(closestPair(a,l,m),closestPair(a,m,r));
  inplace_merge(a.begin()+l, a.begin()+m, a.begin()+r, compY);
  VP b;
  for(int i=l;i<r;i++){
    if(abs(a[i].X - x)>=d)continue;
    for(int j=b.size()-1;j>=0;j--){
      if((a[i]-b[j]).Y>=d)break;
      d = min(d,abs(a[i]-b[j]));
    }
    b.push_back(a[i]);
  }
  return d;
}

double closestPair(VP ps){
  sort(ps.begin(),ps.end(),compX);
  return closestPair(ps,0,ps.size());
}

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

    VP p(n);
    rep(i,n){
        double x,y;
        cin >>x >>y;
        p[i] = Point(x,y);
    }

    printf("%.10f\n", closestPair(p));
    return 0;
}



Measured memory_bytes: 9216
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn = 100005;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
#endif
  int n,m;
  string s;
  cin>>n>>m>>s;
  vector<pair<int,int>>p;
  for(int i=0;i<n;i++){
    if(s[i]=='1')continue;
    int j = i;
    while(j+1<n&&s[j+1]=='0')j++;
    p.push_back(make_pair(i,j));
    i=j;
  }
  if(p.size()<=m)cout<<n<<endl;
  else {
    //cout<<p.size()<<endl;
    int ret = 0;
    for(int i=m-1;i<p.size();i++){
      int l,r;
      if(i-m<0)l=0;
      else l = p[i-m].second+1;
      if(i==p.size()-1)r=n-1;
      else r = p[i+1].first-1;
      ret=max(ret,r-l+1);
    }
    cout<<ret<<endl;
  }
  return 0;
}

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

using namespace std;

using ll = long long;

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

    ll n;
    cin >> n;
    string s;

    while (n) {
        bool bit = (n % 2 != 0);
        s += (bit ? "1" : "0");
        n = (n - bit) / (-2);
    }

    if (s.empty()) s = "0";
    reverse(s.begin(), s.end());
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

#ますの数
n = int(arr_data[0][0])

#料金所の数
m = int(arr_data[0][1])

#最初の位置
x = int(arr_data[0][2])

arr=list(map(int, arr_data[1]))

#print(n,m,x,arr)

kingaku1=0
kingaku2=0

for i in range(1,x):
    
    if i in arr:
        
        kingaku1+=1

for j in range(x+1,n+1):
    
    if j in arr:
        
        kingaku2+=1

    
print(kingaku1 if kingaku1<=kingaku2 else kingaku2)    

Measured memory_bytes: 3064
N, X = map(int, input().split())

C = [0]*(N+1)
D = [0]*(N+1)
C[0] = D[0] = 1
for i in range(1, N+1):
    C[i] = 2*C[i-1] + 1
    D[i] = 2*D[i-1] + 3

ans = 0
for i in range(N-1, -1, -1):
    if X == 0:
        break
    X -= 1
    if X < D[i]:
        continue
    ans += C[i]
    X -= D[i]
    if X == 0:
        break
    X -= 1; ans += 1
    if X < D[i]:
        continue
    X -= D[i]
    ans += C[i]
    if X == 0:
        break
    X -= 1
print(ans)

Measured memory_bytes: 3064