akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

map<string,ll> m;

ll f(string s){
	if(m.find(s)!=m.end()) return m[s];
	if(!s.size()) return m[s]=1;
	ll n=s.size(),res=f(s.substr(1));
	if(s[0]=='1') (res*=2)%=mod;
	for(int i=1;2*i<=n;i++){
		string t=s.substr(0,i);
		for(int j=2;j*i<=n;j++){
			for(int k=0;k<i;k++) if(s[i*(j-1)+k]=='0') t[k]='0';
			(res+=f(t)*f(s.substr(i*j)))%=mod;
		}
	}
	return m[s]=res;
}

string s;

int main(){
	cin>>s;
	cout<<f(s)<<endl;
}

Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;

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

int main(void){
  ll n,m;
  cin >> n >> m;
  string s,t;
  cin >> s >> t;
  ll g = gcd(n,m);
  ll l = n*m / g;
  ll nn = l / n;
  ll mm = l / m;
  map<ll, char> res;
  for(ll i = 0;i < n;++i){
    res[i*nn] = s[i];
  }
  for(ll i = 0;i < m;++i){
    if(res.find(i*mm) != res.end() && res[i*mm] != t[i]){
      cout << "-1" << endl;
      return 0;
    }
  }
  cout << l << endl;
  return 0;
}



Measured memory_bytes: 6144
import sys
input = sys.stdin.readline

def partition(A, p, r):
    x = A[r][1]
    i = p-1
    for j in range(p, r):
        if A[j][1] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1

def quicksort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quicksort(A, p, q-1)
        quicksort(A, q+1, r)

def marge(A, left, right, mid):
    n1 = mid - left
    n2 = right - mid
    L = [[] for _ in range(n1+1)]
    R = [[] for _ in range(n2+1)]
    for i in range(n1):
        L[i] = A[left + i]
    for i in range(n2):
        R[i] = A[mid + i]
    L[n1] = ('Z', 10 ** 9 + 1)
    R[n2] = ('Z', 10 ** 9 + 1)
    i = 0
    j = 0
    for k in range(left, right):
        if L[i][1] <= R[j][1]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    return

def margesort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        margesort(A, left, mid)
        margesort(A, mid, right)
        marge(A, left, right, mid)
        return
    return


def main():
    n = int(input())
    A = [[] for _ in range(n)]
    B = [[] for _ in range(n)]
    for i in range(n):
        a, b = input().split()
        b = int(b)
        A[i] = (a, b)
        B[i] = (a, b)
    margesort(A, 0, n)
    quicksort(B, 0, n-1)
    if A == B:
        print("Stable")
    else:
        print("Not stable")
    for a in B:
        print(a[0], a[1])

if __name__ == '__main__': main()


Measured memory_bytes: 30280
#include <iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    string t = "";
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '1') t += '1';
        else if (s[i] == '0') t += '0';
        else if (t.size() > 0) t.erase(t.end() - 1);
    }
    cout << t;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

struct edge
{
    ll from, to, cost;
};
edge es[2005]; // 辺
ll d[1005];    // 最短距離
ll V, E;        // 頂点数･辺数

/* デカい配列はここで宣言 */

