akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    // 入力
    string S; cin >> S;
    int n = (int)S.size();

		vector<int> child(S.size());

	  int i = 0;

	  while (i < S.size()){
	    if(S[i]=='R'){
	      for (int j = 0; j < S.size()-i; j++)
	      {
	        if (S[i + j] == 'L')
	        {
	          if (j % 2 == 1)
	          {
	            child[i + j - 1] += j/2+1;
	            child[i + j ] += j / 2 ;
	          }
	          else
	          {
	            child[i + j - 1] += j / 2;
	            child[i + j] += j / 2;
	          }
	          i = i + j;
	          break;
	        }
	      }
	    }
	    else{
	      for (int j = 0; j < S.size()-i; j++)
	      {
	        if (S[i + j] == 'R')
	        {
	          if (j % 2 == 1)
	          {
	            child[i] += j / 2 + 1;
	            child[i - 1] += j / 2;
	          }
	          else
	          {
	            child[i] += j / 2;
	            child[i - 1] += j / 2;
	          }
	          i = i + j;
	          break;
	        }
	        else if(i+j==S.size()-1){
	          if (j % 2 == 1)
	          {
	            child[i] += j / 2 + 1;
	            child[i - 1] += j / 2+1;
	          }
	          else
	          {
	            child[i] += j / 2+1;
	            child[i - 1] += j / 2;
	          }
	          i = i + j+1;
	          break;
	        }
	      }
	    }

}
	  for (int i = 0; i < S.size();i++){
	    cout << child[i] << " ";
	  }
	  cout << "" << endl;
  
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,d[1<<19],i,j,k,l,p[1<<19],x,y;
bool f;
main(){
  for(cin>>n;i<n;p[i]++,p[i+d[i]/10]--,++i)cin>>d[i];
  for(;j<n;x<1?f=1:0)x+=p[j++];
  fill(p,p+n,0);
  for(reverse(d,d+n);k<n;p[k]++,p[k+d[k]/10]--,++k);
  for(;l<n;y<1?f=1:0)y+=p[l++];
  cout<<(f?"no\n":"yes\n");
}

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int a,b; char op; cin>>a>>op>>b;
    if(op == '+') cout<<a+b<<endl;
    else cout<<a-b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll n,m; cin>>n>>m;
	if(n>m) swap(n,m);
	if(n==1)
	{
		if(m==1) cout<<1<<'\n';
		else cout<<m-2<<'\n';
	}
	else
	{
		cout<<(m-2)*(n-2)<<'\n';
	}
}


Measured memory_bytes: 256
n = int(input())
p = [int(i) for i in input().split()]

pos_list = [0] * n
for ind, i in enumerate(p):
	pos_list[i-1] = ind

left_nextInd = list(range(-1, n-1)) + [-1, -1]
right_nextInd = list(range(1, n+1)) + [n, n]

answer = 0
for i in range(1, n):
	ind = pos_list[i-1]
	l1 = left_nextInd[ind]
	l2 = left_nextInd[l1]
	r1 = right_nextInd[ind]
	r2 = right_nextInd[r1]

	answer += i * ((ind-l1) * (r2-r1) + (r1-ind) * (l1-l2))

	left_nextInd[r1] = l1
	right_nextInd[l1] = r1
print(answer)

Measured memory_bytes: 19580
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define allr(x) (x).rbegin(),(x).rend()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N,H; cin>>N>>H;
	vi B;
	int maxA = 0;
	rpz(i, N){
		int a,b; cin>>a>>b;
		B.push_back(b);
		maxA = max(maxA, a);
	}
	sort(allr(B));
	int count = 0;
	for(int i=0; i<N && H>0 && B[i]>maxA; ++i){
		H -= B[i];
		count++;
	}
	if(H > 0) count += (H+maxA-1)/maxA;//round up
	cout<< count <<endl;
}

Measured memory_bytes: 892
n = int(input())

l = list(map(int,input().split()))

ans = 0
c = 0

for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k] + l[i] > l[j]:
                c += 1
                #print("aa",l[i],l[j],l[k])
                if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                    c += 1
                else:
                    #print(l[i],l[j],l[k])
                    ans += 1
                    c += 1

print(ans)

