akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i,k) for(int i=0;i<k;i++)
ll n, m, i, j, k,o,p;
ll a[100005], b[100005];

ll f[100005],g[100005], zz[100005];
int find(int x) {
	if (f[x] != x)
		f[x] = find(f[x]);
		
	return f[x];
}
void lian(ll x, ll y,ll i) {
	f[y] = x;
	zz[i] = zz[i + 1] - (g[x] * g[y]);
	g[x] += g[y];
	g[y] = g[x];
}
int main() {
	cin >> n >> m;
	for (i = 1; i < m + 1; i++)cin >> a[i] >> b[i];
	zz[m+1] = n*(n-1)/2;

	for (int i = 1; i <= n; i++) {
		f[i] = i;
		g[i] = 1;
	}
	for (int i = m; i >= 1; i--) {
		ll y, z;
		y = a[i]; z = b[i];
			o = find(y); p = find(z);
			if (o != p) {
				lian(find(o), find(p), i);
			}
			else zz[i] = zz[i + 1];
	}


	rep(i, m)cout << zz[i+2]<< "\n";
	
	return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

#define rep(i,n) for(int i=0; i<(n); i++)

vector<bool> completed;
vector<bool> visited;
vector<vector<int>> E;
vector<int> memo;

int dfs(int s){
    if(visited[s]) return -1;
    if(completed[s]) return memo[s];

    visited[s] = true;
    int ans = 1;
    for(int &to:E[s]){
        int res = dfs(to);
        if(res==-1) return -1;
        ans = max(ans, res+1);
    }
    visited[s] = false;
    completed[s] = true;
    
    return memo[s] = ans;
}




int main() {
    int N; cin >> N;
    
    vector<vector<int>> A(N, vector<int>(N-1));
    rep(i, N){
        rep(j, N-1){
            cin >> A[i][j];
            A[i][j]--;
        }
    }
    
    vector<vector<int>> id(N, vector<int>(N));
    int V = 0;
    rep(i, N){
        rep(j, N){
            if(i<j){
                id[i][j] = V++;
            }
        }
    }
    
    auto toId = [&](int i, int j){
        if(i>j) swap(i, j);
        return id[i][j];
    };
    
    E.resize(V);
    completed.resize(V);
    visited.resize(V);
    memo.resize(V);

    for(int i=0; i<N; i++){
        for(int j=0; j<N-2; j++){
            int from = toId(i, A[i][j]);
            int to = toId(i, A[i][j+1]);
            E[from].push_back(to);
        }
    }
    
    int ans = 1;
    for(int i=0; i<V; i++){
        int res = dfs(i);
        if(res==-1){
            cout << -1 << endl;
            return 0;
        }
        ans = max(ans, res);
    }
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 37632
import bisect
n=int(input())
a=list(map(int,input().split()))
s=max(a)-min(a)
if s>=2:
    print("No")
elif s==0:
    if a[0]==n-1 or n//a[0]>=2:
        print("Yes")
    else:
        print("No")
else:
    a.sort()
    x=bisect.bisect_right(a,a[0])
    if x+1<=a[-1]<=x+(n-x)//2 and n-x>=2:
        print("Yes")
    else:
        print("No")

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

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



int main(void) {
	ll a, b, k;

	cin >> a >> b >> k;

	if (a + k - 1 >= b-k+1) {
		FOR(i, a, b) {
			cout << i << endl;
		}
	}
	else {
		FOR(i, a, a + k - 1) {
			cout << i << endl;
		}
		FOR(i, b - k + 1, b) {
			cout << i << endl;
		}
	}

	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
const int _ = 200005;
int A[_];
int B[_];
int main()
{
   int N;
   cin>>N;
   int fm = 0;
   int sm = 0;
   for(int i = 0 ;i<N;i++)
   {
       cin>>A[i];
       B[i]= A[i];
       if(A[i]>fm)
       {
           fm = A[i];
       }
   }
   sort(B,B+N);
   int f = 0;
   if(B[N-2]==fm)
   {
       f= 1;
   }
   int id = N-1;
   while(B[id]==fm&&id>=0)
   {
       id--;
       if(B[id]!=fm)
       {
           sm = B[id];
           break;
       }
   }
   for(int i = 0 ; i<N;i++)
   {
       if(A[i]<fm){
           cout<<fm<<endl;
       }else
       {
           if(f==1)
           {
               cout<<fm<<endl;
           }else
           {
               cout<<sm<<endl;
           }
           
       }
       
   }
    return 0;
}

Measured memory_bytes: 3200
import java.util.*;
import java.io.*;

class Main{
  static PrintWriter out = new PrintWriter(System.out);
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    String s=sc.next();
    int count1=0;
    for(int i=0;i<n;i++){
      if(s.charAt(i)=='('){
        count1++;
      }else if(count1>0){
        count1--;
      }
    }
    int count2=0;
    for(int i=n-1;i>=0;i--){
      if(s.charAt(i)==')'){
        count2++;
      }else if(count2>0){
        count2--;
      }
    }
    for(int i=0;i<count2;i++){
      out.print("(");
    }
    out.print(s);
    for(int i=0;i<count1;i++){
      out.print(")");
    }
    out.println();
    out.flush();
  }
}

Measured memory_bytes: 23764
# 貪欲に一つ目の要素をとっていってはいけない。
# 累積和からうまくえらぶ

n,m,k = map(int, input().split())

A = [0]
B = [0]
for a in input().split():
    A.append(A[-1]+int(a))
for b in input().split():
    B.append(B[-1]+int(b))

ans = 0
b_num = m
for i in range(n+1):
    while b_num>=0 and B[b_num]>k-A[i]:
        b_num -= 1
    if b_num>=0 and i+b_num > ans:
        ans = i+b_num
#        print(i, b_num)
print(ans)


Measured memory_bytes: 46552
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int dp[3010][3010] = {0};

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

  cin.tie(0);
  ios::sync_with_stdio(false);

  string s, t;
  cin >>  s >> t;
  // DP : len(LCS) = dp[s.size()][t.size()]
  for (int i = 0; i < s.size(); ++i) {
    for (int j = 0; j < t.size(); ++j) {
      if (s[i] == t[j]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
    }
  }

  int len = dp[s.size()][t.size()];
  string res(len, 0);
  int strIdx = len - 1;
  int i = s.size(), j = t.size();
  while (strIdx >= 0) {
    if (dp[i - 1][j] == dp[i][j]) {
      --i;
    }
    else if (dp[i][j - 1] == dp[i][j]) {
      --j;
    }
    else {
      --i, --j;
      res[strIdx--] = s[i];
    }
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 35584
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/rope>
// #include <type_traits>
using namespace std;
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)

#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(xs) ((int)(xs).size())
#define all(xs) xs.begin(),xs.end()
#define lla(xs) xs.rbegin(),xs.rend()
#define sum(xs) accumulate(all(xs), 0)
#define sortup(xs) sort(all(xs))
#define sortdown(xs) sort(lla(xs))
#define reverse(xs) reverse(all(xs))
#define contain(xs,n) (find(all(xs),n)!=xs.end())
#define unique(xs) xs.erase(unique(all(xs)),xs.end())
#define search(xs,n) distance(xs.begin(),find(all(xs),n))
#define count(xs,n) count(all(xs),n)
// #define vecmin(xs) *min_element(all(xs))
// #define vecmax(xs) *max_element(all(xs))

template<class C>void mini(C &a,C b){a=min(a,b);}
template<class C>void maxi(C &a,C b){a=max(a,b);}

// 複数，シフト，演算
// #define newvec(T,n,xs) vector<T> xs(n)

#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__)
#define invec(T,n,...) vector<T> __VA_ARGS__;T t;_cinvec(t,n,__VA_ARGS__)
#define invec2(T,n,xs,ys) vector<T> xs(n),ys(n);fou(i,0,n)cin>>xs.at(i)>>ys.at(i)
#define invec3(T,n,xs,ys,zs) vector<T> xs(n),ys(n),zs(n);fou(i,0,n)cin>>xs.at(i)>>ys.at(i)>>zs[i]
// #define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
// #define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define out(...) _cout(__VA_ARGS__)
#define outvec(xs) tra(x,xs) cout << x << " ";cout << endl
void _cin(){}template<class Head,class...Tail>void _cin(Head&&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
void _cout(){}template<class Head,class...Tail>void _cout(Head&&head,Tail&&...tail){cout<<head<<endl;_cout(forward<Tail>(tail)...);}
template<class Type>void _cinvec(Type t,int n){}template<class Type,class Head,class...Tail>void _cinvec(Type t,int n,Head&&head,Tail&&...tail){rep(n){cin>>t;head.eb(t);}_cinvec(t,n,forward<Tail>(tail)...);}


#define int int64_t
// #define double long double

// map,文字列処理


signed main(){
  in(int,n,a,b,c,d,e);
  int m=min({a,b,c,d,e});
  int x=(n-1)/m+5;
  out(x);
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n, m, k;
    int like, a, po, cnt;
    int i, j;
    po = 0xffffffff;
    scanf("%d %d", &n, &m);
    for (i = 0; i < n; i++) {
	scanf("%d", &k);
	like = 0;
	for (j = 0; j < k; j++) {
	    scanf("%d", &a);
	    like |= 1 << (a-1);
	}
	po &= like;
    }
    cnt = 0;
    for (i = 0; i < 32; i++) {
	if (po & (1<<i)) cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}


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

ll n,K;
ll x[55];
ll y[55];

int main(){
    cin >> n >> K;
    vector<ll> dx;
    vector<ll> dy;
    for(ll i=0;i<n;i++){
        cin >> x[i] >> y[i];
        dx.push_back(x[i]);
        dy.push_back(y[i]);
    }
    sort(dx.begin(),dx.end());
    sort(dy.begin(),dy.end());
    ll res=abs(dx[n-1]-dx[0])*abs(dy[n-1]-dy[0]);
    for(ll i=0;i<n;i++){
        for(ll k=i+1;k<n;k++){
            for(ll j=0;j<n;j++){
                for(ll l=j+1;l<n;l++){
                    ll lx=dx[i],rx=dx[k],ly=dy[j],ry=dy[l];
                    ll count=0;
                    for(ll c=0;c<n;c++){
                        if(lx<=x[c]&&x[c]<=rx&&ly<=y[c]&&y[c]<=ry) count++;
                    }
                    if(K<=count) res=min(res,abs(rx-lx)*abs(ry-ly));
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}  


Measured memory_bytes: 3600
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::slice::*;

fn main() {
    let mut io = IO::new(stdin(), stdout(), stderr());
    // ===================================== //
    let (n, m, x): (usize, usize, usize) = (io.read(), io.read(), io.read());
    let mut a = io.readmat::<usize>(n, m + 1);

    let mut ans: isize = 1 << 30;
    for i in 0..(1 << n) {
        let mut vecs = vec![0; m];
        let mut cos = 0;
        for b in 0..n {
            if (i >> b & 1) == 1 {
                cos += a[b][0];
                let mut clear = true;
                for al in 0..m {
                    vecs[al] += a[b][al + 1];
                    if vecs[al] < x {
                        clear = false;
                    }
                }
            }
        }

        let mut clear = true;
        for al in 0..m {
            if vecs[al] < x {
                clear = false;
            }
        }
        if clear {
            ans = min(ans, cos as isize);
        }
    }
    io.writeln(if ans == (1 << 30) { -1 } else { ans });
}

// IO
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
}


Measured memory_bytes: 2164
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#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 ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

typedef tree<pair<ll,ll> ,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

const int MAXN = 1e5 + 5;

vector<ll>adj[MAXN];
ll p[MAXN][22], parent[MAXN], level[MAXN], n, u, v, a, b, res;

void precom()                                        // for calculating 2^k th parent of every node
{
	for(int i = 0 ; i < n ; i++)
		for(int j = 0 ; (1ll << j) < n ; j++)
			p[i][j] = -1;
	for(int i = 0 ; i < n ; i++)
		p[i][0] = parent[i];
	for(int j = 1 ; (1ll << j) < n ; j++)
		for(int i = 0 ; i < n ; i++)
			if(p[i][j - 1] != -1)
				p[i][j] = p[p[i][j - 1]][j - 1];
}

ll lca(ll u, ll v)
{
	if(min(level[u], level[v]) == level[u]) swap(u, v);
	ll dist = level[u] - level[v];
	while(dist)
	{
		ll raise = log2(dist);
		u = p[u][raise];
		dist -= (1ll<<raise);
	}
	if(u == v) return u;
	for(int j = 21 ; j >= 0 ; j--)
	{
		if(p[u][j] != -1 && p[u][j] != p[v][j])
		{
			u = p[u][j];
			v = p[v][j];
		}
	}
	return parent[u];
}

void dfs(ll node, ll par, ll lev)                              // dfs to set parent and calculate levels
{
	level[node] = lev;
	for(auto it : adj[node])
	{
		if(it == par) continue;
		parent[it] = node;
		dfs(it, node, lev + 1);
	}		
}

ll dist(ll x, ll y)
{
	return level[x] + level[y] - 2 * level[lca(x, y)];
}

void dfs1(ll node, ll par)
{
	for(auto it : adj[node])
	{
		if(it == par) continue;
		dfs1(it, node);
	}
	ll x1 = dist(u, node);
	ll x2 = dist(v, node);
	if(x1 < x2) res = max(res, x2 - 1);	
}

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

 	cin >> n >> u >> v;
 	u -= 1; v -= 1;
 	for(int i=0;i<n-1;i++)
 	{
 		cin >> a >> b;
 		adj[a - 1].pb(b - 1);	
 		adj[b - 1].pb(a - 1);	
 	}
 	dfs(0, -1, 0);
 	precom();
 	dfs1(0, -1);
 	cout << res << endl;
    return 0;
}

Measured memory_bytes: 29952
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    int n;
    cin >> n;
    VI as, bs, cs;
    REP(i,n) {
        long d;
        cin >> d;
        as.push_back(d);
    }
    REP(i,n) {
        long d;
        cin >> d;
        bs.push_back(d);
    }
    REP(i,n) {
        long d;
        cin >> d;
        cs.push_back(d);
    }
    sort(as.begin(), as.end());
    sort(bs.begin(), bs.end());
    sort(cs.begin(), cs.end());
    long ans = 0;
    REP(i,n) {
        ans += (lower_bound(as.begin(), as.end(), bs[i]) - as.begin()) * (n - (upper_bound(cs.begin(), cs.end(), bs[i]) - cs.begin()));
    }
    cout << ans << endl;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli odd[100100];
lli even[100100];
lli cnt[100100];

void func(long long N, long long M, std::vector<long long> X){

    REP(i,0,N){
        cnt[X[i]]++;
    }

    REP(i,0,100100){
        even[i%M]+= cnt[i]%2;
        odd[i%M] += (cnt[i]/2)*2;
    }

    //0は先に処理する
    lli ans = 0;
    ans += even[0]/2+odd[0]/2;

    //Mが偶数の場合、m/2が厄介なのでこれも処理する。
    if(M%2==0)ans += even[M/2]/2 + odd[M/2]/2;

    REP(i,0,M/2+1){
        if(i==0 || (M%2==0 && i==M/2))continue;
        if(DEBUG)cout<<"i="<<i<<endl;
        //相手同士でマッチングさせる
        if(even[i]>even[M-i]){
            swap(even[i],even[M-i]);
            swap(odd[i],odd[M-i]);
        }

        ans += even[i];
        even[M-i]-=even[i];
        even[i]=0;

        //余ったeven[M-i]をoddにマッチングさせられるか？
        lli tmp = min(odd[i],even[M-i]);
        if(DEBUG)cout<<"tmp="<<tmp<<endl;
        odd[i]-=tmp;
        even[M-i]-=tmp;
        ans += tmp;

        ans += odd[i]/2;
        ans += odd[M-i]/2;
    }
    cout<<ans<<endl;


}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> X(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
    }
    func(N, M, std::move(X));
    return 0;
}


Measured memory_bytes: 3328
A, B, C, D = map(int, input())

if A + B + C + D == 7:
    print("{0}+{1}+{2}+{3}=7".format(A, B, C, D))

elif A + B + C - D == 7:
    print("{0}+{1}+{2}-{3}=7".format(A, B, C, D))

elif A + B - C + D == 7:
    print("{0}+{1}-{2}+{3}=7".format(A, B, C, D))

elif A + B - C - D == 7:
    print("{0}+{1}-{2}-{3}=7".format(A, B, C, D))

elif A - B + C + D == 7:
    print("{0}-{1}+{2}+{3}=7".format(A, B, C, D))

elif A - B + C - D == 7:
    print("{0}-{1}+{2}-{3}=7".format(A, B, C, D))

elif A - B - C + D == 7:
    print("{0}-{1}-{2}+{3}=7".format(A, B, C, D))

else:
    print("{0}-{1}-{2}-{3}=7".format(A, B, C, D))

Measured memory_bytes: 9104
import numpy as np
S = input()

R = [0]*len(S)
L = [0]*len(S)
R[0] = 1
L[-1] = 1

for i in range(len(S)-1):
	if (S[i] == "R" and S[i+1] == "R"):
		R[i+1] = R[i] + 1
	elif (S[i] == "L" and S[i+1] == "R"):
		R[i+1] = 1
	if (S[-i-1] == "L" and S[-i-2] == "L"):
		L[-i-2] = L[-i-1] + 1
	elif (S[-i-1] == "R" and S[-i-2] == "L"):
		L[-i-2] = 1

rans = [0]*len(S)
lans = [0]*len(S)
for i in range(len(S)-1):
	if (R[i] != 0 and R[i+1] == 0):
		rans[i] = -(-R[i]//2)
		rans[i+1] = R[i]//2
	if (L[-i-1] != 0 and L[-i-2] == 0):
		lans[-i-1] = -(-L[-i-1]//2)
		lans[-i-2] = L[-i-1]//2

ans = [np.array(rans)+np.array(lans)]
print(*ans[0])

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

int main()
{
long unsigned int i;
string s,t;
cin>>s>>t;
for(i=0;i<s.size();i++)
{
  if(s[i]!=t[i])
    break;
}
if(i==s.size())
  cout<<"Yes";
else
  cout<<"No";
return 0;
}

Measured memory_bytes: 3628
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
   
    string s;
    cin>>s;
    
    cout<<"2018";
    for(int i=4;i<10;i++){
        cout<<s[i];
    }
    cout<<endl;
    
    return 0;
   
}






Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){
	int a[3],n,i,j,k,tmp,cnt;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a[0],&a[1],&a[2]);
		for(j=0;j<3;j++){
			for(k=j+1;k<3;k++){
				if(a[j]>a[k]){
					tmp=a[k]; a[k]=a[j]; a[j]=tmp;
				}
			}
		}
		if(a[2]*a[2]==a[0]*a[0]+a[1]*a[1]) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}
	

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

int main() {

  string S, T;
  cin >> S >> T;
  int n = T.size();
  bool flag = 0;
  if (S == T.erase(n-1)) {
    flag =1;
  }

  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

class DP {
    static void Main(string[] args) {
        var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int N = st[0];
        int W = st[1];
        var w = new int[N];
        var v = new int[N];
        for (int i = 0; i < N; i++) {
            var x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            w[i] = x[0];
            v[i] = x[1];
        }

        //考えうる価値の最大値
        int max_value = N * 1000 + 100;

        //少し大きめに配列を確保
        var dp = new long[N + 2, max_value + 10];

        long max_weight = 1000000000L * N + 100;

        //値は全て大きな値で初期化する
        for (int i = 0; i < N; i++) {
            for (int j = 0; j <= max_value; j++) {
                dp[i, j] = max_weight;
            }
        }
        dp[0, 0] = 0;
        for (int j = 1; j <= v[0]; j++) {
            dp[0, j] = w[0];
        }

        for (int i = 0; i < N - 1; i++) {
            for (int j = 0; j <= max_value; j++) {
                long kari = dp[i, j];
                if (j - v[i + 1] >= 0) {
                    kari = Math.Min(kari, dp[i, j - v[i + 1]] + w[i + 1]);
                }
                dp[i + 1, j] = kari;
            }
        }

        long ans = 0;

        for (int j = 0; j <= max_value; j++) {
            if (dp[N - 1, j] <= W) {
                ans = j;
            }
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 91232
# -*- coding: utf-8 -*-
S_ = input()
T = input()

S = []
for i in range(0, len(S_) - len(T) + 1):
    tmp = S_[:]
    tmp = tmp[:i] + T + tmp[i + len(T):]

    double = [_ if _ == S_[i] else '?' for i, _ in enumerate(tmp)]
    if ''.join(double) == S_:
        S = tmp

if S:
    S = ''.join(['a' if _ == '?' else _ for _ in S])
    print(S)
else:
    print('UNRESTORABLE')


Measured memory_bytes: 3060
import java.util.*;

public class Main {

	static final long n = 1000000000;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long s = sc.nextLong();
		sc.close();
		long ans[][] = new long[3][2];
		ans[0][0] = 0;
		ans[0][1] = 0;
		ans[1][1] = 0;
		ans[2][1] = n;
		ans[2][0] = 1;
		ans[1][0] = s / n;
		long r = s % n;
		ans[1][1] = r;
		if(r != 0) {
			ans[1][1] = n - r;
			ans[1][0]++;
		}
		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 2; ++j)
				System.out.print(ans[i][j] + " ");
		}
		System.out.println();
	}
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
int main(void){
   long int num_x[2],num_y[2];
   long long int max=-1000000000000000001;
   for(int i=0;i<2;i++){
       cin >> num_x[i];
   }
   for(int i=0;i<2;i++){
       cin >> num_y[i];
   }
   for(int i=0;i<2;i++){
       for(int j=0;j<2;j++){
           if(max <= num_x[i] * num_y[j]) max = num_x[i] * num_y[j];
       }
   }
   cout << max << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
long long n,l,r,s;   
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>l>>r;
        s+=r-l+1;    
    }
    cout<<s<<endl;
    return 0;
}
 

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define NOT -1
struct Node {int pa, le, ri;};
struct Node T[MAX];
int D[MAX];
int j,c;
//depth
int recDepth(int u,int p){
  D[u]=p;
  if(T[u].ri!=NOT)recDepth(T[u].ri,p);
  if(T[u].le!=NOT)recDepth(T[u].le,p+1);
}
//print
void print(int u){
  printf("node %d: parent = %d, depth = %d, ",u,T[u].pa,D[u]);
  if(T[u].pa==NOT)printf("root, ");
  else if(T[u].le==NOT) printf("leaf, ");
  else printf("internal node, ");
  
  printf("[");
  for(j=0,c=T[u].le;c!=NOT;j++,c=T[c].ri){
    if(j)printf(", ");
      printf("%d",c); 
  }
    printf("]\n");
}
int main(){
  int node,n,cou=0,i,degree,x,y,r;
  scanf("%d",&n);
  for(i=0;i<n;i++)T[i].pa=T[i].le=T[i].ri=NOT;
  
  for(j=0;j<n;j++){
    scanf("%d",&node);
    scanf("%d",&degree);
    
    for(i=0;i<degree;i++){
      scanf("%d",&c);
      if(i==0)T[node].le=c;
      else T[x].ri=c;
      x=c;
      T[c].pa=node;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].pa==NOT)r=i;
  }
  recDepth(r,0);
  
  for(i=0;i<n;i++)print(i);
  return 0;
}

Measured memory_bytes: 5296
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007
#define mp(a,b) make_pair(a,b)

ll N;
vector<ll> a(51);


int main() {
    ll MAX = -inf;
    ll MIN = inf;
    ll maxi;
    ll mini;
    cin >> N;
    rep(i,N) {
        cin >> a[i];
        if (a[i] > MAX){
            maxi = i+1;
            MAX = a[i];
        }
        if (a[i] < MIN){
            mini = i+1;
            MIN = a[i];
        }
    }
    if (MIN >= 0){
        cout << N-1 << endl;
        rep(i,N-1){
            cout << i+1 << " " << i+2 << endl;
        }
    }
    else if(MAX <= 0){
        cout << N-1 << endl;
        rep(i,N-1){
            cout << N-i << " " << N-i-1 << endl;
        }
    }
    else{
        if (abs(MIN) <= abs(MAX)){
            ll num = N-1;
            rep(i,N){
                if (a[i] < 0){
                    num++;
                }
            }
            cout << num << endl;
            rep(i,N){
                if (a[i] < 0){
                    cout << maxi << " " << i+1 << endl;
                }
            }
            rep(i,N-1){
                cout << i+1 << " " << i+2 << endl;
            }
        }
        else{
            ll num = N-1;
            rep(i,N){
                if (a[i] > 0){
                    num++;
                }
            }
            cout << num << endl;
            rep(i,N){
                if (a[i] > 0){
                    cout << mini << " " << i+1 << endl;
                }
            }
            rep(i,N-1){
                cout << N-i << " " << N-i-1 << endl;
            }
        }
    }
  
    
    return 0;
}


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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 110, M = 110;

LL h, t = 1, res;

int main()
{
	cin >> h;
	while (h)
	{
		h /= 2;
		res += t;
		t *= 2;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		int begin = S.indexOf('A');
		int end = S.lastIndexOf('Z');

		System.out.println(end - begin + 1);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 10196
#include<stdio.h>
#include<math.h>
int main()
{
	int n,bestIndex,i;
	while(scanf("%d",&n),n)
	{
		double bestBMI=999,h,w,b;
		while(n--)
		{
			scanf("%d%lf%lf",&i,&h,&w);
			b=fabs(w/h/h*10000-22);
			if(bestBMI > b)
				bestBMI = b, bestIndex=i;
		}
		printf("%d\n",bestIndex);
	}
	return 0;
}

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

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

  string result = "No";

  if (S[0] == S[1] && S[2] == S[3])
    result = "Yes";
  if (S[0] == S[2] && S[1] == S[3])
    result = "Yes";
  if (S[0] == S[3] && S[1] == S[2])
    result = "Yes";
  
  if (S[0] == S[1] &&
      S[0] == S[2] &&
      S[0] == S[3]) {
    result = "No";
  }

  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF=1e18;
vector<ll> x[210005];
vector<ll> used(210005,0);
vector<ll> c(2);
ll cx,cy;

void dfs(ll t){
  //used[n][t]=1;
  if (t>=100005)cx++;
  if (t<100005)cy++;
  used[t]=1;
  for(ll to:x[t]){
    if (used[to])continue;
    dfs(to);
  }
}


int main() {
  ll N;
  cin >> N;
  vector<P> v(N);


  rep(i,N){
    ll a1,b1;
    cin>>a1>>b1;
    a1--;b1+=100005;
    v[i]=make_pair(a1,b1);
    x[a1].push_back(b1);
    x[b1].push_back(a1);
  }
ll ans=0;
  rep(i,N){
    c[0]=0;c[1]=0;
cx=0;cy=0;
    dfs(v[i].first);
  //  cout<<"i"<<i<<cx<<" "<<cy<<endl;
    ans+=cx*cy;

  }

  ans-=N;
  cout<<ans;

}


Measured memory_bytes: 17292
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define Reverse(a) reverse(All(a))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define Lower(a,t) lower_bound(All(a),t)
using namespace std;
void Debug(auto a);


signed main(){
    int n;
    cin >> n;
    vec(a,100010);
    vec(b,100010);
    vec(c,100010);
    vec(d,100010);
    REP(i,n){
        int t;
        if(i%2==0){
            cin >> t;
            a[t]++;
            c[t]++;
        }
        else{
            cin >> t;
            b[t]++;
            d[t]++;
        }
    }
    Sort(c);
    Sort(d);
    Reverse(c);
    Reverse(d);
    REP(i,100010){
        int a_max = -1;
        int b_max = -2;
        if(a[i] == c[0]){
            a_max = a[i];
        }
        if(b[i] == d[0]){
            b_max = b[i];
        }
        if(a_max == b_max){
            if(d[1]>= c[1]){
                d[0] = d[1];
            }
            else{
                c[0] = c[1];
            }
        }
    }
    cout << n - (d[0] + c[0]) << endl;


    return 0;
}



void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m,n;
    	ll a,b,c;
    	cin>>a>>b>>c;
    	ll x=c-a-b;
    	if(x<0)
    	{
    		cout<<"No";
    		return 0;
    	}
    	x=x*x;
    	ll y=4*a*b;
    	if(x>y)
    		cout<<"Yes";
    	else
    		cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

int main(void){

char num_str[1002];

int num;

long sum=0;

int i;

char tmp;

while(1){

fgets(num_str,sizeof(num_str),stdin);

if(num_str[0]=='0')break;

for(i=0;i<strlen(num_str)-1;i++){

tmp=num_str[i];

num=atoi(&tmp);

sum=sum+num;

}

printf("%d\n",sum);

sum=0;

memset(num_str,1002,0);

}

return 0;

}
 

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100001

ll gcd(ll a, ll b) {
    if(a < b) swap(a, b);
    if (b==0) return a;
    return gcd(b, a%b);
}

int main() {

    int n, d, ans;
    cin >> n >> d;
    for(int i=1; i<21; i++) {
        if (n <= (2*d+1)*i) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;

}



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

    ans = str()
    x = a

    ans = str()
    for i in range(0, 100):
        if x > a + b:
            break
        if x > b:
            x = x % b
        if x == c:
            ans = "YES"
            break
        if i == 100 - 1:
            ans = "NO"
        ##print(f"{i} times {x} {x+a}")
        x += a
    print(ans)

resolve()

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

int main() {
	string s;
	cin >> s;
	int ans = 1<<30;
	for(int i = 0; i < s.size()-2; i++) {
		int num = stoi(s.substr(i,3));
		ans = min(ans,abs(753-num));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = []
for i in range(n):
    s.append(input())
s.sort()
# print(s)
m = 1
cnt = [1]
ans = []
for i in range(1,n):
    if s[i] == s[i-1]:
        cnt[-1] += 1
    else:
        if cnt[-1] > m:
            ans = [s[i-1]]
        elif cnt[-1] == m:
            ans.append(s[i-1])
        m = max(m, cnt[-1])
        cnt.append(1)
    if i == n-1 and cnt[-1] > m:
        ans = [s[i]]
    elif i == n-1 and cnt[-1] == m:
        ans.append(s[i])
print('\n'.join(ans))

Measured memory_bytes: 29632
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = (LL)1e9+7;
const int SIZE = 2e5+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;
const LL MULT = 1e7;

vector<int> adj[200009];
unordered_map<int,int> cc[200009];
bool vis[200009];

vector<PII> c[200009];
PII d[200009];
LL f[200009],inv[200009];

LL expo(LL a,LL b){
	if(b==0)return 1;
	LL h=expo(a,b/2);
	h=(h*h)%MOD;
	if(b%2)h=(h*a)%MOD;
	return h;
}

int ci=0;

void dfs(int x){
	cc[ci][d[x].F]++;
	for(int i:adj[x]){
		if(vis[i])continue;
		vis[i]=1;
		dfs(i);
	}
}

int main(){
	DRIII(n,x,y);
	f[0]=inv[0]=1;
	REPP(i,1,n+1){
		f[i]=(f[i-1]*i)%MOD;
		inv[i]=expo(f[i],MOD-2);
	}
	REP(i,n){
		RII(d[i].F,d[i].S);//col,weight
		d[i].F--;
		c[d[i].F].PB(MP(d[i].S,i));
	}
	PII m1=MP(MOD,0),m2=MP(MOD,0);
	REP(i,n){
		sort(ALL(c[i]));
		REPP(j,1,SZ(c[i])){
			PII a=c[i][0],b=c[i][j];
			if(a.F+b.F<=x){
				adj[a.S].PB(b.S);
				adj[b.S].PB(a.S);
			}
		}
		if(SZ(c[i])){
			if(c[i].front().F<=m1.F){
				m2=m1;m1=c[i].front();
			}
			else if(c[i].front().F<=m2.F){
				m2=c[i].front();
			}
		}
	}
	REP(i,n){
		if(d[i].F!=d[m1.S].F&&m1.F+d[i].S<=y){
			adj[m1.S].PB(i);
			adj[i].PB(m1.S);
		}
		if(d[i].F!=d[m2.S].F&&m2.F+d[i].S<=y){
			adj[m2.S].PB(i);
			adj[i].PB(m2.S);
		}
	}
	REP(i,n){
		if(vis[i])continue;
		vis[i]=1;
		dfs(i);
		ci++;
	}
	LL ans=1;
	REP(i,ci){
		LL sum=0;
		for(PII j:cc[i])sum+=j.S;
		LL cur=f[sum];
		for(PII j:cc[i]){
			cur=(cur*inv[j.S])%MOD;
		}
		ans=(ans*cur)%MOD;
	}
	printf("%lld",ans);
}


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

using namespace std;

typedef long long LL;
const LL MAXN=128;
const LL MAXK=100000+100;
const LL MOD=1e9+7;
LL a[MAXN],dp[MAXN][MAXK],sum[MAXN][MAXK];
LL n,k;

int main(){
	cin>>n>>k;
	for(LL i=1;i<=n;i++){
		cin>>a[i];
	}
	dp[0][0]=1;
	sum[0][0]=1;
	for(LL i=1;i<=k;i++){
		sum[0][i]=1;
	}
	for(LL i=1;i<=n;i++){
		for(LL j=0;j<=k;j++){
			if(a[i]+1>j) dp[i][j]=(dp[i][j]+sum[i-1][j])%MOD;
			else dp[i][j]=(dp[i][j]-sum[i-1][j-a[i]-1]+MOD+sum[i-1][j])%MOD;
		//	dp[i][j]=(sum[j]+mod-(j-a[i]-1<0?0:sum[j-a[i]-1]))%mod;
			if(j) sum[i][j]=(sum[i][j-1]+dp[i][j])%MOD;
			else sum[i][j]=dp[i][j];
		}
	}

	cout<<dp[n][k]<<endl;
	return 0;
}


Measured memory_bytes: 162176
#include <iostream>
#include <cmath>

using namespace std;

bool prime[10000001];


int main() {

  int n;
  
  prime[0]=prime[1]=false;

  for(int i=2;i<=10000000;i++) prime[i]=true;

  for(int i=2;i<=sqrt(10000000);i++) {

    if(prime[i]==true) {

      for(int j=2*i;j<=10000000;j+=i) {

	prime[j]=false;

      }

    }

  }

  //for(int i=0;i<=10000000;i++) if(prime[i]==true) cout << i << " ";

  while(cin >> n) {

    if(n==0) break;

    for(int i=n;i>=13;i--) {

      if(prime[i]==true && prime[i-2]==true && prime[i-6]==true && prime[i-8]==true) {

	cout << i << endl;
	
	break;

      }

    }

  }

  return 0;

}

Measured memory_bytes: 10000
a,b=map(int,input().split())
l=[]
for _ in range(a):
    l1=input()
    l.append(l1)
flag=True
for i in range(b):
    for j in range(a):
        if i>=1 and j!=a-1 and l[j][i]=='#':
            for k1 in range(i):
                for k2 in range(j+1,a):
                    if l[k2][k1]=='#':
                        flag=False
                        break
for i in range(b):
    for j in range(a):
        if i!=b-1 and j>=1 and l[j][i]=='#':
            for k3 in range(j):
                for k4 in range(i+1,b):
                    if l[k3][k4]=='#':
                        flag=False
                        break
if flag==True:
    print('Possible')
else:
    print('Impossible')
    

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

#define ll long long

int main(){
	ll n,i,j,k,ans=0;
	cin >> n;
	string s;
	unordered_set<string> stringset;
	for(i=0;i<n;i++){
		cin >> s;
		stringset.insert(s);
	}
	cout << stringset.size();
	return 0;
}

Measured memory_bytes: 17728
/*
    if you can't see the repay
    Why not just work step by step
    rubbish is relaxed
    to ljq
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
using namespace std;

#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define lc (rt<<1)
#define rc (rt<<11)
#define mid ((l+r)>>1)

typedef pair<int,int> pll;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll _INF = 0xc0c0c0c0c0c0c0c0;
const ll mod =  (int)1e9+7;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}
void exgcd(ll a,ll b,ll &x,ll &y,ll &d){if(!b) {d = a;x = 1;y=0;}else{exgcd(b,a%b,y,x,d);y-=x*(a/b);}}//printf("%lld*a + %lld*b = %lld\n", x, y, d);
const int MAX_N = 3025;
char str[MAX_N],str_[MAX_N];
int dp[MAX_N][MAX_N];
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    scanf("%s",str+1);
    scanf("%s",str_+1);
    int len = strlen(str+1),len_ = strlen(str_+1);
    for(int i = len;i>=1;--i)
    {
        for(int j = len_;j>=1;--j)
        {
            if(str[i]==str_[j])  dp[i][j] = dp[i+1][j+1]+1;
            else dp[i][j] = max(dp[i+1][j],dp[i][j+1]);
        }
    }
    int l = 1,r = 1;
    while(l<=len&&r<=len_)
    {

        if(str[l]==str_[r])
        {
            printf("%c",str[l]);
            l++,r++;
        }
        else if(dp[l][r]==dp[l+1][r]) l++;
        else r++;
    }
    printf("\n");
    //fclose(stdin);
    //fclose(stdout);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 35712
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long h1,m1,h2,m2,k,a,b,c,d;
cin>>h1>>m1>>h2>>m2>>k;
a=(h2-h1)*60+m2-m1;
cout<<abs(a-k)<<endl;






}


Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, k;
	cin >> n >> k;

	int r, s, p;
	cin >> r >> s >> p;

	string match;
	cin >> match;

	map<char, int> win;
	win['r'] = p;
	win['s'] = r;
	win['p'] = s;

	vector<int> points(n);
	for (int i = 0; i < k; ++i) {
		points[i] = win[match[i]];
	}

	for (int i = k; i < n; ++i) {
		if (match[i] == match[i - k]) {
			if (points[i - k]) {
				points[i] = 0;
			} else {
				points[i] = win[match[i]];
			}
		} else {
			points[i] = win[match[i]];
		}
	}

	int score = 0;
	for (int i = 0; i < n; ++i) {
		score += points[i];
	}

	cout << score << "\n";

	return 0;

}

Measured memory_bytes: 848
N, M = map(int, input().split())
x = list(map(int, input().split()))

x.sort()
diffx = [x[i+1]-x[i] for i in range(M-1)]
diffx.sort(reverse = True)

if M == 1:
    print(0)
else:
    tmp = sum(diffx[:(N-1)])
    print(x[-1] - x[0] - tmp)

Measured memory_bytes: 57512
// Code by H~$~C
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, k, s;
  cin >> n >> k >> s;
  vector<int> arr;
  for (int i = 0; i < k; ++i) {
    arr.push_back(s);
  }
  for (int i = k; i < n; ++i) {
    arr.push_back((s + 1) % 1000000000);
  }
  for (int i = 0; i < n; ++i) {
    cout << arr[i] << " \n"[i == n - 1];
  }
  return 0;
}


Measured memory_bytes: 1784
n, m = map(int, input().split())
x = []
y = []
for i in range(m):
    xi, yi = map(int, input().split())
    x.append(xi)
    y.append(yi)
num = [1]*n
able = [False]*n
able[0] = True
for i in range(m):
    if able[x[i]-1] == True:
        able[y[i]-1] = True
    num[x[i]-1] -= 1
    num[y[i]-1] += 1
    if num[x[i]-1] == 0:
        able[x[i]-1] = False
print(sum(able))

Measured memory_bytes: 12540