akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N, M;
    cin >> N >> M;
    vector<vector<ll>> info(M);
    rep(i, M) {
        ll k;
        cin >> k;
        rep(j, k) {
            ll s;
            cin >> s;
            s--;
            info[i].push_back(s);
        }
    }
    vector<ll> P(M);
    rep(i, M) cin >> P[i];
    ll ans = 0;
    rep(i, 1 << N) {
        bool ok = true;
        rep(j, M) {
            ll c = 0;
            for (ll v: info[j]) {
                if ((1<<v) & i) {
                    c ++;
                }
            }
            if (c % 2 != P[j]) ok = false;
        }
        if (ok) ans++;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
        	int rate = sc.nextInt();      	
            System.out.println(rate < 1200 ? "ABC" : "ARC");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 8148
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n; cin >> n;
    vector<vector<ll>> to(n), cost(n);
    rep(i, n-1) {
        ll u, v, w; cin >> u >> v >> w;
        u--; v--;
        to[u].push_back(v);
        to[v].push_back(u);
        cost[u].push_back(w);
        cost[v].push_back(w);
    }
    vector<ll> ans(n, -1);
    queue<ll> q;
    ans[0] = 0; q.push(0);
    while (!q.empty()) {
        ll v = q.front(); q.pop();
        rep(i, to[v].size()) {
            ll u = to[v][i];
            ll w = cost[v][i];
            if (ans[u] != -1) continue;
            ans[u] = (ans[v] + w) % 2;
            q.push(u);
        }
    }
    rep(i, n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 13184
package main

import (
	"fmt"
	"math"
)

var A, B, C, D, E, F int

func main() {
	fmt.Scan(&A, &B, &C, &D, &E, &F)
	var ans_w, ans_s int = 100 * A, 0

	for a := 0; a <= F; a += 100 * A {
		for b := 0; a+b <= F; b += 100 * B {
			for c := 0; a+b+c <= F; c += C {
				for d := 0; a+b+c+d <= F; d += D {
					if E*(a+b)/100 < c+d {
						break
					}
					if float64(ans_s*100)/(float64(ans_w+ans_s)) < float64(float64(c+d)*100)/float64((a+b+c+d)) {
						ans_w = a + b
						ans_s = c + d
					}
				}
			}
		}
	}
	fmt.Println(ans_w+ans_s, ans_s)
}

/*  ----------------------------------------  */

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy []XY

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i].x == a[j].x {
		return a[i].y > a[j].y
	}
	return a[i].x > a[j].x
}


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

Measured memory_bytes: 580
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin>>N;
    long long int dp[N+3];
    for(int i=0;i<N+1;i++){
        dp[i]=i;
    }
    int GA,SA,BA,GB,SB,BB;
    cin>>GA>>SA>>BA>>GB>>SB>>BB;
    for(int i=0;i<N+1;i++){
        for(int j=1;j<4;j++){
            if(j==1 && i>=GA){
                dp[i]=max(dp[i],dp[i-GA]+GB);
            }else if(j==2 && i>=SA){
                dp[i]=max(dp[i],dp[i-SA]+SB);
            }else if(j==3 && i>=BA){
                dp[i]=max(dp[i],dp[i-BA]+BB);
            }
        }
    }
    //cout<<dp[N]<<endl;
    long long int dp2[dp[N]+5];
    for(int i=0;i<dp[N]+2;i++){
        dp2[i]=i;
        }


    //cout<<dp2[5]<<endl;
    for(int i=0;i<dp[N]+1;i++){
        for(int j=1;j<4;j++){
            if(j==1 && i>=GB){
                    dp2[i]=max(dp2[i],dp2[i-GB]+GA);
            }else if(j==2 && i>=SB){
                    dp2[i]=max(dp2[i],dp2[i-SB]+SA);
            }else if(j==3 && i>=BB){
                    dp2[i]=max(dp2[i],dp2[i-BB]+BA);
            }

    
}
}
cout<<dp2[dp[N]]<<endl;
    return 0;
}


Measured memory_bytes: 195584
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
    string s;
    cin>>s;
    if (s=="RRR")
    {
        cout<<3<<endl;
    }else if(s=="SRR" or s=="RRS")
    {
        cout<<2<<endl;
    }else if (s=="SSS")
    {
        cout<<0<<endl;
    }else
    {
        cout<<1<<endl;
    }
    
    
    
    

    return 0;
}

