akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
#define Nil -1;

struct Node { int parent, left, right; };

int getDepth(Node* T,int u) {
	int d = 0;
	while(T[u].parent != -1){
		u = T[u].parent;
		d++;
	}
	return d;
}

void setDepth(Node* T,int u, int p,int* D) {
	D[u] = p;
	if (T[u].right != -1)
		setDepth(T, T[u].right, p,D);
	if (T[u].left != -1)
		setDepth(T, T[u].left, p+1, D);
}

void printfChildren(Node* T,int u) {
	int c = T[u].left;
	int i = 0;
	while (c != -1) {
		if (i++) cout << ", ";
		cout << c;
		c = T[c].right;
	}
}

int main(void) {

	int N = 0;

	cin >> N;
	struct Node* T = new Node[N];
	int* D = new int[N];
	int* n = new int[N];
	int* c = new int[N];

	for (int i = 0; i < N; i++) {
		T[i].parent = Nil; T[i].left = Nil; T[i].right = Nil;
		D[i] = 0;
	}

	for (int i = 0; i < N; i++) {
		cin >> n[i] >> c[i];
		if (c[i] != 0) {
			cin >> T[n[i]].left;
			int u = T[n[i]].left;
			for (int j = 0; j < c[i]; j++) {
				T[u].parent = n[i];
				if (j == c[i] - 1) {
					T[u].right = Nil;
					break;
				}
				cin >> T[u].right;
				u = T[u].right;
			}
		}
		else
			T[n[i]].left = Nil;
	}

	int r = 0;
	for (int i = 0; i < N; i++) {
		if (T[i].parent == -1) r = i;
	}

	setDepth(T, r, 0, D);
	
	for (int i = 0; i < N; i++) {
		cout << "node " << i << ": parent = " << T[i].parent << ", depth = " << D[i];
		if (T[i].parent == -1)
			cout << ", root, [";
		else if (T[i].left == -1)
			cout << ", leaf, [";
		else
			cout << ", internal node, [";
		printfChildren(T, i);

		cout << "]\n";
	}
}


Measured memory_bytes: 10080
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)n;i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1001001001; const long long INFLL=1001001001001001001ll;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
    #ifdef int
        cerr<<"\x1b[7m"<<"'int' is defined as 'long long' !!!!"<<"\x1b[m"<<endl;
    #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(12)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int k,s;
    cin>>k>>s;
    int ans=0;
    REP(i,k+1) {
        REP(j,k+1) {
            if(i+j>s) continue;
            else if(s-i-j>k) continue;
            else {
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var Sa = Utility.ReadString();
            var Sb = Utility.ReadString();
            var Sc = Utility.ReadString();
            var cards = new[] { Sa, Sb, Sc };
            var man = 0;
            var index = new[] { 0, 0, 0 };
            while (true)
            {
                if (index[man] >= cards[man].Length)
                {
                    break;
                }
                else
                {
                    var next = cards[man][index[man]] - 'a';
                    index[man]++;
                    man = next;
                }
            }
            Console.WriteLine($"{"ABC"[man]}");
        }
    }

    public static class Utility
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(v => int.Parse(v));

        public static IEnumerable<int> EnumerateDigits(int value)
        {
            while (value > 0)
            {
                yield return value % 10;
                value /= 10;
            }
        }

    }

    public class Factorial
    {
        public static long Number(long term)
        {
            return term > 1 ? Number(term - 1) * term : 1;
        }

        public static long[] Cache(long term)
        {
            var cache = new long[term + 1];
            cache[0] = 1;
            for (int i = 1; i < cache.Length; i++)
            {
                cache[i] = cache[i - 1] * i;
            }
            return cache;
        }

        public static long[] CacheMod(long term, long mod)
        {
            var cache = new long[term + 1];
            cache[0] = 1;
            for (int i = 1; i < cache.Length; i++)
            {
                cache[i] = cache[i - 1] * i % mod;
            }
            return cache;
        }
    }
}


Measured memory_bytes: 13140
n , t = map(int,input().split(' '))
ans_x = -1
ans_y = -1
ans_ans = -1
for x in range(n+1):
    for y in range(n+1):
        ans = n -x - y
        if ans>= 0:
            if 10000 * x + 5000 * y + 1000 * ans == t:
                ans_x = x
                ans_y = y
                ans_ans = ans
                break
 
print(ans_x,ans_y,ans_ans)

Measured memory_bytes: 3060
a, b = gets.split.map(&:to_i)
cnt = 0