Measured memory_bytes: 9240
R, G, B, N = gets.split.map(&:to_i)
ans = 0
(0..(N / R)).each do |r|
  (0..(N / G)).each do |g|
    rest = N - (R * r + G * g)
    if rest >= 0 && rest % B == 0
      ans += 1
    end
  end
end
puts ans


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    int n; cin >> n;
    vll t(n);
    rep(i, n) cin >> t[i];

    ll ans = 1;
    rep(i, n) {
        ans = lcm(ans, t[i]);
    }

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

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string s;
  cin >> s;
  int N = sz(s);
  int pcnt = 0;
  int ans = 0;
  rep(i,N) {
    if(s[i] == 'g') {
      if(pcnt < i-pcnt) {
        ans++;
        pcnt++;
      }
    } else {
      if(pcnt < i-pcnt) {
        pcnt++;
      } else {
        ans--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    string x , y ;
    ll table[3005][3005] ;
    while( cin >> x >> y ){
        for( int i = 0; i <= x.size(); i++ ){
            for( int j = 0; j <= y.size(); j++ ){
                if( i == 0 || j == 0 ){
                    table[i][j] = 0;
                }
                else if( x[i-1] == y[j-1] ){
                    table[i][j] = table[i-1][j-1]+1;
                }
                else{
                    table[i][j] = max( table[i-1][j] , table[i][j-1] ) ;
                }
            }
        }
        string ans = "";
        int i = x.size() , j = y.size();
        while( i > 0 && j > 0 ){
            if( x[i-1] == y[j-1] ){
                ans = ans+x[i-1];
                i--;j--;
            }
            else if( table[i-1][j] > table[i][j-1] ){
                i--;
            }
            else{
                j--;
            }
        }
        reverse(ans.begin(),ans.end());
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 70784
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int k = scanner.nextInt();
		int ans = 0;

		for (int i = 0; i < n; i++) {
			int x = scanner.nextInt();
			ans += Math.min(Math.abs(x - k), x) * 2;
		}

		System.out.println(ans);
	}
}


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

int main(){
  string n;
  cin>>n;
  vector<string>str(4);
  for(int i=0;i<4;i++)str[i]=n.at(i);
  vector<int>num(4);
  for(int i=0;i<4;i++)num[i]=stoi(str[i]);
  int a=num[0];
  int b=num[1];
  int c=num[2];
  int d=num[3];
  if(a+b+c+d==7)cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
  else if(a+b+c-d==7)cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
  else if(a+b-c+d==7)cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
  else if(a+b-c-d==7)cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
  else if(a-b+c+d==7)cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
  else if(a-b+c-d==7)cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
  else if(a-b-c+d==7)cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
  else if(a-b-c-d==7)cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

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

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

long long int a[110000], LIS[110000];

int main(){
	
	int N;
	cin >> N;
	
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}
	
	for(int i = 0; i < N; i++){
		LIS[i] = INF;
	}
	
	bool flag = false;
	
	for(int i = 0; i < N; i++){
		int pos = lower_bound(LIS, LIS + N, a[i]) - LIS;
		LIS[pos] = a[i];
	}
	
	int num = (int)(lower_bound(LIS, LIS + N, INF) - LIS);
	
	cout << num << endl;
	
	return 0;
}


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

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int N;
    scan(N);
    auto x = readln.split.to!(int[]);
    int L, Q;
    scan(L);
    scan(Q);

    auto dp = new int[][](N, 20);
    int r = N - 1;
    foreach_reverse (i ; 0 .. N) {
        while (x[r] - x[i] > L) {
            r--;
        }
        assert(r >= i);
        dp[i][0] = r;
    }
    foreach (j ; 1 .. 20) {
        foreach (i ; 0 .. N) {
            dp[i][j] = dp[dp[i][j - 1]][j - 1];
        }
    }

    debug {
        writefln("%(%s\n%)", dp);
    }

    foreach (_ ; 0 .. Q) {
        int a, b;
        scan(a, b);
        a--, b--;
        if (a > b) swap(a, b);
        int ans;
        foreach_reverse (i ; 0 .. 20) {
            if (a == b) break;
            if (dp[a][i] < b) {
                a = dp[a][i];
                ans += 1 << i;
            }
        }
        assert(a <= b);
        if (a < b) ans++;
        writeln(ans);
    }
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 23600
"use strict";
function main(input) {
  const inputs = input.split("\n").filter(x => x !== "");

  let S = inputs[0];

  let minSub = Number.MAX_VALUE;
  for (let i = 0; i <= S.length - 3; i++) {
    let number = Number(S[i] + S[i + 1] + S[i + 2]);
    let sub = Math.abs(753 - number);

    if (sub < minSub) {
      minSub = sub;
    }
  }

  console.log(minSub);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7496
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
  int n;
  rep(i,INF){
    cin>>n;
    if(!n) return;
    cout<<"Case "<<i+1<<": "<<n<<endl;
  }
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1160
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int N = in.i();
        int ans = (N+1)/2;
        out.println(ans);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


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

int main(){
	string s;
	cin >> s;
	rep(i,s.size()-1){
		if(s[i] == s[i+1]){
			cout << i+1 << " " << i+2 << endl;
			return 0;
		}
	}
	rep(i,s.size()-2){
		if(s[i] == s[i+2]){
			cout << i+1 << " " << i+3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
    return 0;
}

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

typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

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

  int N = 13;
  vector<ll> dp(N, 0);
  dp[0] = 1;

  for (int i = 0; i < s.size(); i++) {
    vector<ll> next(N, 0);
    char c = s[i];
    if (c == '?') {
      for (int k = 0; k < 10; k++) {
        for (int j = 0; j < N; j++) {
          next[(j * 10 + k) % N] += dp[j];
          next[(j * 10 + k) % N] %= MOD;
        }
      }
    } else {
      ll k = c - '0';
      for (int j = 0; j < N; j++) {
        next[(j * 10 + k) % N] += dp[j];
        next[(j * 10 + k) % N] %= MOD;        
      }
    }
    dp = next;
  }
  cout << dp[5] << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int x;
cin >> x;
if( x<1200) {
  cout << "ABC" << endl;
} else {
  cout << "ARC" << endl;
}
return 0;
}


Measured memory_bytes: 256
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


bool solve(int L, int N, int R, in string S, in string T, char plus, char minus) {
  int a = 1, b = L;
  foreach_reverse (i; 0 .. N) {
    if (T[i] == plus) {
      if (a > 1) {
        --a;
      }
    } else if (T[i] == minus) {
      if (b < L) {
        ++b;
      }
    }
    if (S[i] == plus) {
      --b;
    } else if (S[i] == minus) {
      ++a;
    }
    
    if (a > b) {
      return false;
    }
  }
  return (a <= R && R <= b);
}

void main() {
  try {
    for (; ; ) {
      const H = readInt();
      const W = readInt();
      const N = readInt();
      const RX = readInt();
      const RY = readInt();
      const S = readToken();
      const T = readToken();
      
      const resX = solve(H, N, RX, S, T, 'D', 'U');
      const resY = solve(W, N, RY, S, T, 'R', 'L');
      writeln((resX && resY) ? "YES" : "NO");
    }
  } catch (EOFException e) {
  }
}


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

using namespace std;

//freopen("input.txt", "r", stdin);

void construct_segment_tree(vector<int>& segtree,
							vector<int>& a, int n)
{
	// assign values to leaves of the segment tree
	for (int i = 0; i < n; i++)
		segtree[n + i] = a[i];

	/* assign values to internal nodes
	to compute maximum in a given range */
	for (int i = n - 1; i >= 1; i--)
		segtree[i] = max(segtree[2 * i],
						segtree[2 * i + 1]);
}

void update(vector<int>& segtree, int pos, int value,
			int n)
{
	// change the index to leaf node first
	pos += n;

	// update the value at the leaf node
	// at the exact index
	segtree[pos] = value;

	while (pos > 1) {

		// move up one level at a time in the tree
		pos >>= 1;

		// update the values in the nodes in
		// the next higher level
		segtree[pos] = max(segtree[2 * pos],
						segtree[2 * pos + 1]);
	}
}

int range_query(vector<int>& segtree, int left, int right, int n)
{
	/* Basically the left and right indices will move
		towards right and left respectively and with
		every each next higher level and compute the
		maximum at each height. */
	// change the index to leaf node first
	left += n;
	right += n;

	// initialize maximum to a very low value
	int ma = INT_MIN;

	while (left < right) {

		// if left index in odd
		if (left & 1) {
			ma = max(ma, segtree[left]);

			// make left index even
			left++;
		}

		// if right index in odd
		if (right & 1) {

			// make right index even
			right--;

			ma = max(ma, segtree[right]);
		}

		// move to the next higher level
		left /= 2;
		right /= 2;
	}
	return ma;
}

// Driver code
int main()
{
    int N;
    while(cin>>N){
        vector<int> a;
        while(N--){
            int temp;
            cin>>temp;
            a.push_back(temp);
        }
        int n = a.size();
        int save_value = -1;
        vector<int> segtree(2 * n);
        construct_segment_tree(segtree, a, n);

        for(int i=0; i<n;i++){
            save_value = a[i];
            update(segtree, i, 0, n);
            cout<<range_query(segtree, 0, n, n)<<endl;
            update(segtree, i, save_value, n);
        }
    }
	return 0;
}




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

int main() {
    int n;
    int m;
 
   cin >> n >> m;
  
   
  
   if(n <= 8 && m <= 8){
    
      cout << "Yay!" << endl;
   }else{
      cout << ":(" << endl;
     
   }
  
  
  
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [0] * N
for i in range(N):
    A[i] = int(input())

maxA = max(A)
index = A.index(maxA)
A.sort()

for i in range(N):
    if i == index:
        print(A[-2])
    else:
        print(A[-1])

Measured memory_bytes: 14332
#include <iostream>
#include <queue>
#include <vector>
#include <string>

int main()
{
    std::priority_queue<int> q;
    int a;
    std::string s;

    while (1)
    {
        std::cin >> s;
        if (s.at(0) == 'i')
        {
            std::cin >> a;
            q.push(a);
        }
        else if (s.at(1) == 'x')
        {
            std::cout << q.top() << std::endl;
            q.pop() ;
        }
        else
        {
            break ;
        }
        
    }
    return 0 ;
}


Measured memory_bytes: 6928
eval"N,C,*H="+`dd`.split*?,;g,*q=->i{x,y=q[i,2];1.0*($*[x]-$*[y])/(H[y]-x=H[x])-x-H[y]};N.times{|i|q.shift while q[-2]&&g[0]>-2*H[i];$*<<X=i>0?$*[q[0]]+C+(H[q[0]]-H[i])**2:0;q.pop 2while(q<<i)[-3]&&g[-2]>g[-3]};p X

Measured memory_bytes: 85776
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 1000000007
const int MAX = 210000;
using namespace std;
long long fac[MAX], finv[MAX], inv[MAX];
vector <pair<ll,ll> >prime(ll n){
    vector<pair<ll,ll>>res;
    for(ll p=2;p*p<=n;p++){
        if(n%p!=0)continue;
        ll num=0;
        while(n%p==0){
            num++;
            n/=p;
        }
        res.push_back(make_pair(p,num));
        
    }
    if(n!=1){
        res.push_back(make_pair(n,1));
    }
    return res;
}
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){
    int n,m;
    cin>>n>>m;
    COMinit();
    auto p=prime(m);
    ll ans=1;
    for(auto val:p){
        int a=val.second;
        ans=(ans*(COM(a+n-1,n-1)))%MOD;
    }
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9+5;

int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  int dp[n]={0};
  dp[1]=abs(a[0]-a[1]);
  for(int i=2;i<n;i++){
      int ans=INF;
      for(int j=1;j<=i and j<=k;j++){
          ans=min(ans,(dp[i-j]+abs(a[i]-a[i-j])));
      }
      dp[i]=ans;
  }
  cout<<dp[n-1];
  return 0;
}

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

int main()
{
    int n , i , ans =0 , A[100]={0} , B[100]={0} , C[100]={0};

    cin>>n;

    for(i=0;i<n;i++)
    {
        cin>>A[i];
    }

    for(i=0;i<n;i++)
    {
        cin>>B[i];
    }

    for(i=1;i<n;i++)
    {
        cin>>C[i];
    }

    for(i=0;i<n;i++)
    {


        if(A[i] + 1 == A[i+1] && i!=n-1 )
        {
           // cout<<A[i]+1<<" "<<A[i+1]<<endl;
            ans += B[i] + C[A[i]];
        }
        else ans += B[i];

        //cout<<ans<<endl;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc054/tasks/abc054_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    REP(i, n) cin >> a[i];
    REP(i, m) cin >> b[i];
    REP(i, n - m + 1) REP(j, n - m + 1) {
        int flag = true;
        REP(k, m) REP(l, m) {
            if (a[i + k][j + l] != b[k][l]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main (void)
{
    long long A=0;
    int N,i;
    long long cul,bef;
    char c;

    scanf("%d",&N);
    scanf("%c",&c);

    scanf("%lld",&bef);
    scanf("%c",&c);

    A+=bef;

    if(N>2){
        for(i=1;i<N-1;i++){
            scanf("%d",&cul);
            scanf("%c",&c);

            if(bef<cul){
                //printf("ad b %d\n",bef);
                A+=bef;
                bef=cul;
            }else{
                //printf("ad c %d\n",cul);
                A+=cul;
                bef=cul;
            }
        }
    }//end if

    A+=bef;

    printf("%lld",A);



    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)N;i++)
#define p(s) cout<<(s)<<endl
using namespace std;

int main() {
	int five=0,seven=0;
	REP(i,0,3) {
		int a;
		cin>>a;
		if(a==5) five++;
		else if(a==7) seven++;
	}
	if(five==2&&seven==1) p("YES");
	else p("NO");
	return 0;
}

Measured memory_bytes: 256
#%%
n, k, s = map(int, input().split())
ans = []
tmp = 0
for i in range(n):
    if i < k :
        tmp = s
    else:
        if s == 10**9:
            tmp = 10**9-1
        else:
            tmp = 10**9
    ans.append(str(tmp))
print(' '.join(ans))




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

using namespace std;
using i64 = std::int_fast64_t;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  int K;
  cin >> S >> K;
  int N = (int)S.size();
  vector<vector<vector<i64>>> dp(N + 1,
                                 vector<vector<i64>>(2, vector<i64>(K + 2, 0)));
  dp[0][0][0] = 1;
  for (int d = 0; d < N; d++) {
    for (int is_less = 0; is_less < 2; is_less++) {
      for (int k = 0; k < K + 1; k++) {
        int c = S[d] - '0';
        for (int nxt = 0; nxt < 10; nxt++) {
          if (c < nxt && is_less == 0) continue;

          int nis_less = is_less;
          if (nxt < c) nis_less = 1;

          int nk = k + (nxt == 0 ? 0 : 1);

          dp[d + 1][nis_less][nk] += dp[d][is_less][k];
        }
      }
    }
  }
  cout << dp[N][0][K] + dp[N][1][K] << '\n';
  return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
import bisect


class Bit():
    def __init__(self, N):
        self.size = N
        self.bit = [0] * (self.size+1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.bit[i] += x
            i += i & -i

    def __str__(self):
        return str(self.bit)


N, K = map(int, input().split())
A = [-10**9] + [int(input()) for i in range(N)]

diff = [a - K for a in A]
diff = list(accumulate(diff))
graph = Bit(N+1)
temp = sorted(diff)
order = [bisect.bisect_right(temp, d) for d in diff]
ans = 0

for x in order:
    ans += graph.sum(x)
    graph.add(x, 1)

print(ans)

Measured memory_bytes: 81960
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    
    while(cin >> a >> b >> c)
    {
        cout << (a + b + (55 - a - b - c) / 7 <= 20 ? "YES" : "NO") << endl;
    }
    
    return 0;
}

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

int main() {
    ll l, r;
    cin >> l >> r;

    if(r - l >= 2019) {
        l %= 2019;
        r = l + 2019;
    }

    ll ans = 2019;
    for(ll i = l; i < r; i++) {
        for(ll j = i + 1; j <= r; j++) {
            ans = min(ans, (i * j) % 2019);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

#define Max 110000
int N;
int h[Max];
ll dp[Max];

int main(int argc, const char * argv[]) {
    N = inputValue();
    inputArray(h, N);

    memset(dp, -1, N+1);

    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);

    repd(i, 2, N) {
        dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]));
    }

    output(dp[N-1]);

    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
//typedef pair<int, int> P;

/** Problem1145 : The Genome Database of All Space Life**/
string s, ret;
int pos, idx;
// <code> := <num> <c> | <num> ( <code> ) | <num> ( <code> <code> ) | ...
// <num> := <digit> | <digit> <num>
// <c> := A | B | ... | Z

string factor()
{
	if ('A' <= s[pos] && s[pos] <='Z') {
		
	}
}

string formula()
{
	string ret="";
	
	if ('A' <= s[pos] && s[pos] <= 'Z') {
		ret = s[pos];
		pos++;
	} else if (isdigit(s[pos])) {
		int num = 0;
		while (isdigit(s[pos])) {
			num*=10;
			num+=s[pos]-'0';
			pos++;
		}
		string ss = formula();
		rep(i, num) {
			ret += ss;
			if (ret.size()>idx)
				break;
		}
	} else if (s[pos] == '(') {
		pos++;
		while (s[pos] != ')') {
			ret += formula();
		}
		pos++;
	}
	
	return ret;
}

int main()
{
	while (cin>>s>>idx, s!="0"||idx) {
		pos = 0;
		ret = "";
		
		while (pos != s.size()) {
			ret += formula();
			if (ret.size() > idx)
				break;
		}
		
		if (idx>=ret.size())
			cout << 0 << endl;
		else
			cout << ret[idx] << endl;
	}
}

Measured memory_bytes: 7472
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
#include <complex>
using namespace std;
int main()
{
    int a,b,sum;
    cin>>a>>b;
    sum=a*b;
    if(sum%2==0) cout<<"Even";
    else cout<<"Odd";
    //system ("pause"); 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

const long long baseNum = 2,bases[] = {10007,10009};

template<long long mod = 1000000007>
struct RollingHash{
	using ll = long long;
	vector<ll> hashes[baseNum],powers[baseNum];
	RollingHash(string &s){
		int n = s.length();
		for(int i = 0;i < baseNum;i++){
			hashes[i].resize(n + 1,0);
			powers[i].resize(n + 1,1);
			for(int j = 0;j < n;j++){
				powers[i][j + 1] = powers[i][j] * bases[i] % mod;
				hashes[i][j + 1] = (hashes[i][j] * bases[i] + s[j]) % mod;
			}
		}
	}
	inline ll getHash(int l,int r,int b){
		return (hashes[b][r] - hashes[b][l] * powers[b][r - l] % mod + mod) % mod;
	}
	ll getHash(int l = 0,int r = -1){
		if(r == -1) r = hashes[0].size() - 1;
		return getHash(l,r,0) * mod + getHash(l,r,1);
	}
};

int n;
string s;

bool isOK(int x,RollingHash<> &rh){
	map<int,int> ind;
	for(int j = 0;j + x <= n;j++){
		int hash = rh.getHash(j,j + x);
		if(!ind.count(hash)) ind[hash] = j;
		else if(ind[hash] <= j - x) return true;
	}
	return false;
}

signed main(){
	cin >> n >> s;
	RollingHash<> rh(s);
	int ok = 0,ng = n;
	while(ng - ok > 1){
		int mid = (ng + ok) / 2;
		if(isOK(mid,rh)) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}


Measured memory_bytes: 768
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"from fractions import*;input();a,*b=map(int,input().split())\n"
"for i in b:a=gcd(a,i)\n"
"print(a)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 16588
#include <stdio.h>

int main(void) {
   int a,b,N,s,f,i;
   scanf("%d %d",&a,&b);
   scanf("%d",&N);
   for(i=0;i<N;i++){
      scanf("%d %d",&s,&f);
      if(!(b<=s || a>=f)){printf("1\n");return 0;}
   }
   printf("0\n");
   return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define fi first
#define sec second
#define pr priority_queue
ll maxn = 1000003;
vector<ll> v;
void sieve()
{
    vector<bool> is(maxn, true);
    for (ll i = 4; i < maxn; i += 2)
        is[i] = false;
    for (ll i = 3; i * i < maxn; i++)
    {
        if (is[i])
        {
            for (ll j = i * i; j < maxn; j += i)
                is[j] = false;
        }
    }
    for (ll i = 2; i < maxn; i++)
    {
        if (is[i])
            v.push_back(i);
    }
    return ;
}
vector<ll> spf(maxn);
void prime()
{
    for (ll i = 1; i < maxn; i++)
        spf[i] = i;
    for (ll i = 4; i < maxn; i += 2) spf[i] = 2;
    for (ll i = 3; i * i < maxn; i++)
    {
        if (spf[i] == i)
        {
            for (ll j = i * i; j < maxn; j += i)
                if (spf[j] == j)
                    spf[j] = i;
        }
    }
    return ;
}
vector<ll> get(ll x)
{
    vector<ll> ftrs;
    while (x != 1)
    {
        ftrs.push_back(spf[x]);
        x = x / spf[x];
    }
    return ftrs;
}
void dfs(vector<vector<ll> > &vec, vector<ll> &sz, ll par, ll x)
{
    ll n = vec[x].size();
    sz[x] = 1;
    for (ll i = 0; i < n; i++)
    {
        ll v = vec[x][i];
        if (v != par)
        {
            dfs(vec, sz, x, v);
            sz[x] += sz[v];
        }
    }
    return ;
}
ll mod = 1000000007;
ll func(ll s, vector<ll> &dp)
{
    if (s == 0) return 1;
    if (s < 3) return 0;
    if (dp[s] != -1) return dp[s];
    ll v = 0;
    for (ll i = 3; i <= s; i++)
    {
        v = (v + func(s - i, dp)) % mod;
    }
    return dp[s] = v;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll s; cin >> s;
    vector<ll> dp(s + 1, -1);
    ll ans = func(s, dp);
    cout << ans << "\n";
    return 0;
}

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

int main()
{
int x,p;
    cin>>x;
    if(400<=x && x<600)
        p=8;
    else if(600<=x && x<800)
        p=7;
    else if(800<=x && x<1000)
        p=6;
   else if(1000<=x && x<1200)
        p=5;
   else if(1200<=x && x<1400)
        p=4;
   else if(1400<=x && x<1600)
        p=3;
   else if(1600<=x && x<1800)
        p=2;
   else 
        p=1;
    cout<<p;
	return 0;
}

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

int n;
vector<int> p;

string solve();

int main() {
  cin >> n;
  p.assign(n, 0);
  for(int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    p[--a] = i;
  }
  cout << solve() << endl;
  return 0;
}

string solve() {
  int now = 0, nows = 0;
  string ans;
  stack<int> st;
  while(st.size() > 0 || nows < n) {
    if(nows < n) st.push(p[nows++]);
    ans += '(';
    while(st.size() > 0 && now == st.top()) {
      ans += ')';
      ++now;
      st.pop();
    }
    if(st.size() > 0 && nows >= n) return ":(";
  }
  return ans;
}


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

int main(){
  ll N, M;
  cin >> N >> M;

  cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
  
  return 0;
}

Measured memory_bytes: 256
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0];
  var up=1;
  var down=0;
  var nup,ndown;
  for(var i=0;i<N.length;i++){
    nup=Math.min(9-N[i]+up,1+down+(N[i]-0));
    ndown=Math.min(10-N[i]+up,down+(N[i]-0));
    up=nup;
    down=ndown;
  }
  console.log(down);

}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  



  


Measured memory_bytes: 34708
#include <bits/stdc++.h>  // ver1.8
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int n,k;
  cin >> n >> k;
  if(n>=2*k-1) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pii pair<int,int>
#define reset(x,n) memset((x),(n),sizeof(x))
#define all(n) (n).begin(),(n).end()
#define pb push_back
#define IOS ios::sync_with_stdio(0),cin.tie(0);
int gd[25][25];
ll dp[2100000];
vector<int> go[25];
const ll mod = 1000000007;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>gd[i][j];
		}
	}
	for(int i=0;i<(1<<n);i++){
		go[__builtin_popcount(i)].pb(i);
	}
	dp[0] = 1;

	for(int i=0;i<n;i++){
		for(auto k:go[i]){
			for(int j=0;j<n;j++){
				if(gd[i][j] && !(k&(1<<j))){
					dp[k|(1<<j)] = (dp[k|(1<<j)]+dp[k])%mod;
				}
			}
		}
	}
	

	
	cout<<dp[(1<<n)-1]<<'\n';
}


Measured memory_bytes: 26044
// ABC145-D
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る

ll modpow(ll x,ll y,ll mod){
    if(y==0) return 1;
    if(y==1) return x%mod;
    if(y%2==1) return x*modpow(x,y-1,mod)%mod;
    ll t=modpow(x,y/2,mod);
    return t*t%mod;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    ll x,y;
    ll mod=pow(10,9)+7;
    cin>>x>>y;
    if((2*x-y)%3==0){
        ll b=(2*x-y)/3;
        ll a=x-2*b;
        if(a>=0 && b>=0){
            vector<ll> fact(a+b+10,0);
            fact[0]=1;
            for(int i=1;i<=a+b;i++){
                fact[i]=fact[i-1]*i%mod;
            }
            vector<ll> invfact(a+b+10,0);
            invfact[a+b]=modpow(fact[a+b],mod-2,mod);
            for(int i=a+b-1;i>=0;i=i-1){
                invfact[i]=invfact[i+1]*(i+1)%mod;
            }
            ll ans=fact[a+b]*invfact[a]%mod*invfact[b]%mod;
            cout<<ans<<endl;
        }else cout<<0<<endl;
    }else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 13760
#include <bits/stdc++.h>
 
using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> R[i];
  }

  int minv = R[0];
  int maxv = -1000000000;
  for (int i = 1; i < n; i++) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }
  cout << maxv << endl;
  return 0;
}


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

using namespace std;

int main() {
  	int n,k;
  	cin>>n>>k;
  	int p[n];
  	for(int i=0; i<n; ++i)
      	cin>>p[i];
 	sort(p,p+n);
  	cout<<accumulate(p,p+k,0);
	return 0;
}

Measured memory_bytes: 3636
n = int(input())
h = []
for i in range(n):
    h.append(float(input()))
temp = [165., 170., 175., 180., 185., 190.]
h.sort()
t = 0
ans = [0 for i in range(6)]
for i in h:
    while i >= temp[t]:
        t += 1
    ans[t] += 1
for i in range(6):
    print(str(i+1) + ':' + '*' * ans[i])


Measured memory_bytes: 5612
#include<iostream>
#include<fstream>
#include<vector>
#include<unordered_map>
#include<algorithm> 

using namespace std;

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int N;
  cin>>N;

  unordered_map<string,long> mp;

  long ans=0;

  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    sort(S.begin(),S.end());
    //cout<<S<<endl;
    mp[S]++;
  }

  //for(auto p:mp){
  //  auto k = p.first;
  //  auto t = p.second;
  //  cout<<k<<','<<t<<endl;
  //}

  for(auto p:mp){
    auto t=p.second;
    //cout<<t<<endl;
    long temp=0;
    while(t>0){
      t-=1;
      temp+=t;
    }
    //cout<<"temp"<<temp<<endl;
    ans+=temp;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	int r,g,b,n,ans=0,call=0;cin>>r>>g>>b>>n;
	for(int i=0;i*r<=n;i++){
		for(int j=0;j*g<=n;j++){
			call++;
			int t = n-(i*r+j*g);
			if(t>=0 && !(t%b)){
				ans++;
			}
		}
	}
	cout<<ans;//" "<<call;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	double a, b, x;
	cin >> a >> b >> x;

	x /= a;

	cout << fixed << setprecision(10);
	if (x < a * b / 2.0) {
		double y = 2.0 * x / b;
		cout << atan2(b, y) * 180 / 3.14159265358979; 
	}
	else {
		double y = (2.0 * a * b - 2.0 * x) / a;
		cout << atan2(y, a) * 180.0 / 3.14159265358979;
	}
	return 0;

}


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

int main()
{
    int L;
    cin >> L;
    double x, v;
    x = (double)L / 3.0;
    v = x * x * x;
    cout << fixed << setprecision(10) << v << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M=1e5+5;

int n,A[M];

multiset<int>S;
typedef multiset<int>::iterator sit;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	int ans=0;
	for(int i=1;i<=n;i++){
		if(S.size() and *S.begin()<A[i])S.erase(--S.upper_bound(A[i]-1));
		else ans++;
		S.insert(A[i]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5376
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int len = s.length();
    int ans = 0;
    rep(i, 0, len) if (s[i] != t[i]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t a,b,k;
  cin>>a>>b>>k;
  if(a-k>0)
    cout<<a-k<<" "<<b<<endl;
  else
    cout<<0<<" "<<(b-(k-a)>0?b-(k-a):0)<<endl;
}

Measured memory_bytes: 256
using System;
class Program
 {
        static void Main(string[] args)
        {
    　　string[] str = Console.ReadLine().Split(' ');
	    int a = int.Parse(str[0]);
	    int b = int.Parse(str[1]);

	    int p = a * b;
    	if(p % 2 == 0){
		    Console.WriteLine("Even");
		    } else {
		    Console.WriteLine("Odd");
		    }
	}
 }

Measured memory_bytes: 13140