akhauriyash/Code-Regression huggingface dataset:
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v), std::end(v)
#define REP(i, k) for (decltype(k) i = 0; i < k; i++)
#define LOOP(k) REP (ngtkana_is_a_genius, k)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    std::string s;
    std::cin >> s;
    std::cout << s.substr(0, 3) << '\n';
}


Measured memory_bytes: 3612
N = gets.chomp.to_i
a = [nil] + gets.chomp.split(" ").map(&:to_i)
insert = Array.new(N + 1, 0)
a.each_with_index.reverse_each do |val, i|
    next if i == 0
    if N < i * 2
        insert[i] = a[i]
    else
        buf = 0
        for j in 2..(N / i)
            buf = buf ^ insert[i * j]
        end
        insert[i] = buf ^ a[i]
    end
end
puts insert.inject(:+)
puts insert.zip((0..N).to_a).select{|val, i| val == 1}.map{|val, i| i}.join(" ") if insert.uniq.size == 2

Measured memory_bytes: 36692
sx, sy, tx, ty = map(int, input().split())

x = tx - sx
y = ty - sy

ans = ''

# s -> t, t -> s
ans += "U" * y
ans += "R" * x
ans += "D" * y
ans += "L" * x

# 1マス外側 s -> t, t ->s 
ans += "L"
ans += "U" * (y + 1)
ans += "R" * (x + 1)
ans += "D"

ans += "R"
ans += "D" * (y + 1)
ans += "L" * (x + 1)
ans += "U"

print(ans)

# dijkstraで解く
# 格子上の最短経路，障害なし，なのでまっすぐ行って帰るを繰り返す


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    bool flag = 1;
    cin>>a;
    int sum=0;
        for(int i = 0;i<a.length();++i)
       {
          if(a[0]!='A'){flag=0;break;}
          if(i==0) continue;
          if(i>1&&a[i]=='C'&&i!=a.length()-1) sum++;
          else if(a[i]>='A'&&a[i]<='Z') {flag=0;break;}
       }
       if(flag&&sum==1) cout<<"AC"<<endl;
       else cout<<"WA"<<endl;

}


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

int main(){
  int n;
  cin >> n;
  int count = 0;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; i++){
    cin >> a.at(i);
    cin >> b.at(i);
    if (a.at(i) == b.at(i)){
      count++;
      if (count == 3){
        cout << "Yes" << endl;
        break;
      }
    }
    else{
      count = 0;
    }
  }
  if (count < 3){
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3576
#include<iostream>
#include<vector>
#include<algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
#define CO(x) cout<<(x)<<endl;
#define COSP(x) cout<<(x)<<" ";
#define DICIMAL(x) fixed<<setprecision(x)
using namespace std;
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

  int R,G,B,N; cin>>R>>G>>B>>N;

  int cnt=0;
  REP(r,N/R+1) REP(g,N/G+1){
    if(N<R*r+G*g) break;
    if((N-R*r-G*g)%B==0) ++cnt;
  }

  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
use std::io;
use std::cmp::max;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let mut a = v[0];
	let mut b = v[1];
	let mut c = v[2];
	let mut ret = 0;
	let v:Vec<i32> = procon_read();
	let k = v[0];
	for i in 0..k {
		ret = max(max(2*a+b+c, a+2*b+c), a+b+2*c);
		if ret == 2*a+b+c {
			a = 2*a;
		}else if ret == a+2*b+c {
			b = 2*b;
		}else{
			c = 2*c;
		}
	}
	println!("{}", ret);
}

Measured memory_bytes: 4352
object Main extends App {
    val x = io.StdIn.readInt

    if (x == 1) println(1)
    else {

        /*
        def exponentiation(base: Int): Int = {
            var tmp = base
            while (tmp < x) tmp *= base

            if (tmp == x) x
            else tmp/base
        }
        */

        def exponentiation(base: Int, acc: Int): Int =
            if (x < acc) acc/base
            else exponentiation(base, acc*base)

        // 1 <= 基数 <= √x
        val result = (2 to math.sqrt(x).toInt).map(exponentiation(_, 1)).max
        println(result)

    }

}

Measured memory_bytes: 54760
module Main where

import Control.Applicative
import Text.Printf

main :: IO ()
main = loop

loop :: IO ()
loop = do
  { [a,b,c]  <-getInts
  ; print ( count 0 a b c)
  }
count :: Int -> Int -> Int -> Int -> Int
count n x y z
  | x > y = n
  | z `mod` x == 0 = count (n+1) (x+1) y z
  | otherwise      = count n     (x+1) y z
  
 --
  
getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords .  map show