def palindromic_number?(num)
  str = num.to_s
  str[0] == str[4] && str[1] == str[3]
end

a.upto(b) do |i|
  cnt += 1 if palindromic_number?(i)
end

puts cnt


Measured memory_bytes: 1788
import java.util.Scanner

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val k = scn.nextInt()
	val sfs = IntArray(n){scn.nextInt()}
	val dp = IntArray(n)
	for (j in 1 until n){
		dp[j] = ((j-k).coerceAtLeast(0) until j).map { i ->
			dp[i] + Math.abs(sfs[i]-sfs[j])
		}.min()!!
	}
	println(dp.last())
}

Measured memory_bytes: 118784
n = int(input())
A = []
ans = [0] * n
for i in range(n):
    a = int(input())
    b = []
    for j in range(a):
        x, y = map(int, input().split())
        b.append([x,y])
    A.append([a,b])

c = 0
ans = 0
while c < 2 ** (n):
    q = format(c,'b').zfill(n)
    q = list(str(q))
    q = [int(m) for m in q]
    #print('---')
    #print(c, 'q : ' , q)
    #print('')
    p = [0] * n
    count = 0
    ans_tmp = 0
    for i in range(len(q)):
        if q[i] == 1:
            count += 1
            for j in range(len(A[i][1])):
                x,y = A[i][1][j]
                if y == 1:
                    if not int(q[x-1]) == 1:
                        ans_tmp = -1
                else:
                    if not int(q[x-1]) == 0:
                        ans_tmp = -1
    if ans_tmp == 0:
        ans_tmp = count

    if ans_tmp > ans:
        ans = ans_tmp
    c += 1
print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int i,j,k,tmp;
  char t;
  int a,b,c;
  vector<string> s(3);
  cin>>s[0]>>s[1]>>s[2];
  a=s[0].length();
  b=s[1].length();
  c=s[2].length();
  i=j=k=0;
  t='a';
  while(i<=a&&j<=b&&k<=c){
    if(t=='a'){
      t=s[0][i];
      i++;
    }
    else if(t=='b'){
      t=s[1][j];
      j++;
    }
    else{
      t=s[2][k];
      k++;
    }
  }
  if(i>a) cout<<"A\n";
  else if(j>b) cout<<"B\n";
  else if(k>c) cout<<"C\n";
  return 0;
}

Measured memory_bytes: 256
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn read_vec_char() -> Vec<char> {
    read::<String>().chars().collect()
}

fn read_mat<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_mat_char(n: usize) -> Vec<Vec<char>> {
    (0..n).map(|_| read_vec_char()).collect()
}

fn main() {
    let v = read_vec::<i64>();
    if (v[0]-v[2]).abs() <= v[3] || ((v[0]-v[1]).abs() <= v[3] && (v[1]-v[2]).abs() <= v[3]) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

int N;
ll C;

//source: https://cp-algorithms.com/geometry/convex_hull_trick.html
struct LiChaoTree {
#define x real
#define y imag
    typedef ll ftype;
    typedef complex<ftype> point;
    static const int H = 20;
    static const int N = 1<<H;
    point line[4*N];

    ftype f(point a, ftype x) {
        return (a.x()-x)*(a.x()-x) + a.y() + C;
    }

    LiChaoTree() {
        FOR(i,4*N)
            line[i] = {0LL, (ll)1e18};
    }

    void add_line(point nw, int v = 1, int l = 0, int r=N) {
        int m = (l + r) / 2;
        bool lef = f(nw, l)<f(line[v], l);
        bool mid = f(nw, m)<f(line[v], m);
        if(mid) {
            swap(line[v], nw);
        }
        if(r - l == 1) {
            return;
        } else if(lef != mid) {
            add_line(nw, 2 * v, l, m);
        } else {
            add_line(nw, 2 * v + 1, m, r);
        }
    }

    ll get(int x, int v = 1, int l = 0, int r=N) {
        int m = (l + r) / 2;
        if(r - l == 1) {
            return f(line[v], x);
        } else if(x < m) {
            return min(f(line[v], x), get(x, 2 * v, l, m));
        } else {
            return min(f(line[v], x), get(x, 2 * v + 1, m, r));
        }
    }
};
LiChaoTree lct;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    cin>>N>>C;
    vi height = readVector<int>(N);

    lct.add_line({height[0], 0});

    RNG(i,1,N-2) {
        ll h = height[i];
        ll c = lct.get(h);
        lct.add_line({h, c});
    }

    cout<<lct.get(height[N-1])<<endl;

    return 0;
}



