akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		var a = GetLongs(N);
		long cnt = 0;
		for(long i = 0; i < N; i += 2)
		{
			if(a[i] % 2 == 1)
				cnt++;
		}
		WriteLine(cnt);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 28436
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int a,b;
  cin >> a >> b;
  
  if(a == 0 || b == 0) cout << "Zero" << endl;
  else if(a > 0) cout << "Positive" << endl;
  else if(b < 0) {
    int d = abs(a-b)+1;
    if(d % 2 == 0) cout << "Positive" << endl;
    else cout << "Negative" << endl;
  }else cout << "Zero" << endl;
  
}



Measured memory_bytes: 256
N = int(input())
XYH = [tuple(map(int, input().split())) for _ in range(N)]
bx, by, bh = [xyh for xyh in XYH if xyh[2] > 0][0]

def solve(cx, cy):
    H = abs(cx - bx) + abs(cy - by) + bh

    for x, y, h in XYH:
        D = max(0, H - abs(cx - x) - abs(cy - y))
        if D != h:
            return 0
    return H

for x in range(101):
    for y in range(101):
        h = solve(x, y)
        if h > 0:
            print(x, y, h)
            exit()

print(-1)


Measured memory_bytes: 3192
#include <stdio.h>

int main(void) {
	int N;
	int goukei = 0;
	int minKisuu = -1;
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		int A;
		if (scanf("%d", &A) != 1) return 1;
		goukei += A;
		if (A % 2 != 0) {
			if (minKisuu < 0 || A < minKisuu) minKisuu = A;
		}
	}
	printf("%d\n", (goukei % 2 != 0 ? goukei - minKisuu : goukei) / 2);
	return 0;
}



Measured memory_bytes: 2128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <cstdlib> 
using namespace std;
int n,y;
int main(){
	cin>>n>>y;
	for (int i=0;i<=n;++i){
		for (int j=0;i+j<=n;++j){
			int k=n-i-j;
			if (10000*i + 5000*j + 1000*k == y){
				cout<<i<<" "<<j<<" "<<k;
				return 0;
			}
		}
	}
	puts("-1 -1 -1");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const int mod = 998244353;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

mint dp[3010][3010];
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  dp[a][b] = 1;

  for(int i = a;i<=c;i++){
    for(int j = b;j<=d;j++){
      dp[i][j]+= dp[i-1][j]*j;
      dp[i][j]+=dp[i][j-1]*i;
      dp[i][j]-=dp[i-1][j-1]*(i-1)*(j-1);
    }
  }
  cout<<dp[c][d].x<<endl;
  return 0;
}

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

const int MAX = 500000, SENTINEL = 2100000000;
int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        cnt++;
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void msort(int A[], int n, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        msort(A, n, left, mid);
        msort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}


