akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc059/tasks/arc072_a

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main()
{
  ll n, a, c[2] = {0, 0}, s[2] = {0, 0};

  cin >> n;

  REP(i, n)
  {
    cin >> a;
    REP(j, 2)
    {
      bool t = (i + j) % 2 == 0;
      s[j] += a;
      if ((t && s[j] <= 0) || (!t && 0 <= s[j]))
      {
        c[j] += abs(s[j]) + 1;
        s[j] = t ? 1 : -1;
      }
    }
  }

  cout << min(c[0], c[1]) << '\n';

  return 0;
}


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


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	ll operator()(int n) {
		if(n==0) return 0;
		int m=(n-1)/1000+1;
		return m*1000-n;
	}
};

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

	for(;;)
	{
		int n;
		cin >> n;
		if(cin.fail()) break;
		cout << solve()(n) << "\n";
	}
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define MAXN 200010
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const ll mod = 1e18 + 7;


int main (){
    ios_base::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;

    cout << b*((int)pow(b-1, a-1) ) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include<stdio.h>
using namespace std;
int main(void){
    int a,b;
    int d,r;
    double f;
    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = (double)a / b;
    printf("%d %d %f\n",d,r,f);
    return 0;
}


Measured memory_bytes: 3200
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

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

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	_ = iScan()
	s := Scan()
	t := Scan()
	for i, _ := range s {
		fmt.Print(string(s[i]))
		fmt.Print(string(t[i]))
	}
	fmt.Println("")
}


Measured memory_bytes: 1772
#include <stdio.h>

int main(){
	int apples, applePiece;
	scanf("%d %d", &apples, &applePiece);
	int cutApple = apples*3;
	int appleAll = cutApple + applePiece; 
	printf("%d", appleAll/2);
	
	
	
	return 0;
}

Measured memory_bytes: 1704
// {{{
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

typedef long int i32;
typedef unsigned long int u32;
typedef long long int i64;
typedef unsigned long long int  u64;
typedef pair<i32, i32> PII;
typedef vector<i32> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<i32, i32> MPII;
typedef set<i32> SETI;
typedef multiset<i32> MSETI;
#define IN(x) cin >> x;
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define BTW(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define PF push_front
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
// }}}

const u32 MAX_N = 100000;
vector<u32> e[MAX_N];
u32 d[2][MAX_N];
int main() {
    u32 N;
    IN(N);
    REP(i, N-1) {
        u32 a, b;
        cin >> a >> b;
        e[a-1].PB(b-1);
        e[b-1].PB(a-1);
    }
    REP(i, 2)REP(j, N) {
        d[i][j] = (u32)INF;
    }
    u32 ss[] = {0, N-1};
    REP(z, 2) {
        auto q = queue<u32>();
        q.push(ss[z]);
        d[z][ss[z]] = 0;
        while(!q.empty()) {
            u32 x = q.front();
            q.pop();
            for(u32 y : e[x]) {
                if(d[z][y] > d[z][x] + 1) {
                    d[z][y] = d[z][x] + 1;
                    q.push(y);
                }
            }
        }
    }
    i32 fennec, snuke;
    fennec = snuke = -1;
    REP(i, N) {
        if(d[0][i] <= d[1][i]) {
            fennec++;
        } else {
            snuke++;
        }
    }
    if(fennec > snuke) {
        cout << "Fennec" << endl;
    } else {
        cout << "Snuke" << endl;
    }

    return 0;
}



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

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

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)
int a,b;

int main(){
  cin >> a>>b;
  if(a*b%2 == 0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a<=b && c<=b/a){
    printf("%d",c);
  }else if(a<=b && b/a<=c){
    printf("%d\n",b/a);
  }
  else{
    printf("0\n");
  }
  return 0;
}

Measured memory_bytes: 128
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int a, b, x; cin >> a >> b >> x;
    double A = 1.0 * x / a, h = 1.0 * x / (a * a);
    double theta = atan2(2*A, a*a);

    const double PI = acos(-1);
    double ub = PI / 2.0, lb = 0;
    for(int z=0; z<100; z++) {
        double phi = (ub + lb) / 2;
        if(phi < theta) {
            double d = a * tan(phi) / 2.0;
            if(d + h <= b) lb = phi;
            else ub = phi;
        }
        else {
            double d = sqrt(2.0 * A * tan(phi));
            if(d <= b) lb = phi;
            else ub = phi;
        }
    }
    double ans = ub / PI * 180.0;
    printf("%.12f\n", ans);
    return 0;
}