Measured memory_bytes: 66688
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;

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


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

ll N,M;
string S,T;
cin >> N >> M >> S >> T;

ll G = gcd(N, M);
ll L = N / G * M;

rep(i,G) {
    if(S[L/M*i] != T[L/N*i]) {
        cout << -1 << endl;
        return 0;
    }
}
cout << L << endl;
return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}


ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

ll f(ll N, ll C, ll D) {
  ll ans = 0;
  ans += N / C;
  ans += N / D;
  ans -= N / lcm(C, D);
  return N - ans;
}

int main2() {
  ll A, B, C, D; cin >> A >> B >> C >> D;
  cout << f(B, C, D) - f(A-1, C, D) << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;
const int Max_NM(2050);

int N, M, Q, V[Max_NM][Max_NM], X[Max_NM][Max_NM], Y[Max_NM][Max_NM];
char S[Max_NM][Max_NM];

inline int query(int P[Max_NM][Max_NM], int x1, int y1, int x2, int y2)
{
	return x1 <= x2 && y1 <= y2 ? P[x2][y2] - P[x1 - 1][y2] - P[x2][y1 - 1] + P[x1 - 1][y1 - 1] : 0;
}

int main()
{
	scanf("%d%d%d", &N, &M, &Q);
	for (int i = 1;i <= N;++i)
		scanf("%s", S[i] + 1);
	for (int i = 1;i <= N;++i)
		for (int j = 1;j <= M;++j)
		{
			V[i][j] = V[i - 1][j] + V[i][j - 1] - V[i - 1][j - 1] + (S[i][j] == '1');
			X[i][j] = X[i - 1][j] + X[i][j - 1] - X[i - 1][j - 1] + (S[i][j] == '1' && S[i - 1][j] == '1');
			Y[i][j] = Y[i - 1][j] + Y[i][j - 1] - Y[i - 1][j - 1] + (S[i][j] == '1' && S[i][j - 1] == '1');
		}
	for (int x1, y1, x2, y2;Q--;)
	{
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		printf("%d\n", query(V, x1, y1, x2, y2) - (query(X, x1 + 1, y1, x2, y2) + query(Y, x1, y1 + 1, x2, y2)));
	}
	return 0;
}

Measured memory_bytes: 54912
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque
import copy

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def bubble_sort(A, N):
    for i in range(N):
        for j in reversed(range(i + 1, N)):
            if A[j][1:] < A[j - 1][1:]:
                A[j], A[j - 1] = A[j - 1], A[j]


def selection_sort(A, N):
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j][1:] < A[minj][1:]:
                minj = j
        if minj != i:
            A[i], A[minj] = A[minj], A[i]


def is_stable(bubble, selection):
    for b, s in zip(bubble, selection):
        if b != s:
            return False
    else:
        return True


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = sl()
    bubble_list = copy.copy(A)
    selection_list = copy.copy(A)

    bubble_sort(bubble_list, N)
    selection_sort(selection_list, N)
    print(*bubble_list)
    print('Stable')
    print(*selection_list)
    print('Stable' if is_stable(bubble_list, selection_list) else 'Not stable')


if __name__ == '__main__':
    main()



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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int a,b,h; cin >> a>>b>>h;
    cout << (a+b)*h/2 << endl; 
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  ll a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) cout << 0 << endl;
	else cout << min({a * b, b * c, c * a}) << endl;
}


Measured memory_bytes: 256
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

dp = [0] * (N + 1)
for k in range(K):
    sta = [max(i-A[i], 0) for i in range(N)]
    end = [min(i+A[i]+1, N) for i in range(N)]
    for s in sta:
        dp[s] += 1
    for e in end:
        dp[e] -= 1
    for i in range(1, len(dp)-1):
        dp[i] += dp[i-1]
    B = dp[:-1]
    if A == B:
        break
    A = B
    dp = [0] * (N + 1)
 
print(' '.join(map(str, A)))

Measured memory_bytes: 188944
def cmd(n, r, D):
    r = min(r, n-r)
    upper = 1
    lower = 1
    counter = 1
    while counter <= r:
        upper = (upper * (n - counter +1)) % D
        lower = (lower * counter) % D
        counter = counter + 1
    return (upper * pow(lower, D - 2, D)) % D

D = 10 ** 9 + 7
n, a, b = map(int, input().split())