int main(void) {
    int n, A[MAX];
    cnt = 0;

    cin >> n;
    for (int i = 0; i < n; i++) cin >> A[i];

    msort(A, n, 0, n);

    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << cnt << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n;
int matrix[1000][1000];
int main() {
  while (scanf("%d", &n) > 0) {
    ll ans = 0;
    REP(y, n) REP(x, n) { scanf("%d", &matrix[y][x]); }
    REP(x, n) REP(y, x) { ans += min(matrix[y][x], matrix[x][y]); }
    printf("%lld\n", ans);
  }
}

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

int main() {
  int N;
  cin >> N;
  
  if (N % 1111 == 0 || N / 10 % 111 == 0 || N % 1000 % 111 == 0)
    cout << "Yes" << endl;
  
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
while 1:
    s=map(int, raw_input().split())
    s.sort()
    if s==[0,0,0]: break
    n = input()
    cr = float(s[0]**2+s[1]**2)/4.0
    for i in xrange(n):
        r = input()
        print "OK" if cr<r**2 else "NA"

Measured memory_bytes: 4224
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int n, m;

    scanf("%d%d", &n, &m);

    long long x[n+1], y[m+1];

    for(int i = 1; i <= n; i++){
        scanf("%lld", &x[i]);
    }
    for(int i = 1; i <= m; i++){
        scanf("%lld", &y[i]);
    }

    long long t = 0;

    for(int i = 1; i <= n; i++){
        t = (t + (i-1)*x[i] - (n-i)*x[i]) % 1000000007;
    }

    long long k = 0;

    for(int i = 1; i <= m; i++){
        k = (k + (i-1)*y[i] - (m-i)*y[i]) % 1000000007;
    }

    printf("%lld\n", (t*k)%1000000007);

    return 0;
}

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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<vector<int>> g(n);
    vector<int> a(n);
    for (int _ = 1; _ < n; _++) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    for (auto& x: a) {
        cin >> x;
    }
    sort(a.begin(), a.end());

    int sum = 0;
    for (int i = 0; i < n-1; i++) {
        sum += a[i];
    }
    vector<int> res(n);
    int i = 0;
    function<void(int,int)> dfs = [&](int u, int p){
        for (int v: g[u])if(v!=p){
            dfs(v,u);
        }
        res[u] = a[i++];
    };
    dfs(0,-1);

    cout << sum << "\n";
    for (auto& x: res) {
        cout << x << ' ';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int x, a, b;

int main() {
	cin >> x >> a >> b;
	if (b <= a) {
		cout << "delicious" << endl;
	}
	else {
		if (b <= a + x)cout << "safe" << endl;
		else cout << "dangerous" << endl;
	}
}

Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

a,b,h,m = get_all_int()
theta_h = math.radians(360 * (h/12+m/60/12))
theta_m = math.radians(360 * (m/60))

# log(360 * (h/12+m/60))
# log(360 * (m/60))

hx = math.cos(theta_h) * a
hy = math.sin(theta_h) * a
mx = math.cos(theta_m) * b
my = math.sin(theta_m) * b

dx = abs(hx - mx)
dy = abs(hy - my)

print(math.sqrt(dx**2 + dy**2))

Measured memory_bytes: 68148
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,a) for(int i = 0; i < (a); i++)
using namespace std;

int main(){
	int p,q,r;
	cin >> p >> q >> r;
	cout << min(p + q, min(q + r, r + p));
}

Measured memory_bytes: 256
a, b = map(int, input().split())

if a > b:
    a, b  = b, a
if a == 1 or b == 1:
  print(1)
  exit()

ls = []
for i in range(1, int(a**(1/2)) + 1):
    if a % i == 0:
        ls.append(i)
        ls.append(int(a/i))

ls1 = []
for j in ls:
    if b % j == 0:
        ls1.append(j)

ans = []
for k in ls1:
    if k == 1 or k == 2 or k == 3:
      ans.append(k)
      continue
    for x in range(2, int(k**(1/2)) + 1):
        if k % x == 0:
            break
        if x == int(k**(1/2)):
            ans.append(k)

print(len(ans))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw				"\n"
int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	string s;
	cin>>s;
	l=s.size();
	ll max=1e9;
	for(ll i=0;i<l-2;i++){
		max=min(max,(ll)abs(753-stoi(s.substr(i,3))));
	}
	cout<<max;
}


Measured memory_bytes: 3640
import math

n, m = map(int, input().split())
if abs(n - m) > 1:
    ans = 0
else:
    if n == m:
        ans = 2
        for i in range(n):
            ans *= (i + 1) **2
            if ans > 10**9 + 7:
                ans %= 10**9 + 7
    else:
        ans = 1
        for i in range(n):
            ans *= i + 1
            if ans > 10**9 + 7:
                ans %= 10**9 + 7
        for i in range(m):
            ans *= i + 1
            if ans > 10**9 + 7:
                ans %= 10**9 + 7
print(ans)

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

using namespace std;

int main()

{

    int n;
    scanf("%d", &n);
    int L = n /100;
    int R = n%100;

    if(L >= 1 && L <= 12)
    {

        if(R >= 1 && R <= 12)
            cout << "AMBIGUOUS" <<endl;
        else
            {
                cout << "MMYY" <<endl;
            }
    }
    else
    {
        if(R >= 1 && R <= 12)
            cout << "YYMM"<<endl;
        else
            cout << "NA"<<endl;
    }
}


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

int main(){
    int l,n;
    cin >> l >> n;
    int b = 0;
    for(int i=0; i<n; i++){
        int x,w;
        cin >> x >> w;
        b += x*w;
    }
    if(b == 0){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
        cout << -b/abs(b) << " " << abs(b) << endl;
    }
    return 0;
}


Measured memory_bytes: 3132
#include "bits/stdc++.h"
using namespace std;

// コンテスト中のみ
#define int long long


