akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}

struct SegmentTree{
private:
  int N;
  vector<int> node;
public:
  SegmentTree(vector<int> v){
    int size = v.size();
    N = 1;while(N<size)N*=2;
    node.resize(2*N-1,INF_INT);
    //底を埋める
    for(int i=0;i<size;i++)node[i+N-1] = v[i];
    //下層から埋める
    for(int i=N-2;i>=0;i--)node[i] = min(node[2*i+1],node[2*i+2]);
  }
  void update(int x,int val){
    x += (N-1);
    node[x] = val;
    while(x > 0){
      x = (x-1)/2;
      node[x] = min(node[2*x+1], node[2*x+2]);
    }
  }
  int getmin(int a,int b,int k=0,int l=0,int r=-1){
    if(r<0)r=N;
    if(r<=a || b<=l)return INF_INT;
    if(a<=l && r<=b)return node[k];
    int vl = getmin(a,b,2*k+1,l,(l+r)/2);
    int vr = getmin(a,b,2*k+2,(l+r)/2,r);
    return min(vl,vr);
  }
  
};

int main()
{
  int N,Q,d,c,x,y;
  cin >> N >> Q;
  vector<int> v(N,INF_INT),pri(0);
  struct SegmentTree seg(v);
  REP(i,Q){
    cin >> c >> x >> y;
    if(!c){
      seg.update(x,y);
    }else{
      pri.push_back(seg.getmin(x,y+1));
    }
  }
  REP(i,pri.size())
    cout << pri[i] << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}



Measured memory_bytes: 4688
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return 1;}return 0;}

int a,b,c;

int main(){
    cin >> a >> b >> c;
    put(min(b/a,c));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fir first
#define sec second
#define mp std::make_pair

typedef long long ll;

int n, t, cnt;
std::vector< std::pair<int, int> > v;
std::priority_queue<int> q;

int main() {
    std::cin >> n;
    for (int i = 1; i <= n; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        v.push_back(mp(b, a));
    }
    std::sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++) {
        int a = v[i].sec, b = v[i].fir;
        if (t + a <= b) {
            t += a;
            cnt++;
            q.push(a);
        } else {
            if (q.empty()) continue;
            int tmp = q.top();
            if (a < tmp) {
                q.pop();
                q.push(a);
                t = t - tmp + a;
            }
        }
    }
    if (cnt == n) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3568
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

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

    string ans = "No";
    if(n >= 30) {
        ans = "Yes";
    }

    cout << ans << endl;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<math.h>
int main()
{ short high[10];
  short n,l=0,k=0,temp;
  while(k<10)
  {
  scanf("%d",&n);
  high[l]=n;
  l=l+1	;
  k++;
  } 
  int    i, j;  
    for (i = 0; i < 10; i++)  
    {  
        for (j = 9; j > i; j--)  
        {  
            if (high[j] < high[j-1])  
            {  
				temp=high[j];
				high[j]=high[j-1];
				high[j-1]=temp;
            }  
        }  
    }  
    for (i = 9; i>6; i=i-1)  
    {  
        printf("%d\n", high[i]);  
    }  
    return  0;  
}  

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

#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"

lli a,cvp;

int main(){
	#ifndef ONLINE_JUDGE
		freopen("zgir.gir","r",stdin);
		freopen("zcik.cik","w",stdout);
	#endif

	cin>>a;
	for(int i=1;i<=a;i++){
		if(i%3!=0 && i%5!=0){
			cvp+=i;
		}
	}
	cout<<cvp;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

int Power3(int p) {
  int r = 1;
  for (int i = 0; i < p; i++) {
    r *= 3;
  }
  return r;
}

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

  int n;
  cin >> n;
  string original_command;
  cin >> original_command;
  vector<vector<int>> output_table(n + 1);
  vector<vector<string>> command_table(n + 1);
  for (int k = 1; k <= n; k++) {
    output_table[k].resize(Power3(k));
    command_table[k].resize(Power3(k));
  }

  for (int k = 1; k <= n; k++) {
    for (int x = 0; x < Power3(k); x++) {
      string command;
      if (k == 1) {
        command = original_command;
      } else {
        command = command_table[k - 1][x % Power3(k - 1)];
      }

      int d = x / Power3(k - 1);
      string next_command = "";
      for (char c : command) {
        if (c == 'R') {
          d++;
          if (d == 3) {
            d = 0;
            next_command.append("R");
          }
        } else if (c == 'S') {
          if (d == 1) d = 2;
          else if (d == 2) d = 1;

          next_command.append("S");
        }
      }

      next_command = std::regex_replace(next_command, std::regex("SS"), "");

      output_table[k][x] = d;
      command_table[k][x] = next_command;
    }
  }

  vector<int> outputs;
  for (int x = 0; x < Power3(n); x++) {
    int output = 0;
    for (int k = 1; k <= n; k++) {
      output += output_table[k][x % Power3(k)] * Power3(k - 1);
    }
    outputs.push_back(output);
  }

  for (int i = 0; i < outputs.size(); i++) {
    if (i > 0) cout << " ";
    cout << outputs[i];
  }
  cout << endl;
}


Measured memory_bytes: 38328
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        int T = cin.nextInt();
        int A = cin.nextInt();
        int[] H = new int[N];

        for (int i = 0; i < N; i++) {
            H[i] = cin.nextInt();
        }

        double min = Math.abs(A - (T - H[0] * 0.006));
        int idx = 0;
        for (int i = 1; i < N; i++) {
            double d = Math.abs(A - (T - H[i] * 0.006));
            if (min > d) {
                min = d;
                idx = i;
            }
        }
        System.out.println(idx + 1);
    }
}

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