N = pow(2, n, D)
P = cmd(n, a, D)
Q = cmd(n, b, D)
Ans = (N - 1 - P - Q) % D
print(Ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b;
    cin>>a>>b;
    for(int i=max(-1000000LL,b-a+1);i<min(1000000LL,b+a);i++)
    {
        cout<<i<<" ";
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
using namespace std;

#define iter(i, n) for (int i = 1; i <= n; ++i)
#define iter0(i, n) for (int i = 0; i < n; ++i)

const int inf = 1e9;

int n, m, U, M, f[20][1 << 15], h[20][1 << 15], g[20][20], ws[1 << 15];

int dfs(int x, int s);

int dfs2(int x, int s) {
	//printf("!!%d %d\n", x, s);
	assert(s >> x & 1);
	if (s == U) {
		return x == n - 1 ? 0 : -inf;
	}
	int &w = h[x][s];
	if (w != -1) return w;
	w = -inf;
	iter0(i, n) if (!(s >> i & 1) && g[x][i]) {
		w = max(w, g[x][i] + dfs(i, s));
	}
	//if (x == 0 && s == 29)	printf("h[%d][%d]=%d %d\n", x, s, h[x][s], s >> (n - 1) & 1);
	return w;
}
int sum = 0;
int dfs(int x, int s) {
//	printf("!d %d %d\n", x, s);
	int &w = f[x][s];
	if (w != -1) return w;
	w = -inf;
	int t = U - s;
	for (int _t = t; _t; _t = (_t - 1) & t) {
		if (_t >> x & 1) {
			w = max(w, ws[_t] + dfs2(x, s | _t));
		//	if (x == 1 && s == 29) printf("%d %d %d %d %d\n", x, s, _t, sum - dfs2(x, s | _t) - ws[_t], ws[_t]);
		}
	}
//	printf("f[%d][%d]=%d\n", x, s, sum - f[x][s]);
	return w;
}

int main() {
	//freopen("78F.in", "r", stdin);
	memset(f, -1, sizeof(f));
	memset(h, -1, sizeof(h));
	scanf("%d%d", &n, &m);
	M = 1 << n;
	U = M - 1;
	
	iter(i, m) {
		int x, y, c;
		scanf("%d%d%d", &x, &y, &c); --x, --y;
		g[x][y] = g[y][x] = c;
		sum += c;
	}

	iter0(s, M) {
		iter0(i, n) if (s >> i & 1) {
			iter0(j, i) if (s >> j & 1) ws[s] += g[i][j];
		}
		//printf("!%d %d\n", s, ws[s]);
	}

	printf("%d\n", sum - dfs(0, 0));
	return 0;
}

Measured memory_bytes: 5376
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

S = input()

def gen(s):
    l = len(s)

    for i in range(1, l):
        c = int(s[0: i])
        for v in gen(s[i:]):
            yield c + v

    yield int(s)

print(sum(gen(S)))

Measured memory_bytes: 3828
import heapq
n, m, s, t = map(int, input().split())
E = [[] for _ in range(n)]
A = [0] * m
B = [0] * m
for i in range(m):
  u, v, a, b = map(int, input().split())
  E[u - 1].append([v - 1, i])
  E[v - 1].append([u - 1, i])
  A[i] = a
  B[i] = b
L = [0] * n
Y = [10 ** 15] * n
S = [10 ** 15] * n
def dijkstra(s, D, W):
  Q = [[0, s]]
  D[s] = 0
  pos = 0
  while Q:
    d, q = heapq.heappop(Q)
    for adj, e in E[q]:
      if d + W[e] < D[adj]:
        D[adj] = d + W[e]
        pos += 1
        heapq.heappush(Q, [D[adj], adj])
  return D
dijkstra(s - 1, Y, A)
dijkstra(t - 1, S, B)
for i in range(n):
  L[i] = Y[i] + S[i]
for i in range(n - 2, -1, -1):
  L[i] = min(L[i + 1], L[i])
for i in range(n):
  print(10 ** 15 - L[i])

Measured memory_bytes: 67152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n,m;cin>>n>>m;
    vector<vector<int>> t(n);
    rep(i,m){
        int a,b;cin>>a>>b;a--;b--;
        t[a].push_back(b);
        t[b].push_back(a);
    }
    queue<int> que;
    que.push(0);
    vector<int> v(n,0);
    v[0]=-1;
    while(que.size()){
        int x=que.front();que.pop();
        rep(i,t[x].size()){
            int y=t[x][i];
            if(v[y]!=0)continue;
            v[y]=x+1;
            que.push(y);
        }
    }
    cout<<"Yes"<<endl;
    rep(i,n){
        if(i==0)continue;
        cout<<v[i]<<endl;
    }
}

Measured memory_bytes: 10264
#include <iostream>
using namespace std;
#define INF 10000000

int M[101][101],p[101];

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

  //次元を入力
  for ( int i = 1; i <= n; i++ ) {
    cin >> p[i-1] >> p[i];
  }

  //行列がひとつのとき
  for ( int i = 1; i <= n; i++ ) M[i][i] = 0;

  //連鎖行列積をもとめている
  for ( int l = 2; l <= n; l++ ) {
    for ( int i = 1; i <= n-l+1; i++ ) {
      int j = i+l-1;
      M[i][j] = INF;
      for ( int k = i; k <= j-1; k++ ) {
	int q = M[i][k] + M[k+1][j] + p[i-1]*p[k]*p[j];
	M[i][j] = min(M[i][j],q);
      }
    }
  }

  //出力
  cout << M[1][n] << endl;
  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    int N;
    cin >> N;
    valarray<i64> A(N), B(N), C;
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    i64 upper = B.sum() - A.sum();
    i64 ope = (B - A).apply([](i64 x){ return x > 0 ? (x+1)/2 : 0; }).sum();
    if(ope > upper) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 512
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif




#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

using namespace std;
//using ll = long long;


const int MOD = 1000000007;
const int INF = 1e18;

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

const double pi = acos(-1);



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


using Graph = vector<vector<int>>;



void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b; cin >> a >> b;
    int ans = -1;
    for (int i = 0; i < 2000; i++) {
        if(floor(i*0.08)==a && floor(i*0.10)==b) {
            ans = i;
            break;
        }
    }
    
    
    cout << ans << endl;
    
    
}



signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 256
import math

n=int(input())

l = math.ceil(math.sqrt(n))

for i in range(l+1, 0, -1):
    if n%i==0:
        a = n//i
        b = i
        if a<b:
            ans = b
        else:
            ans = a
        c = 0
        while ans>0:
            ans = ans//10
            c += 1
        print(c)
        break

Measured memory_bytes: 3060
a,b,c,d = map(int,input().split())

while(True):
    #print(c)
    c -= b
    #print("C",c)
    if c<=0:
        print("Yes")
        break
    #print(a)
    a -= d
    #print("A",a)
    if a<=0:
        print("No")
        break

Measured memory_bytes: 9108
#include <stdio.h>

#define LIM 100000

int main(void)
{
	int n;
	long k, cur;
	int i;
	int a, b, min, num[LIM] = {0};
	
	scanf("%d%ld", &n, &k);
	for (i = 0; i < n; i++) {
		scanf("%d%d", &a, &b);
		num[a - 1] += b;
	}
	
	cur = 0;
	for (i = 0; i < LIM; i++) {
		min = i + 1;
		cur += num[i];
		if (cur >= k) {
			break;
		}
	}
	
	printf("%d\n", min);
	
	return (0);
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int dp[N][3];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1,a,b,c;i<=n;i++)
    {
        scanf("%d %d %d",&a,&b,&c);
        dp[i][0] = a+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = b+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = c+max(dp[i-1][0],dp[i-1][1]);
    }
    printf("%d\n",max(dp[n][0],max(dp[n][1],dp[n][2])));
    return 0;
}


Measured memory_bytes: 1408
n,m=map(int,input().split())
ps=[input().split() for i in range(m)]

acl=[0]*n
wal=[0]*n
for p,s in ps:
    p=int(p)-1
    if s=='AC' and acl[p]==0:
        acl[p]+=1
    elif s=='WA' and acl[p]==0:
        wal[p]+=1

wa=0
for i,ac in enumerate(acl):
    if ac==1:
        wa+=wal[i]
print(sum(acl),wa)

Measured memory_bytes: 33676
import sys
import numpy as np

N, K, Q = map(int, input().split())
A = []
for _ in range(Q):
    a = int(sys.stdin.readline())
    A.append(a)

score = [K - Q] * N

for a in A:
    score[a - 1] += 1

for n in range(N):
    if score[n] > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 21312
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
 
int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
 
    int i = 0;
    int ma = 0;
    int count = 0;
    while(i < n - 1) {
        if (h[i] < h[i + 1]) {
            i++;
            ma = max(ma, count);
            count = 0;
        }
        else{
            i++;
            count++;
        }
    }
 
    ma = max(ma, count);
 
    cout << ma;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
