akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <math.h>
using namespace std;
int main()
{
	int n,i;
	cin>>n;
	int xi,yi,ti;
	bool find=true;
	int sx=0,sy=0,d,rest,lastT=0;
	for(i=1;i<=n;i++)
	{
		cin>>ti>>xi>>yi;
		rest=ti-lastT;
		d=abs(xi-sx);
		if(d>rest)
		{
			cout<<"No";
			return 0;
		}
		rest-=d;
		d=abs(yi-sy);
		if(d>rest)
		{
			cout<<"No";
			return 0;
		}
		rest-=d;
		if(rest%2!=0)
		{
			cout<<"No";
			return 0;
		}
		lastT=ti;
		sx=xi;
		sy=yi;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
# by the authority of GOD     author: manhar singh sachdev #

import os,sys
from io import BytesIO, IOBase

def main():
    n = int(input())
    l = list(map(int,input().split()))
    ans = 0
    for i in range(n):
        for j in range(i+1,n):
            for k in range(j+1,n):
                if l[i] != l[j] and l[k] != l[j] and l[i] != l[k]:
                    if 2*max(l[i],l[j],l[k]) < l[i]+l[j]+l[k]:
                        ans += 1
    print(ans)

#Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

Measured memory_bytes: 68244
#include<bits/stdc++.h>
#define rep(i,f,n) for(int i=(f); (i) < (n); i++)
#define repe(i,f,n) for(int i=(f); (i) <= (n); i++)
using namespace std;

typedef long long ll;
ll INF = 1LL << 60;

int 
main() 
{

  int n; cin >> n;
  vector<int> arr(n);
  rep(i, 0, n) cin >>arr[i];

  int mul4_num = 0;
  int odd_num = 0;
  rep(i, 0, n){
    if(arr[i] % 2 != 0) odd_num++;
    if(arr[i] %4 == 0) mul4_num++;
  }

  if((n % 2 == 0) && (odd_num <= mul4_num)){
    cout << "Yes" << endl;
  } else if((n % 2 != 0) && (odd_num - 1 <= mul4_num)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  

  return 0;
}




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

typedef long long ll;
int main() {

    int n;
    string s;
    cin >> n >> s;
    ll ans(0);
    int r(0), g(0), b(0);
    for (char c: s) {
        if (c == 'R') r++;
        if (c == 'G') g++;
        if (c == 'B') b++;
    }
    ans = (ll) r * g * b;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int k = 2 * j - i;
            if (s[i] == s[j]) continue;
            if (k >= n) continue;
            if (s[k] != s[i] && s[k] != s[j]) ans--;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int n,l; cin>>n>>l;
  vector<string> s(n);
  rep(i,n) cin>>s[i];
  sort(ALL(s));
  rep(i,n)
  cout<<s[i];
  cout<<endl;

  return 0;
}


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


int main(){
	int n,m;
	cin >> n >> m;
	int vecA[n][m],vecB[m];

//	vecA
	for(int i = 0;i<n;i++)
		for(int k=0;k<m;k++)
			cin >> vecA[i][k];

//	vecB
	for(int i=0;i<m;i++)
		cin >> vecB[i];


	int result[n]={};

	for(int i=0;i<n;i++){
		for(int k=0;k<m;k++){
			result[i] += vecA[i][k]*vecB[k];
		}
		cout << result[i] <<endl;
	}
	return 0;
}



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

signed main(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b == c || b == a + c || a == b + c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100];

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++)
  	a[s[i] - 'A']++;
  for (int i = 0; i < 26; i++)
    if ((a[i] ^ 0) && (a[i] ^ 2))
 		return cout << "No" << '\n', 0;
  cout << "Yes" << '\n';
      return 0; 
}


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

using namespace std;
using ll = long long;

int main() {
    ll N = 0;
    cin >> N;
    ll M = 0;
    cin >> M;
    vector<ll> p(M,0);
    vector<string> S(M);
    for(ll i = 0; i < M; i++) {
        cin >> p.at(i);
        cin >> S.at(i);
    }


    
    vector<int> A(N,0);
    vector<bool> B(N,0);
    ll sum = 0;
    ll ans = 0;
    for (size_t i = 0; i < M; i++) {
        if(S.at(i) == "AC" && !B.at(p.at(i) - 1)) {
            ans++;
            sum += A.at(p.at(i) - 1);
            B.at(p.at(i) - 1) = 1;
        } else if (S.at(i) == "WA" && !B.at(p.at(i) - 1)) {
            A.at(p.at(i) - 1)++;
        }
    }
    
    cout << ans << ' ' << sum << endl;

    return 0;
}

Measured memory_bytes: 7472
import itertools
import copy
h, w, k = list(map(int, input().split()))
maze = []
for i in range(h):
  li = []
  tmp = input()
  for j in range(w):
    li.append(tmp[j])
  maze.append(li)

h_total_li = list(itertools.product([1, 0], repeat=h))
w_total_li = list(itertools.product([1, 0], repeat=w))
ans = 0
for h_val in h_total_li:
  for w_val in w_total_li:
    now = 0
    tmp_maze = copy.deepcopy(maze)
    for h_ind, each_h in enumerate(h_val):
      if each_h == 1:
        for i in range(w):
          tmp_maze[h_ind][i] = 1
    for w_ind, each_w in enumerate(w_val):
      if each_w == 1:
        for i in range(h):
          tmp_maze[i][w_ind] = 1

    for i in range(h):
      for j in range(w):
        if (tmp_maze[i][j] == '#'):
          now += 1

    if now == k:
      ans += 1

print(ans)

Measured memory_bytes: 9384
#include <bits/stdc++.h>
#define SIZE 10
#define PI 3.141592653589793

using namespace std;
typedef long long ll;

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

	int answer=0;
	int i,j;
	int tmp;
	int counter=0;
	vector<int> given;

	for(i=0;i<5;i++){
		cin >> tmp;
		given.push_back(tmp);
	}
	
	for(i=0;i<5;i++){
		if(given[i]==0){
			cout << i+1 << endl;
			return 0;
		}
	}
}