#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
int MOD = 1000000007;
const int inf = 1001001001;
const ll INF = 1LL << 60;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, d; cin >> n >> d;
	vector<int>x(n), y(n);
	rep(i, n)cin >> x[i] >> y[i];
	int ans = 0;
	rep(i, n) {
		if (x[i] * x[i] + y[i] * y[i] <= d * d) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6364
from itertools import permutations
from itertools import combinations
from math import sqrt
from math import factorial
from collections import defaultdict

N = int(input())

points = [list(map(int, input().split())) for _ in range(N) ]

length = defaultdict(float)
l_sum = 0
res = 0

for a, b in combinations(range(N),2):
    length[(a, b)] = (sqrt( (points[a][0] - points[b][0])**2 + (points[a][1] - points[b][1])**2 ))

for a in permutations(range(N)):
    for i in range(N-1):
        l_sum += length[(min(a[i], a[i+1]), max(a[i], a[i+1]))]

res = l_sum/factorial(N)

print(res)

Measured memory_bytes: 41964
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
  int64_t N, A, B;
  cin >> N >> A >> B;
  int64_t div = N / (A + B);
  int64_t mod = N % (A + B);
  int64_t bc = A * div;
  if (mod >= A)
    bc += A;
  else
    bc += mod;
  cout << bc << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int K = Integer.parseInt(scan.nextLine());
		String S = scan.nextLine();
		String str = null;
		
		if (S.length() <= K) {
			System.out.println(S);
		}else {
			str = S.substring(0, K);
			System.out.println(str + "...");
		}
	}
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, Q;
    cin >> A >> B >> Q;
    set<ll> jinjyaPoints;
    set<ll> teraPoints;
    for (int i = 0; i < A; i++)
    {
        ll s;
        cin >> s;
        jinjyaPoints.insert(s);
    }
    for (int i = 0; i < B; i++)
    {
        ll s;
        cin >> s;
        teraPoints.insert(s);
    }
    vector<ll> questions;
    for (int i = 0; i < Q; i++)
    {
        ll q;
        cin >> q;
        questions.push_back(q);
    }
    for (ll question : questions)
    {
        ll answer = 1e12;
        auto jinjyaIte = jinjyaPoints.upper_bound(question);
        auto teraIte = teraPoints.upper_bound(question);
        ll jinjyaEast = 1e12;
        ll jinjyaWest = -1e12;
        ll teraEast = 1e12;
        ll teraWest = -1e12;
        if (jinjyaIte != jinjyaPoints.end())
        {
            jinjyaEast = *jinjyaIte;
        }
        if (jinjyaIte != jinjyaPoints.begin())
        {
            jinjyaIte--;
            jinjyaWest = *jinjyaIte;
        }
        if (teraIte != teraPoints.end())
        {
            teraEast = *teraIte;
        }
        if (teraIte != teraPoints.begin())
        {
            teraIte--;
            teraWest = *teraIte;
        }

        //16通り全部試す
        //神社先
        //西西
        answer = min(answer, question - jinjyaWest + abs(jinjyaWest - teraWest));
        //西東
        answer = min(answer, question - jinjyaWest + abs(jinjyaWest - teraEast));
        //東西
        answer = min(answer, jinjyaEast - question + abs(jinjyaEast - teraWest));
        //東東
        answer = min(answer, jinjyaEast - question + abs(jinjyaEast - teraEast));
        //寺先
        //西西
        answer = min(answer, question - teraWest + abs(teraWest - jinjyaWest));
        //西東
        answer = min(answer, question - teraWest + abs(teraWest - jinjyaEast));
        //東西
        answer = min(answer, teraEast - question + abs(teraEast - jinjyaWest));
        //東東
        answer = min(answer, teraEast - question + abs(teraEast - jinjyaEast));
        cout << answer << endl;
    }
    return 0;
}


Measured memory_bytes: 11636
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>

using namespace std;