Measured memory_bytes: 4156
import java.util.*;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
private int totalVertex;
private LinkedList<LinkedList<Integer>> adjList;
//adjacency list of edges
public Graph() { totalVertex = 0; }

public void loadAdjList() {
Scanner in = new Scanner(System.in);
totalVertex = in.nextInt();
adjList = new LinkedList<LinkedList<Integer>>();
for(int i = 0; i < totalVertex; i ++) {
LinkedList<Integer> tmp = new LinkedList<Integer>();
int idx1 = in.nextInt() - 1;
int degree = in.nextInt();
//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
for(int j = 0; j < degree; j ++) {
int idx2 = in.nextInt() - 1;
tmp.add(idx2);
}
adjList.add(tmp);
}
in.close();
}

public void printAdjMatrix() {
Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
for(int i = 0 ; i < totalVertex; i++) {
for(int j=0; j < totalVertex; j++) {
adjMatrix[i][j] = 0;
}
}

for(int i = 0; i< adjList.size(); i++) {
LinkedList<Integer> num = adjList.get(i);
for(int j = 0; j< num.size(); j++) {
adjMatrix[i][(adjList.get(i)).get(j)] = 1;
}
}
for(int i = 0 ; i < totalVertex; i++) {
for(int j=0; j < totalVertex; j++) {
if(j == totalVertex-1) {
System.out.println(adjMatrix[i][j]);
}
else System.out.print(adjMatrix[i][j] + " ");
}
}
}
}
public class Main{
public static void main(String argv[]) {
Graph g = new Graph();
g.loadAdjList();
g.printAdjMatrix();
}
}


Measured memory_bytes: 32640
nx = []

while True:
    n, x = map(int,input().split())
    if n == 0:
        break
    
    nx.append([n,x])

for n, x in nx:
    ans = []
    
    for i in range(1,n+1):
        for j in range(1,n+1):
            if i == j:
                continue
            
            k = x - i -j
            
            if (not k == i) and (not k == j):
                if 1 <= k <= n:
                    ans.append([i,j,k])
    
    print(int(len(ans)/6))


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

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