using ll=long long;

ll f(ll n,ll x){
	if(n==-1)return 0;
	return (ll)n/x+1;
}

int main() {
	ll a,b,x;
	cin>>a>>b>>x;
	cout<<f(b,x)-f(a-1,x)<<endl;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a < b)
    {
        cout << "a < b" << endl;
    }
    else if (a > b)
    {
        cout << "a > b" << endl;
    }
    else if(a==b)
    {
        cout << "a == b" << endl;
    }

    return 0;
    
}


Measured memory_bytes: 3080
#include<iostream>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(li i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

li tume(li x,li u){
  li bs=1,p=1,ret=0;
  while(bs<=u){
    if((x&bs) and (u&bs)){
      ret+=p;
    }
    if(u&bs) p<<=1;
    bs<<=1;
  }
  return ret;
}

li solve(vector<li>& v,int k,li c){
  int n=v.size();
  vector<vector<li>> dp(k+1,vector<li>(n+1,0)); // j個の中から 1~i 個を選ぶ
  rep(i,k){
    rep(j,n){
      dp[i+1][j+1]=dp[i][j]+1+dp[i+1][j];
    }
  }
  vector<li>& count=dp[k];
  if(df) print("cnt",count);
  li lim=1<<c;
  li ans=0;
  rep(bs,lim){
    map<li,int> mp;
    rep(i,n) mp[v[i]&bs]++;
    int flag=(__builtin_popcount(bs)%2)?-1:1;
    for(auto p:mp){
      ans+=flag*count[p.second];
      //      if(df)print(p.first,p.second,"->",flag*count[p.second]);
    }
  }
  return ans;
}

int main(){
  int n,k; li s,t; cin >>n >>k >>s >>t;
  vector<li> a(n); rep(i,n) cin >>a[i];
  if((s&t)!=s){
    print(0);
    return 0;
  }
  li u=t-s;
  vector<li> v;
  rep(i,n){
    li x=a[i];
    if((s&x)!=s) continue;
    if((x&t)!=x) continue;
    v.push_back(tume(x,u));
  }
  if(df)print("v",v);
  int c=__builtin_popcount(u);
  if(df)print("c",c);
  print(solve(v,k,c));
}


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

using namespace std;
long long x[10000010], y[10000010];
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i < (n)i++)
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define int long long
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int a, b, ans = 0;
   cin >> a >> b;
   cout << a - b + 1 << '\n';
}

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

using namespace std;


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

  for(i = 1; i <= n; ++i)
  {
      if(a[i] != i)
        ++k;
  }
  if(k == 0 || k == 2)
    cout << "YES";
  else
    cout << "NO";
}


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

static const double EPS = 1e-10;

class Point
{
public:
	double x, y;

	Point(double x=0,double y=0):x(x),y(y){}

	Point operator + (Point p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point p) { return Point(x - p.x, y - p.y); }
	Point operator * (double a) { return Point(a * x, a * y); }
	Point operator / (double a) { return Point(x / a, y / a); }

	double norm() { return x * x + y * y; }

	double abs() { return sqrt(norm()); }

	bool operator == (const Point &p) const
	{
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}

	bool operator < (const Point &p) const
	{
		return (x != p.x) ? x < p.x : y < p.y;
	}
};

#define Vector Point

double dot(Vector a, Vector b)
{
	return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b)
{
	return a.x * b.y - a.y * b.x;
}

bool equals(double a, double b)
{
	return fabs(a - b) < EPS;
}

bool isOrthogonal(Vector a, Vector b)
{
	return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2)
{
	return equals(dot(a1 - a2, b1 - b2), 0.0);
}

bool isParallel(Vector a, Vector b)
{
	return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2)
{
	return equals(cross(a1 - a2, b1 - b2), 0.0);
}

int main()
{
	Point a1;
	Point a2;
	Point b1;
	Point b2;

	int q;
	cin >> q;

	for (int i = 0; i < q; i++)
	{
		int x, y;

		cin >> x >> y;
		a1.x = x;
		a1.y = y;

		cin >> x >> y;
		a2.x = x;
		a2.y = y;

		cin >> x >> y;
		b1.x = x;
		b1.y = y;

		cin >> x >> y;
		b2.x = x;
		b2.y = y;

		if (isParallel(a1, a2, b1, b2))
		{
			cout << 2 << endl;
		}
		else if (isOrthogonal(a1, a2, b1, b2))
		{
			cout << 1 << endl;
		}
		else
		{
			cout << 0 << endl;
		}
	}
}


Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <queue>
#include <cstring>
#include <cmath>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;