int main(){
  int n, W;
  cin >> n >> W;
  vector<int> v(n), w(n);
  rep(i,n) cin >> w[i] >> v[i];
  vector<ll> dp(W+1, 0);
  for (int i = 0; i < n; i++) {
    vector<ll> dp2(W+1, 0);
    for (int j = 0; j <= W; j++) {
      if (j - w[i] >= 0) dp2[j] = max(dp2[j], dp[j - w[i]] + v[i]);
      dp2[j] = max(dp2[j], dp[j]); 
    }
    dp = dp2;
  }
  cout << dp[W] << endl;
}

Measured memory_bytes: 1804
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
a, b = gets_i_list

count = 0
a.upto(b) do |i|
  before = i.to_s.chars
  after  = before.reverse

  if before.join == after.join
    count += 1
  end
end

puts count

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



int main() {
    int n; cin>>n;
    int d,x;
    cin >> d >>x;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int cnt =0;
    rep(i,n){
    cnt+=(d-1)/a[i];
    }
    int ans = cnt + n + x;
    cout << ans << endl;

}

Measured memory_bytes: 256
package main

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

var in = newIo(bufio.NewScanner(os.Stdin))

func main() {
	var n = in.nextInt()
	print(solve(n))
}

func print(result int) {
	fmt.Println(result)
}

func solve(n int) int {
	var sum = 0
	for i := 1; i <= n; i++ {
		if i%2 == 0 {
			continue
		}
		if count(i, 8) {
			sum++
		}
	}
	return sum
}

func count(n int, c int) bool {
	var count = 1
	for i := 2; i <= n; i++ {
		var e = 1
		for {
			if n%i != 0 {
				break
			}
			n = n / i
			e++
		}
		count = count * e
	}
	return count == c
}

type io struct {
	sc *bufio.Scanner
}