Measured memory_bytes: 3656
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

S = raw_input()
if S == "Sunny":
    print "Cloudy"
elif S == "Cloudy":
    print "Rainy"
else:
    print "Sunny"

Measured memory_bytes: 4396
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define MOD 1000000007;
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> counter(n,0);
  int tmp;
  rep(i,n){
    cin >> tmp;
    a.at(i) = tmp;
    counter.at(tmp)++;
  }
  if(n % 2 == 0){
    for(int i = 1; i < n ;i += 2){
      if(counter.at(i) != 2){
        cout << 0 << endl;
        return 0;
      }
    }
  }else{
    if(counter.at(0) != 1){
      cout << 0 << endl;
      return 0;
    }
    for(int i=2;i < n;i += 2){
      if(counter.at(i) != 2){
        cout << 0 << endl;
        return 0;
      }
    }
  }
  long answer = 1;
  rep(i,n/2){
    answer *= 2;
    answer %= MOD;
  }
  cout << answer << endl;
}


Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	s := nextStr()

	if s[0] != 'A' {
		fmt.Println("WA")
		return
	}
	if strings.Count(s, "C") != 1 {
		fmt.Println("WA")
		return
	}
	cidx := strings.Index(s, "C")
	if cidx == 1 || cidx == len(s)-1 {
		fmt.Println("WA")
		return
	}

	for i := 1; i < len(s); i++ {
		if s[i] != 'C' {
			if 'a' > s[i] || s[i] > 'z' {
				fmt.Println("WA")
				return
			}
		}
	}

	fmt.Println("AC")

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