Measured memory_bytes: 256
n=input()
s=raw_input()
whites=0
for ch in s:
    if ch == ".":
        whites+=1
blacks=n-whites

best=whites #index -1, all stones black
currwhite=0
currblack=0
for ind in range(n):
    if s[ind]==".":
        currwhite+=1
    else:
        currblack+=1
    thisscore = currblack + (whites-currwhite)
    best=min(best,thisscore)
print best


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

public class Main{
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}
        String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();}
        int nextInt(){return Integer.parseInt(next());}
        long nextLong(){return Long.parseLong(next());}
        double nextDouble(){return Double.parseDouble(next());}
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;}
    }
    static int getgcd(int n1,int n2){
        while(n1 != n2){
            if(n1 > n2) n1 -= n2;
            else n2 -= n1;
        }
        return n1;
    }
    static boolean isSorted(int[] arr, int n){
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]) return false;
        }
        return true;
    }
    static boolean isPrime(long n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static void printArray(int[] arr){
        for(int x:arr){
            System.out.print(x+" ");
        }
        System.out.println();
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        FastReader s=new FastReader();
        int n=s.nextInt();
        long m = 1000,count=0;
        int[] a = s.readArray(n);
        for(int i=0;i<(n-1);i++){
            count=0;
            if(a[i+1]>a[i]) {
                count=(m/a[i]);
                m=(m%a[i]);
                while(i<(n-1) && a[i+1]>a[i]) i++;
                m+=(count*a[i]);
            }
        }
        System.out.println(m);
    }
}

Measured memory_bytes: 25332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b;
    cin >> a >> b;
    a+=11;
    a%=13;
    b+=11;
    b%=13;
    if (a<b)
    {
      cout << "Bob" << endl;
    }
    else if (a==b)
    {
      cout << "Draw" << endl;
    }
    else
    {
      cout << "Alice" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

void solve() {
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;

    while (true) {
        c -= b;
        if (c <= 0) {
            std::cout << "Yes" << std::endl;
            return;
        }

        a -= d;
        if (a <= 0) {
            std::cout << "No" << std::endl;
            return;
        }
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int n;
lint i, j;

void solve(){
    --i; --j;
    int rev[n + 1], bottom[n + 1];
    memset(rev, 0, sizeof(rev));
    memset(bottom, 0, sizeof(bottom));
    for(int k = n; k >= 1; --k){
        if(i < (1LL << (k - 1))){
            i = (1LL << (k - 1)) - i - 1;
            rev[k] = 1;
        }
        else{
            i -= (1LL << (k - 1));
            bottom[k] = 1;
        }
    }
    rep(k, n) rev[k + 1] ^= rev[k];
    string ans;
    for(int k = n; k >= 1; --k){
        if(rev[k - 1] ^ (j >> (n - k) & 1) ^ bottom[k]) ans += 'R';
        else ans += 'L';
    }
    reverse(ans.begin(), ans.end());
    cout << ans << "\n";
}

int main(){
    while(scanf("%d%lld%lld", &n, &i, &j) && n){
        solve();
    }
}


Measured memory_bytes: 3248
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>
#include<set>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n, m;cin >> n >> m;
  if(n % 2){
    for(int i = 0; i < m; i++){
      cout << i+1 << ' ' << n-i << endl;
    }
  }
  else{
    int cnt = 0;
    int half = n/2;
    for(int i = 0; i < half/2; i++){
      cout << i+1 << ' ' << half-i << endl;
      if(++cnt == m) return 0;
    }
    for(int i = 0; i < half/2; i++){
      cout << half + i+2 << ' ' << n - i << endl;
      if(++cnt == m) return 0;
    }
  }

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3640
//
// Created by Hideaki Imamura on 2020-03-16.
//
# include <bits/stdc++.h>

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

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N, M;
vector<vector<int>> G;
vector<int> dp(100010, -1);

int rec(int v) {
    if (dp[v] != -1) return dp[v];

    int ans = 0;
    for (auto u : G[v]) {
        chmax(ans, 1 + rec(u));
    }
    dp[v] = ans;
    return ans;
}

int main() {
    cin >> N >> M;
    G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        G[x].push_back(y);
    }

    int ans = 0;
    for (int v = 0; v < N; ++v) chmax(ans, rec(v));
    cout << ans << endl;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); ++(i))
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); ++(i))
using ll = long long;
const int INF = (1 << 30) + (1 << 29);