int main(){

  ll n;cin>>n;

  rep(i,0,n){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    --a,--b,--c;
    num[a][b][c]+=d;
  }

  rep(i,0,4){
    rep(j,0,3){
      cout<<" ";
      rep(k,0,10){
        if(k<9)cout<<num[i][j][k]<<" ";
        else out(num[i][j][k]);
      }
      // cout<<endl;
    }
    if(i!=3){
      rep(i,0,20)cout<<"#";
      cout<<endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3112
"""
#editorialより
頂点1から頂点iへの最短路の長さをdiとするとd1≦d2≦....≦dN
各iに対して頂点i+ 1から頂点iに長さ0の辺を追加
このときi回目に追加される辺について考えると、
頂点Liから頂点Riへの長さCiの辺を追加すれば十分
"""
import sys,heapq
input = sys.stdin.readline

n,m = map(int,input().split( ))
Ad = [[] for _ in range(n)]
for i in range(m):
    li,ri,ci = map(int, input().split( ))
    Ad[li-1].append((ri-1,ci))
for i in range(1,n):
    Ad[i].append((i-1,0))

inf = 10**20###これ不十分だった
D = [inf for _ in range(n)]
#Prev = [-1 for _ in range(n)]
D[0] = 0
Q = []
heapq.heappush(Q, (0,0))

while Q:
    d,q = heapq.heappop(Q) #qは[距離、頂点番号]：キューの優先度の都合で番号が後
    #print(q)
    for v,c in Ad[q]:
        if D[v]>d+c:
            D[v] = d+c
            #Prev[n[0]] = q[1]
            heapq.heappush(Q, (d+c,v))

if D[n-1]<inf:
    print(D[n-1])
else:
    print(-1)


Measured memory_bytes: 74288
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,ans=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<n;i++)
    {
        if(a[i-1]>a[i])
        {
            ans+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4408
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 10000;
static const int VMAX = 100000;

int n,A[MAX],s;
int B[MAX],T[VMAX+1];

int solve(){
    int i,ans = 0;
    
    bool V[MAX];
    for(i=0;i<n;i++){
        B[i] = A[i];
        V[i] = false;
    }
    sort(B,B+n);
    for(i=0;i<n;i++) T[B[i]] = i;
    for(i=0;i<n;i++){
        if(V[i]) continue;
        int cur=i;
        int S = 0;
        int m = VMAX;
        int an = 0;
        while(1){
            V[cur] = true;
            an++;
            int v=A[cur];
            m = min(m,v);
            S+=v;
            cur = T[v];
            if(V[cur]) break;
        }
        ans += min(S+(an-2)*m,m+S+(an+1)*s);
    }
    return ans;
}

int main(){
    int i;
    cin>>n;
    s=VMAX;
    for(i=0;i<n;i++){
        cin>>A[i];
        s=min(s,A[i]);
    }
    int ans = solve();
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3184
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		StringBuffer sb = new StringBuffer();

		for(int i = 0; i < 3; i++) {
			sb.append(sc.next().substring(0, 1));
		}

		System.out.println(sb);
	}

}

Measured memory_bytes: 35632
N = int(input())

A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = float("inf")

for ii in range(2 ** N):

    s = format(ii,'b').zfill(N)
    on = 0
    
    for j in s:
        if j == "1":
            on += 1

    if on != (N+1)//2:
        continue

    q = []
    q2 = []

    for i in range(N):
        if s[i] == "1":
            if i % 2 == 0:
                q.append([A[i],i])
            else:
                q.append([B[i],i])
        else:
            if i % 2 != 0:
                q2.append([A[i],i])
            else:
                q2.append([B[i],i])           

    q.sort()
    q2.sort()
    q2.append([float("inf"),0])
    #print (q,q2)

    flag = True
    nmax = 0

    for i in range((N+1)//2):


        if nmax > q[i][0]:
            flag = False
        nmax = q[i][0]

        if nmax > q2[i][0]:
            flag = False
        nmax = q2[i][0]

    if flag:
        r = []
        for i in range((N+1)//2):
            r.append(q[i][1])
            r.append(q2[i][1])

        #print (r)

        now = 0
        z = [i for i in range(N)]
        for i in range(N):
            for j in range(len(z)):
                if z[j] == r[i]:
                    now += j
                    del z[j]
                    break
            #print (z,now)
        ans = min(now,ans)

if ans == float("inf"):
    ans = -1
print (ans)


Measured memory_bytes: 54748
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
  int k;
  Node *next, *prev;
};

Node *nil;

Node* lis(int k){
  Node *cur = nil->next;
  while(cur!=nil && cur->k!=k){
    cur=cur->next;
  }
  return cur;
}


void ini(){
  nil=(Node *)malloc(sizeof(Node));
  nil->next=nil;
  nil->prev=nil;
}


void pri(){
  Node *cur=nil->next;
  int isf=0;
  while(1){
    if(cur==nil) break;
    if(isf++>0)printf(" ");
    printf("%d",cur->k);
    cur=cur->next;
  }
  printf("\n");
}


void delN(Node *t){
  if(t==nil) return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}


void delF(){
  delN(nil->next);
}


void delL(){
  delN(nil->prev);
}


void delK(int k){
  delN(lis(k));
}

void ins(int k){
  Node *x=(Node *)malloc(sizeof(Node));
  x->k=k;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}




int main(){
  int k,n,i;
  int size=0;
  char com[20];
  int np=0,nd=0;
  scanf("%d",&n);
  ini();
  for(i=0;i<n;i++){
    scanf("%s%d",com,&k);
    if(com[0]=='i'){
      ins(k);
      np++;
      size++;
    }
    else if(com[0]=='d'){
      if(strlen(com)>6){
        if(com[6]=='F') delF();
        else if(com[6]=='L') delL();
      }
      else{
        delK(k);
        nd++;
      }
      size--;
    }
  }

  pri();

  return 0;
}




Measured memory_bytes: 33976
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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

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

    vector<pair<int, int> >vp;
    rep(i, 0, 5) {
        int a, b;
        cin >> a;
        b = (a % 10 == 0) ? 0 : 10 - a % 10;
        vp.push_back(make_pair(b, a));
    }
    vsort(vp);

    int rsl = 0;
    rep(i, 0, 4) rsl += vp[i].second + vp[i].first;
    rsl += vp[4].second;
    cout << rsl << endl;
}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<algorithm>

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define For(i,x,y) for(int i=((int)x);i<=((int)y);i++)
#define Dep(i,y,x) for(int i=((int)y);i>=((int)x);i--)
#define Rep(i,x) for (int y,i=head[x];i;i=E[i].nxt)
using namespace std;

const int inf=1000000009;

typedef double db;
typedef long long ll;
typedef unsigned int uint;
typedef pair<int,int> pii;

int rd() {
	char c=getchar(); int t=0,f=1;
	while (!isdigit(c)) f=(c=='-')?-1:1,c=getchar();
	while (isdigit(c)) t=t*10+c-48,c=getchar(); return t*f;
}
void wt(int x) {
	if (x<0) putchar('-'),wt(-x);
	else { if (x>9) wt(x/10); putchar(x%10+48); }
}

#include<deque>

deque<int>Q;
deque<int>::iterator it;

int n;

int main() {
	n=rd();
	For (i,1,n) {
		if (i&1) Q.push_back(rd());
		else Q.push_front(rd());
	}
	if (n%2==1) reverse(Q.begin(),Q.end());
	for (it=Q.begin();it!=Q.end();it++)
		printf("%d ",*it);
}






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

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#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 DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int h;
	while(cin>>h,h){
		vvint vv;
		initvv(vv,h,5);
		rep(i,h) rep(j,5){
			cin>>vv[i][j];
		}
		int ans = 0;
		rep(i,h) rep(j,5) ans += vv[i][j];
		bool update = true;
		int cnt = 0;
		while(update){
			update=false;
			vvint ww;
			initvv(ww,h,5,0);
			rep(i,h){
				rep(j,3){
					if(vv[i][j]&&vv[i][j]==vv[i][j+1]&&vv[i][j]==vv[i][j+2]){
						ww[i][j]=ww[i][j+1]=ww[i][j+2]=1;
						update=true;
					}
				}
			}
			rep(i,h) rep(j,5){
				if(ww[i][j]) vv[i][j]=0;
			}
			for(int i=h-1;i>=0;i--){
				rep(j,5){
					if(vv[i][j]==0){
						int p = i-1;
						while(p >= 0){
							if(vv[p][j]){
								vv[i][j]=vv[p][j];
								vv[p][j]=0;
								break;
							}
							p--;
						}
					}
				}
			}
		}
		int tmp = 0;
		rep(i,h){
			rep(j,5){
				tmp += vv[i][j];
			}
		}
		cout<<ans-tmp<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 3140
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    int price;
    cin >> price;
    
    int v = price;
    int c500 = v / 500; v -= 500 * c500;
    int c5 = v / 5; v -= 5 * c5;
  
    int score = c500 * 1000 + c5 * 5;
    
    cout << score << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
const int mod = 1e9 + 7;
void solve() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, 0, n)cin >> a[i];
	vector<ll>  sumj(n + 1, 0);
	vector<ll> sumi(n + 1, 0);
	for (int j = n - 1; j >= 1; j--) {
		sumj[j] = sumj[j + 1] + a[j];
		sumj[j] %= mod;
	}
	for (int i = n - 2; i >= 0; i--) {
		sumi[i] = sumi[i + 1] + a[i] * sumj[i + 1];
		sumi[i] %= mod;
	}
	cout << sumi[0] << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}



Measured memory_bytes: 7948
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;
int main(void){
  int x,y;
  cin >> x >> y;

  bool flag = false;
  for(int i=0;i<=x;i++){
    if(i*2+(x-i)*4 == y){
      flag = true;
    }
  }

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


Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const ll maxn=2e5+5;
ll v[maxn];
ll x[maxn];
int main()
{
   ll n;
   cin>>n;
   ll s=0;
   for(ll i=0;i<n;i++)
   {
       cin>>x[i];
       v[x[i]]++;
   }
   for(ll i=1;i<=n;i++)
   {
      s+=v[i]*(v[i]-1)/2;
   }
   for(ll i=0;i<n;i++)
   {
       if(i!=n-1)
        cout<<s-(v[x[i]]-1)<<endl;
       else
        cout<<s-(v[x[i]]-1);
   }
   return 0;
}
/*
10 6
8 3 7 8 2 9 3 8 2 4


20 20
*/


Measured memory_bytes: 4736
#define  _USE_MATH_DEFINES

#define  rep(i, n) for(int i = 0; i < n; i++)
#define  repx(i, a, n) for(int i = a; i < n; i++)
#define  loop while(1)
#define  lli long long int
 
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <utility>
#include <set>
  
using namespace std;

int stack_pop(vector<int> &v, int &topi) {
  if (topi >= 0) {
    int rt = v[topi];
    topi -= 1;
    return rt;
  }
  else {
	return -0;
  }
}

void stack_push(vector<int> &v, int &topi, int tmp) {
  v[topi + 1] = tmp;
  topi += 1;
}

int main() {

  vector<int> stk(200, 0);
  string tmp;
  int a, b;
  int topi = 0;

  while (cin >> tmp && tmp != "\0") {

    if (tmp == "+") {
      a = stack_pop(stk, topi);
      b = stack_pop(stk, topi);
      stack_push(stk, topi, b + a);
    }
    else if (tmp == "-") {
      a = stack_pop(stk, topi);
      b = stack_pop(stk, topi);
      stack_push(stk, topi, b - a);
    }
    else if (tmp == "*") {
      a = stack_pop(stk, topi);
      b = stack_pop(stk, topi);
      stack_push(stk, topi, b * a);
    }
    else {
      stack_push(stk, topi, atoi(tmp.c_str()));
    }
  }
  cout << stk[topi] << endl;

  return 0;
}



Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

struct edge {
	int from,to;
	int cost;

	edge(int t,int c) : to(t),cost(c) {}
	edge(int f,int t,int c) : from(f),to(t),cost(c) {}

	bool operator<(const edge &e) const {
		return cost < e.cost;
	}
};

vector<edge> G[100005];
int d[100005], d2[100005], cnt[100005], in[100005], pre[100005];
bool used[100005];

void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P> > que;
	rep(i, 100005) d[i] = INF, pre[i] = -1;
	

	que.push(mp(0, s));
	d[s] = 0;

	while(que.size()) {
		P p = que.top(); que.pop();
		int cost = p.first;
		int v = p.second;

		if(d[v] < cost) continue;

		rep(i, G[v].size()) {
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				pre[e.to] = v;
				que.push(mp(d[e.to], e.to));
			}
		}
	}
}

vector<int> get_path(int t) {
	vector<int> path;
	for(;t!=-1;t=pre[t]) path.push_back(t);
	reverse(path.begin(),path.end());
	return path;
}

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

	int s, t;
	cin >> s >> t;
	s--; t--;

	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;

		G[a].push_back(edge(b, 1));
		G[b].push_back(edge(a, 1));
	}

	dijkstra(s);
	rep(i, n) d2[i] = d[i];

	dijkstra(t);
	rep(i, n) swap(d[i], d2[i]);

	memset(cnt, 0, sizeof(cnt));
	rep(i, n) {
		if(d2[i] == INF) continue;
		cnt[d2[i]]++;
	}

	ll ans = 0;
	rep(i, n) {
		if(d[i] == INF || d2[i] == INF) continue;
		int x = d[t] - 2 - d[i];

		if(x >= 0) {
			ans += cnt[x];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 11916
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use num::integer::{gcd, lcm};
#[allow(unused_imports)]
use permutohedron::LexicalPermutation;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(dead_code)]
const MOD: i32 = 1e9 as i32 + 7;

fn main() {
    input!(n:i32,a:[i128;n]);
    let mut x:i128 = 1;
    let mut a = a.clone();
    a.sort();
    for elm in &a {
        x*=elm;
        if x > 1000000000000000000 {
            println!("-1");
            return;
        }
    }
    println!("{}",x);
}


Measured memory_bytes: 5940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vl;
typedef vector<vector<ll>> vll;
typedef vector<bool> vb;
typedef set<int> si; 
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
//#define __builtin_popcountll bitCountLL
//#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
#define maxn 100005
#define Mod 1000000007
const int INF = 2e9;
const ll ML = 4e18;
    
void solve() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int r = 0;
    while(b <= a) {
        r++;
        b <<= 1;
    }
    while(c <= b) {
        r++;
        c <<= 1;
    }
    if(r <= k) cout << "Yes";
    else cout << "No";

}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
	//freopen("D:\\data_in.txt", "r", stdin);
   solve();
   
    /*
    clock_t start,finish;
    start = clock();
    
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


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

using namespace std;
typedef long long ll;
const ll LINF = 1e18;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main()
{
  int h,w;
  int ans = 0;
  cin >> h >> w;
  vector<string> table(h);
  vector<vector<int>> cnt(h, vector<int>(w, 0));

  for(int i=0;i<h;i++){
    string s;
    cin >> s;
    table[i] = s;
  }

  for(int i=0;i<h;i++){
    int t = 10000;
    vector<int> tmp(w,0);
    for(int j=0;j<w;j++){
      if (table[i][j] == '#') t = 0;
      tmp[j] = t;
      t++;
    }
    t = 10000;
    for(int j=w-1;j>=0;j--){
      if (table[i][j] == '#') t = 0;
      if (t < tmp[j]) tmp[j] = t;
      t++;
    }
    //cout << tmp << endl;
    cnt[i] = tmp;
  }
  for(int i=0;i<w;i++){
    int t = cnt[0][i];
    vector<int> tmp(h,0);
    for(int j=0;j<h;j++){
      t = min(cnt[j][i],t);
      tmp[j] = t;
      t++;
    }
    t = cnt[h-1][i];
    for(int j=h-1;j>=0;j--){
      t = min(min(cnt[j][i],t),tmp[j]);
      tmp[j] = t;
      t++;
    }
    //cout << tmp << endl;
    for(int j=0;j<h;j++){
      if (ans<tmp[j]) ans = tmp[j];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5248
#include <iostream>
    #include <algorithm>
     
    using namespace std;
     
    int n;
    int a[16][16];
    int b[16][16];
    int c[16];
    int ans = 0;
     
    void dfs(int d) {
        if (d > n) {
            int cnt = 0;
            for (int i = 1; i <= n; ++i) {
                if (c[i]) { // 1:正直
                    for (int j = 1; j <= n; ++j) {
                        if (b[i][j]) {
                            if (a[i][j] != c[j])
                                return;
                        }
                    }
                    cnt++;
                }
            }
            ans = max(ans, cnt);
            return;
        }
        dfs(d + 1);
        c[d] = 1;
        dfs(d + 1);
        c[d] = 0;
    }
     
    int main() {
        cin >> n;
        int k, x, y;
        for (int i = 1; i <= n; ++i) {
            cin >> k;
            while (k--) {
                cin >> x >> y;
                a[i][x] = y;
                b[i][x] = 1;
            }
        }
        dfs(1);
        cout << ans << endl;
     
        return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>

#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORN(i, a, b) for (int i = a; i <= b; i++)
#define P(s) cout << s << endl
#define PC(condition, _true, _false) if (condition) _true; else _false;

using namespace std;
//
// Created by karayuu on 2019-3-28.
//

/**
 * char型の数字をint型に変換します.
 * ただし入力値が数字でない場合は-1を返します.
 * @param _char int型に変換したい数字の文字(1文字).
 * @return int型に変換した数字.ただし数字以外が入力されたときは-1.
 */