Measured memory_bytes: 3584
using System;

class Program
{
  static void Main(string[] args)
  {
    string str = Console.ReadLine();

    for (int i=0; i<str.Length; i++) {
      int num = int.Parse(str[i].ToString());
      if (num == 9) {
        Console.WriteLine("Yes");
        return;
      }
    }
    Console.WriteLine("No");
    return;
  }
}


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

string n;
int main() {
  int i;
  int sum = 0;
  cin >> n;
  for(i=0; i<n.length(); i++){
    sum += n[i] - '0';
  }
  if(stoi(n) % sum == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,(e))
#define irp(i,s,e) for(int i=(s);i>(e);--i)
#define irpz(i,s) irp(i,(s),-1)
template<class T> T in(){T x;cin>>x;return x;}
// long long a = in<long long>();
template<class T> vector<T> inarr(int s,int e, T init=0){
	vector<T> v;T x;
	rp(i,0,s)v.push_back(init);
	rp(i,s,e){x=in<T>();v.push_back(x);}
	return v;
}
// vi P = inarr<int>(1,N+1,INT_MAX);
// vi P = inarr<int>(0,N);

// #define NMAX 1000000000
ll H;

ll solve(){
	ll ans=0;
	// if(H&1) H--;
	ll count = 1;
	while(H){
		ans+=count;
		count<<=1;
		H>>=1;
		// if(H&1) H--;
	}
	return ans;
}

int main(){
	cin>>H;
	cout<< solve() <<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void inline swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void inline swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class A {
	int x, t;
public:
	A()
	{
		cin >> x >> t;
	}
	void solve()
	{
		cout << max(0, x - t) << endl;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int n, d;
	int x, y;
	scanf("%d %d", &n, &d);
	x = n / (2 * d + 1);
	y = n % (2 * d + 1);
	if (y == 0)
	{
		printf("%d\n", x);
	}
	else
	{
		printf("%d\n", x + 1);
	}
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

vector<int> TopologicalSort(ll root, vector<set<int>> ga, vector<set<int>> gb) {
  vector<int> res;
  queue<int> que;
  que.push(root);

  while (que.size()) {
    int p = que.front();
    que.pop();
    res.push_back(p);
    for (auto&& i : ga[p]) {
      gb[i].erase(p);
      if (gb[i].size() == 0) {
        que.push(i);
      }
    }
  }

  return res;
}

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

  int N, M;
  cin >> N >> M;
  //ga[i] := iから出る有向辺の集合
  //gb[i] := iに向かう有向辺の集合
  vector<set<int>> ga(N);
  vector<set<int>> gb(N);

  rep(i, N+M-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    ga[a].insert(b);
    gb[b].insert(a);
  }

  int root = -1;
  rep(i, N) {
    if (gb[i].size() == 0) root = i;
  }

  auto res = TopologicalSort(root, ga, gb);
  vector<int> tp_pos(N);
  rep(i, N) {
    tp_pos[res[i]] = i;
  }

  vector<int> ans(N);
  rep(i, N) {
    if (i == root) {
      cout << 0 << endl;
      continue;
    }
    int max_pos = -1;
    int parent = -1;
    for (auto&& j : gb[i]) {
      if (tp_pos[j] > max_pos) {
        max_pos = tp_pos[j];
        parent = j;
      }
    }
    cout << parent+1 << endl;
  }

}


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

using namespace std;

#define fo(i, n) for(int i = 1; i <= n; ++i)

#define pb push_back
#define eb emplace_back

typedef long long ll;
const int N = 200200;
const int mod = 1e9 + 7;
int u[26];

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    int n = s.length();
    for(int i = 0; i < n; ++i)
        u[s[i] - 'a'] = 1;
    for(int i = n; i >= 0; --i) {
        for(int j = 0; j < 26; ++j)
            if(!u[j] && (i == n || s[i] - 'a' < j)) {
                cout << s.substr(0, i);
                cout << char(j + 'a');
                return 0;
            }
        u[s[i] - 'a'] = 0;
    }
    cout << -1;
    return 0;
}

Measured memory_bytes: 256
#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 r;
  cin >> r;
  double PI = M_PI;
  cout << SYOU(5) << 2 * r * PI << '\n';
  return 0;
}


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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define sort(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> p;

int main(){
int a,b,c;
cin>>a>>b>>c;
int money = a+b;
if(money>=c){
	cout<<"Yes"<<endl;

  }
  else{
	  cout<<"No"<<endl;
	}
  
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) throws Exception {
	Scanner sc = new Scanner(System.in);
	int N1 = sc.nextInt();
	int tmp = 0;
	String ans = "No";

	for(int i = 1;i<10;i++)	{
        tmp = N1 / i;
		if ((N1 % i == 0)) {
			for (int j = 1; j < 10; j++) {
				if ((tmp % j == 0 ) && ((tmp / j) == 1 )) {
					ans = "Yes";
					System.out.println(ans);
					return;
				}
			}
		}
	}

	System.out.println(ans);
    }
}


Measured memory_bytes: 23508
def solve(N):
    N = [0] + N
    k = 0  # 繰り上がり
    ans = 0
    for d, d_next in zip(N[::-1], N[-2::-1]):
        d += k
        if d <= 4 or (d==5 and d_next<5):
            k = 0
            ans += d
        else:
            k = 1
            ans += 10 - d
    if k:
        ans += 1
    return ans

def test(N, ans):
    for i in range(N, 10000):
        rem = i - N
        if sum(map(int, str(i))) + sum(map(int, str(rem))) < ans:
            print(f"!!! N={N}, ans={ans}, trueans={i, rem}")
def main():
    N = list(map(int, input()))
    print(solve(N))
    # for i in range(1, 10000):
    #     ans = solve(list(map(int, str(i))))
    #     test(i, ans)
main()


Measured memory_bytes: 41920
#include <stdio.h>

#define MAX_N 10000
#define MAX_Q 500


void trace(int* x, int n) {
  for(int i=0; i<n; i++) {
    printf("%d", x[i]);
    if(i != n-1) {
      printf(" ");
    }
  }
  printf("\n");
}

int linear_search(int* arr, int n, int v) {
  arr[n] = v;

  int i=0;
  while(arr[i] != v)
    i++;

  if (i == n) {
    return -1;
  }
  return i;
}

int main() {
  int n, q;
  int s[MAX_N+1], t[MAX_Q];

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

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

  int c = 0;
  for(int i=0; i<q; i++) {
    if(linear_search(s, n, t[i]) != -1) {
      c++;
    }
  }
  printf("%d\n", c);

  return 0;
}

Measured memory_bytes: 2760
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t N, A, B;
    cin >> N >> A >> B;
    if (A > B){
        cout << 0 << endl;
    }
    else if (A == B){
        cout << 1 << endl;
    }
    else {
        if (N < 2){
            cout << 0 << endl;
        }
        else if (N == 2){
            cout << A + B << endl;
        }
        else {
            cout << (B - A) * (N - 2) + 1 << endl;
        }
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

const int N = 4e3 + 5;
const int P = 998244353;

int n, k, c[N][N];

void init(int n) {
	c[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		c[i][0] = 1;
		for (int j = 1; j <= i; j++) {
			c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % P;
		}
	}
}
void add(int &x, int y) {
	(x += y) >= P && (x -= P);
}
int main() {
	scanf("%d%d", &k, &n);
	init(n + k);
	for (int i = 2; i <= k + k; i++) {
		int cnt = 0, ans = 0;
		for (int j = 1; i - j >= j; j++) {
			cnt += (j <= k && i - j <= k);
		}
		for (int j = 0, sgn = 1; j <= cnt && j + j <= n; j++, sgn = P - sgn) {
			add(ans, 1LL * sgn * c[cnt][j] % P * c[n - 2 * j + k - 1][k - 1] % P);
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

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

using namespace std;

using pii = pair<int, int>;

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

    int N, M;
    cin >> N >> M;
    if (M & 1) {
        cout << -1 << endl;
        return 0;
    }
    vector<vector<pii>> g(N);
    REP(i, M) {
        int A, B;
        cin >> A >> B;
        --A;
        --B;
        g[A].emplace_back(B, i);
        g[B].emplace_back(A, i);
    }

    int root = 0;
    vector<bool> used_vertices(N, false);
    vector<bool> used_edges(M, false);
    used_vertices[root] = true;
    vector<int> outdegree(N, 0);

    function<void(int, int)> dfs = [&](int v, int parent) {
        for (const pii &e: g[v]) {
            int to, id;
            tie(to, id) = e;
            if (!used_vertices[to]) {
                used_vertices[to] = true;
                dfs(to, v);
            } else if (to != parent && !used_edges[id]) {
                cout << (v + 1) << ' ' << (to + 1) << '\n';
                ++outdegree[v];
                used_edges[id] = true;
            }
        }
        if (parent != -1) {
            if (outdegree[v] & 1) {
                cout << (v + 1) << ' ' << (parent + 1) << '\n';
                ++outdegree[v];
            } else {
                cout << (parent + 1) << ' ' << (v + 1) << '\n';
                ++outdegree[parent];
            }
        }
    };

    dfs(root, -1);

    return 0;
}

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

int main() {
  double s;
  cin >> s;
  int s1 = s/100, s2 = s/10 - s1 * 10, s3 = s - s2 * 10 - s1 * 100;
  cout << s1 + s2 + s3 << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

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

ll mod = 998244353;


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

  int n;
  cin >> n;
  vvi a(n,vi(n,-1));
  rep(i,n){
    int m;
    cin >> m;
    rep(j,m){
      int x,y;
      cin >> x >> y;
      x--;
      a[i][x] = y;
    }
  }

  int ret = 0;

  rep(i,1<<n){
    vi tmp(n);
    rep(j,n){
      tmp[j] = ((i >> j) & 1);
    }
    bool check = true;
    int cnt = 0;
    rep(j,n){
      if(tmp[j] == 1){
        cnt++;
        rep(k,n){
          if(a[j][k] == -1)continue;
          else{
            if(a[j][k] != tmp[k])check = false;
          }
        }
      }
    }
    if(check){ret = max(ret,cnt);}
  }

  cout << ret << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;
 
class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
    readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
    int N;
    void solve()
    {
        N = cin.nextint;
        var Q = new int[100002];
        for (int i = 0; i < N; i++)
        {
            Q[cin.nextint]++;
            Q[cin.nextint + 1]--;
        }
        for (int i = 1; i < Q.Length; i++)
        {
            Q[i] += Q[i - 1];
        }
        WriteLine(Q.Count(i => i >= 1));
    }
 
}
 
class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////
#define pii pair<int,int>
#define mkp make_pair

int H,W,N,X[202020],Y[202020];
vector<pii> XYv;

int wall[202020];
int i,j,h;
int main(){
    scanf("%d%d%d",&H,&W,&N);
    fornum (i,0,N){
        scanf("%d%d", &X[i],&Y[i]);
        XYv.push_back(mkp(X[i], Y[i]));
    }
    sort(XYv.begin(), XYv.end());

    h = 0;
    fornum(i, 1, H+1){
        while(j<XYv.size()&&XYv[j].first==i){
            if(XYv[j].second<=h){
                printf("%d", i-1);
                return 0;
            }
            wall[XYv[j].second] = i;
            j++;
        }
        if(wall[h+1]!=i){
            h++;
        }
    }

    printf("%d", H);
    return 0;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}
// end of Template

int n;
int main(){

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;
    cout<<n*n*n<<newl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <math.h>
#include <assert.h>

using namespace std;

#define x first
#define y second
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define all(x) x.begin(),x.end()
#define SZ(x) int(x.size())
#define rep(i, a, b) for(int i = a; i < b; i++)
#define per(i, a, b) for(int i = b-1; i >= a; i--)
#define DBG(x) cerr << (#x) << "=" << x << "\n";
#define ll long long
#define inf 1000000007
#define mod 1000000007
#define N 200005

template<typename U, typename V> void Min(U &a, const V & b){if(a > b)a = b;}
template<typename U, typename V> void Max(U &a, const V & b){if(a < b)a = b;}
template<typename U, typename V> void add(U &a, const V & b){a = (a + b) % mod;}
template<typename U> U gcd(U a, U b){
    if(a == 0)return b;
    if(b == 0)return a;
    if(a >= b)return gcd(a % b, b);
    else return gcd(a, b % a);
}
int pow(int a, int b){
    int ans = 1;
    while(b){
        if(b & 1)ans = 1LL * ans * a % mod;
        a = 1LL * a * a % mod;
        b >>= 1;
    }
    return ans;
}
int pow(int a, int b, int c){
    int ans = 1;
    while(b){
        if(b & 1)ans = 1LL * ans * a % c;
        a = 1LL * a * a % c;
        b >>= 1;
    }
    return ans;
}

ll a[N];
int main(){
    int T, i, j, k, ca = 0, K, n, m;
    scanf("%d", &n);
    rep(i, 0, n)scanf("%lld", &a[i+1]), a[i+1] += a[i];
    ll ans = -1;
    rep(i, 1, n){
        ll w = abs(a[i] - (a[n] - a[i]));
        if(ans < 0 || ans > w)ans = w;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 1792
import numpy as np
from collections import deque

def resolve():
    H, W = map(int, input().split())

    maze = []
    for i in range(H):
        maze.append(input())

    def bfs(st):

        INF = -1
        d = np.full((H, W), INF)

        dx = [1, 0, -1, 0]
        dy = [0, 1, 0, -1]

        que = deque()
        que.append(st)
        d[st[1]][st[0]] = 0

        while len(que):
            p = que.popleft()
            # print(p)

            for i in range(4):
                nx = p[0] + dx[i]
                ny = p[1] + dy[i]

                if nx >= 0 and nx < W and ny >= 0 and ny < H and maze[ny][nx] != "#" and d[ny][nx] == INF:
                    # print("next is ", nx, ny)
                    que.append([nx, ny])
                    d[ny][nx] = d[p[1]][p[0]] + 1
                    # print(d)
                    # print(que)

        cost = np.max(d)
        # idx = np.unravel_index(np.argmax(d), d.shape)
        # print(idx)
        # print(cost)
        return cost

    max_cost = 0
    for y in range(H):
        for x in range(W):
            if maze[y][x] == '.':
                st = [x, y]
                cost = bfs(st)
                if cost > max_cost:
                    max_cost = cost 
    
    # print(maze[1])
    # idx, cost = bfs(st)
    # idx, cost = bfs((idx[1], idx[0]))
    print(int(max_cost))

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 14424
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;

template<typename T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template<typename... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	ll R,G,B,N, ans = 0; cin >> R >> G >> B >> N;
	for(ll r = 0; r <= 3000; ++r){
		for(ll b = 0; b <= 3000; ++b){
			ll gG = N - R*r - B*b;
			if(gG >= 0 && gG % G == 0) ans++;
		}
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>

int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  /* */
  std::string w;
  std::cin >> w;
  int counts[26] = {0};
  for (char c : w) {
    counts[c - 'a']++;
  }
  for (int i = 0; i < 26; ++i) {
    if (counts[i] % 2 != 0) {
      std::printf("No\n");  std::exit(EXIT_SUCCESS);
    }
  }
  std::printf("Yes\n"); 
  /* */

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;

int main() {
    int n;
    cin >> n;
    for(int i=1; i<10; i++) {
        if(n <= i * 111) {
            cout << 111 * i << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
def main():
    N = int(input())
    AC = 0
    WA = 0
    TLE = 0
    RE = 0
    for i in range(N):
        St = input()
        if St == 'AC':
            AC += 1
        elif St == 'WA':
            WA += 1
        elif St == 'TLE':
            TLE += 1
        elif St == 'RE':
            RE += 1
        else:
            Er += 1
    print('AC x', AC)
    print('WA x', WA)
    print('TLE x', TLE)
    print('RE x', RE)
main()

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n;cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];

    vector<vl> dp(n+10, vl(n+10,0));
    rep(i,n) dp[i][i] = a[i];

    for(int inter=1;inter<=n;++inter){
        for(int l=0;l<n;++l){
            int r = l + inter -1;
            if(r>=n) continue;

            if(inter&1){
                dp[l][r] = max((r!=0? dp[l][r-1] : 0) + dp[r][r] , (l!=n-1? dp[l+1][r] : 0) + dp[l][l]);
            }else{
                dp[l][r] = min((r!=0? dp[l][r-1] : 0) - dp[r][r] , (l!=n-1? dp[l+1][r] : 0) - dp[l][l]);
            }
        }
    }
    cout << ((n&1)?dp[0][n-1] : -dp[0][n-1]) << endl;
}

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

using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
const int M=300005;
const int N=998244353;
int n;
ll m,x,y,a,b,k,fact[M],inv[M];
int modpow(int x,int p,int m){
    if(p==0)return 1;
    int k=modpow(x,p/2,m)%m;
    k=(1LL*k*k)%m;
    if(p%2==1)k=(1LL*k*x)%m;
    return k;
}
int stuff(int a,int b){
    ll x=fact[n]*inv[a]%N*inv[n-a]%N;
    ll y=fact[n]*inv[b]%N*inv[n-b]%N;
    return (x*y)%N;
}
int main()
{
    cin>>n>>a>>b>>k;
    fact[0]=inv[0]=1;
    for(int i=1;i<=n;i++){
        fact[i]=i*fact[i-1]%N;
        inv[i]=modpow(fact[i],N-2,N);
    }
    for(int i=0;i<=n;i++){
        if((k-i*a)%b==0&&(k-i*a)/b<=n&&k-i*a>=0){
            x+=stuff(i,(k-i*a)/b);
            x%=N;
        }
    }
    cout<<x;
    return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

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

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll t(n),x(n),y(n);
  rep(i,n) cin>>t[i]>>x[i]>>y[i];
  
  ll pt=0,py=0,px=0;
  rep(i,n){
    int T=t[i]-pt;
    int d=abs(px-x[i])+abs(py-y[i]);
    pt=t[i]; px=x[i]; py=y[i];
    if(T<d || abs(T-d)%2==1){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 2560
import numpy as np

W, H, N = map(int, input().split())

area = np.ones((W, H))

for _ in range(N):
    x, y, a = map(int, input().split())

    if a == 1:
        area[:x, :] = 0
    elif a == 2:
        area[x:, :] = 0
    elif a == 3:
        area[:, :y] = 0
    elif a == 4:
        area[:, y:] = 0

print(int(np.sum(area)))


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

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

int64_t mod_inv(int64_t a) {
    int64_t b = MOD, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

int main(void) {
    int N;
    cin >> N;
    vector<int64_t> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }

    int64_t sum = accumulate(A.begin(), A.end(), 0L) % MOD;
    int64_t ans = sum * sum % MOD;

    for(int i=0; i<N; i++) {
        ans -= A[i] * A[i];
        ans %= MOD;
    }

    ans *= mod_inv(2);
    ans %= MOD;
    if(ans < 0) ans += MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4836
import java.util.Scanner;

class Problem {
    private int A, B, C;
    Problem() {
        Scanner sc = new Scanner(System.in);

        A = sc.nextInt();
        B = sc.nextInt();
        C = sc.nextInt();
    }

    String solve() {
        return A == B && B == C && C == A ? "Yes" : "No";
    }
}

public class Main {
    public static void main(String[] args) {
        System.out.println(new Problem().solve());
    }
}


Measured memory_bytes: 25300
#include <cstdio>
#include <cstring>
#include <numeric>
#include <algorithm>

const int maxN = (int)3e5 + 10;

int N;
char str[maxN];
int prefW[maxN], prefE[maxN];

void input()
{
    scanf("%d%s", &N, str + 1);
}

int solve()
{
    for (int i = 1; i <= N; i++)
    {
        if (str[i] == 'W')
        {
            prefW[i] = prefW[i - 1] + 1;
            prefE[i] = prefE[i - 1];
        }
        else
        {
            prefE[i] = prefE[i - 1] + 1;
            prefW[i] = prefW[i - 1];
        }
    }
    int ans = maxN;
    for (int i = 1; i <= N; i++) //i-th as center
    {
        int t = prefW[i - 1] //turn from west to east
                + (prefE[N] - prefE[i]); //from east to west
        ans = std::min(ans, t);
    }
    return ans;
}

int main()
{
    input();
    printf("%d", solve());
    return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include <deque>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  deque<int> deq;

  for(int i=0;i<n;i++){
    int k;
    cin >> k;
    deq.push_front(k);
  }
  for(deque<int>::iterator it=deq.begin(),end=deq.end();it!=end;it++){
    cout << (it!=deq.begin()?" ":"")<< *it;
  }
  cout << endl;
}




Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <queue>
#include <utility>
using namespace std;

int main(void){
  int A,B,c=0;
  cin >> A >> B;
  A = A - 1;
  for(int i = A+1;i<B;i=i+A){
    c++;
  }
  if(B == 1){
    cout << 0 << endl;
  }else{
    c++;
    cout << c << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import Foundation
func toTuple<T>(_ args: [T]) -> (T, T) { (args[0], args[1]) }
func readInts() -> [Int] { readLine()!.split(separator: " ").map { Int($0)! } }

let (n, m) = toTuple(readInts())
var aibi: [(Int, Int)] = []
var cidi: [(Int, Int)] = []
for _ in 0..<n {
  aibi.append(toTuple(readInts()))
}
for _ in 0..<m {
  cidi.append(toTuple(readInts()))
}
for ab in aibi {
  var di: [Int] = []
  for cd in cidi {
    di.append(abs(ab.0 - cd.0) + abs(ab.1 - cd.1))
  }
  print(di.firstIndex(of: di.min()!)! + 1)
}

Measured memory_bytes: 13596
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long long,long long>
#define INF 1000000000000000000
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<int, int> mp;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n; vector<int>a(n); rep(i, n)cin >> a.at(i);
	int ans = a[0];
	for (int i = 1; i < n; i++) {
		ans = gcd(ans, a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define trav(x,v) for(auto  &x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) (int)(v).size()
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

const ll md = 1e9+7;

ll mpow(ll a, int e){
	ll res = 1;
	do {
		if(e & 1) res = res * a % md;
		a = a * a % md;
	} while(e >>= 1);
	return res;
}

ll ninv = mpow(9, md-2);

ll fun(int len){
	return (mpow(10,len)-1)*ninv % md;
}

int main(){
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);

	int n, q;
	cin >> n >> q;

	vector<pii> lr(q);
	trav(pa, lr) cin >> pa.first >> pa.second, --pa.first;
	
	map<int,int> ren;
	trav(pa, lr) ren[pa.first] = ren[pa.second] = 0;
	int ix = 0;
	trav(pa, ren) pa.second = ix++;
	vi ner(ix);
	trav(pa, ren) ner[pa.second] = pa.first;

	auto uni = [&](vi &cmp, int a, int b){
		a = cmp[a], b = cmp[b];
		if(a == b) return;
		if(b < a) swap(a,b);
		trav(x, cmp) if(x == a) x = b;
	};

	vi cmp(ix);
	rep(i,0,ix) cmp[i] = i;
	trav(pa, lr) uni(cmp, ren[pa.first], ren[pa.second]);

	int nix = 0;
	vi num(ix,-1);
	rep(i,0,ix) if(cmp[i] == i) num[i] = nix++;

	map<pair<int,ll>,ll> mem;

	function<ll(int,vi)> rek = [&](int l, vi cmp){
		if(l == ix-1) return 1LL;

		ll hs = 0;
		rep(i,0,ix) if(num[i] >= 0) hs = (hs<<4) | num[cmp[i]];
		pair<int,ll> hsh(l, hs);

		if(!mem.count(hsh)){
			ll ans;
			int len = ner[l+1] - ner[l];
			if(cmp[l] == l){
				ans = rek(l+1,cmp)*mpow(10,len) % md;
			} else if(cmp[l] == cmp[l+1]) {
				ans = rek(l+1,cmp)*(1 + fun(len)) % md;
			} else {
				ans = rek(l+1,cmp)*fun(len) % md;
				uni(cmp, l, l+1);
				ans = (ans + rek(l+1,cmp)) % md;
			}
			return mem[hsh] = ans;
		}
		return mem[hsh];
	};
	cout << mpow(10, ner[0] + n-ner[ix-1]) * rek(0, cmp)%md << endl;
}


Measured memory_bytes: 252672
function solve()
    N = parse(Int, readline())
    A = parse.(Int, split(readline()))

    res = 0
    for i = 2:N
        d = A[i-1] - A[i]
        if d < 0 continue end
        A[i] += d
        res += d
    end

    println(res)
end

solve()


Measured memory_bytes: 198496
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Describe
"""

STR_HELLO_WORLD = 'Hello World'

def main():
    n = int(input())
    if n == 1:
        s = STR_HELLO_WORLD
    elif n == 2:
        a = int(input())
        b = int(input())
        s = str(a + b)
    print(s)

main()


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

int N;
ll A[200000];

void solve() {
  ll ans = 0;
  ans += A[0] / 2;
  A[0] = A[0] % 2;
  for (int i = 1; i < N; i++) {
    ll min_tmp = min(A[i-1], A[i]);
    A[i] -= min_tmp;
    ans += min_tmp;
    ans += A[i] / 2;
    A[i] = A[i] % 2;
  }
  cout << ans << endl;
}

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

  solve();
  return 0;
}


Measured memory_bytes: 1024