int main()
{
  double r;
  cin >> r;
  printf("%lf ", r * r * M_PI);
  printf("%lf\n", r * 2	* M_PI);
  return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
int n,cnt,fir[101010];
int dep[101010],nxt[202020],to[202020];
void add(int x,int y)
{
	nxt[++cnt]=fir[x];fir[x]=cnt;
	to[cnt]=y;
}
void dfs(int x)
{
	priority_queue<int> q;
	dep[x]=0;
	for(int i=fir[x];i;i=nxt[i])
	{
		dfs(to[i]);
		q.push(dep[to[i]]);
	}
	int k=1;
	while(!q.empty())
	{
		dep[x]=max(dep[x],q.top()+k);
		q.pop();k++;
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		add(x,i);
	}
	dfs(1);
	printf("%d\n",dep[1]);
	return 0;
}

Measured memory_bytes: 8064
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

int N, M, K, H, W, L, R;
//long long int N, M, K, H, W, L, R;

class XorShift {
	unsigned int x, y, z, w, t;
public:
	XorShift() {
		x = 133553533;
		y = 314867339;
		z = 664298413;
		w = 999999937;
		t = 0;
	}
	unsigned int rand() {
		t = x ^ (x << 11);
		x = y;
		y = z;
		z = w;
		w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
		return w & 0x7fffffff;
	}
};

constexpr int LOOP = 1000000;

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

	cin >> N >> M;
	M = min(M, 20);
	string s;
	cin >> s;
	string u = s;
	reverse(u.begin(), u.end());
	s += u;
	string ans = s;
	for (int i = N; i < N * 2; i++) {
		string t;
		int num = 0;
		for (int j = i; j >= 0; j--) {
			if (s[i] == s[j])num++;
			else break;
		}
		for (int j = 0; j < min(N, num << (M-1)); j++)t.push_back(s[i]);
		int index = i - num;
		while (t.size() < N) {
			t.push_back(s[index]);
			index--;
		}
		ans = min(ans, t);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int h, n; cin >> h >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
	vector<int> dp(h + 20000, 1e9);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < h; j++) {
			dp[j + a[i]] = min(dp[j + a[i]], dp[j] + b[i]);
		}
	}
	int ans = 1e9;
	for (int i = h; i <= h + 10000; i++) ans = min(ans, dp[i]);
	cout << ans << endl;
	return 0;
}


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