int main(int argc, char const *argv[])
{
    cin >> V >> E;
    for (ll i = 0; i < E; i++)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        es[i].from = a - 1;
        es[i].to = b - 1;
        es[i].cost = -c;
    }

    ll s = 0;
    for (ll i = 0; i < V; i++)
        d[i] = LLONG_MAX;
    d[s] = 0;
    for (ll k = 0; k < V - 1; k++)
    {
        for (ll i = 0; i < E; i++)
        {
            edge e = es[i];
            if (d[e.from] != LLONG_MAX && d[e.to] > d[e.from] + e.cost)
            {
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }

    ll ans = d[V - 1];

    bool negative[1005] = {false};
    for (ll i = 0; i < 1005; i++)
    {
        negative[i] = false;
    }

    for (ll k = 0; k < V; k++)
    {
        for (ll i = 0; i < E; i++)
        {
            edge e = es[i];

            if (d[e.from] == LLONG_MAX)
                continue;

            if (d[e.to] > d[e.from] + e.cost)
            {
                d[e.to] = d[e.from] + e.cost;
                negative[e.to] = true;
            }

            if (negative[e.from])
            {
                negative[e.to] = true;
            }
        }
    }

    if (negative[V - 1])
        cout << "inf" << endl;
    else
    {
        cout << -ans << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

void A(){
    ll N,K; cin >> N >> K;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    vector<ll> x(200001);
    set<ll> s;
    for(int i = 0; i < N;i++){
        x[A[i]]++;
        s.insert(A[i]);
    }
    sort(x.begin(),x.end());
    ll ans = 0;
    for(int i = 0; i <= 200000;i++){
        if(s.size() <= K) break;
        if(x[i] == 0) continue;
        ans += x[i];
        s.erase(*s.begin());
    }
    cout << ans << endl;
}

void B(){
    ll N; cin >> N;
    vector<ll> a(N); for(auto& in:a) cin >> in;
    map<ll,ll> mp;
    for(int i = 0; i < N;i++) mp[a[i]]++;
    ll ans = 0;
    for(auto p:mp){
        if(p.first < p.second) ans += (p.second-p.first);
        if(p.second < p.first) ans += p.second;
    }
    cout << ans << endl;
}

void C(){
    ll X,Y; cin >> X >> Y;
    ll ans = 0;
    while(X <= Y){
        ans++;
        X*=2;
    }
    cout << ans << endl;
}
void D(){
    ll N; cin >> N;
    vector<ll> C(N),S(N),F(N);
    for(int i = 0; i < N-1;i++) cin >> C[i] >> S[i] >> F[i];
    for(int i = 0; i < N;i++){
        ll ans = S[i] + C[i];
        for(int j = i+1; j < N-1;j++){
            if(ans <= S[j]){
                ans = S[j]+C[j];
            }else{
                ans = (ans - S[j]+F[j]-1)/F[j]*F[j] + S[j]+C[j];
            }
        }
        cout << ans << endl;
    }
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    //A();
    //B();
    //C();
    D();
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC136A()
{
	int A, B, C;
	cin >> A >> B >> C;
	cout << max(0, C - (A - B)) << endl;
}

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

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int a,b,c;
	scanf("%d %d %d", &a, &b, &c);
	int max = a;
	if (b > max) {
		max = b;
	}
	if (c > max) {
		max = c;
	}
	int answer = a+b+c+max*9;
	printf("%d\n", answer);

  return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
# 整数の入力
from functools import reduce


def main():
    # a, b
    n = int(input())
    v = map(int, input().split())
    print(process(n, v))


def process(n, v):
    v = sorted(v)
    return reduce((lambda x, y: (x + y) / 2), v)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};
int n,m,k,d[801][801],xs,ys,ans=INF;
char s[801][801];
int asd(int i,int j)
{
	int r=i;
	r=min(r,j);
	r=min(r,n-1-i);
	r=min(r,m-1-j);
	return r;
}
queue<pair<int,int> > q;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>k;
	for (int i=0;i<n;++i)
		for (int j=0;j<m;++j)
		{
			cin>>s[i][j];
			if (s[i][j]=='S') xs=i,ys=j;
		}
	memset(d,-1,sizeof(d));
	d[xs][ys]=0;
	q.push(make_pair(xs,ys));
	while (!q.empty())
	{
		int x=q.front().first;
		int y=q.front().second;
		q.pop();
		for (int i=0;i<4;++i)
		{
			int xx=x+dx[i];
			int yy=y+dy[i];
			if (xx>=0 && xx<n && yy>=0 && yy<m && s[xx][yy]=='.' && d[xx][yy]<0)
			{
				d[xx][yy]=d[x][y]+1;
				q.push(make_pair(xx,yy));
			}
		}
	}
	for (int i=0;i<n;++i)
		for (int j=0;j<m;++j)
			if (d[i][j]>=0 && d[i][j]<=k)
				ans=min(ans,1+(asd(i,j)+k-1)/k);
	cout<<ans;
	return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

void solve() {
    int a, b; scanf("%d%d", &a, &b);
    int ans = 0;
    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            for (int k = 0; k < 10; ++k) {
                int x = k+10*j+100*i+1000*j+10000*k;
                if (x >= a && x <= b) ++ans;
            }
        }
    }
    printf("%d", ans);
}

int main() {
    init();
    int t = 1; //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let hs: Vec<i32> = buf.trim().split(" ").map(|x| x.parse().unwrap()).collect();
    let mut ans = 0;
    let mut max = 0;
    for h in hs {
        if h >= max {
            ans += 1;
        }
        max = std::cmp::max(h, max);
    }
    println!("{}", ans);
}


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

typedef long long ll;
const int MAX_N = 100;

int main() {
  int N, X;
  std::cin >> N >> X;

  int D = 0, cnt = 1;
  for(int i = 0; i < N; ++i) {
    int L;
    std::cin >> L;
    D += L;
    if(D <= X) ++cnt;
  }
  std::cout << cnt << std::endl;
}


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

// why am I so weak

int n, a, b;
int x[100055];

int main() {
	scanf("%d %d %d", &n, &a, &b);

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

	long long res = 0ll;

	for (int i = 1; i < n; i++) {
		res += min(1ll * a * (x[i] - x[i - 1]), 1ll * b);
	}

	cout << res;

	return 0;
}


Measured memory_bytes: 640
#import sys
#input = sys.stdin.buffer.readline
#input = sys.stdin.readline

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


def main():
	n=int(input())
	s=[]
	t=[]
	for i in range(n):
		a,b=input().split()
		s.append(a)
		t.append(int(b))
	x=input()
	for i in range(n):
		if x==s[i]:
			ans=sum(t[i+1:])
			print(ans)
			exit(0)


if __name__ == "__main__":
	main()


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

using namespace std;

const int N = 2e5 + 5;
vector<int> adj[N];
vector<int> sizes[N];
int sz[N];

int dfs(int node , int par) {
    sz[node] = 1;
    for (int child : adj[node]) {
        if (child != par) {
            sizes[node].push_back(dfs(child , node));
            sz[node] += sizes[node].back();
        }
    }
    return sz[node];
}

void dfs(int node , int par , int s) {
    if (node != 1)
        sizes[node].push_back(s);
    for (int child : adj[node])
        if (child != par)
            dfs(child , node , s + sz[node] - sz[child]);
}


const long long MOD = 1e9 + 7; // have to be a prime

long long mul(long long a , long long b) {
    return a * b % MOD;
}

int add (int a , int b) {
    a += b;
    while (a >= MOD) a -= MOD;
    while (a < 0) a += MOD;
    return a;
}

long long power(long long a , long long b) {
    if (!b) return 1;
    long long r = power(a , b / 2);
    r = mul(r , r);
    if (b&1) return mul(r , a);
    return r;
}

long long mod_inv(long long x) {
    return power(x , MOD - 2);
}


int main() {
    int n;
    cin >> n;
    for (int i = 0 ;i < n - 1 ;i++) {
        int u , v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dfs(1 , -1);
    dfs(1 , -1 , 0);

    int ans = 0;
    for (int i = 1 ;i <= n ;i++) {
        int zero = 1 , one = 0 , atleasttwo = 0;
        for (int x : sizes[i]) {
            int black = add(1 , -mod_inv(power(2 , x)));
            int white = add(1 , -black);
            atleasttwo = add(atleasttwo , mul(black , one));
            one = add(mul(one , white) , mul(zero , black));
            zero = mul(zero , white);
        }
        ans = add(ans , mul(atleasttwo , mod_inv(2)));
    }

    cout << ans;
}

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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
int lcm(int a, int b) { return a / __gcd(a,b) * b;}
/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  int ans = 1;
  REP(i,n) {
    int t;
    cin >> t;
    ans = lcm(ans,t);
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

int main() {
    int K,A,B;
    cin >> K;
    cin >> A >> B;
    for(int i=A;i<B+1;i++) {
        if(i%K==0) {
            cout << "OK" << endl;
            exit(0);
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N; cin >> N;
	string s; cin >> s;

	int ans = 0;
	int x = 0;
	REP(i,N){
		if(s[i] == 'I'){
			x++;
			ans = max(x, ans);
		}else{
			x--;
		}
	}

	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int X,Y;
  cin>>X>>Y;
  rep(i,100){
    int tmp=i*2+(X-i)*4;
    if(X-i>=0 and tmp==Y){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}



Measured memory_bytes: 3636
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement,groupby
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=ST()
    G=groupby(S)
    ans = -1
    for i in G:
        ans+=1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 40176
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define fi first
#define se second
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 2000009
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll, ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}




void test_case()
{
    int a , b, c;
    cin >>a>>b>>c;

    if(a+b+c >= 22) {
        cout<<"bust"<<endl;
    } else {
        cout<<"win"<<endl;
    }



}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);

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

    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}



signed main(){
	
	ll n,k,cnt = 0;
	cin >> n >> k;
	ll a[n] = {};
	
	rep(i,0,n){
		cin >> a[i];
		if(a[i] >= k) cnt++;
	}
	
	cout << cnt << endl;
	
    return 0;
}

Measured memory_bytes: 1024
url = "https://atcoder.jp/contests/abc044/tasks/abc044_a"

def main():

    n = [int(input()) for i in range(4)]
    if n[0] > n[1]:
        n1 = (n[0] - n[1]) * n[3]
        n2 = n[1] * n[2]
    else:
        n1 = 0
        n2 = n[0] * n[2]
    print(n1 + n2)


if __name__ == '__main__':
    main()




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



int main() {
	int l, r;
	cin >> l >> r;
	vector<ll> mods;
	for (int i = l; i <= min(r, l+2019 * 2); i++) {
		mods.push_back(i % 2019);
	}

	ll ans = 1e18;
	for (int i = 0; i < (int)mods.size(); i++) {
		for (int j = i + 1; j < (int)mods.size(); j++) {
			ans = min(ans, (mods[i] * mods[j]) % 2019);
		}
	}

	cout << ans;

}

Measured memory_bytes: 256
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/numeric/ublas/vector.hpp>
// ↓これいる？
#include <boost/graph/strong_components.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;
using namespace boost::numeric;

using ll = long long;
namespace bst = boost;
template<class T> void fill(T& v) { for (auto&& i : v) cin >> i; }

//#include "atcoder.hpp"

int main() {
    int X;
    
    cin >> X;
  
  if (X >= 10000) {
    cout << 1 << endl;
    return 0;
  }
  
  int h = X / 100, l = X % 100;
    
    cout << (h * 5 >= l ? 1 : 0) << endl;
    
    return 0;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n; cin >> n;
  vector<ll> a(n); REP(i, n) cin >> a[i];
  ll ans = 0;
  REP(i, n-2){
    if(a[i] < a[i+1] && a[i+1] < a[i+2] || a[i] > a[i+1] && a[i+1] > a[i+2]){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
//#pragma GCC optimize(2)
using namespace std;
//const double eps=1e-6;
//typedef complex<double>C;
//const double PI(acos(-1.0));
//for(int mask=i;mask>0;mask=(mask-1)&i)
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){int s=0;while(x){s+=BIT[x];x-=x&-x;}return s;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a,LL b){LL t=1;for(;b;b>>=1,a=a*a%M)b&1?t=t*a%M:0;return t;}
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//isalnum() decimal digit or an uppercase or lowercase letter
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//cout<<fixed<<setprecision(12)<<ans<<endl;
//__builtin_popcount(mask)
const int N=60000;
const int M=1e9+7;


int n,m;
vector<int>pr;
int p[N];
int main() {
	for(int i=2;i<=55555;i++)
		if(!p[i]){
			pr.PB(i);
			for(int j=i+i;j<=55555;j+=i)p[j]=1;
		}
	cin>>n;
	int c=0;
	for(auto x:pr){
		if(x%5==1){
			cout<<x<<" ";
			c++;
			if(c==n)break;
		}

	}
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

N, K = MII_split()
As = LII_split()

# search loop
visited = [False for _ in range(N)]
start = 1
visited[0] = True
loop = [start]
cur = start
for _ in range(N):
    nex = As[cur - 1]
    # print(cur)
    if not visited[nex - 1]:
        loop.append(nex)
        visited[nex - 1] = True
        cur = nex
    else:
        start_idx = loop.index(nex)
        before_num = start_idx
        befores = loop[:start_idx + 1]
        loop = loop[start_idx:]

        break

# print(loop)
# return
# print(befores)
# print(K)
# return
if K < before_num:
    print(befores[K])
else:
    K -= before_num
    idx = K % len(loop)
    print(loop[idx])

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

const int MAX = 1000000;
const int MOD = 1000000007;


int main(){
   int n, m;
   cin >> n >> m;
   vector<int>imos(n+1);
   rep(i, 0, m){
       int p, q;
       cin >> p >> q;
       p--;
       imos[p]++;
       imos[q]--;
   }
   rep(i, 1, n+1){
       imos[i]+=imos[i-1];
   }
   int ans = 0;
   rep(i, 0, n+1)if(imos[i]==m)ans++;
   cout << ans << endl;
}

Measured memory_bytes: 3780
import java.util.Scanner;


public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(; scanner.hasNext();)
		{
			int w = scanner.nextInt();			
			for(int i=0; w>0; i++,w>>=1)
			{
				if(w%2 == 1)
				{
					System.out.print((int)Math.pow(2, i) + (w/2>0?" ":""));
				}				
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 26212
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
using namespace std;

int main() {
	int N;
	cin >> N;
	cout << N / 3 << endl;
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
using P = pair<int,int>;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main()
{
    int a,b,h,m;
    cin >> a >> b>> h >> m;

    double tan = 0.5 * (h*60+m);
    double tyo =  6 * m;
    double kaku = abs(tan - tyo);

    
    kaku *= acos(-1)/180 ;

    double c = sqrt(a*a+b*b - 2*a*b*cos(kaku));

    printf( "%.15f",c);

    return 0;
}

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

int main(){
	ll A,B,m; cin >> A >> B >> m;
	vl a(A); vl b(B); vl x(m); vl y(m); vl c(m);
	rep(i,A)cin >> a[i];
	rep(i,B)cin >> b[i];
	rep(i,m){
		cin >> x[i] >> y[i] >> c[i];
		x[i]--; y[i]--;}
	ll a_min = *min_element(a.begin(), a.end());
	ll b_min = *min_element(b.begin(), b.end());
	ll ans = a_min + b_min;
	rep(i,m)ans = min(ans,a[x[i]]+b[y[i]]-c[i]);
	cout << ans << endl;
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef long long ll;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second
#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef long long ll;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second


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

    ll n;
    cin >> n;
    vector<ll> v(5);
    for(auto &z : v)
        cin >> z;

    ll mini = *min_element(all(v));
    ll res = (mini+n-1) / mini + 4;
    cout << res << '\n';
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T = ll> constexpr T TEN(int n) {return (n==0)?1:10*TEN<T>(n-1);}

const int MP = 100100;
vector<int> pr;
vector<ull> bpr;

void first() {
    bool used[MP] = {};
    for (int i = 2; i < MP; i++) {
        if (used[i]) continue;
        pr.push_back(i);
        ull x = ((__int128(1)<<64) + i-1 ) / i;
        bpr.push_back(x);
        for (int j = 2*i; j < MP; j += i) {
            used[j] = true;
        }
    }
}

map<ll, int> fact(ll n) {
    int pc = (int)pr.size();
    map<ll, int> mp;
    for (int i = 0; i < pc; i++) {
        ll d = pr[i]; ull rd = bpr[i];
        if (n < d*d) break;
        while (true) {
            ll nd = __int128(n)*rd >> 64;
            if (nd * d != n) break;
            n = nd;
            mp[d]++;
        }
    }
    if (n > 1) mp[n]++;
    return mp;
}

ll mul(ll a, ll b) {
    if (TEN(12)/a < b) return TEN(12);
    return a*b;
}

int main() {
    first();
    using P = pair<ll, ll>;
    map<ll, P> g;
    int n;
    scanf("%d", &n);
    bool one = false;
    for (int i = 0; i < n; i++) {
        if (i % 1000 == 0) {
//            cout << i << " " << gc << endl;
        }
        ll s;
        scanf("%lld", &s);
        map<ll, int> fac = fact(s);
        ll d0 = 1, d1 = 1;
        for (auto p: fac) {
            p.second %= 3;
            if (p.second == 1) {
                d0 = mul(d0, p.first);
                d1 = mul(d1, p.first);
                d1 = mul(d1, p.first);
            } else if (p.second == 2) {
                d0 = mul(d0, p.first);
                d0 = mul(d0, p.first);
                d1 = mul(d1, p.first);
            }
        }
        if (d0 == 1) {
            one = true;
            continue;
        }
        if (d0 < d1) {
            g[d0].first++;
        } else {
            g[d1].second++;
        }
    }

    int ans = 0;
    for (auto p: g) {
        ans += max(p.second.first, p.second.second);
    }
    cout << ans + (one ? 1 : 0) << endl;
    return 0;
}


Measured memory_bytes: 7292
import java.util.*;
import java.util.TreeMap;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    ArrayList<Integer> list = new ArrayList<Integer>();
    for (int i = 0; i < N; i++) {
      list.add(sc.nextInt());
    }
    ArrayList<Integer> list1 = new ArrayList<>(list);
    Collections.sort(list1, Collections.reverseOrder());
    int first = list1.get(0);
    int second = list1.get(1);
    for (int i = 0; i < N; i++) {
      if (list.get(i) < first) {
        System.out.println(first);
      } else {
        System.out.println(second);
      }
    }
  }
}


Measured memory_bytes: 96520
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

int main()
{
    int a, b, x;
    cin >> a >> b >> x;

    if (a > x) {
        cout << "NO" << endl;
    } else {
        if (a + b >= x) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n"

ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; }
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; }
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; }
ll modPow(ll x,ll n,ll mod=MOD){
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod);
}
using namespace std;
//-------------------------------------------

int main(void){
  ll N;cin>>N;
  vi a(N);
  REP(i,N)cin>>a[i];
  ll k=1,c=0;
  REP(i,N){
  	if(k==a[i]){
  		k++;
  		continue;
  	}
    else c++;
  }
  cout<<(k==1?-1:c);
  return 0;
}

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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;

lli n;
vll a;
lli ans = 0;

int main(){
  cin >> n;
  a = vll(n);
  for(lli i = 0;i < n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  for(lli i = a[0];i <= a[a.size()-1];i++){
    ans = max(ans,(lli)(upper_bound(a.begin(),a.end(),i+2)-lower_bound(a.begin(),a.end(),i)));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
H, W = map(int, input().split())
a = [list(input()) for i in range(H)]
a = [x for x in a if '#' in x]
aT = list(zip(*a))
aT = [x for x in aT if '#' in x]
a = list(zip(*aT))
for i in a:
    print(''.join(i))


Measured memory_bytes: 9132
from collections import deque

inf = 10 ** 9

def bfs(si, sj, str_list, dist, h, w):
    q = deque([[si, sj]])
    dist[si][sj] = 0
    max_tmp = 0
    while len(q) != 0:
        i, j = q.popleft()
        for dx, dy in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            ni = i + dx
            nj = j + dy
            if ni < 0 or ni >= h or nj < 0 or nj >= w:
                continue
            if str_list[ni][0][nj] != '.':
                continue
            if dist[ni][nj] != inf:
                continue
            dist[ni][nj] = dist[i][j] + 1
            q.append([ni, nj])
            max_tmp = max(max_tmp, dist[ni][nj])
    return max_tmp

def main():
    h, w = map(int, input().split())
    str_list = []
    for i in range(h):
        str_list.append(list(input().split()))

    max_num = 0

    for si in range(h):
        for sj in range(w):
            if str_list[si][0][sj] != '.':
                continue
            dist = [[inf] * w for i in range(h)]
            bfs_result = bfs(si, sj, str_list, dist, h, w)
            max_num = max(max_num, bfs_result)

    print(max_num)  

if __name__ == '__main__':
    main()

Measured memory_bytes: 44396
def is_prime(n):
    for i in range(2, n-1):
        if n % i == 0:
            return False
        if i * i > n:
            break
    return True


ans = 0
while True:
    try:
        n = int(input())
        if is_prime(n):
            ans += 1
    except EOFError:
        break

print(ans)



Measured memory_bytes: 5608
<?php
fscanf(STDIN,"%d %d",$k,$n);
$a = explode(" ",fgets(STDIN));
$a = array_map('trim', $a);
$a = array_map('intval', $a);
sort($a);
$b = [];
for($i=0;$i<$n;$i++){
	if($i==$n-1){
		$b[] = intval($k)-intval($a[$i])+intval($a[0]);
	}else{
		$b[] = intval($a[$i+1])-intval($a[$i]);
	}
}
echo intval($k)-max($b);

Measured memory_bytes: 29168
n = int(input())
a = [int(x) for x in input().split()]

bl = [a[-2*i-1-n%2] for i in range(n//2)]
br = [a[2*i] for i in range((n+1)//2)]
b = bl + br
if n%2 == 0 :
    print(*b, sep=" ")
else :
    print(*b[::-1], sep=" ")


Measured memory_bytes: 26020
s = input()
n = len(s)

check = True
for i in range(n//2):
    if s[i] != s[n - i - 1]:check = False
for i in range((n-1)//2):
    if s[i] != s[(n-1)//2 - i - 1]:check = False
for i in range((n-1)//2):
    if s[(n-1)//2 + i + 1] != s[n - i - 1]:check = False
if check:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
// Created by js0805
#include <bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
void solve() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(abs(a[i - 1] - a[i]) + dp[i - 1], abs(a[i - 2] - a[i]) + dp[i - 2]);
    }
    cout << dp[n - 1] ;
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    solve();
    return 0;
}



Measured memory_bytes: 4388
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int N; cin >> N;
    vector<vector<P>> G(N);
    rep(i, N - 1) {
        int u, v, w; cin >> u >> v >> w; --u, --v;
        G[u].pb(mp(v, w));
        G[v].pb(mp(u, w));
    }
    vector<int> dist(N, INF);
    dist[0] = 0;
    queue<int>Q;
    Q.push(0);
    while(!Q.empty()) {
        int q = Q.front(); Q.pop();
        for(P next : G[q]) {
            if(dist[next.first] == INF) {
                dist[next.first] = dist[q] + next.second;
                Q.push(next.first);
            }
        }
    }
    rep(i, N) {
        if(dist[i] % 2) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
    }
}


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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

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

    if((b-a)%2==0)
        cout << (b-a)/2 << endl;
    else
        cout << min(a-1,n-b)+1+(b-a-1)/2 << endl;

    return 0;
}

Measured memory_bytes: 3636
n = int(input())
b = list(map(int, input().split()))
a = []
a.append(b[0])

for i in range(1, n-1):
    if b[i] >= b[i - 1]:
        a.append(b[i - 1])
    else:
        a.append(b[i])

a.append(b[n-2])
print(sum(a))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;


int main(){
    
    string s;
    cin>>s;
    if(s.size()%2 == 0){
        puts("No");
        return 0;
    }
    
    int m = s.size()/2;
    string aa = s.substr(0, m), bb = s.substr(m+1);
    //cout<<aa<<' '<<bb<<'\n';
    string a = aa, b = bb;
    reverse(all(a));
    reverse(all(b));
    if(a == aa and b == bb and a == bb){
        puts("Yes");
    }
    else{
        puts("No");
    };
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    string S, T; cin >> S >> T;
    for (int i = 0; i < N; ++i) {
        cout << S[i] << T[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    int N; cin>>N;
    vector<int> A(N);
    REP(i, N) cin>>A[i];
    sort(ALL(A));

    auto itr = lower_bound(A.begin(), A.begin()+N-1, A[N-1]/2);
    int r = 0;
    int target = A[N-1]/2;
    if(*itr==target){
        r = target;
    } 
    else {
        if(itr == A.begin()+N-1) itr--;
        int ru = *itr;
        int rl = *(itr-1);
        if(ru-(A[N-1]-target) < target-rl) r = ru;
        else r = rl;
    }
    cout << A[N-1] << " " << r << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,l;
  cin >> n >> l;
  int sum = 0,m = 99999;
  for(int i=0;i<n;i++){
    sum += l + i;
    if(abs(l+i)<abs(m)) m  = l+i;
  }
  cout << sum - m << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace contest_Csharp
{
    class Program
    {
        static long N = 0, A = 0, B = 0, C = 0, D = 0;
        static Dictionary<long, long> memo = new Dictionary<long, long>();


        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var vals = Console.ReadLine().Split(' ')
                .Select(x => int.Parse(x)).ToList();

            int T = vals[0];
            for (int i = 0; i < T; i++)
            {
                memo = new Dictionary<long, long>();
                var vals2 = Console.ReadLine().Split(' ')
                .Select(x => long.Parse(x)).ToList();
                N = vals2[0];
                A = vals2[1];
                B = vals2[2];
                C = vals2[3];
                D = vals2[4];
                var ans = serch(N);
                Console.WriteLine(ans);


            }



            Console.Out.Flush();

        }
        static long serch(long num)
        {
            checked
            {
                if (num == 900000000000000000)
                {

                }
                long ans;
                long gval;
                if (memo.TryGetValue(num, out gval))
                {
                    return gval;
                }
                if (num == 1)
                {
                    memo[num] = D;
                    return D;

                }
                if (num == 0)
                {
                    return 0;
                }
                ans = serch(num / 2) + A + D * (num % 2);
                
                if (num > 2)
                    ans = Math.Min(serch(num / 2 + 1) + A + D * (2-num % 2), ans);
                
                ans = Math.Min(serch(num / 3) + B + D * (num % 3), ans);
                ans = Math.Min(serch(num / 3 + 1) + B + D * (3 - num % 3), ans);
                ans = Math.Min(serch(num / 5) + C + D * (num % 5), ans);
                ans = Math.Min(serch(num / 5 + 1) + C + D * (5 - num % 5), ans);
                if (long.MaxValue / num > D)
                {
                    ans = Math.Min(ans, D * num);
                }

                memo[num] = ans;
                

                return ans;
            }
        }



    }

}


Measured memory_bytes: 32808