func newIo(sc *bufio.Scanner) *io {
	i := new(io)
	i.sc = sc
	i.sc.Split(bufio.ScanWords)
	return i
}
func (i *io) next() string {
	i.sc.Scan()
	return i.sc.Text()
}
func (i *io) nextInt() int {
	in, _ := strconv.Atoi(i.next())
	return in
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
  int N;
  bool d[100]={};
  int temp, ans=0;

  cin>>N;
  for(int i=0;i<N;i++){
    cin>>temp;
    d[temp-1]=true;
  }
  for(int i=0;i<100;i++){
    if(d[i])ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define se second
#define fi first
using namespace std;
typedef pair<ll,ll> pll;
const int N=1e5+5;
vector<pll> g[N];
ll d[N],vis[N];

void dijk(ll s){
    for(int i=1;i<N;i++) d[i]=1e18;
    d[s]=0;
    priority_queue<pll,vector<pll>,greater<pll>> pq;
    pq.push({s,0});
    while(!pq.empty()){
        pll temp=pq.top(); pq.pop();
        ll u=temp.fi;
        ll cost=temp.se;
        if(d[u]<cost) continue;
        for(int i=0;i<g[u].size();i++){
            int v=g[u][i].fi;
            int w=g[u][i].se;
            if(d[v]>d[u]+w){
                d[v]=d[u]+w;
                pq.push({v,d[v]});
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n; cin>>n;
    for(int i=1;i<n;i++){
        ll u,v,w; cin>>u>>v>>w;
        g[u].pb({v,w});
        g[v].pb({u,w});
    }
    int q,k; cin>>q>>k;
    dijk(k);
    for(int i=0;i<q;i++){
        int u,v; cin>>u>>v;
        cout<<d[u]+d[v]<<endl;
    }
    return 0;
}

Measured memory_bytes: 11120
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> P;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int inf = 1e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

vector<ll> fac,inv,finv;

void initcom(){
    fac=inv=finv=vector<ll>(1e6);
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(ll i=2;i<1e6;++i){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll com(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll x,ll y){
    if(y==0) return x;
    return gcd(y,x%y);
}
ll mopow(ll a,ll x,ll mod){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;
}

int main(){
    int n;cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;++i) cin>>a[i];
    ll ans=0;
    ll mx=a[0];
    for(int i=0;i<n;++i){
        if(a[i]>mx) mx=a[i];
        else if(a[i]<mx) ans+=mx-a[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4828
N,M=map(int,input().split())
X=list(map(int,input().split()))
if(N>=M):
    print(0)
else:
    X.sort()
    b=[]
    for i in range(M-1):
        b.append(X[i+1]-X[i])
    b.sort()
    for _ in range(N-1):
        b.pop()
    print(sum(b))


Measured memory_bytes: 13960
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXLEN = 200000;

char s[MAXLEN + 1]; int n;

int best[1 << 26];

void run() {
	scanf("%s", s); n = strlen(s);
	memset(best, -1, sizeof(best));
	int cur = 0; best[cur] = 0;
	REP(i, n) {
		int x = s[i] - 'a'; cur ^= 1 << x;
		REP(j, 26) {
			int now = best[cur ^ (1 << j)];
			if (now != -1 && (best[cur] == -1 || now + 1 < best[cur])) best[cur] = now + 1;
		}
	}
	int ret = best[cur]; if (ret == 0) ret = 1;
	printf("%d\n", ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 262656
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> //std::priority_queue<int> que; // 4, 3, 2, 1 (defualt, less) : 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>  // std::accumulate(m.begin(), m.end(), 0LL);
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int H, W; std::cin >> H >> W;
  std::vector< std::vector<char> > M(H, std::vector<char>(W));
  for(int i=0; i<H; i++) for(int j=0; j<W; j++) std::cin >> M[i][j];


  for(int i=0; i<H; i++) {
    for(int j=0; j<W; j++) {
      if ( M[i][j] == '#' ) {
        int cnt = 0;
        if ( i-1>=0 && M[i-1][j] == '#' ) cnt++;
        if ( i+1<H  && M[i+1][j] == '#' ) cnt++;
        if ( j-1>=0 && M[i][j-1] == '#' ) cnt++;
        if ( j+1<W  && M[i][j+1] == '#' ) cnt++;
        if ( cnt == 0 ) {
          std::cout << "No" << std::endl;
          return 0;
        }
      }
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

int dp[64][2];
int n, k;
int A[100010];
int calc(int x, int smaller) {
    //cout << x << " " << smaller << endl;
    if(x == -1) return 0;
    if(dp[x][smaller] != -1) return dp[x][smaller];
    int cnt1 = 0, cnt0 = 0;
    rep(i, n) {
        if((1LL << x) & A[i]) cnt1++;
        else cnt0++;
    }
    int num0 = cnt0 * (1LL << x);
    int num1 = cnt1 * (1LL << x);
    if(smaller)
        return dp[x][smaller] = max(num0, num1) + calc(x - 1, 1);
    if((1LL << x) & k) {
        return dp[x][smaller] = max(num1 + calc(x - 1, 1), num0 + calc(x - 1, 0));
    } else {
        return dp[x][smaller] = num1 + calc(x - 1, 0);
    }
    
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n >> k;
    rep(i, n) cin >> A[i];
    rep(i, 64) rep(j, 2) dp[i][j] = -1;
    cout << calc(60, 0) << endl;
    // rep(i, 60) {
    //     cout << i << ":";
    //     rep(j, 2) cout << dp[i][j] << " ";
    //     cout << endl;
    // }
    

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define sqr(x) ((x)*(x))
    #define mp make_pair
    #define int long long
    #define uint unsigned
    inline char gc(){
        static char buf[100000],*p1=buf,*p2=buf;
        return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
    }
    #define gc getchar
    inline int read(){
    	int x = 0; char ch = gc(); bool positive = 1;
    	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
    	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
    	return positive ? x : -x;
    }
    inline void write(int a){
        if(a>=10)write(a/10);
        putchar('0'+a%10);
    }
    inline void writeln(int a){
        if(a<0){
        	a=-a; putchar('-');
    	}
    	write(a); puts("");
    }
    const int N=100005,mod=1000000007;
    ll n,a,b,arr[N];
    int f[N],g[N],s1[N],s2[N],s3[N],s4[N];
    signed main(){
    	n=read(); a=read(); b=read();
    	for(int i=1;i<=n;i++)arr[i]=read();
    	arr[0]=-4e18;
    	arr[n+1]=4e18; f[0]=g[0]=1; f[1]=g[1]=-1; s1[n+1]=s2[n+1]=n+1;
    	for(int i=n;i;i--){
    		s1[i]=arr[i+1]-arr[i]<a?i+1:s1[i+1];
    		s2[i]=arr[i+1]-arr[i]<b?i+1:s2[i+1];
    	}
    	for(int i=0;i<=n;i++){
    		if(i)s3[i]=s3[i-1]; while(arr[s3[i]+1]-arr[i]<a)s3[i]++;
    		if(i)s4[i]=s4[i-1]; while(arr[s4[i]+1]-arr[i]<b)s4[i]++;
    	}
    	for(int i=0;i<n;i++){
    		s3[i]=max(s3[i],i+1); s4[i]=max(s4[i],i+1);
    		f[i+1]=(f[i+1]+f[i])%mod; 
    		if(s3[i]<s2[i+1]){g[s3[i]]=(g[s3[i]]+f[i])%mod;
    		g[s2[i+1]]=(g[s2[i+1]]-f[i])%mod;}
    		g[i+1]=(g[i+1]+g[i])%mod;
    		if(s4[i]<s1[i+1]){f[s4[i]]=(f[s4[i]]+g[i])%mod;
    		f[s1[i+1]]=(f[s1[i+1]]-g[i])%mod;}
    		//cout<<i<<" "<<f[i]<<" "<<g[i]<<" "<<s3[i]<<" "<<s2[i+1]<<" "<<s4[i]<<" "<<s1[i+1]<<endl;
    	}
    	cout<<((f[n]+g[n])%mod+mod)%mod;
    }

Measured memory_bytes: 5760
#include<cstdio>
#include<algorithm>

using namespace std;

long long N, M;

long long solve(){
	if(N > M) swap(N, M);
	if(N == 1){
		if(M == 1) return 1;
		return max(0ll, M - 2);
	}
	return (N - 2) * (M - 2);
}

int main(){
	scanf("%lld%lld", &N, &M);
	long long ans = solve();
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include<cstdio>
#include<algorithm>
#define lca long long
using namespace std;
const int MX = 200005;
const int MAXN = 200005;
int n, m, op, l, r;
lca a[MX], w;
struct node
{
    int l, r, len;
    lca sum, add;
} tr[MX << 3];
inline void pushup(int ro) { tr[ro].sum = tr[ro << 1].sum + tr[ro << 1 | 1].sum; }
void build(int ro, int l, int r)
{
    tr[ro].l = l;
    tr[ro].r = r;
    tr[ro].add = 0;
    tr[ro].len = r - l + 1;
    if (l == r)
    {
        tr[ro].sum = a[l];
        return;
    }
    int mid = (l + r) >> 1;
    build(ro << 1, l, mid);
    build(ro << 1 | 1, mid + 1, r);
    pushup(ro);
}
void pushdown(int ro)
{
    if (!tr[ro].add)
        return;
    tr[ro << 1].sum += 1ll * tr[ro << 1].len * tr[ro].add;
    tr[ro << 1 | 1].sum += 1ll * tr[ro << 1 | 1].len * tr[ro].add;
    tr[ro << 1].add += tr[ro].add;
    tr[ro << 1 | 1].add += tr[ro].add;
    tr[ro].add = 0;
}
void update(int ro, int l, int r, lca w)
{
    pushdown(ro);
    if (tr[ro].l == l && tr[ro].r == r)
    {
        tr[ro].sum += 1ll * tr[ro].len * w, tr[ro].add += w;
        return;
    }
    int mid = (tr[ro].l + tr[ro].r) >> 1;
    if (r <= mid)
        update(ro << 1, l, r, w);
    else if (l > mid)
        update(ro << 1 | 1, l, r, w);
    else
        update(ro << 1, l, mid, w), update(ro << 1 | 1, mid + 1, r, w);
    pushup(ro);
}
lca ask(int ro, int l, int r)
{
    pushdown(ro);
    if (tr[ro].l == l && tr[ro].r == r)
        return tr[ro].sum;
    int mid = (tr[ro].l + tr[ro].r) >> 1;
    if (r <= mid)
        return ask(ro << 1, l, r);
    else if (l > mid)
        return ask(ro << 1 | 1, l, r);
    else
        return ask(ro << 1, l, mid) + ask(ro << 1 | 1, mid + 1, r);
}

struct pp
{
    lca x, h;
    bool operator<(const pp b)const
    {
        return x < b.x;
    }

} p[MAXN];

lca tims, att, d;
lca heal;
lca ans;
int main()
{
    scanf("%d%lld%lld", &n, &d, &att);
    for (int i = 1; i <= n; i++)
        scanf("%lld%lld", &p[i].x, &p[i].h);
    sort(p + 1, p + n + 1);
    for (int i = 1; i <= n; i++)
        a[i] = p[i].h;
    build(1, 1, n);
    for (int i = 1; i <= n; i++)
    {
        heal = ask(1, i, i);
        if (heal > 0)
        {
            tims = heal / att + ((heal % att) ? 1 : 0);
            pp res;
            res.h = 0;
            res.x = p[i].x + 2 * d;
            int pos = upper_bound(p + 1, p + n + 1, res) - p - 1;
            lca inj = -1ll * (lca)tims * (lca)att;
            update(1, i, max(i, pos), -1 * tims * att);
            ans += (lca)tims;
        }
    }
    cout << ans << endl;
    return 0;
}


//  1 2 1+2 3 2+3 1+2+3 

Measured memory_bytes: 40576
using System;
class ProgramC
    {
        static void Main(string[] args)
        {
            
            string input = Console.ReadLine();
            int n = int.Parse(input);

            string slime = Console.ReadLine();
            int count = 0;

            for(int i = 0; i < n - 1;i++)
            {
                if(slime[i] != slime[i + 1])
                    count++;
                
            }

            Console.WriteLine(count + 1);
                
        }
    }

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

using namespace std;

const int N = 400000 + 77;
vector < int > U;
inline int GetId(int x) { return lower_bound(U.begin() , U.end() , x) - U.begin() + 1; }
int n , q , S[N] , T[N] , X[N] , D[N] , A[N] , Mx[N << 2];
vector < int > Q[N] , I[N] , O[N];
multiset < int > MS;
int main() {
   scanf("%d %d" , & n , & q);
   for(int i = 1;i <= n;++ i) {
      scanf("%d %d %d" , S + i , T + i , X + i);
      S[i] -= X[i];
      T[i] -= X[i];
      U.push_back(S[i]);
      U.push_back(T[i]);
   }
   sort(U.begin() , U.end());
   U.resize(unique(U.begin() , U.end()) - U.begin());
   for(int i = 1;i <= q;++ i)
      scanf("%d" , D + i) , Q[GetId(D[i] + 1) - 1].push_back(i);
   for(int i = 1;i <= n;++ i)
      I[GetId(S[i])].push_back(X[i]) , O[GetId(T[i])].push_back(X[i]);
   for(int i = 0;i < N;++ i) {
      for(int x : I[i])
         MS.insert(x);
      for(int x : O[i])
         MS.erase(MS.find(x));
      for(int x : Q[i])
         A[x] = (MS.empty() ? - 1 : (* MS.begin()));
   }
   for(int i = 1;i <= q;++ i)
      printf("%d\n" , A[i]);
   return 0;
}


Measured memory_bytes: 68720
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    int N, i, a[101];
    double ave=0, min=1000;

    cin >> N;

    for(i=0; i<=N-1; i++){
        cin >> a[i];
        ave += a[i];
    }

    ave /= (double)N;

    for(i=0; i<=N-1; i++){
        chmin(min, fabs(ave-a[i]));
    }

    for(i=0; i<=N-1; i++){
        if(fabs(ave-a[i])==min){
            cout << i << endl;
            break;
        }
    }

    return 0;
}

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

int main() {
    int64_t N, D;
    cin >> N >> D;
    vector<int64_t> X(N), Y(N);

    int64_t ans = 0;
    for (int64_t i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];

        int64_t d_d = X[i] * X[i] + Y[i] * Y[i];
        if (d_d <= D * D) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 6420
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cstdlib>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/

int main()
{
	int n, k, x, y, a[11] = {0};
	
	scanf("%d%d", &n, &k);
	for (int i = 0; i < k; i++){
		scanf("%d", &x);
		a[x] = 1;
	}
	int fg = 0;
	while (fg == 0){
		x = n;
		fg = 1;
		while (x){
			y = x % 10;
			if (a[y]){
				fg = 0;
				break;
			}	 
			x /= 10;
		}
		if (fg)
		break;
		n++;
	}
	printf("%d\n", n);
}

Measured memory_bytes: 256
def main(n: int, s_t: list, x: str):
    ans = 0
    i = 0

    for s, _ in s_t:
        i += 1
        if s == x:
            break

    for _, t in s_t[i:]:
        ans += int(t)

    print(ans)


if __name__ == "__main__":
    n = int(input())
    s = [input().split() for _ in range(n)]
    x = input()

    main(n, s, x)


Measured memory_bytes: 3060
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

ans = 0
temp = [a,b,c,d,e]
min_list = 1<<50
min_index = 0
judge = True

for i in range(5):
    if (temp[i]%10) != 0:
        min_list = min(temp[i]%10,min_list)
    # print(min_list)
# print()
for i in temp:
    if i % 10 == 0:
        ans += i
    else:
        if (i % 10 == min_list) and judge:
            ans += i
            judge = False
        else:
            ans += ((i//10)+1)*10
print(ans)


Measured memory_bytes: 3064
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto RGBN = RDR.ARR;

	long ans;
	foreach (i; 0..3001)
	{
		long x = RGBN[0] * i;
		foreach (j; 0..3001)
		{
			auto y = x + RGBN[1] * j;
			if (y > RGBN[3]) break;
			auto z = RGBN[3] - y;
			if (z % RGBN[2] == 0)
				++ans;
		}
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
hs = gets.split.map(&:to_i)

dp = [0]
# refer back
1.upto(n - 1) do |i|
  last = i - 1
  dp[i] = dp[last] + (hs[i] - hs[last]).abs # 仮

  [i - k, 0].max.upto(last - 1) do |j|
    # change min
    cost = dp[j] + (hs[i] - hs[j]).abs
    dp[i] = cost if dp[i] > cost
  end
end

p dp.last


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

using namespace std;

#define llong long long 
int n;
int ans;
bool memo[1001];

void solve(int num, int sum, int d){
	if(d == 4){
		if(sum == num){
			ans++;			
		}
		return;
	}

	if(num < sum) return;

	for(int i = 0;i <= 9; i++){
		solve(num, sum + i, d + 1);
	}
	return;
}

int main(){
	while(cin >> n){
		ans = 0;
		solve(n, 0, 0);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3000
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    for i in range(N):
        if A[i] == 0:
            print(0)
            return
    ans = 1
    for i in range(N):
        ans *= A[i]
        if ans > 10**18:
            print(-1)
            return
    print(ans)

if __name__ == '__main__':
    main()

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

int main(){
  int H, W;
  cin >> H >> W;
  char map[H+2][W+2];
  for(int i=0; i<H+2; i++){
    for(int j=0; j<W+2; j++) map[i][j]='.';
  }
  for(int i=1; i<H+1; i++){
    for(int j=1; j<W+1; j++) cin >> map[i][j];
  }
  int flag=0;
  for(int i=1; i<H+1; i++){
    for(int j=1; j<W+1; j++){
      if(map[i][j]=='#'){
        if(map[i-1][j]=='.' && map[i+1][j]=='.' && map[i][j-1]=='.' && map[i][j+1]=='.') flag++;
      }
    }
  }
  if(flag==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];

int main(){
	int N,M,K;
	stack<int> s;   
    queue<int> que;
    //std::cin >> N;
    //std::cin >> N >> M;
    std::cin >> N >> M >> K;
    
    std::vector<long long> v(N);
 
    // 入力
    /*
    for(long long i=0; i<N; i++){
		v[i]=1;
	}
	*/
    
    //std::cin >> N;
    if(N== M && N==K && M==K){
    printf("Yes");
    }
    else{
		printf("No");
    }
    //printf("%d",N*M);
	return 0;
}

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

string board[8];

inline bool a(int x, int y){return (0<=x && x<8 && 0<=y && y<8);}

int p[7][3][2]={{{0,  1}, {1,  0}, {1,  1}},
                {{1,  0}, {2,  0}, {3,  0}},
                {{0,  1}, {0,  2}, {0,  3}},
                {{1, -1}, {1,  0}, {2, -1}},
                {{0,  1}, {1,  1}, {1,  2}},
                {{1,  0}, {1,  1}, {2,  1}},
                {{0,  1}, {1, -1}, {1,  0}}};

void solve(){
  for(int i=0; i<8; i++){
    for(int j=0; j<8; j++){
      if(board[i][j]=='1'){
        for(int k=0; k<7; k++){
          bool flag=true;
          for(int l=0; l<3; l++){
            if(!a(i+p[k][l][0], j+p[k][l][1]))flag=false;
          }
          if(flag){
            bool flag2=true;
            for(int l=0; l<3; l++){
              if(board[i+p[k][l][0]][j+p[k][l][1]]!='1') flag2=false;
            }
            if(flag2){
              char ans='A'+k;
              cout<<ans<<endl;
              return;
            }
            else continue;
          }
          else continue;
        }
      }
    }
  }
}

int main(){
  while(cin>>board[0]){
    for(int i=1; i<8; i++) cin>>board[i];
    solve();
  }
  return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define LL long long
#define PI 3.14159265359
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

int main(void) {
	string S;
	cin >> S;
	sort(ALL(S));

	if (S == "abc") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll A;
  scanf("%lld",&A);
  ll B;
  scanf("%lld",&B);
  ll C;
  scanf("%lld",&C);
  ll X;
  scanf("%lld",&X);
  ll ans=0;
  for (int i=0; i<=A; i++) {
    for (int j=0; j<=B; j++) {
      for (int k=0; k<=C; k++) {
        if (500*i+100*j+50*k==X) ans++;
      }
    }
  }
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll a,b;
  char c;
  while(cin>>a>>c>>b){
    if(c=='?')break;

    if(c=='+')out(a+b);
    else if(c=='-')out(a-b);
    else if(c=='*')out(a*b);
    else if(c=='/')out(a/b);
  }


  return 0;
}



Measured memory_bytes: 3096
N = int(input())
s, t = [], []
for _ in range(N):
    tmp_s, tmp_t = input().split()
    s.append(tmp_s)
    t.append(int(tmp_t))
X = input()

if s.index(X) == N-1:
    print(0)
else:
    print(sum(t[s.index(X)+1:]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL K, Q; cin >> K >> Q;
		vector<ULL> D(K); rep(i, K) cin >> D[i];
		vector<ULL> MD(K);
		rep(i, Q) {
			ULL N, X, M; cin >> N >> X >> M;
			ULL ans = N - 1;
			UL t = (N - 1) / K + 1;
			ULL S, T; S = T = X;
			rep(i, K) {
				if (i == (N - 1) % K) t--;
				MD[i] = D[i] % M;
				T += MD[i] * t;
				if (MD[i] == 0) ans -= t;
			}
			ans -= ((T / M) - (S / M));
			cout << ans << endl;
		}
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 384
S = input()
N = len(S)
l = [0]*N
start = 0
while True:
    i = S.find('RL', start)
    if i + 2 > N:
        break
    if i == -1:
        for j in range(start, N):
            if (j-start) % 2 == 0:
                l[start-2] += 1
            else:
                l[start-1] += 1
        break
    l[i] += 1
    l[i+1] += 1
    for j in range(start, i):
        if S[j] == 'R':
            if (i-j) % 2 == 0:
                l[i] += 1
            else:
                l[i+1] += 1
        else:
            if (j-start) % 2 == 0:
                l[start-2] += 1
            else:
                l[start-1] += 1
    start = i + 2
print(*l)


Measured memory_bytes: 6400
import java.util.Scanner;

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

        int sumVote = 0;
        for(int i = 0; i<n; i++){
            sumVote += voteNum[i];
        }
        
        double availableNum = sumVote * ( 1.0 / (4.0 * (double)choiceNum) );
        int count = 0;

        for(int i = 0; i<n; i++){
            if(voteNum[i] >= availableNum){
                count++;
            }
        }
        System.out.println(count >= choiceNum ? "Yes" : "No");
    }
}

Measured memory_bytes: 35900
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define cst first
#define dur second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e7 + 5, M = 2 * N + 5;

vector<int> res;
void KMP(const string &s, const string &k){
    res.clear();
    if (k.empty())
        return ;
    vector<int> tmp(k.size(), 0);
    for (int i = 1, j = 0; i < k.size(); ++i){
        while (j && k[j] != k[i])
            j = tmp[j - 1];
        if (k[j] == k[i])
            ++j;
        tmp[i] = j;
    }
    for (int i = 0, j = 0; i < s.size(); ++i){
        while (j && k[j] != s[i])
            j = tmp[j - 1];
        if (k[j] == s[i])
            ++j;
        if (j == k.size())
            res.push_back(i - j + 1);
    }
}

int n, m;

string a, b;

int f(){
    n = res.size();
    int mx = 0;
    int len = a.size();
    vector<int> sum(len, 0);
    for(auto i : res){
        if(i - m >= 0)
            sum[i] = sum[i - m] + 1;
        else sum[i] = 1;
        mx = max(mx, sum[i]);        
    }
    return mx;
}


int main(){
    IO;
    cin >> a >> b;
    m = b.size();
    while(a.size() <= m)
        a += a;
    a += a;
    a += a;
    KMP(a, b);
    int hna = f();
    a += a;
    KMP(a, b);
    if(f() > hna)return cout << -1 << endl, 0;
    if(n == 0)return cout << n << endl, 0;
    cout << hna << endl;
}

Measured memory_bytes: 72968
main(){double a,l,x,s,t;
for(;~scanf("%lf%lf%lf",&a,&l,&x);)
printf("%lf\n",sqrt((a/2)*(a/2)*((l+l-a)/2)*((l+l+a)/2))+sqrt(l*l*x*(l+x+l))/2);exit(0);}

Measured memory_bytes: 648
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
A.sort()
BC.sort(key=lambda x: - x[1])
tmp = []
for B, C in BC:
    tmp += [C] * B
    if len(tmp) >= N:
        break
if len(tmp) < N:
    n = len(tmp)
else:
    n = N
for i in range(n):
    if A[i] < tmp[i]:
        A[i] = tmp[i]
    else:
        break
print(sum(A))

Measured memory_bytes: 36076
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>  // min, max
#include <fstream>  // ifstream
#include <iomanip>  // setprecision
using namespace std;
typedef long long ll;

int main(void)
{
#ifdef FILE_DEBUG
    ifstream inputFile("data/input.txt");
    cin.rdbuf(inputFile.rdbuf());
#endif
    // これより下にコードを書く

    int A, B;
    cin >> A >> B;

    cout << ((A-1)*(B-1)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
//#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;


int main(void)
{
	int N; cin >> N;
	int cnt = 0;
	rep(i, 0, N) {
		int tmp; cin >> tmp;
		cnt += (tmp % 2);
	}
	cout << (cnt % 2 ? "NO" : "YES") << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lg long long
#define jxc 1000000007
int n;lg dp[500005];
char cc[500005],dd[500005];
int main(){
	scanf("%d",&n);scanf("%s%s",cc+1,dd+1);dp[0]=1;
	for(int i=0;i<n;++i){
		if(cc[i+1]==dd[i+1])dp[i+1]=dp[i]*(i==0?3:(cc[i]==dd[i]?2:1))%jxc;
		else dp[i+2]=dp[i]*(i==0?6:(cc[i]==dd[i]?2:3))%jxc,i+=1;
	}cout<<dp[n];
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define irep(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define rrep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

const int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    int t = 1;
    while (t * 2 <= n)
        t *= 2;
    cout << t << endl;
    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 M = sc.nextInt();
      	if (N >= M) {
          System.out.println(0);
          return;
        }
        int[] x = new int[M];
  
        for (int i =0; i<M; i++) {
            x[i] = sc.nextInt();
        }

        Arrays.sort(x);

        int[] diff = new int[M-1];
        for (int i =1; i<M; i++) {
            diff[i-1] = x[i] - x[i-1];
        }

        Arrays.sort(diff);
        int result = 0;
        for (int i =0; i<(M-1)-(N-1); i++) {
            result += diff[i];
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 48920
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int sum=0;
    for(int i=n-1;i>=0;i--)
    {
        sum+=a[i];
    }
    if(sum%10==0)
    {
        int i=0;
        while(i<n)
        {
            if((sum-a[i])%10!=0)
            {
                cout<<sum-a[i]<<endl;
                return 0;
            }
            i++;
        }
    }
    if(sum%10==0)
        cout<<0;
    else
    cout<<sum<<endl;
}


Measured memory_bytes: 256
N, D = gets.split.map(&:to_i)
X = []
N.times do
  X << gets.split.map(&:to_i)
end

ans = 0

N.times do |i|
  ((i + 1)...N).each do |j|
    dist = X[i].zip(X[j]).map { |y, z| (y - z) ** 2 }.inject(:+)

    d = Math.sqrt(dist)
    e = d.ceil

    ans += 1 if d - e == 0
  end
end

puts ans


Measured memory_bytes: 3836
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();

		int k = S.length();
		int o = 0;
		int x = 0;
		for(int i=0;i<k;i++) {
			if(S.charAt(i) == 'o') {
				o++;
			}else {
				x++;
			}
		}

		if(k < 8) {
			System.out.println("YES");
		}else if(o >= k-7) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21844
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int n, f[100005];
int main() {
	scanf ("%d", &n);
	memset (f, 0x7f, sizeof f);
	f[0] = 0;
	int a = 1, b = 1;
	for (int i = 1; i <= 7; i++) {
		a *= 6, b *= 9;
		for (int j = 1; j <= 100000; j++) {
			f[j] = min (f[j], f[j - 1] + 1);
			if (j >= a) f[j] = min (f[j], f[j - a] + 1);
			if (j >= b) f[j] = min (f[j], f[j - b] + 1);
		}
	}
	printf ("%d", f[n]);
}

Measured memory_bytes: 640
import sys
from heapq import heappop, heappush

n, q = map(int, input().split())
lines = sys.stdin.readlines()
events = []
kkk = []
for line in lines[:n]:
    s, t, x = map(int, line.split())
    events.append((s - x, 2, x))
    events.append((t - x, 1, x))
for line in lines[n:]:
    events.append((int(line), 3))
events.sort()

constructing = []
available = set()
buf = []
for ev in events:
    if ev[1] == 2:
        heappush(constructing, ev[2])
        available.add(ev[2])
    elif ev[1] == 1:
        available.remove(ev[2])
    else:
        if not available:
            buf.append(-1)
        else:
            while constructing[0] not in available:
                heappop(constructing)
            buf.append(constructing[0])
print('\n'.join(map(str, buf)))


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

using ll = long long;
using pii = pair<int, int>;

template <typename T> constexpr T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;
template <> constexpr double inf<double> = 1e18;

int main() {
    int N, K; cin >> N >> K;
    if(K == 0) {
        cout << 1LL * N * N << endl;
        return 0;
    }
    ll ans = 0;
    for(int b = K + 1; b <= N; ++b) {
        ans += N - K + 1 - (N - b) / b * K - min((N - b) % b + 1, K);
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = input()

PassNo = 0
Limit = A + B
StuJpn = 0
StuInt = 0

for i in S:
  if PassNo < Limit:
    if i == 'a':
      StuJpn += 1
      print("Yes")
    elif i == 'b':
      if StuInt < B:
        StuInt += 1
        print("Yes")
      else:
        print("No")
    else:
      print("No")
  else:
    print("No")
  PassNo = StuJpn + StuInt

Measured memory_bytes: 4016
int main(void){
  int id[251];
  int k,pk,lk,rk;
  int i,N;

  scanf("%d",&N);
  for(i=1;i<=N;i++){
    scanf("%d",&id[i]);
  }

  for(i=1;i<=N;i++){
    k=id[i];
    pk=id[i/2];
    lk=id[2*i];
    rk=id[2*i+1];
    printf("node %d: key = %d, ",i,k);
    if(i/2 > 0){
      printf("parent key = %d, ",pk);
    }
    if(2*i <= N){
      printf("left key = %d, ",lk);
    }
    if(2*i+1 <= N){
      printf("right key = %d, ",rk);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int, Z: int):
    print(Z, X, Y)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    solve(X, Y, Z)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060