signed main() {
    ll N;
    cin>>N;
    map<ll,ll> mp; // id -> num of id
    rep(i,0,N){
        ll a;
        cin>>a;
        mp[a]++;
    }
    ll ans=0;
    for (auto e: mp) {
        ll id = e.first;
        ll num = e.second;
        // cout<<id<<" " <<num<<endl;
        if (num > id){
            ans+=num-id;
        } else if (num < id ){
            ans+=num;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6272
#include<iostream>
#include<map>
using namespace std;
map<int,int>M;
string s;
string t[]={"that","this"};
main()
{
	int n;cin>>n;cin.ignore();
	for(;n--;)
	{
		getline(cin,s);
		bool f=0;
		for(int a=1;!f&&a<26;a+=2)for(int b=0;!f&&b<26;b++)
		{
			map<int,int>M;
			if(a==13)continue;
			for(int z=0;z<26;z++)M[(a*z+b)%26]=z+'a';
			string S="";
			for(int i=0;i<s.size();i++)S+=(s[i]>='a'&&s[i]<='z'?M[s[i]-'a']:s[i]);
			for(int i=0;!f&&i<2;i++)
			{
				for(int j=0;!f&&j+t[i].size()<=S.size();j++)
				{
					if(S.substr(j,t[i].size())==t[i])
					{
						cout<<S<<endl;
						f=1;
					}
				}
			}
		}
	}
}


Measured memory_bytes: 3064
class Combination:
    def __init__(self, size=100, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, size + 2):
            self.fact[i] = self.fact[i - 1] * i % mod
            self.inv[i] = -self.inv[mod % i] * (mod // i) % mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

def sol():
    H, W, A, B = map(int, input().split())
    MOD = 10**9 + 7

    comb = Combination(H + W + 100)

    ans = 0
    for i in range(W - B):
        ans = (ans + comb.ncr(H - 1 - A + B + i, H - 1 - A) * comb.ncr(A - 1 + W - 1 - B - i, A - 1)) % MOD

    print(ans)


sol()

Measured memory_bytes: 29632
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int n; cin >> n;
  string s, t;
  cin >> s >> t;

  F0R(i, n) {
    cout << s[i] << t[i];
  }
}
#endif


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n;
    map<string, int> cnt;

    cin >> n;
    while(--n >= 0){
        string s;
        cin >> s;
        ++ cnt[s];
    }

    cin >> n;
    while(--n >= 0){
        string s;
        cin >> s;
        -- cnt[s];
    }

    int ans = 0;
    for(const auto& p : cnt)
        ans = max(ans, p.second);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) (*find_by_order(i))
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define mod 998244353
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
#define int ll
vector<ll> ft(1, 1LL);
/*======================================================================*/

void solve() {
    int n, s;
    cin >> n >> s;
    vl dp(s+1, 0);
    ll ans= 0;
    dp[0] = 1;
    rep(i, 0, n){
        int x;
        cin >> x;
        vl ndp(s+1, 0);
        rep(j, 0, s+1){
            if(j+x <= s)ndp[j+x] = (ndp[j+x] + dp[j])%mod;
            ndp[j] = (ndp[j] + dp[j]*2)%mod;
        //    deb(dp[j]);
        //    deb(x);
        }
        dp = ndp;
    }
    cout << dp[s];
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int h,w; cin >> h >> w;
    vvi a(h,vi(w));
    rep(i,h) rep(j,w) cin >> a[i][j];

    vector<pair<pii,pii>> ans;
    rep(i,h){
        rep(j,w){
            if(a[i][j]%2){
                if(j+1<w){
                    a[i][j]--;
                    a[i][j+1]++;
                    ans.emplace_back(pii(i,j), pii(i,j+1));
                }else if(i+1<h){
                    a[i][j]--;
                    a[i+1][j]++;
                    ans.emplace_back(pii(i,j), pii(i+1,j));
                }
            }
        }
    }

    cout << ans.size() << endl;
    for(auto p : ans){
        cout << p.first.first+1 << " " << p.first.second+1 << " " << p.second.first+1 << " " << p.second.second+1 << endl;
    }
}


Measured memory_bytes: 6348
package main

import(
  "fmt"
)

func main() {
  var N int
  fmt.Scan(&N)
  if N % 2 == 0 {
    fmt.Println(0.5)
  } else {
    N := float64(N)
    fmt.Println(((N-1.0)/2.0+1.0)/N)
  }
}

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

#define ll long long
#define F first
#define S second
#define ii pair < int , int >
#define ever (;;)

int main()
{
    int d,t,s;
    cin>>d>>t>>s;

    if( t*s >= d )
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
const ll MOD=1000000007;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll pow3[100002];
    pow3[0]=1;
    for(ll i=1;i<=100001;i++){
        pow3[i]=(pow3[i-1]*3)%MOD;
    }
    ll pow2[100002];
    pow2[0]=1;
    for(ll i=1;i<=100001;i++){
        pow2[i]=(pow2[i-1]*2)%MOD;
    }
    string L;
    cin>>L;
    vector<ll>numof1(L.size());
    ll sum=0;
    numof1[0]=0;
    for(ll i=1;i<L.size();i++){
        if(L[i-1]=='1')sum++;
        numof1[i]=sum;
    }
    ll N=L.size();
    ll sub=0;
    ll A;
    for(ll i=N-1;i>=0;i--){
        if(L[i]=='1'){
            A=pow2[numof1[i]];
            A*=pow3[N-i-1];
            A%=MOD;
            sub+=A;
            sub%=MOD;
        }
    }
    if(L[N-1]=='1'){
        sub+=pow2[numof1[N-1]+1];
        sub%=MOD;
    }
    if(L[N-1]=='0'){
        sub+=pow2[numof1[N-1]];
        sub%=MOD;
    }
    cout<<sub<<endl;
}

Measured memory_bytes: 2768
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"-----------"<<endl;
#define ll long long
#define P pair<int,int>
#define mk make_pair
#define en endl
#define RE return 0
#define int ll

// C

vector<int> plu;
vector<int> minu;

signed main(){
  int n,k;
  cin>>n>>k;
  bool zero=false;
  for(int i=1; i<=n; i++){
    int x; cin>>x;
    if(x==0){
      zero=true;
      --k;
    }
    else if(x>0) plu.push_back(x);
    else minu.push_back(abs(x));
  }
  if(zero&&k==0){
    cout<<0<<en;RE;
  }else if(!zero&&k==1){
    cout<<min(plu[0],minu[0])<<en; RE;
  }
  reverse(minu.begin(), minu.end());
  
  if(plu.size()==0){
    cout<<minu[k-1]<<en; RE;
  }else if(minu.size()==0){
    cout<<plu[k-1]<<en; RE;
  }

  int ans=INF;
  int p=min((int)plu.size(),k)-1;
  for(int i=p; i>=0; i--){
    int m=k-i-2;
    if(m>minu.size()-1) continue;
    if(m>=0){
      ans=min(ans,minu[m]+2*plu[i]);
    }
  }

  int m=min((int)minu.size(),k)-1;
  for(int i=m; i>=0; i--){
    int p=k-i-2;
    if(p>plu.size()-1) continue;
    if(p>=0){
      ans=min(ans,plu[p]+2*minu[i]);
    }
  }

  if(plu.size()>=k) ans=min(ans,plu[k-1]);
  if(minu.size()>=k) ans=min(ans,minu[k-1]);

  cout<<ans<<en;
}





Measured memory_bytes: 1656
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)

#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };


signed main() {
	ios::sync_with_stdio(false);
	int n, m;
	int i;
	cin >> n >> m;
	vector<int> ans(n,0);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		ans[a]++;
		ans[b]++;
	}
	rep(i, n) {
		cout << ans[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	set<ll> s ;
	for(int i=0;i<n;i++){
		ll a ; cin >> a ;
		s.insert(a) ;
	}
	YorN(n==s.size()) ;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   int  a, b;
   cin >> a >> b;
if ((a + b) % 2 == 0) { 
   cout << (a + b) / 2;
  }
else {
   cout << (a + b) / 2 + 1;
  }
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
typedef double dd;
#define pb push_back
#define mp make_pair
#define endl "\n"
ll const M = 1000000007;
dd const pi = acos(-1);
ll const inf = 2e18;
ll const N = 200001;
vector<vector<ll> > g(N);
vector<bool> visited(N,false);
ll a = 1;
void dfs2(ll node)
{
  visited[node] = true;
  for(auto x : g[node])
  {
    if(!visited[x])
      dfs2(x);
    else
        a = x;
  }
}
ll dfs1(ll node)
{
  ll ans = 0;
  visited[node] = true;
  for(auto x : g[node])
  {
    if(!visited[x])
      ans = ans + dfs1(x);
  }
  return 1 + ans;
}
int main()
{
    fast;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    ll i,j,t;
    ll n,k;
    cin >> n >> k;
    vector<ll> v(n + 1);
    for(i = 1; i <= n; i++)
    {
        cin >> v[i];
        g[i].pb(v[i]);
    }
    ll cnt = dfs1(1);
    ll ans = 1;
    if(k <= cnt)
    {
        for(i = 1; i <= k; i++)
        ans = v[ans];
    }
    else
    {
        for(i = 1; i <= n; i++)
            visited[i] = false;
        dfs2(1);
        for(i = 1; i <= n; i++)
            visited[i] = false;
        cnt = dfs1(a);
        map<ll,bool> m;
        while(!m[ans])
        {
            m[ans] = true;
            ans = v[ans];
            k--;
        }
        k %= cnt;
        for(i = 1; i <= k; i++)
            ans = v[ans];
    }
    cout<<ans<<endl;
    return 0;
}        

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int ans,memo[500000],MIN=INF;
string s;

signed main() {
    cin >> s;
    int cnt = 0;
    for(int i=s.size();i>0;--i) {
        if (s[i-1] == '>') cnt++;
        else {
            memo[i] = cnt;
            cnt = 0;
        }
    }
    memo[0] = cnt;
    cnt = 0;
    rep(i,s.size()+1) {
        if (memo[i]) cnt = memo[i], memo[i] = 0;
        memo[i] += cnt;
        cnt = max(0LL,cnt-1);
    }
    rep(i,s.size()) {
        if (s[i] == '<') {
            memo[i+1] = max(memo[i+1],memo[i]+1);
        }
    }
    rep(i,s.size()+1) ans += memo[i];
    cout << ans << endl;

}



Measured memory_bytes: 4740
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	ans := make(map[int]int, n)
	for _, v := range a {
		if _, ok := ans[v]; ok {
			fmt.Println("NO")
			return
		}
		ans[v] = 1
	}
	fmt.Println("YES")
}


Measured memory_bytes: 10368
def main():
    H, W = map(int, input().split())
    s = [['.'] * (W+2)]
    for i in range(H):
        s.append(list('.' + input() + '.'))
    s.append(['.'] * (W+2))

    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if s[i][j] == '#':
                if s[i + 1][j] != '#' and\
                        s[i][j + 1] != '#' and\
                        s[i - 1][j] != '#' and\
                        s[i][j - 1] != '#':
                    print('No')
                    return 0

    print('Yes')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
N = int(input())
h = list(map(int, input().split()))

min_cost = [0, abs(h[0] - h[1])]
for i in range(2, N):
    min_cost.append(min(
        min_cost[i - 1] + abs(h[i - 1] - h[i]),
        min_cost[i - 2] + abs(h[i - 2] - h[i])))
print(min_cost[N - 1])

Measured memory_bytes: 13980
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

int main(){
  int N,T[1000],A[1000];
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>T[i]>>A[i];
  }
  ll t=T[0],a=A[0],mult;
  for(int i=1;i<N;i++){
    mult=max((t+T[i]-1)/T[i],(a+A[i]-1)/A[i]);
    t=mult*T[i]; a=mult*A[i];
  }
  cout<<t+a<<endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
	string s;
	while(getline(cin, s)){
		vector<string> words;
		int p = 0;
		s += " ";
		for(int i = 0; i < s.size(); ++i){
			if(s[i] == ' ' || s[i] == '.' || s[i] == ','){
				if(3 <= (i - p) && (i - p) <= 6){
					words.push_back(s.substr(p, i - p));
				}
				p = i + 1;
			}
		}
		for(int i = 0; i < words.size(); ++i){
			cout << words[i];
			if(i + 1 == words.size()){
				cout << endl;
			}else{
				cout << " ";
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1176
h, w, d = map(int, input().split())
A = []
for _ in range(h):
    a = list(map(int, input().split()))
    A.append(a)

q = int(input())
LR = []
for _ in range(q):
    l, r = map(int, input().split())
    LR.append([l,r])

Inds = {x:[] for x in range(1, h*w+1)}
for j in range(h):
    for k in range(w):
        Inds[A[j][k]].append(j)
        Inds[A[j][k]].append(k)

Dist = [-1 for _ in range(h*w+1)]
for i in range(1,h*w+1):
    if i <= d:
        Dist[i] = 0
    else:
        Dist[i] = Dist[i-d] + abs(Inds[i][0]-Inds[i-d][0]) + abs(Inds[i][1]-Inds[i-d][1])

for lr in LR:
    ans = Dist[lr[1]] - Dist[lr[0]]
    print(ans)

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


int main(){
    string s; cin >> s;
    string ref = "AKIHABARA";
    int n=9;
    int s_p = 0;
    int s_len = s.size();
    for(int i=0; i<n; i++){
        if(ref[i]=='A'){
            if(s[s_p]=='A') s_p++;
        }
        else{
            if(ref[i]==s[s_p]) s_p++;
            else{
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    if(s_p==s_len){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int n;string s;
	cin>>n>>s;int ans=0;
	for(int i=0;i<n-2;i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
	}cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N, M, R;
vector<int> order;
const int INF = 100000000; //INT_MAXにしたらオーバーフローを起こす
vector<vector<int>> dist(201, vector<int>(201, INF)); //dist[u][v]は辺(u,v)のコスト（辺が存在しない場合はINF、ただしdist[i][i] = 0）

void Warshallfloyd(int n = N){ //nは頂点数
    for(int i = 1; i <= n; i++){      // 経由する頂点
        for(int j = 1; j <= n; j++){    // 開始頂点
            for(int k = 1; k <= n; k++){  // 終端
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
    return;
}

int main(void){
    
    scanf("%d %d %d", &N, &M, &R);
    for(int i = 0; i < R; ++i){
        int a; scanf("%d", &a);
        order.push_back(a);
    }
    for(int i = 0; i <= N; i++) dist[i][i] = 0;
    for(int i = 0; i < M; ++i){
        int a, b, c; scanf("%d %d %d", &a, &b, &c);
        dist[a][b] = dist[b][a] = c;
    }
    
    Warshallfloyd();
    
    int ans = INF;
    sort(order.begin(), order.end());
    do{
        int sum = 0;
        for(int i = 0; i < order.size() - 1; ++i){
            int cost = dist[order[i]][order[i + 1]];
            if(cost == INF){ sum = INF; break; }
            sum += cost;
        }
        ans = min(ans, sum);
    }while(next_permutation(order.begin(), order.end()));
    printf("%d\n", ans);
    
    return 0;
}


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

int main(){
    string S,T;
    cin >> S >> T;
    int i,j;
    int dabu=0;
    int counta;
    for(i=0; i+T.length()<=S.length(); i++){
        counta=0;
        for(j=0; j<T.length(); j++){
            if(T[j]==S[i+j]) counta++;
        }
        dabu=max(dabu,counta);
    }
    cout << T.length()-dabu << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <set>
using namespace std;

int main(void) {
    set<char> left, right;
    string up = "qwertyuiop", mid = "asdfghjkl", down = "zxcvbnm";
    for (int i = 0; i < 5; i++) {
        left.insert(up[i]);
        left.insert(mid[i]);
        left.insert(down[i]);
    }
    for (int i = 5; i < up.size(); i++) right.insert(up[i]);
    for (int i = 5; i < mid.size(); i++) right.insert(mid[i]);
    for (int i = 5; i < down.size(); i++) right.insert(down[i]);

    string s;
    while (cin >> s, s != "#") {
        char which;
        if (left.find(s[0]) != left.end()) {
            which = 'l';
        } else {
            which = 'r';
        }

        int cnt = 0;
        for (int i = 1; i < s.size(); i++) {
            if (which == 'l') {
                if (left.find(s[i]) == left.end()) {
                    which = 'r';
                    cnt++;
                }
            } else {
                if (right.find(s[i]) == right.end()) {
                    which = 'l';
                    cnt++;
                }
            }
        }

        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 3224
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int b1=0,b2=0,b3=0,ted =0,i,n; 
    char s[20];
    scanf("%s",s);
    if(s[0]=='A')
        b1=1;

    for(n=0;s[n];n++);
    for(i=0;s[i];i++)
        if(s[i]=='C'&& i>=2 && i<=n-2)
            b2++;
    for(i=0;s[i];i++)
        if(s[i]=='C')
            ted++;
    for(i=0;s[i];i++)
        if((s[i]>'A'&&s[i]<='Z') && s[i]!='C')
            b3=1;

    if(b1==1 && b2 ==1&&ted==1 && b3!=1)
        printf("AC\n");
    else
        printf("WA\n");
    return 0;
}

Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func rScan() []rune {
	return []rune(Scan())
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func mod(x, d int) int {
	x %= d
	if x < 0 {
		x += d
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bPrint(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}
func iSSPrint(x []int) {
	fmt.Println(strings.Trim(fmt.Sprint(x), "[]"))
}

var lp int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, lp)
	sc.Split(bufio.ScanWords)
	t := iScan()
	for i := 0; i < t; i++ {
		fmt.Println(floorSum(iScan(), iScan(), iScan(), iScan()))
	}
}
func floorSum(n, m, a, b int) int {
	ret := 0
	if a >= m {
		ret += (n - 1) * n * (a / m) / 2
		a %= m
	}
	if b >= m {
		ret += n * (b / m)
		b %= m
	}
	ymx := (a*n + b) / m
	xmx := ymx*m - b
	if ymx == 0 {
		return ret
	}
	ret += (n - (xmx+a-1)/a) * ymx
	ret += floorSum(ymx, a, m, (a-xmx%a)%a)
	return ret
}


Measured memory_bytes: 6064
#include <bits/stdc++.h>
using namespace std;
int main() {
 string S; cin >> S;
 string T; T = "ATCG";
    int ans = 0;
    int now = 0;
  for(int i = 0; i < S.size(); i++) {
   
   bool isATCG = false;
   for(int j = 0; j < T.size(); j++) {
     if (S[i] == T[j]) isATCG = true;
}
   if(!isATCG) now = 0;
   else {
     now++; ans = max(ans, now);
   }
  }
    
  cout << ans << endl;
  }

Measured memory_bytes: 256
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, m, d;
  cin >> n >> m >> d;
  int b = max(n - 2 * d, 0ll);
  if (n - d < d + 1) b = 0;
  if (d == 0) b = 0;
  int a = n - b;
  cout << setprecision(9) << fixed << (a + 2.0 * b) * (m - 1) / n / n<< "\n";
}



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

int main(){
	LL s,c;cin>>s>>c;
	LL cv=max((c-2*s)/4,0LL);
	s+=cv;c-=cv*2;
	printf("%lld",min(s,c/2));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const long long inf=1LL<<61;
typedef long long LL;
struct sgt{
	LL mn[maxn*2];
	int id(int l,int r){return l+r|l!=r;}

	void build(int l,int r){
		mn[id(l,r)]=inf;
		if(l==r)return ;
		int mid=(l+r)>>1;
		build(l,mid);
		build(mid+1,r);
	}
	LL Q(int l,int r,int l0,int r0){
		if(l0<=l&&r0>=r)
			return mn[id(l,r)];
		int mid=(l+r)>>1;
		LL ans=inf;
		if(l0<=mid)ans=min(ans,Q(l,mid,l0,r0));
		if(r0>mid)ans=min(ans,Q(mid+1,r,l0,r0));
		return ans;
	}
	void C(int l,int r,int ps,LL val){
		if(l==r){
			mn[id(l,r)]=val;
			return ;
		}
		int mid=(l+r)>>1;
		if(ps<=mid)C(l,mid,ps,val);
		else C(mid+1,r,ps,val);
		mn[id(l,r)]=min(mn[id(l,mid)],mn[id(mid+1,r)]);
	}
}T1,T2;
int n;
LL T,E;
LL d[maxn];
LL dp[maxn],d2[maxn];

LL bf(){

	dp[1]=0;
	for(int i=2;i<=n;i++){
		dp[i]=inf;
		for(int j=1;j<=i;j++){
			dp[i]=min(dp[i],dp[j-1]+d[i]-d[j-1]+max(T,2*(d[i]-d[j])));
		}
		printf("dp[%d]=%lld\n",i,dp[i]);
	}


	LL ans=dp[n]+E-d[n];

	return ans;
}

int main(){
	scanf("%d%lld%lld",&n,&E,&T);
	n++;
	d[1]=0;
	for(int i=2;i<=n;i++){
		scanf("%lld",&d[i]);
		d2[i]=d[i]*2;
	}


	//TODO
//	cout<< bf() <<endl;
//	return 0;
	T1.build(1,n);
	T2.build(1,n);


	dp[1]=0;
	T1.C(1,n,1,0);
	T2.C(1,n,1,0);

	for(int i=2;i<=n;i++){

		dp[i]=dp[i-1]+d[i]-d[i-1]+T;


		auto bin=[&](int lef,int rig){
			int l=1,r=rig-1;

			while(l<r){
				int mid=(l+r)>>1;
				if(2*(d[rig]-d[mid])>=T)
					l=mid+1;
				else
					r=mid;
			}

			int ans=0;
			for(int delta=-5;delta<=5;delta++){
				int ps=delta+l;
				if(1<=ps&&ps<rig){
					if(2*(d[rig]-d[ps])>=T){
						ans=ps;
					}else{
						break;
					}
				}
			}

			return ans;
		};
		int ps=bin(1,i);
		/*
		int ps=0;
		for(int j=1;j<i;j++){
			if(2*(d[i]-d[j])>=T){
				ps=j;
			}else{
				break;
			}
		}
*/
//		cerr<<ps<<" "<<bin(1,i)<<endl; 
//		assert(bin(1,i)==ps);

		//assert(ps==bin(1,i));

//		cerr<<"it is "<<i<<" "<<ps<<endl;
		LL res1=inf,res2=inf;

		if(ps>=1)
			res1=T1.Q(1,n,1,ps)+3*d[i];

		if(ps+1<=i-1)
			res2=T2.Q(1,n,ps+1,i-1)+d[i]+T;
//		cerr<<res1<<" "<<res2<<endl;

		dp[i]=min(dp[i],res1);
		dp[i]=min(dp[i],res2);
//		cerr<<"dp = "<<dp[i]<<endl;
		T1.C(1,n,i,dp[i-1]-d[i-1]-2*d[i]);
		T2.C(1,n,i,dp[i-1]-d[i-1]);
	}

	LL ans=dp[n]+E-d[n];

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

Measured memory_bytes: 5760
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

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

using namespace std;

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

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	int a, b;
	cin >> a >> b;
	if (a > b) {
		cout << a - 1;
	}
	else cout << a;

	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t n, m, k; cin >> n >> m >> k;

	vector<int64_t> sa(n + 1);
	vector<int64_t> sb(m + 1);

	{
		int64_t s = 0;
		FOR_LT(i, 0, n) {
			int64_t a; cin >> a;
			s += a;
			sa[i + 1] = s;
		}
	}
	{
		int64_t s = 0;
		FOR_LT(i, 0, m) {
			int64_t b; cin >> b;
			s += b;
			sb[i + 1] = s;
		}
	}
	int64_t maxans = 0;
	FOR_LE(i, 0, n) {
		if (k < sa[i]) break;
		int64_t r = k - sa[i];

		auto it = upper_bound(sb.begin(), sb.end(), r);
		it--;
		maxans = max(maxans, (int64_t)(i + (it - sb.begin())));
	}
	cout << maxans << endl;

	return 0;
}

Measured memory_bytes: 6364
#include <bits/stdc++.h>
 
 
#define ll long long int  
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
 
 
using namespace std;


const int N = (int)2e5+ 1;

vector<int> adj[N];


void util(){
	
	int n,m;cin>>n>>m;
	int x, y;
	
	rep(m){
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	
	std::vector<bool> vis(n+1, false);

	int ans = 0;

	queue<int> q;

	for(int i =1;i<=n;i++){
		if(vis[i]==false){

			q.push(i);

			int count = 0;
			while(!q.empty()){

				int s = q.front();
				q.pop();

				if(vis[s])
					continue;

				vis[s] = true;
				count++;

				for(int k = 0; k<adj[s].size();k++){

					q.push(adj[s][k]);
				}

			}

			ans = max(ans, count);

		}
	}

	cout<<ans<<endl;

}


int main()
{
	/* code */

	
	util();
	

	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

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

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

const double PI=acos(-1.0);

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

    double th = double(60*h + m)/720 * 2*PI;
    double tm = double(m)/60 * 2*PI;
    double ans = double(a*a + b*b) - double(2*a*b)*cos(th - tm);
    ans = sqrt(ans);
    printf("%.10f\n", ans);
    

    return 0;
}

Measured memory_bytes: 4096
N = int(input())
keirolist = [tuple(map(int, input().split())) for i in range(N-1)]

graph = [[] for _ in range(N+1)]
for (u, v, w) in keirolist:
  graph[u].append([v, w])
  graph[v].append([u, w])

root = 1
dist = [-1 for _ in range(N+1)]
dist[root] = 0

stack = [root]
while stack:
  idx = stack.pop()
  for i, w in graph[idx]:
    if dist[i] == -1:
      dist[i] = dist[idx] + w
      stack.append(i)

[print(0 if d % 2 == 0 else 1) for d in dist[1:]]

Measured memory_bytes: 58508
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;

int main() {
	long long N, sum;
	cin >> N;
	sum = N % 10 + N % 100 / 10 + N % 1000 / 100 + N % 10000 / 1000 + N % 100000 / 10000 + N % 1000000 / 100000 + N % 10000000 / 1000000 + N % 100000000 / 10000000 + N % 1000000000 / 100000000 + N % 10000000000 / 1000000000;
	if (N%sum == 0) puts("Yes");
	else puts("No");

	return(0);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}
	
int main(){
	init();
	string s;cin>>s;
	set<char>set;
	for(int i=0;i<s.length();i++){
		set.insert(s[i]);
	}
	if(set.size()==s.size())cout<<"yes"<<endl;
	else cout<<"no"<<endl;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**7)
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
printn = lambda x: print('\n'.join(x))

x = ni()
for i in range(-500, 501):
    for j in range(-500, 501):
        if i**5 - j**5 == x:
            print(i, j)
            exit(0)


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

multiset<tuple<int,int,int>> dsu[200000];

int n, h, w;
int par[200000];

int find(int p) {
  return par[p] = (p == par[p] ? p : find(par[p]));
}

void join(int a, int b, tuple<int,int,int> v) {
  a = find(a);
  b = find(b);
  dsu[a].erase(dsu[a].find(v));
  if (a == b) {
    return;
  }
  dsu[b].erase(dsu[b].find(v));
  if (dsu[b].size() > dsu[a].size()) swap(a,b);
  par[b] = a;
  for (auto&v : dsu[b])
    dsu[a].insert(v);
}

int fetch(int p) {
  p = find(p);
  auto it = dsu[p].rbegin();
  if (it == dsu[p].rend()) return 0;
  int a,x,y;
  tie(a,x,y)= *it;
  join(x,y+w,*it);
  return a;
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  cin >> n >> h >> w;
  for (int i = 0; i < w+h; i++)
    par[i] = i;
  set<pair<int,int>> taken;
  for (int i = 0; i < n; i++) {
    int y, x, a;
    cin >> y >> x >> a;
    y--, x--;
    tuple<int,int,int> v(a,x,y);
    dsu[x].insert(v);
    dsu[y+w].insert(v);
  }
  ll ans = 0;
  for (int i = 0; i < w+h; i++) {
    int a = fetch(i);
    //cout << a << endl;
    ans += a;
  }
  cout << ans << endl;
}


Measured memory_bytes: 48640