void Main() {
  int n;
  cin >> n;
  vector<pair<long long, long long>> task(n);
  for (int i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    task[i] = pair<long long, long long>{b, a};
  }

  sort(task.begin(), task.end());
  long long now = 0;
  for (int i = 0; i < n; i++) {
    now += task[i].second;
    if (now > task[i].first) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}

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


Measured memory_bytes: 3456
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;


class Program
{
    public void Slove()
    {    
        var inputs = Console.ReadLine().Split();
        int n = int.Parse(inputs[0]);
        int m = int.Parse(inputs[1]);
        int[] chkPoints =
            Console.ReadLine().Split()
            .Select(int.Parse)
            .OrderBy(x => x)
            .ToArray();
        int[] distance =
            Enumerable.Range(0, m - 1)
            .Select(x => chkPoints[x + 1] - chkPoints[x])
            .ToArray();
        int result =
            distance
            .OrderByDescending(x => x)
            .Skip(n - 1)
            .Sum();
        Console.WriteLine(result);

    }
    static void Main(string[] args)
    {
        var p = new Program();
        p.Slove();
    }
}


Measured memory_bytes: 25056
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>

#define rep(i,n,m) for(int i=n;i<(int)(m);i++)

using namespace std;

int main() {

	vector<int>mp((int)pow(10, 5)+1, 0);
	int n;
	cin >> n;
	int sum = n;
	vector<int>num(n);

	rep(i, 0, n) {
		cin >> num[i];
		mp[num[i]]++;
	}

	sort(num.begin(), num.end());

	num.erase(std::unique(num.begin(), num.end()), num.end());

	rep(i, 0, num.size()) {
		if (mp[num[i]] > 1) {
			if (mp[num[i]] % 2 == 0)mp[num[i]] = 2;
			else mp[num[i]] = 1;
		}
	}

	int cnt = 0;

	rep(i, 0, num.size()) {
		if (mp[num[i]] == 2) cnt++;
	}

	if (cnt % 2 == 1)cnt=1;
	else cnt = 0;
	cout << num.size() - cnt << endl;


	return 0;
}

Measured memory_bytes: 1152
'use strict';

(function(input){
  input=input.trim().split(/\s+/).map(x=>x-0);
  const N=input.shift();
  const K=input.shift();
  const dp=[0];
  for(let i=1;i<N;i++){
    dp[i]=Infinity;
  }
  for(let i=1;i<N;i++){
    for(let j=1;j<=Math.min(i,K);j++){
      let c=dp[i-j]+Math.abs(input[i]-input[i-j]);
      if(dp[i]>c){
        dp[i]=c;
      }
    }
  }
  console.log(dp[N-1]);
})(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 25420
#include <iostream>
#include <algorithm>

int main() {
	int n, x, y;
	std::cin >> n >> x >> y;

	for (int i = 1; i <= n - 1; ++i) {
		int ans = 0;
		for (int j = 1; j <= n; ++j) {
			if (j <= x) {
				if (j + i <= x)
					++ans;
				else {
					if (x + 1 < j + i && j + i <= x + n - y + 1)
						++ans;
					if (j + i - x <= (y - x) / 2)
						ans += 2;
					else if ((j + i - x) * 2 - 1 == y - x)
						++ans;
				}
			}
			else if (y <= j) {
				if (j + i <= n)
					++ans;
			}
			else {
				int a = std::min(j - x + 1, y - j);
				if (i > a && i - a <= n - y)
					++ans;

				if (i >= j - x + 1) {
					if (i * 2 < y - x + 1)
						ans += 2;
					if (i * 2 == y - x + 1)
						++ans;
				}
				else if (j + i <= y)
					++ans;
			}
		}

		std::cout << ans << std::endl;
	}
}

Measured memory_bytes: 256
"use strict";
function I(s,f){this._s=s.split("\n");this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s[this._l];if(!l)return;this._c=0;this._l++;return l.split(" ").map(this._f)};
function buildArray(r,e){let n=e||0;for(let e=r.length;e>0;e--){const t=r[e-1];if("number"!=typeof t)return void console.error("Arguments must be number");n=Array(t).fill().map(()=>JSON.parse(JSON.stringify(n)))}return n}

function main(input) {
  const o = new I(input, String);

  const N = o.a();

  const dp = buildArray([Number(N + 10), 4, 4, 4]);

  dp[0][3][3][3] = 1;
  for (let i = 1; i <= N; i++) {
    for (let s1 = 0; s1 < 4; s1++) {
      for (let s2 = 0; s2 < 4; s2++) {
        for (let s3 = 0; s3 < 4; s3++) {
          if (dp[i - 1][s1][s2][s3] === 0) continue;

          for (let a = 0; a < 4; a++) {
            if (s2 === 0 && s3 === 2 && a ===1) continue;
            if (s2 === 0 && s3 === 1 && a ===2) continue;
            if (s2 === 2 && s3 === 0 && a ===1) continue;
            if (s1 === 0 && s2 === 2 && a ===1) continue;
            if (s1 === 0 && s3 === 2 && a ===1) continue;
            dp[i][s2][s3][a] += dp[i - 1][s1][s2][s3];
            dp[i][s2][s3][a] %= 1000000007
          }
        }
      }
    }
  }

  let total = 0;
  for (let s1 = 0; s1 < 4; s1++) {
    for (let s2 = 0; s2 < 4; s2++) {
      for (let s3 = 0; s3 < 4; s3++) {
        total += dp[N][s1][s2][s3];
      }
    }
  }
  console.log(total % 1000000007);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 53452
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<int> v;

    S.push_back('2');

    char c = S[0];
    int cnt = 1;
    if(c == '0')
        v.push_back(0);
    for(int i=1; i<=N; i++){
        if(S[i] != c){
            c = S[i];
            v.push_back(cnt);
            cnt = 1;
        }else{
            cnt++;
        }
    }
    if(S[N-1] == '0')
        v.push_back(0);

    int ans = 0;
    int l = 0;
    int r = min(2*K+1, int(v.size()));
    for(int i=l; i<r; i++)
        ans += v[i];
    int cur = ans;
    while(true){
        if(r+1 >= v.size()) break;
        cur -= v[l];
        cur -= v[l+1];
        cur += v[r];
        cur += v[r+1];
        l += 2;
        r += 2;
        ans = max(ans, cur);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n,ans = 0;
  cin >> n;
  vector<int>l(n);vector<int>r(n);
  for(int i = 0;i < n;i++){
    cin >> l.at(i) >> r.at(i);
    ans += r.at(i) - l.at(i) + 1;
  }
  cout << ans << endl;
}


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

int main() {
  char com[10];
  int key;
  std::priority_queue<int> PQ;

  while (1) {
    scanf("%s", com);
    if (com[0] == 'e' && com[1] == 'n') break;
    if (com[0] == 'i') {
      scanf("%d", &key);
      PQ.push(key);
    } else if (com[0] == 'e') {
      printf("%d\n", PQ.top());
      PQ.pop();
    }
  }

  return 0;
}



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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,b,a)     for(int i=b;i>=a;i--)

string s;
long int temp,mini=0;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    

    cin>>s;
    rep(i,0,s.length()-3)
    {
        temp = (int(s[i])-48)*100+(int(s[i+1])-48)*10+(int(s[i+2])-48);
        if(i==0)
            mini=abs(753-temp);
        else
            mini=min(mini,abs(temp-753));
    }    
    cout<<mini;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#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 all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const ll MOD = 1000000007;
//const long double PI = (acos(-1));
//const long double EPS = 0.0000000001;
int dy[4] = {-1, 0, 1, 0};
int dx[4] = {0, 1, 0, -1};

int n;
vector<pii> adj[100050];
bool visited[100050];
int record[100050];

void dfs(int here, int color) {
	visited[here] = true;
	record[here] = color;
	for(int i=0; i<adj[here].size(); ++i) {
		int there = adj[here][i].F;
		int weight = adj[here][i].S;
		if(!visited[there]) {
			int ncolor = (weight % 2 == 0 ? color : (color+1)%2);
			dfs(there, ncolor);
		}
	}
}


int main(void) {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	cout.tie(NULL);
	//freopen("in.txt", "r", stdin);
	cin >> n;
	rep(i,0,n-1) {
		int a,b,w;
		cin >> a >> b >> w;
		a--; b--; 
		adj[a].pb(mp(b,w));
		adj[b].pb(mp(a,w));
	}
	memset(visited, false, sizeof(visited));
	memset(record, -1, sizeof(record));
	dfs(0, 0);
	rep(i,0,n) {
		cout << record[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 8832
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll A, B;
  cin >> A >> B;
  for (int c = 1; c <= 3; c++) {
    if (A * B * c % 2 == 1) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    int n, m;
    cin>> n >> m;
    vector<int> a(m);
    ll sum=0;
    for(int i=0; i<m; i++){
        cin>> a[i];
        sum += a[i];
    }
    if (sum > n){
        cout << -1 << endl;
        return 0;
    }
    cout << n - sum <<endl;
    return 0;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll h,w;
    cin>>h>>w;
    ll t=h*w;
    ll a=t&1;
    if(h==1 or w==1)cout<<1;
    else if(a and t!=1e18)cout<<((t+1)>>1);
    else if(a)cout<<1e18+1;
    else cout<<(t>>1);
}

Measured memory_bytes: 256
# frozen_string_literal: true
def factorial(n)
  arr = (1..n).to_a
  loop do
    return arr[0] if arr.length == 1
    arr = arr.each_slice(2).map { |a, b| b ? a * b : a }
  end
end

puts factorial(gets.to_i) % (10**9 + 7)


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

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

int arr[s];

for(int i = 0;i<s;i++){
        cin>>arr[i];
}
int arr2[s];
int res = 1;
int j = 0;
for(int i=1;i<=s;i++){

    arr2[j] = i ;
    j++;
}

int countt=0;
for(int i=0;i<s;i++){

    if(arr[i]!=arr2[i]){
        countt++;
    }

}

if(countt==2 || countt==0){
    cout<<"YES"<<endl;
}
else{
    cout<<"NO"<<endl;
}

    }




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double ans=0;
double p;
vector<vector<vector<double>>>dp;
double solve(double l,double m,double n){
    if(m<0||n<0||l<0||(l+m+n==0)) return 0;
    if(dp[l][m][n]!=0){
        // ans=(dp[l][m][n])+1/(l+m+n)*(l*solve(l-1,m,n)+m*solve(l+1,m-1,n)+n*solve(l,m+1,n-1));
        // cout<<ans;
        return dp[l][m][n];
    }
    else{
        // cout<<l<<m<<n;
        dp[l][m][n]=p/(l+m+n)+1/(l+m+n)*(l*solve(l-1,m,n)+m*solve(l+1,m-1,n)+n*solve(l,m+1,n-1));
        // cout<<ans;
        return dp[l][m][n];
    }
}
int main(){
    double l=0,m=0,n=0;
    cin>>p;
    for(int i=0,x;i<p;i++){
        cin>>x;
        if(x==1) l++;
        else if(x==2) m++;
        else n++;
    }
    dp.resize(307,vector<vector<double>>(307,vector<double>(307)));
    ans= solve(l,m,n);
    printf("%.10lf",ans);
    return 0;
}

Measured memory_bytes: 230016
import java.io.*;
import java.util.ArrayList;
import java.util.List;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            String line; // ??\???????????????????????\???
            int cnt = 0;
            List<Integer> numList = new ArrayList<Integer>();
            int row = 0;
            int column = 0;
            while ((line = br.readLine()) != null) {
            	if(cnt == 0){
            		cnt++;
            		row = Integer.parseInt(line);
            		for(int i = 1; i < row+1; i++){
            			numList.add(i);
            		}
            	}else if(cnt == 1){
            		cnt++;
            		column = Integer.parseInt(line);
            	}else{
            		String[] convertList = line.split(",", 0);
            		int first = Integer.parseInt(convertList[0]);
            		int second = Integer.parseInt(convertList[1]);
            		
            		int firstNum = numList.get(first - 1);
            		int secondNum = numList.get(second - 1);
            		
            		numList.set(first - 1, secondNum);
            		numList.set(second - 1, firstNum);
            	}  	
            }
            for(int j = 0; j < numList.size(); j++){
        		System.out.println(numList.get(j));
        	}
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 24220
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;
int MAX1=1;

void dfs(Graph &G, vector<int>&seen, vector<int>&done, int v, int cnt){
    seen[v]=MAX1++;
    for(auto next_v : G[v]){
        if(seen[next_v]!=0)continue;
        dfs(G,seen,done,next_v,cnt);
    }
    done[v]=MAX1++;
}

int main() {
    int n;
    cin>>n;
    Graph G(n);
    for(int i=0;i<n;i++){
        int u;
        cin>>u;
        int k;
        cin>>k;
        vector<int>a(k);
        for(int j=0;j<k;j++){
            cin>>a[j];
            a[j]--;
        }
        sort(a.begin(),a.end());
        G[u-1]=a;
    }
    // for(int i=0;i<n;i++){
    //     sort(G[i].begin(),G[i].end());
    // }
    vector<int>seen(n,0);
    vector<int>done(n,0);

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

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





    return 0;
}



Measured memory_bytes: 3092
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,d;
  cin >> n >> d;

  cout << n/(2*d+1) + (n%(2*d+1)>0) << endl;

  return 0;
}

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

def ri():
    return int(input())

def rl():
    return list(input().split())

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

MOD = 10**9+7

def main():
    s = input()
    dp = [[0 for _ in range(4)] for _ in range(len(s)+1)]
    dp[0][0] = 1
    for i, c in enumerate(s):
        if c == '?':
            for j in range(4):
                dp[i+1][j] = 3*dp[i][j]
        else:
            for j in range(4):
                dp[i+1][j] = dp[i][j]
        if c == 'A' or c == '?':
            dp[i+1][1] += dp[i][0]
        if c == 'B' or c == '?':
            dp[i+1][2] += dp[i][1]
        if c == 'C' or c == '?':
            dp[i+1][3] += dp[i][2]
        if i & 1:
            for j in range(4):
                dp[i+1][j] %= MOD

    print(dp[len(s)][3]%MOD)


if __name__ == '__main__':
    main()


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

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

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int k; cin >> k;
  int a, b; cin >> a >> b;
  if(a % k  && (b - a) + a%k < k) cout << "NG" <<endl;
  else cout << "OK" << endl;

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


Measured memory_bytes: 3604
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 1000000009;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[]={-1,-2,1,-2,2,-1,2,1},ddy[]={-2,-1,-2,1,-1,2,1,2};

int n,m;
Vi v[601];
db d[601];
db go(int N,int ban)
{
	if(N==n)return 0;
	db &ret=d[N];
	if(ret>=0)return ret;
	db mx=-1,s=0;
	int tt=v[N].size();
	for(int next:v[N])
	{
		db t=go(next,ban);
		mx=max(mx,t);
		s+=t;
	}
	if(N==ban && tt>1)
	{
		tt--,s-=mx;
	}
	return ret=1+s/tt;
}
int main(){
	scanf("%d%d",&n,&m);
	fup(i,1,m,1)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].pb(y);
	}
	db ans=INF;
	fup(i,1,n-1,1)
	{
		fup(ii,1,n,1)d[ii]=-1;
		ans=min(ans,go(1,i));
	}
	printf("%.9f",ans);
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[100];
ll v[9];
ll k;
void solve(){

}

int main(){
  scanf("%s", s);
  cin >> k;
  char ans = '1';
  for(int i=0 ; i<k ; i++){
    if(s[i] != ans){
      ans = s[i];
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

    for (int i = n; i > 0; i--) {
        s = to_string(i);
        if (s.size() & 1) ans++;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
ll M=1e9+7;
int quick_pow(int x,int p){
    int a=1,po=x;
    while(p){
        if(p&1)  a=1ll*a*po%M;
        po=1ll*po*po%M;p>>=1;
    }
    return a;
}
//Start from Here
int main(){
    ll A, B, N;
    cin>>A>>B>>N;
    ll C=min(B-1, N);
    cout<<(A*C)/B-A*(C/B)<<endl;
}

Measured memory_bytes: 3600
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
Arr.shift();
Arr.forEach(function(V){
var arr=V.split(" ").map(Number);
var a=0;
var b=0;
var flag=true;
for(var i=0;i<arr.length;i++){
var v=arr[i];
if(a<v){a=v;continue;}
if(b<v){b=v;continue;}
flag=false;
}
console.log(flag?"YES":"NO");
});

Measured memory_bytes: 7644
program successive_subtraction
  implicit none
  integer :: n, i, l, r, p, x
  integer(8) :: a(100000), m, s
  a = 0_8
  read(*,*) n
  read(*,*) a(1:n)
  call quick_sort(a(1:n))
  l = 0
  r = n+1
  do while (r-l.gt.1)
    p = (r+l)/2
    m = a(p)
    if (m.gt.0_8) then
      r = p
    else
      l = p
    end if
  end do
  if (r.eq.n+1) then
    write(*,'(i0)') 2_8*a(n)-sum(a(1:n))
    m = a(n)
    do i = n-1, 1, -1
      write(*,'(i0,x,i0)') m, a(i)
      m = m-a(i)
    end do
    stop
  end if
  x = r
  l = 0
  r = n+1
  do while (r-l.gt.1)
    p = (r+l)/2
    m = a(p)
    if (m.lt.0_8) then
      l = p
    else
      r = p
    end if
  end do
  if (l.eq.0) then
    write(*,'(i0)') sum(a(1:n))-2_8*a(1)
    m = a(1)
    do i = 2, n-1
      write(*,'(i0,x,i0)') m, a(i)
      m = m-a(i)
    end do
    write(*,'(i0,x,i0)') a(n), m
    stop
  end if
  r = x
  write(*,'(i0)') sum(a(r:n))-sum(a(1:l))
  m = a(n)
  do i = 2, r-1
    write(*,'(i0,x,i0)') m, a(i)
    m = m-a(i)
  end do
  s = a(1)
  do i = r, n-1
    write(*,'(i0,x,i0)') s, a(i)
    s = s-a(i)
  end do
  write(*,'(i0,x,i0)') m, s
  stop
contains
  recursive subroutine quick_sort(a)
    implicit none
    integer(8), intent(inout) :: a(:)
    integer(8) :: p, c
    integer :: n, l, r
    n = size(a)
    l = 1
    r = n
    p = a((l+r)/2)+a(l)+a(r)-max(a((l+r)/2),a(l),a(r))-min(a((l+r)/2),a(l),a(r))
    do
      do while (a(l).lt.p)
        l = l+1
      end do
      do while (a(r).gt.p)
        r = r-1
      end do
      if (l.ge.r) exit
      c = a(l)
      a(l) = a(r)
      a(r) = c
      l = l+1
      r = r-1
    end do
    if (l.gt.2) call quick_sort(a(1:l-1))
    if (n.gt.r+1) call quick_sort(a(r+1:n))
  end subroutine quick_sort
end program successive_subtraction

Measured memory_bytes: 3200
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
 
using namespace std;
int main(){
    int n,t,a;std::cin >> n>>t>>a;
    int h[n];
    double mi=1000;int ans=0;
    rep(i,n)std::cin >> h[i];
    rep(i,n){
        if(mi>abs(a-t+h[i]*0.006))ans=i+1;
        mi=min(mi,abs(a-t+h[i]*0.006));
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256