int main() {
  int N, M, ans = 1;
  cin >> N >> M;

  for (int i = 1; i <= sqrt(M); ++i) {
    if (M % i == 0) {
      if (i <= M / N) {
        ans = std::max(ans, i);
      }
      if (N <= i) {
        ans = std::max(ans, M / i);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
S = str(input())

if N % 2 != 0:
    print("No")

else:
    if S[:N//2] == S[N//2:]:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 7740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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

int main()
{
    int a,b,c; cin >> a >> b >> c;
    if(a==b && b==c && c==a)cout << "No" << endl;
    else if(a == b || b==c || c==a)cout <<"Yes"<<endl;
    else cout << "No" << endl;
}
    

Measured memory_bytes: 256
import itertools
import math

n = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
N_lis = [(i + 1) for i in range(n)]
PAT = itertools.permutations(N_lis)
a, b = 0, 0
i = 0
flag = 0
for one_case in PAT:
    if P == list(one_case):
        a = i
        flag += 1
    if Q == list(one_case):
        b = i
        flag += 1
    if flag == 2:
        break
    i += 1
print(abs(a - b))

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

using namespace std;
inline void read(long long &x) {
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}
inline void write(long long x) {
    static const long long maxlen = 100;
    static char s[maxlen];
    if (x < 0) {   putchar('-'); x = -x;}
    if (!x) { putchar('0'); return; }
    long long len = 0; for (; x; x /= 10) s[len++] = x % 10 + '0';
    for (long long i = len - 1; i >= 0; --i) putchar(s[i]);
}

inline void read(int &x){
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}

const long long MAXN =1001000;

long long n,A,B;
long long a[ MAXN ];
long long add;

bool check(long long lim){
long long cnt=0;
for (long long i=1;i<=n;i++)
    {
        long long tmp=max(0ll,a[i]-lim*B);
        cnt+=(tmp+add-1)/add;
        //printf("%d %d\n",tmp,cnt);
    }
return cnt<=lim;
}


int main(){
    read(n);read(A);read(B);
    add=A-B;
    for(long long i=1;i<=n;i++)
        read(a[i]);
    sort(a+1,a+n+1);
    long long l=1,r=a[n];
    long long ans=0;
    while (l<=r)
        {
            long long mid=(l+r)/2;
            if( check( mid ) )
                {
                    ans=mid;
                    r=mid-1;
                }
            else
                l=mid+1;
        }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s := scanString()
	if s == "RRR" {
		fmt.Fprintln(wr, 3)
	} else if s[:2] == "RR" || s[1:] == "RR" {
		fmt.Fprintln(wr, 2)
	} else if s[0] == 'R' || s[1] == 'R' || s[2] == 'R' {
		fmt.Fprintln(wr, 1)
	} else {
		fmt.Fprintln(wr, 0)
	}
}


Measured memory_bytes: 1776
function main (arg) {
  const args = arg.split(' ')
  const a = parseInt(args[0], 10);
  const b = parseInt(args[1], 10);
  console.log((a * b) % 2 === 0 ? "Even" : "Odd")
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

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

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  ll ans = 0;
  for(int i=1; i<n; i++) ans += a[i/2];
  cout << ans << endl;
  return 0;
}


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


int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans=0;
  int cnt=0;

  rep(i,n) {
    if (s[i] == 'R') ans++;
    else cnt++; 
  }
  if (ans > cnt) cout << "Yes";
  else cout << "No";
  cout << endl;
  return 0;  

}


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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  int a = r * 100 + g * 10 + b;
  if (a % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
k = int(input())

queue = [1,2,3,4,5,6,7,8,9]
cnt = 0
while cnt + len(queue) < k:
  cnt += 1
  n = queue.pop(0)
  if n%10 != 0:
    queue.append(n*10+n%10-1)
  queue.append(n*10+n%10)
  if n%10 != 9:
    queue.append(n*10+n%10+1)
print(queue[k-cnt-1])

Measured memory_bytes: 11876
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;
constexpr int mod = 1e9 + 7;
string t[] = {"AC", "WA", "TLE", "RE"};
int main(){ 
  map<string, int> id;
  id["AC"] = 0;
  id["WA"] = 1;
  id["TLE"] = 2;
  id["RE"] = 3;
  vector<int> res(4, 0);
  int n;
  cin >> n;
  rep(i,n) {
    string s;
    cin >> s;
    res[id[s]]++;
  }
  for (int i = 0; i < 4; i++) {
    cout << t[i] << " " << 'x' << " ";
    cout << res[i] << endl;
  }
  return 0;
} 

Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
const int maxn=10000007;
int pown(int n,int m){
	int ans=1;
	while(m){
		if(m&1) ans*=n;
		n=n*n;
		m>>=1;
	}
	return ans;
}
int vis[maxn];
int main(){
	int n;scanf("%d",&n);
	int ans=1;
	for(int i=2;i<=(int)sqrt(n+0.5);i++){
		if(vis[i]) continue;
		if(n%i==0){
			int cnt=0;
			while(n%i==0){
				cnt++;
				n/=i;
			}
			ans*=pown(i,cnt-1);ans*=(i-1);
		}
		for(int k=i*i;k<=(int)sqrt(n+0.5);k+=i) vis[k]=1;
	}
	if(n!=1) ans*=(n-1);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3348
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int N, A;
    io.read(N, A);
    cout << N * N - A;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int a,b,i,c=0;

        scanf("%d%d",&a,&b);

        char s[a+b+1];

        scanf("%s",s);

        for(i=0;i<a+b+1;i++){
                if(i!=a){
                        if(s[i]>='0' && s[i]<='9')c++;
                }
                else if(s[i]=='-')c++;
        }
        if(c==a+b+1)printf("Yes\n");
        else printf("No\n");
        return 0;
}


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

using namespace std;

int main(void){
    int n;
    cin >> n;
    double ans = n % 2 == 0 ? n/2 / (double)n: (n/2+1) / (double)n;
    cout << fixed << setprecision(10) <<  ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int A,B;
    cin >> A >> B;
    if(A - B * 2 > 0){
        cout << A - B * 2 << endl;
    }else if(A - B * 2 <= 0){
        cout << 0 << endl;
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define ll long long
#define pp pair<ll,ll>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
ll max(ll x, ll y)
{
    return x>y ? x : y;
}
ll min(ll x, ll y)
{
    return x<y ? x : y;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string a,b;cin >> a >> b;ll c,d;cin >> c >> d;string s;cin >> s;
    if(s==a)cout << c-1 << " " << d;
    else cout << c << " " << d-1;

    }

Measured memory_bytes: 256
#include<iostream>
#define yes "YES"
#define no "NO"
using namespace std;


//  Problem https://atcoder.jp/contests/abc060/tasks/abc060_b
// 1st C++ Try
// Reference https://atcoder.jp/img/arc073/editorial.pdf

int main(void){
    bool answer;
    answer = false;
    int A,B,C;
    cin >> A >> B >> C;
    for(int j=1;j<=B;j++){
        int amari;
        amari = (j*A) % B;
        if(amari == C){
            answer=true;
        }
    }

    if(answer){
        cout << yes << endl;
    }
    else{
        cout << no << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long;
using namespace std;

int main()
{
    int n;
  cin >>n;
    int a = -1;
    rep(i, n + 1)
    {
        if ((int)(i * 1.08) == n)
        {
            a = i;
            break;
        }
    }
    if (a == -1)
    {
        cout << ":(" << endl;
    }
    else
    {
        cout << a << endl;
    }
}

Measured memory_bytes: 256
def solve():
    N = int(input())
    p = list(map(int, input().split()))
    count = int(0)
    for i in range(N):
        if p[i] == i+1:
            if i+1 == N:
                p[i], p[i - 1] = p[i - 1], p[i]
                count += 1
            else:
                p[i], p[i+1] = p[i+1], p[i]
                count += 1
    print(count)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 14008
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 50000000000000000;
typedef std::pair<int,int> P;
struct edge {int to,cost;};
    ll N;
    std::string A,B;
    ll ans=0;

int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N>>A>>B;
    REP(i,N){
        if(A[i]==B[i]){
            if(i==0)ans=3;
            else{
                if(A[i-1]==B[i-1])ans=ans*2%MOD;
            }
        }else{
            if(i==0)ans=6;
            else{
                if(A[i-1]!=B[i-1])ans=ans*3%MOD;
                else ans=ans*2%MOD;
            }
            i++;
        }
    }
    cout<<ans%MOD;
    return 0;
}

//ARC 081 D - Coloring Dominoes


Measured memory_bytes: 256