struct SegmentTree {
    using F = function< int(int, int) >;
    vector< int > seg;
    int size;
    const F func;
    const int M1;
    SegmentTree(int n, const F f, const int &M) : func(f), M1(M) {
        size = 1; while (size < n) size <<= 1;
        seg.resize(2 * size - 1, M1);
    }
    void set(int k, int x) {seg[k + size - 1] = x;}
    void build() {
        for (int i = size - 2; i >= 0; --i) seg[i] = func(seg[2 * i + 1], seg[2 * i + 2]);
    }
    void update(int k, int x) {
        k += size - 1;
        seg[k] = x;
        while (k > 0) {
            k = (k - 1) / 2;
            seg[k] = func(seg[2 * k + 1], seg[2 * k + 2]);
        }
    }
    void add(int k, int x) {
        k += size - 1;
        seg[k] += x;
        while (k > 0) {
            k = (k - 1) / 2;
            seg[k] = func(seg[2 * k + 1], seg[2 * k + 2]);
        }
    }
    int query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = size;
        if (r <= a || l >= b) return M1;
        if (l >= a && r <= b) return seg[k];
        int f_l = query(a, b, 2 * k + 1, l, (l + r) / 2);
        int f_r = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return func(f_l, f_r);
    }
};

vector<int> brightness;

signed main() {

    int N, d;
    cin >> N >> d;

    vector<tuple<int, int, int>> star;
    REP(i, N) {
        int x, y, b;
        cin >> x >> y >> b;
        star.emplace_back(b, x, y);
        brightness.emplace_back(b);
    }
    sort(star.begin(), star.end());
    sort(brightness.begin(), brightness.end());
    brightness.emplace_back((int)2e9 + 10);

    auto nxtidx = [&](int idx) -> int {
        auto itr = upper_bound(brightness.begin(), brightness.end(), brightness[idx] + d);
        return (int)(itr - brightness.begin());
    };

    SegmentTree seg_x_min(N + 1, [](int a, int b){return min(a, b);}, INF);
    SegmentTree seg_x_max(N + 1, [](int a, int b){return max(a, b);}, -INF);
    SegmentTree seg_y_min(N + 1, [](int a, int b){return min(a, b);}, INF);
    SegmentTree seg_y_max(N + 1, [](int a, int b){return max(a, b);}, -INF);
    REP(i, N) {
        seg_x_min.update(i, get<1>(star[i]));
        seg_x_max.update(i, get<1>(star[i]));
        seg_y_min.update(i, get<2>(star[i]));
        seg_y_max.update(i, get<2>(star[i]));
    }
    seg_x_min.build();
    seg_x_max.build();
    seg_y_min.build();
    seg_y_max.build();

    // return 0;

    ll res = 0;
    REP(frm, N) {
        int until = nxtidx(frm);
        ll x = seg_x_max.query(frm, until) - seg_x_min.query(frm, until);
        ll y = seg_y_max.query(frm, until) - seg_y_min.query(frm, until);
        ll tmp = x * y;
        res = max(res, tmp);
    }
    cout << res << endl;

}


Measured memory_bytes: 15312
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_3_B
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string line;
            int i = 0;

            do
            {
                i++;
                line = Console.ReadLine();
                if (line == "0") return;
                Console.WriteLine("Case {0}: {1}",i,line);

            } while (line != null) ;
        }
    }

}



Measured memory_bytes: 17864
#include <bits/stdc++.h>
using i64 = long long;

long long *fact, *inv;