int toInt(char single_number) {
    if ('0' <= single_number && single_number <= '9') {
        return single_number - '0';
    }
    return -1;
}

int main() {
    vector<int> a;

    while (true) {
        string s;
        cin >> s;

        if (toInt(s[0]) == 0) break;

        int sum = 0;
        for (char c : s) {
            sum += toInt(c);
        }

        a.push_back(sum);
    }

    for (int n : a) {
        P(n);
    }
}


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

int main()
{
	int price[5];

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

	sort(price, price + 3);
	
	cout << price[0] + min(price[3], price[4]) - 50 << endl;

	return (0);
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <queue>
#include<algorithm>
#define rep(i,n) for(int i = 0;i < n;i++)
using namespace std;
vector<vector<int>> v; vector<int> in;
bool f = 0;
vector<int> to_sort(vector<vector<int>>& G, vector<int>& ind, int V) {
    vector<int> sorted(V); queue<int> q;
    rep(i, V) {
        if (ind[i] == 0) q.push(i);
    }
    while (!q.empty()) {
        int v = q.front(); q.pop();
        for (int i : G[v]) {
            ind[i]--;
            if (ind[i] == 0)sorted[i] = v+1,q.push(i);
        }
    }return sorted;
}
int main() {
    int n, m, x, y; cin >> n >> m;
    v.resize(n+m+1); in.resize(n+m+1, 0);
    rep(i, n+m-1) {
        cin >> x >> y; x--; y--;
        v[x].push_back(y);
        in[y]++;
    }vector<int> ans = to_sort(v, in, n+m-1);
    rep(i, n) cout << ans[i] << endl;
}

Measured memory_bytes: 9492
n, m = gets.split.map(&:to_i)
g = Array.new(n) { [] }
m.times do
  u, v = gets.split.map(&:to_i)
  g[u - 1] << v - 1
end
s, t = gets.split.map { |x| x.to_i - 1 }

dist = Array.new(n) { Array.new(3, -3) }
dist[s][0] = 0
q = []
q << [s, 1]
until q.empty?
  from, cnt = q.shift
  g[from].each do |to|
    if dist[to][cnt] == -3
      dist[to][cnt] = dist[from][(cnt - 1) % 3] + 1
      q << [to, (cnt + 1) % 3]
    end
  end
end
p dist[t][0] / 3


Measured memory_bytes: 18556
import java.util.*;

class Main
{
	public static void main(String args[]) throws Exception
	{
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int ac=0;
		int re=0;
		int wa=0;
		int tle=0;
		for(int i=0;i<n;i++)
		{
			String s=in.next();
			if(s.charAt(0)=='A')
			{
				ac++;
			}
			else if(s.charAt(0)=='R')
			{
				re++;
			}
			else if(s.charAt(0)=='W')
			{
				wa++;
			}
			else if(s.charAt(0)=='T')
			{
				tle++;
			}
		}
		System.out.println("AC x "+ac);
		System.out.println("WA x "+wa);
		System.out.println("TLE x "+tle);
		System.out.println("RE x "+re);
	}
}

Measured memory_bytes: 59256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> n>>k;
    vector<PP> VP;
    multiset<PP> VP1;
    vl used(200000,0);

    rep(i,n){
        cin>>x>>y;
        VP.push_back({y,x});
    }

    sort(all(VP));
    reverse(all(VP));

    
    rep(i,k){
        a+=VP[i].first;
        if(used[VP[i].second]==0){
            used[VP[i].second]++;
            b++;
        }
        else VP1.insert(VP[i]);
    }

    ans=a+b*b;

    for(ll i=k;i<n;i++){
        if(used[VP[i].second]==0&&!VP1.empty()){
        	used[VP[i].second]++;
            auto ite=VP1.begin();
            a-=(*ite).first;
            a+=VP[i].first;
            VP1.erase(ite);
            b++;
            ans=max(ans,a+b*b);
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 6640
package main

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

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt64() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextInt() int {
	return int(nextInt64())
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	return int(max64(int64(x), int64(y)))
}

func min64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func min(x, y int) int {
	return int(min64(int64(x), int64(y)))
}

func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func abs(x int) int {
	return int(abs64(int64(x)))
}

func joinInt64s(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

func divUp64(x, y int64) int64 {
	return (x + y - 1) / y
}

func divUp(x, y int) int {
	return int(divUp64(int64(x), int64(y)))
}

func gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func gcd(x, y int) int {
	return int(gcd64(int64(x), int64(y)))
}

func lcm64(x, y int64) int64 {
	return x * y / gcd64(x, y)
}

func lcm(x, y int) int {
	return int(lcm64(int64(x), int64(y)))
}

func main() {
	solve()
	writer.Flush()
}

func solve() {
	s := nextLine()
	c := strings.Index(s, "C")
	if c == -1 {
		out("No")
		return
	}
	f := strings.Index(s[c:], "F")
	if f == -1 {
		out("No")
		return
	}
	out("Yes")
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define Endl endl

signed main(void){
    int N,A,B,C,D;
    string S;
    cin >> N >> A >> B >> C >> D;
    A--;B--;C--;D--;
    cin >> S;
    
    if(C<B || C<D){
        //Bを先に行かせることで追い越しは発生しない
        //A-CとB-Dは独立に考えられる
        int r=0;
        for(int i=A;i<=C-1;i++){
            if(S[i]=='#'&&S[i+1]=='#'){
                r=1;
            }
        }
        for(int i=B;i<=D-1;i++){
            if(S[i]=='#'&&S[i+1]=='#'){
                r=1;
            }
        }
        if(r==1){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
        return 0;
    }
    
    //追い越しは必要
    //...が存在すればその区間で追い越しが可能
    //この場合A<B<D<Cである
    
    int r=0,t=0;
    for(int i=A;i<=C-1;i++){
        if(S[i]=='#'&&S[i+1]=='#'){
            r=1;
        }
    }
    for(int i=B;i<=D-1;i++){
        if(S[i]=='#'&&S[i+1]=='#'){
            r=1;
        }
    }
    
    for(int i=B-1;i<=D-1;i++){
        if(S[i]=='.'&&S[i+1]=='.'&&S[i+2]=='.'){
            t=1;
        }
    }
    if(r==1 || t==0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#define b(x) ((x)==0?0:(1<<((x)-1)))
#define lb(x) ((x)&(-(x)))
const int nMaxn = 100005, nMaxs = 114514;
int N, nXorperp[nMaxn] = {0}, bRec[nMaxs];
int bCalcable[nMaxs], bExibits[nMaxs];
int nStstat = 0, bOutsteps = 0;

int dfs(int vCur) {
    if (bRec[vCur] != -1) return bRec[vCur];
    int& vRes = bRec[vCur];
    vRes = bExibits[vCur]-1;
    
    int bPos = lb(vCur);
    for (int vSpl=(vCur-1)&vCur; vSpl; vSpl=(vSpl-1)&vCur) {
        if ((vSpl&bPos)&&bCalcable[vSpl]&&bCalcable[vCur^vSpl]) {
            vRes = min(vRes, dfs(vSpl)+dfs(vCur^vSpl));
        }
    }
    
    return vRes;
}

inline void check(int vStat) {
    int bCov = 0, bBit = 0;
    int vCopied = vStat;
    while (vCopied) {
        ++bBit;
        if (vCopied&1) ++bExibits[vStat], bCov^=bBit;
        vCopied >>= 1;
    }
    bCalcable[vStat] = bCov==0;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N;
    int u, v, w;
    for (int i=1; i<N; ++i) 
        cin >> u >> v >> w,
        nXorperp[u] ^= w,
        nXorperp[v] ^= w;
    for (int i=0; i<N; ++i)
        nStstat ^= b(nXorperp[i]),
        bOutsteps += nXorperp[i]&&!(nStstat&b(nXorperp[i]));
    for (int i=0; i<nMaxs; ++i) 
        bRec[i] = -1,
        check(i);
    cout << max(0, dfs(nStstat))+bOutsteps << endl;
    return 0;
}

Measured memory_bytes: 5364
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define ALL(a)  (a).begin(),(a).end()
const int MOD = 1000000007;
int l,x,y,s = 0,d,n,m;
int main() {
    cin >> n >> m;
    vector<bool> a(n + 1,false);
    rep(i, m) {
        cin >> x >> y;
        if (x == 1 && !a[y - 1]) a[y - 1] = true;
        else if (x == 1) a[n] = true;
        if (y == n && !a[x -1]) a[x - 1] = true;
        else if(y == n) a[n] = true;
    }
    if (!a[n]) cout << "IMPOSSIBLE" << endl;
    else cout << "POSSIBLE" << endl;
}

Measured memory_bytes: 256
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.trim().split(" ");
	input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var N = parseInt(input[0].split(" ")[0]);
  var K = parseInt(input[0].split(" ")[1]);
  var list = input[1].split(" ").map((a)=>Number(a));
  var output = 0;
  for(var i = 0; i < N; i++){
    if(list[i] >= K){
       output++;
       }
  }
  myout(output);
}

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


Measured memory_bytes: 16588
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Queue;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;



public class Main{
	
	static int posx;
	static int posy;
	static int type;
	static int diff;
	static int INF = Integer.MAX_VALUE;
	static int[][] d;
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}



	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}


	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}


	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}


	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 
	 String S=sc.next();
	 
	 if(S.equals("Sunny")) {
		 System.out.println("Cloudy");
	 }else if(S.equals("Cloudy")) {
		 System.out.println("Rainy");
	 }else if(S.equals("Rainy")) {
		 System.out.println("Sunny");
	 }
     
	
	 
	 
	 
	
	 
	 
	 
 }
	


}


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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l.at(i);
  }
  sort(l.begin(), l.end());
  int sum = 0;
  for (int i = 0; i < n - 1; i++) {
    sum += l.at(i);
  }
  if (sum > l.at(n - 1)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		sc.nextLine();

		String[][] ms = new String[h][w];

		for (int i = 0; i < h; i++) {
			ms[i] = sc.nextLine().split("");
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if ("#".equals(ms[i][j])) {
					continue;
				}

				int bombCount = 0;
				if (i > 0) {
					if (j > 0 && "#".equals(ms[i - 1][j - 1])) {
						bombCount++;
					}
					if ("#".equals(ms[i - 1][j])) {
						bombCount++;
					}
					if (j + 1 < w && "#".equals(ms[i - 1][j + 1])) {
						bombCount++;
					}
				}
				if (i + 1 < h) {
					if (j > 0 && "#".equals(ms[i + 1][j - 1])) {
						bombCount++;
					}
					if ("#".equals(ms[i + 1][j])) {
						bombCount++;
					}
					if (j + 1 < w && "#".equals(ms[i + 1][j + 1])) {
						bombCount++;
					}
				}
				if (j > 0 && "#".equals(ms[i][j - 1])) {
					bombCount++;
				}
				if (j + 1 < w && "#".equals(ms[i][j + 1])) {
					bombCount++;
				}

				ms[i][j] = Integer.toString(bombCount);
			}
		}

		for (String[] sline : ms) {
			System.out.println(String.join("", sline));
		}

		sc.close();
	}
}

Measured memory_bytes: 22608
while 1:
	z3=m=input()**3
	if z3==0:break
	x=0
	while 1:
		x+=1
		x3=x**3
		y=int((z3-x3)**(1/3.))
		if y<x:break
		n=z3-x3-y**3
		if n<m:m=n
	print m

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

int main() {
	int N;
	cin >> N;
	if (N == 1 || N == 2 || N == 3 || N == 5 || N == 6 || N == 9 || N == 10) {
		cout << "No" << endl;
	}
	else {
		if (N % 4 == 0 || N % 7 == 0) {
		cout << "Yes" << endl;
	}
		else {
			if (((N % 13 == 0) && (N / 13 == 1) || (N % 17 == 0) && (N / 17 == 1)) && N % (13 * 17) != 0) {
				cout << "No" << endl;
			}
			else {
				cout << "Yes" << endl;
			}
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<long long> vll;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string A,B;
    cin>>A>>B;
    for(ll i=0;i<A.size();i++)
    {
        cout<<A[i];
        if(i<B.size())
        {
            cout<<B[i];
        }
            
    }
    return 0;

}


Measured memory_bytes: 256