template <typename T, typename U, typename V>
constexpr auto pow(T x_, U n_, V mod_) {
    std::common_type_t<T, U, V> ret = 1, x = x_, n = n_, mod = mod_;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

template <typename T, typename U>
constexpr auto inverse(T x, U p) { return pow(x, p - 2, p); }

void init_factorial(int n, long long mod) {
    fact = new long long[n + 1];
    inv = new long long[n + 1];
    fact[0] = 1;
    for (long long i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % mod;
    inv[n] = inverse(fact[n], mod);
    for (long long i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}

int main() {
    constexpr i64 mod = 998244353;
    i64 n;
    std::cin >> n;
    i64 m = n / 2;
    init_factorial(m + 1, mod);

    i64 t = 0, ret = 0, two = 1, itwo = pow(2, m - 1, mod);
    constexpr i64 k = inverse(2, mod);
    for (int i = 1; i <= m; i++) {
        t = (t + fact[m] * inv[i - 1] % mod * inv[m - i + 1] % mod * two % mod) % mod;
        ret = (ret + fact[m] * inv[i] % mod * inv[m - i] % mod * itwo % mod * t % mod) % mod;
        two = two * 2 % mod;
        itwo = itwo * k % mod;
    }

    ret = (pow(3, n, mod) + mod - ret * 2 % mod) % mod;

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 78336
N, D = map(int,input().split())
X = [list(map(int,input().split())) for i in range(N)]
ans = 0
for i in range(N):
    for j in range(i+1,N):
        y = X[i]
        z = X[j]
        l = 0
        for Y, Z in zip(y, z):
            l += (Y-Z)**2
        for k in range(1,8001):
            if l** (1/2) == k:
                ans += 1
                break
print(ans)


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

using namespace std;
typedef long long int ll;

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    
    int m = a + b;
    if (m < a - b) m = a - b;
    if (m < a * b) m = a * b;
    printf("%d\n", m);
    return 0;
}


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

#define PI acos(-1.0)
#define INF 1e18
#define inf 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)

const int N=123456;
typedef long long LL;
vector <int> E[N];
int w[N],vis[N];
int bestidx,bestval;

void dfs(int x){
    vis[x]=1;
    if(w[x]<bestval){
        bestval=w[x];
        bestidx=x;
    }
    for(auto u:E[x]){
        if(!vis[u]) dfs(u);
    }
}

int main(){
    LL ans=0;
    int n,m,cnt=0;
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++) scanf("%d",&w[i]);
    for(int i=1;i<=m;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        E[x].push_back(y);
        E[y].push_back(x);
    }
    for(int i=0;i<n;i++){
        if(!vis[i]){
            bestval=2e9;
            dfs(i);
            ans+=bestval;
            w[bestidx]=2e9;
            cnt++;
        }
    }
    if(cnt==1) {printf("0\n");return 0;}
    sort(w,w+n);
    for(int i=0;i<cnt-2;i++){
        if(w[i]==2e9){
            printf("Impossible\n");
            return 0;
        }
        ans+=w[i];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[3];
  for(int i=0;i<3;i++){
    cin>>a[i];
  }
  sort(a,a+3);
  cout<<abs(a[0]-a[1])+abs(a[1]-a[2])<<'\n';
}
  


Measured memory_bytes: 3608
n,m = map(int, input().split())

t = [-1]*n
for _ in range(m):
  s,c = map(int, input().split())
  s -= 1
  if t[s] != -1 and t[s] != c:
    print(-1)
    exit()
  t[s] = c
  
if n != 1:
  if t[0] == 0:
    print(-1)
    exit()
    
  if t[0] == -1:
    t[0] = 1
    
  for i in range(1, n):
    if t[i] == -1:
      t[i] = 0
else:
  if t[0] == -1:
    t[0] = 0
    
print(''.join(map(str, t)))

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


int main(){
   int N,b,t;
   cin>>N;
   for(int i=9;i>=1;--i){
        t = N/i;
        if(t<=9 && t*i==N){
            cout<<"Yes";
            return 0;
        }
   }
   cout<<"No";
    return 0;
}


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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int ml = sc.nextInt();
        int mr = sc.nextInt();

        int l = ml % 2019;
        int r = mr % 2019;
        if(r <= l) r += 2019;
        if(mr >= ml + 2019) r += 2019;

        int ans = 2020;
        for(int i=l; i<=r; i++){
            for(int j=l; j<=r; j++){
                if(i == j) continue;
                ans = Math.min(ans, (i*j) % 2019);
                // if(ans == 1){
                //     System.out.println(i + " " + j);
                // }
            }
        }
        System.out.println(ans);
    }

    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
using namespace std;
int N;
string str;

int Ans(){
    int front = 0, back = str.size()-1;
    int ans = 0;
    while(front < back){
        while(front < back && str[front] != 'W') front++;
        while(back > front && str[back] != 'R') back--;
        if(front < back){
            str[back++] = 'W';
            str[front++] = 'R';
            ans++;
        }
    }
    return ans;
}

int main(){
    cin >> N >> str;
    cout << Ans();
    return 0;
}

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

const ll INF = 1e18;

struct LazySeg {
	ll t[N], t_add[N], start;

	void push (int node) {
		t[node] += t_add[node];
		if (node < start) {
			t_add[2 * node] += t_add[node];
			t_add[2 * node + 1] += t_add[node];
		}
		t_add[node] = 0;
	}

	void build (int n) {
		start = 1;
		while (start < n) start <<= 1;
	}

	void update (int node, int tl, int tr, int l, int r, ll d) {
		push (node);
		if (r < tl || tr < l) return;
		if (l <= tl && tr <= r) {
			t_add[node] += d;
			push (node);
			return;
		}

		int tm = (tl + tr) / 2;
		update (2 * node, tl, tm, l, r, d);
		update (2 * node + 1, tm + 1, tr, l, r, d);
		t[node] = max (t[2 * node], t[2 * node + 1]);
	}

	ll get (int node, int tl, int tr, int l, int r) {
		if (r < l) return -INF;
		push (node);
		if (tr < l || r < tl) return -INF;
		if (l <= tl && tr <= r) return t[node];

		int tm = (tl + tr) / 2;
		return max (get (2 * node, tl, tm, l, r), get (2 * node + 1, tm + 1, tr, l, r));
	}
} d;

ll n, m, sum, ans;

struct seg {
	ll l, r, a;

	bool operator < (const seg& b) const {
		if (l == b.l) return r < b.r;
		return l < b.l;
	}
} a[N];

set < pair <int, int> > s;

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

	for (int i = 0; i < m; i++) {
		cin >> a[i].l >> a[i].r >> a[i].a;
		a[i].l--, a[i].r--;
	}

	d.build (n);

	sort (a, a + m);
	int ptr = 0;

	for (int i = 0; i < n; i++) {
		ll x;
		while (ptr < m && a[ptr].l == i) {
			sum += a[ptr].a;
			s.insert ({a[ptr].r, ptr});
			d.update (1, 0, d.start - 1, a[ptr].l, a[ptr].r, -a[ptr].a);
			ptr++;
		}

		x = max (0LL, d.get (1, 0, d.start - 1, 0, i - 1)) + sum;
		ans = max (x, ans);
		d.update (1, 0, d.start - 1, i, i, x);

		while (!s.empty () && s.begin () -> first <= i) {
			int p = s.begin () -> second;
			d.update (1, 0, d.start - 1, a[p].l, a[p].r, a[p].a);
			sum -= a[p].a;
			s.erase (s.begin ());
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 28032
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#define maxn 200010
using namespace std;
string s;
int mx=1;//mx最小值为1
map<string,int> mp;
int main(){
	int n,i;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>s;
		if(mp.count(s))mp[s]++,mx=max(mx,mp[s]);
		else mp[s]=1;
	}
	for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++)
		if(it->second==mx)cout<<it->first<<endl;
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef unsigned long long ull;
typedef long double ld;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265
const int MOD=1e9+7;
 
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()

const int N=1e5+5;

int n,m;
vector<int>v[N];
int dp[N];

int go(int i)
{
    int &ans=dp[i];
    if(ans!=-1)
        return ans;
    ans=0;
    for(auto x:v[i])
    {
        ans=max(ans,1+go(x));
    }
    return ans;
}

int32_t main()
{
    IOS;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        v[x].pb(y);
    }
    memset(dp,-1,sizeof(dp));
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=max(ans,go(i));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define soja(i,a,n) for(ll i=a;i<=n;i++)
#define ulta(i,n,a) for(ll i=n;i>=a;i--)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define in insert
#define ve vector<ll>
#define se set<ll>
#define ma map<ll,ll>
#define mp make_pair
#define pll vector<pair<ll,ll>>
#define ff first
#define ss second
const ll maxx=1e9+7;
ll n,m,k,sum,t;
int main()
{
  bool fg=0,mg=0;
  cin>>n>>m;
  ll count=0,coun=0;
vector<bool> v(103,0);
while(m--)
{
    cin>>k;
    v[k]=1;
}
if(v[n]==0)
    cout<<n<<endl;
else
{
   k=-1,sum=-1;
soja(i,n+1,101)
{
    if(v[i]==0)
        {k=i;
    break;}
        coun++;
}
//cout<<k<<endl;
ulta(i,n-1,0)
{
    if(v[i]==0)
    {
        sum=i;
        break;
    }
        count++;
}

    if(coun<count)
        cout<<k<<endl;
    else if(coun>count)
        cout<<sum<<endl;
    else
        cout<<sum<<endl;

}
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<cmath>
#include <numeric>
#include<iomanip>
#include <cstdint>

using namespace std;


int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if (a + b + c < 22) {
		cout << "win" << endl;
	}
	else {
		cout << "bust" << endl;
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    N = int(input())
    A = [int(e) for e in input().split()]

    A2 = []
    for i, a in enumerate(A):
        A2.append(a - (i+1))
    A2.sort()
    b = 0
    if N%2 == 1:
        b = A2[int(N/2)]
    else:
        b = int((A2[int(N/2)-1] + A2[int(N/2)]) / 2)
    
    s = 0
    for a in A2:
        s += abs(a - b)
    print(s)

main()


Measured memory_bytes: 25760
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll x;cin>>x;
  if(x/100*5>=x%100){
    cout<<1<<endl;
  }
  else cout<<0<<endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 100000;

int n;
int a[3][MaxN + 1];

int pos[MaxN + 1];

int filp[2], rev[2];

bool book[MaxN + 1];

inline bool solve()
{
	for (int i = 1; i <= n; ++i)
	{
		int b[3];
		for (int k = 0; k < 3; ++k)
			b[k] = a[k][i];
		sort(b, b + 3);

		if (b[2] % 3 || b[1] != a[1][i])
			return false;
		if (b[2] - b[1] != 1 || b[1] - b[0] != 1)
			return false;

		pos[i] = b[2] / 3;
		if (pos[i] - i & 1)
			return false;

		if (a[0][i] > a[2][i])
			filp[i & 1] ^= 1;
	}

	for (int i = 1; i <= n; ++i)
		if (!book[i])
		{
			int x = pos[i];
			while (x != i)
			{
				book[x] = true;
				rev[i & 1] ^= 1;
				x = pos[x];
			}
		}

	return filp[0] == rev[1] && rev[0] == filp[1];
}

int main()
{
	cin >> n;
	for (int k = 0; k < 3; ++k)
		for (int i = 1; i <= n; ++i)
			a[k][i] = getint();

	puts(solve() ? "Yes" : "No");

	return 0;
}

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

using namespace std;
using ll = long long;


int n;
vector<vector<int>> hen;
vector<int> in, out;
vector<bool> seen;

void dfs(int cur, int& tim)
{
    tim++;
    in[cur] = tim;
    seen[cur] = true;
    for(auto i : hen[cur])
    {
        if(seen[i])continue;
        dfs(i, tim);
    }
    tim++;
    out[cur] = tim;
}


int main()
{
    cin >> n;
    hen.resize(n);
    in.resize(n);
    out.resize(n);
    seen.resize(n);
    for(int i = 0; i < n; i++){
        int u,k;cin >> u >> k; u--;
        for(int j = 0; j < k; j++){
            int v; cin >> v; v--;
            hen[u].push_back(v);
        }
        sort(hen[u].begin(), hen[u].end());
    }

    int t = 0;
    for(int i = 0; i < n; i++){
        if(!seen[i])dfs(i,t);
    }

    for(int i = 0; i < n; i++){
        cout << i + 1 << " " << in[i] << " " << out[i] << endl;
    }
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  rep(i, a + 1){
    rep(j, b + 1){
      rep(z, c + 1){
	if(500 * i + 100 * j + 50 * z == x){
	  ans ++;
	}
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


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

using namespace std;
typedef long long ll;

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

  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  //cout.setf(ios::fixed), cout.precision(20);

  ll n;
  cin >> n;
  ll arr[n];
  ll dp[n];
  for(int j=0;j<n;j++)
    cin >> arr[j];

  dp[n-1]=0;
  if(n>1)
  dp[n-2]=abs(arr[n-1]-arr[n-2]);

  for(int j=n-3;j>=0;j--)
    {
      dp[j]=min(dp[j+1]+abs(arr[j+1]-arr[j]),dp[j+2]+abs(arr[j+2]-arr[j]));
      
    }
 

  cout<<dp[0]<<"\n";
  return 0;
}



Measured memory_bytes: 1792
class fenwick_tree:
    """
    区間の一点更新と，区間和の取得がO(log n)で可能なデータ構造
    1-indexedで実装
    """

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

    def init_array(self, A):
        for i, a in enumerate(A, start=1):
            self.add(i, a)

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

    def sum_acc(self, i, j):
        """ [i,j] の和を返す """
        return self.sum_until(j) - self.sum_until(i-1)

    def add(self, i, x):
        if i <= 0:
            return
        while i <= self.size:
            self.tree[i] += x
            i += i & (-i)


class fenwick_tree_interval_add(fenwick_tree):
    """
    区間加算と，一点取得がO(log n)
    区間和を求めるのは，区間の長さをkとして，O(k)
    """

    def __init__(self, n):
        super().__init__(n)

    def init_array(self, A):
        for i in range(self.size):
            if i != 0:
                self.__add(i+1, A[i] - A[i-1])
            else:
                self.__add(i+1, A[i])

    def add_interval(self, i, j, w):
        if i <= 0 or self.size < j or j < i:
            raise IndexError
        self.__add(i, w)
        if j < self.size:
            self.__add(j+1, -w)

    def get_val(self, i):
        if i <= 0 or self.size < i:
            raise IndexError
        return self.__sum_until(i)

    def __sum_until(self, i):
        return super().sum_until(i)

    def __add(self, i, x):
        super().add(i, x)


def main():
    N, Q = (int(i) for i in input().split())
    bit = fenwick_tree_interval_add(N)
    for _ in range(Q):
        com, *A = (int(i) for i in input().split())
        if com == 0:
            (x, y, w) = A
            bit.add_interval(x, y, w)
        else:
            x = A[0]
            print(bit.get_val(x))


if __name__ == '__main__':
    main()



Measured memory_bytes: 8472
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = (a+b+1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define mm memset
#define PI 3.14159265358979323846264338327950288419716939937510
#define M 998244353 
#define MAXN   20000001 
#define ll long long int

void solve(){

  char c;
  cin>>c;
  if(c>='a' && c<='z'){
    cout<<'a'<<endl;
  }
  else{
    cout<<'A'<<endl;
  }



}
int main() {

  #ifndef ONLINE_JUDGE
    freopen("./input.txt", "r", stdin  );
  #endif   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
 //   cin>>t;
    for(ll i=0;i<t;i++){
      solve();
    }
    return 0;
}

Measured memory_bytes: 3576
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  const bit = 10, mx = 1e5+1;
  var n = next();
  var vw = nextm(n,2);
  var q = next();
  var need = xArray("[]",n);
  for(var i = 0; i < q; i++){
    var v = next()-1, l = next();
    need[v].push(i,l);
  }
  var ans = xArray(0,q);
  var dp = Array(bit);
  dp[0] = Array(mx).fill(0,0,vw[0][1]).fill(vw[0][0],vw[0][1]);
  f1(0,dp[0]);
  var q1 = [];
  if(n > 2)q1 = [1,-1,2,1];else if(n === 2)q1 = [1,-1];
  while(q1.length){
    var d = q1.pop(), v = q1.pop();
    if(d < 0)d = -d, dp[d] = dp[d-1];
    else dp[d] = dp[d-1].concat();
    var vv = vw[v][0], ww = vw[v][1];
    for(var i = mx-1; i >= ww; i--){
      if(dp[d][i] < dp[d][i-ww]+vv)dp[d][i] = dp[d][i-ww]+vv;
    }
    f1(v,dp[d]);
    v=v+v+1, d++;
    if(v >= n)continue;
    if(d < bit){
      if(v+1 === n)q1.push(v,-d);else q1.push(v,-d,v+1,d);
      continue;
    }
    var q2 = [v,0];
    if(v+1 < n)q2.push(v+1,0);
    var zt = [];
    while(q2.length){
      var ln = q2.pop(), v = q2.pop();
      var vv = vw[v][0], ww = vw[v][1];
      zt.length = ln, zt.push(vv,ww);
      for(var i = 0; i < ln; i+=2){
        if(zt[i+1]+ww < mx)zt.push(zt[i]+vv,zt[i+1]+ww);
      }
      f2(v,dp[bit-1],zt);
      v=v+v+1;
      if(v >= n)continue;
      q2.push(v,zt.length)
      if(v+1 < n)q2.push(v+1,zt.length);
    }
  }
  return ans.join("\n");

  function f1(n,dp){
    var a = need[n];
    for(var i = 0; i < a.length; i+=2){
      var v = a[i], l = a[i+1];
      ans[v] = dp[l];
    }
  }
  function f2(n,dp,zt){
    var a = need[n];
    for(var i = 0; i < a.length; i+=2){
      var v = a[i], l = a[i+1];
      ans[v] = dp[l];
      for(var j = 0; j < zt.length; j+=2){
        var vv = zt[j], ww = zt[j+1];
        if(l < ww)continue;
        if(ans[v] < dp[l-ww]+vv)ans[v] = dp[l-ww]+vv;
      }
    }
  }
}

Measured memory_bytes: 267608
using System;
class Program
 {
        static void Main(string[] args)
        {
    　　int N = int.Parse(Console.ReadLine()); //標準入力
        string dd = Console.ReadLine();
          string[] A = dd.Split(' ');
        int[] Ai = new int[A.Length];
          
          int maxshincho = 0;
          
         decimal dai = 0;
          
          for(int i= 0;i<A.Length;i++){
            Ai[i] = int.Parse(A[i]);
          }
          for(int i= 0;i<Ai.Length-1;i++){
            if(maxshincho<Ai[i]){
              maxshincho=Ai[i];
            }
            if(maxshincho>Ai[i+1]){
              dai = dai + (decimal)(maxshincho-Ai[i+1]);
            }
          }
          Console.WriteLine("{0}",dai);
        }
 }

Measured memory_bytes: 46520
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n,a;
  bool Tf[305],Hf[305];
  while(cin >> n && n){
    vector<int> tque,hque;
    for(int i=0;i<=303;i++){
      Tf[i] = false;
      Hf[i] = true;
    }
    for(int i=0;i<n;i++){
      cin >> a;
      Tf[a] = true;
      Hf[a] = false;
    }
    
    for(int i=1;i<=2*n;i++){
      if(Tf[i]){
	tque.push_back(i);
      }
      else if(Hf[i])hque.push_back(i);
    }

    int FL = -1;
    while(!hque.empty() && !tque.empty()){
	vector<int>::iterator tit = lower_bound(tque.begin(),tque.end(),FL);
	if(tit != tque.end()){
	  FL = *tit;
	  tque.erase(tit);
	}
	else FL = -1;
	if(tque.empty())break;
     
	vector<int>::iterator hit = lower_bound(hque.begin(),hque.end(),FL);
	if(hit != hque.end()){
	  FL = *hit;
	  hque.erase(hit);
	
	}
	else FL = -1;
	if(hque.empty())break;
    }

    cout << hque.size() << endl;
    cout << tque.size() << endl;

  }
  return 0;
}

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

int main() {
  int a, b;

  cin >> a >> b;
  cout << "a ";
  if(a < b) cout << '<';
  if(a > b) cout << '>';
  if(a == b) cout << "==";
  cout << " b" << endl;

}


Measured memory_bytes: 3112
#include<iostream>
using namespace std;
int main()
{
	int n=0;
	int sum=4;
	char m;

	for(int i=0;i<sum;i++)
	{
			cin>>m;
			if(m=='+')
			n++;
			if(m=='-')
			n--;
			
	}
	cout<<n;
	return 0;
}

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

const int INF=99999999;

int main(){
	int N; cin>>N;
	int num[12];
	for(int i=0;i<5;i++){
		int a=9;
		for(int j=0;j<i;j++){
			a*=9;
		}
		num[i]=a;
	}
	for(int i=5;i<11;i++){
		int a=6;
		for(int j=0;j<i-5;j++){
			a*=6;
		}
		num[i]=a;
	}
	num[11]=1;
	int dp[15][200000];
	for(int i=0;i<15;i++){
		for(int j=0;j<200000;j++){
			dp[i][j]=INF;
		}
	}
	dp[0][0]=0;
	for(int i=0;i<12;i++){
		for(int j=0;j<100001;j++){
			if(j>=num[i])dp[i+1][j]=min(dp[i+1][j],dp[i+1][j-num[i]]+1);
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
		}
	}
	cout<<dp[12][N]<<endl;
	return 0;
}

Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
    string st;cin>>st;
    int sz=st.size(),count=0,i=0;
    int j=sz-1;
    while(i<j){
        if(st[i]!=st[j])count++;
        i++;j--;
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, Y: int):
    for i in range(N + 1):
        for j in range(N - i + 1):
            k = N - i - j
            if 10000 * i + 5000 * j + 1000 * k == Y:
                print(' '.join([str(n) for n in [i, j, k]]))
                return
    print(' '.join([str(n) for n in [-1, -1, -1]]))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(N, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;


ll int findTrailingZeros(ll int v,ll int wrt){
    ll int count = 0;
    for(ll int i = wrt ; v/i >=1 ;i *=wrt){
        count += v/i;
    }
    return count;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int n;cin>>n;
    ll int ans = 0 ;
    if(n&1){
        cout<<"0";
    }
    else{
        ll int ans;
        ans = min(findTrailingZeros(n/2 , 5) ,findTrailingZeros(n/2 , 2) + n/2);


        cout<<ans;
     }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;;
 
int main() {
    int n, m;
    cin >> n >> m;
    if (n==m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  map<string, int> S;
  vector<string> ans;
  vector<string> zero;
  REP(i, N) {
    string tmp;
    cin >> tmp;
    if (S.count(tmp))
      S[tmp]++;
    else
      S.emplace(tmp, 1);
  }
  int max = 0;
  for (auto p : S) {
    if (p.second > max) max = p.second;
  }

  for (auto x : S) {
    if (x.second == max) {
      ans.push_back(x.first);
    }
  }
  for (auto s : ans) {
    cout << s << endl;
  }
}

Measured memory_bytes: 25584