akhauriyash/Code-Regression huggingface dataset:
// Author: πα

#include <bits/stdc++.h>
using namespace std;

#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long int64_t

const int N = 1e5 + 105;
const int INF = 1000000007;
int a[N], b[N];

int main()
{
    FastIO;
    int n, i, j, k = 2;
    cin >> n;
    for(i = 0; i < n; ++i)
        cin >> a[i], b[i] = INF;
    b[0] = 0;
    for(i = 0; i < n; ++i)
        for(j = i; j <= i+k; ++j)
            b[j] = min(b[j], b[i] + abs(a[i]-a[j]));
    cout << b[n-1];
    return 0;
}


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

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  int m1,m2,d1,d2; cin >> m1 >> d1 >> m2 >> d2;
  if((m2-m1 == 1) && (d1 == 28 || d1 == 29 || d1 == 30 || d1 == 31)) cout << "1\n";
  else cout << "0\n";
  return 0;
}

Measured memory_bytes: 256
n = gets.to_f

r = n
i = 2

while i * i <= n
  if n%i == 0
    while n%i == 0
      n/=i
    end
    r *= (1.0 - (1.0/i.to_f))
  end
  i += 1
end

if n > 1
  r *= (1.0 - (1.0/n.to_f))
end

puts r.to_i



Measured memory_bytes: 8920
class BinaryTree():
    def __init__(self):
        self.key = None
        self.parent = None
        self.left = None
        self.right = None

def insert(z):
    global root
    y = None
    x = root
    while x != None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y == None:
        root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

def inoder(x):
    if x == None: return []
    else:
        r = []
        r.extend(inoder(x.left))
        r.append(str(x.key))
        r.extend(inoder(x.right))
    return r

def preoder(x):
    if x == None: return []
    else:
        r = []
        r.append(str(x.key))
        r.extend(preoder(x.left))
        r.extend(preoder(x.right))
    return r

def show(x):
    print(" " + " ".join(inoder(x)))
    print(" " + " ".join(preoder(x)))


root = None
n = int(input())
for i in range(n):
    L = input().split()
    if L[0] == "insert":
        T = BinaryTree()
        T.key = int(L[1])
        insert(T)
    else:
        show(root)

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

int main(){
  vector<int> data = { 1, 1, 1, 2, 1, 2, 1, 5,
                       2, 2, 1, 5, 1, 2, 1, 14,
                       1, 5, 1, 5, 2, 2, 1, 15,
                       2, 2, 5, 4, 1, 4, 1, 51 };
  int K;
  cin >> K;
  cout << data.at(K-1) << endl;
  return 0;
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ll n;
  cin >> n;
  VI a(n), order(n);
  rep(i,n) cin >> a[i];
  rep(i,n) order[a[i] - 1] = i;

  set<int> st;
  st.insert(-1);
  st.insert(n);

  ll ans = 0;
  rep(i,n){
    set<int>::iterator itr = st.lower_bound(order[i]);
    ll right = (*itr) - order[i];
    itr--;
    ll left = order[i] - (*itr);
    ll tmp = a[order[i]] * left * right;
    ans += tmp;
    st.insert(order[i]);
  }

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


Measured memory_bytes: 11136
function Main(line) {
  let [first, second, third, ...data] = line.trim().split("\n");

  const [R, C] = first
    .trim()
    .split(" ")
    .map((f) => Number(f - 1));
  const [stR, stC] = second
    .trim()
    .split(" ")
    .map((f) => Number(f - 1));
  const [edR, edC] = third
    .trim()
    .split(" ")
    .map((f) => Number(f - 1));

  const map = [];
  const dp = [];
  data.forEach((v, i) => {
    map[i] = v.trim().split("");
    dp[i] = v
      .trim()
      .split("")
      .map((v) => Number.MAX_SAFE_INTEGER);
  });

  dp[stR][stC] = 0;

  let current_Queue = [{ x: stR, y: stC }];
  let next_Queue = [];

  const xAxis = [0, 1, 0, -1];
  const yAxis = [1, 0, -1, 0];
  const range_3 = [0, 1, 2, 3];

  while (current_Queue.length > 0 || next_Queue.length > 0) {
    if (current_Queue.length === 0) {
      current_Queue = [...next_Queue];
      next_Queue = [];
    }
    const { x, y } = current_Queue.shift();

    for (const val of range_3) {
      const xX = x + xAxis[val];
      const yY = y + yAxis[val];
      if (isOut(xX, yY)) continue;

      if (dp[x][y] + 0 < dp[xX][yY]) {
        dp[xX][yY] = dp[x][y];
        current_Queue.push({ x: xX, y: yY });
      }
    }
    for (let i = -2; i <= 2; i++) {
      for (let j = -2; j <= 2; j++) {
        if (
          (i === 0 && j === 0) ||
          (i === 1 && j === 0) ||
          (i === 0 && j === 1) ||
          (i === -1 && j === 0) ||
          (i === 0 && j === -1)
        ) {
          continue;
        }
        const xX = x + i;
        const yY = y + j;
        if (isOut(xX, yY)) continue;
        if (dp[x][y] + 1 < dp[xX][yY]) {
          dp[xX][yY] = dp[x][y] + 1;
          next_Queue.push({ x: xX, y: yY });
        }
      }
    }

  }
  if(dp[edR][edC] === Number.MAX_SAFE_INTEGER ){
    console.log(-1);
  } else {
    console.log(dp[edR][edC]);
  }

  function isOut(x, y) {
    if (x < 0 || x > R || y < 0 || y > C) {
      return true;
    }
    if (map[x][y] === "#") {
      return true;
    }
    return false;
  }
}

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


Measured memory_bytes: 82488
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int R, G; cin>>R>>G;
    cout<<(2*G - R)<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	char arr[1199];

	scanf("%[^\n]", arr);

	int num = 0;

	while(arr[num]!='\0'){
		num++;
	}

	for(int i = 0; i < num; i++){
		if(arr[i] >= 'a' && arr[i] <= 'z'){
			arr[i] = arr[i] - 32;
		}
		else if(arr[i] >= 'A' && arr[i] <= 'Z')
		{
			arr[i] = arr[i] + 32;
		}
	}

	printf("%s",arr);
	printf("\n");
	return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n; cin >> n;
  vector<ll> data[n];

  int x = -1,y = -1 ,h = -1;
  bool flag = false;
  rep(i,n) {
    ll a,b,c;
    cin >> a >> b >> c;
    if (!flag and c != 0) {
      x = a;
      y = b;
      h = c;
      flag = true;
    }
    data[i].pb(a);
    data[i].pb(b);
    data[i].pb(c);
  }

  if (x == -1) {
    x = data[0][0];
    y = data[0][1];
    h = data[0][2];
  }

  for (int i = 0; i <= 100; ++i) for (int j = 0; j <= 100; ++j) {
    ll H = h + abs(x-i) + abs(y-j);
    if (H < 1) {
      continue;
    }
    bool flag = true;
    for(int k = 0; k < n; ++k) {
      ll tmp = H - abs(data[k][0] - i) - abs(data[k][1] - j);
      if (tmp < 0) tmp = 0;
      if (tmp != data[k][2]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      cout << i << " " << j << " " << H << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll n;
  cin >> n;

  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0 && a[i] % 2 == 1) {
      ans++;
    }
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
#define endl '\n'
using namespace std;
using ll = long long int;
using ii = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 212345;
const ll mod = 1000000007;
int main() {
    ll n, x, y, k;
    scanf("%lld %lld %lld %lld", &n, &k, &x, &y);
    printf("%lld\n", min(n, k)*x + max(0LL, (n-k)*y));
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        boolean judge = y % 2 == 0 && x * 2 <= y && y <= x * 4;
        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
    }
}


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

#define rep(i, first, to) for(ll i = first; i < to; ++i)

using namespace std;
typedef long long ll;

int a[3], origin[3] = {5, 5, 7};
void solve() {
	rep(i, 0, 3) cin >> a[i];
	sort(a, a + 3);
	cout << (memcmp(a, origin, sizeof(int) * 3) == 0 ? "YES" : "NO") << endl;
}

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

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys, math, bisect, random, itertools
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    print(n*n*3)
    return

#B
def B():
    n, d = LI()
    print((n-1)//(2*d+1)+1)
    return

#C
def C():
    n = II()
    a = IR(n)
    b = a[::1]
    b.sort()
    for i in range(n):
        if a[i] == b[-1]:
            print(b[-2])
        else:
            print(b[-1])
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 60368
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    
    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static int N;
        static long H;
        static List<Tuple<long, string>> c = new List<Tuple<long, string>>(2 * N);


        public static void Input()
        {
            var cin = new Solve();

            var input = cin.SplitReader();
            N = input[0];
            H = input[1];

            for(var i = 0; i < N; i++)
            {
                var ab = cin.SplitReaderL();
                c.Add(new Tuple<long, string>(ab[0], "a"));
                c.Add(new Tuple<long, string>(ab[1], "b"));
            }
        }

        static void Main(string[] args)
        {
            Input();
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            c.Sort();
            
            List<long> ans = new List<long>();
            long th = 0;
            
            for (var i = 0; i < 2 * N; i++) 
            {
                int cnt = 2 * N - 1 - i;
                if (c[cnt].Item2 == "b")
                {
                    th++;
                    H -= c[cnt].Item1;
                    if (H <= 0) {
                        ans.Add(th);
                        break; }
                }
                else
                {
                    ans.Add(th + ((H + c[cnt].Item1 - 1) / c[cnt].Item1));
                }
                c.RemoveAt(cnt);
                //Console.WriteLine($"{H} {th}");
            }

            Console.WriteLine(ans.Min());
            //Console.Out.Flush();
        }

        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    
}



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


void solve(long long N){
    switch (N%10)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;

    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    
    case 3:
        cout << "bon" << endl;
        break;

    default:
        break;
    }

    return;


}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3716
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

int main(){
  string s;
  rep(i, 3){
    cin >> s;
    cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

const int MAX_SIZE=100005;
int n,m,k;
double p[2][MAX_SIZE];
void solve() {
    rep(i,MAX_SIZE) p[0][i]=p[1][i]=0.0;

    rep(i,m) p[0][i+1]=1.0/m;
    rep(i,n-1) {
        rep(j,MAX_SIZE) {
            rep(k,m) {
                if(k+j+1>=MAX_SIZE) continue;
                p[1][k+j+1]+=p[0][j]/m;
            }
        }
        rep(j,MAX_SIZE) {
            p[0][j]=p[1][j];
            p[1][j]=0.0;
        }
    }
    double ans = 0.0;

    rep(i,m*n) {
        int b = max(1,i-k+1);
        //cout<<i+1<<" : "<<p[0][i+1]<<","<<b<<endl;
        ans += p[0][i+1]*b;
    }

    printf("%.8f\n",ans);
}

int main() {
    while(cin>>n>>m>>k) {
        if(n+m+k==0) break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 2752
#include "bits/stdc++.h"

/************* Using *************/
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using graph_t = vector<vector<ll>>;

/*********** Constants ***********/
const auto INF  = static_cast<int>(1e10);
const auto INFL = static_cast<ll>(1e18);
const auto MOD  = static_cast<ll>(1e9 + 7);
const auto NIL  = nullptr;

/*********** Variables ***********/
ll N, Q;
graph_t E;
vector<pll> P;
vector<ll> C;
vector<bool> S;

/************* Utils *************/
void DFS(const graph_t& G, ll v) {
    S.at(v) = true;
    for (const auto& next_v : G[v]) {
        if (S.at(next_v)) {
            continue;
        }
        C[next_v] += C[v];
        DFS(G, next_v);
    }
}

/*********** Functions ***********/
bool init() {
    cin >> N >> Q;
    E.resize(N); C.resize(N, 0); S.assign(N, false);
    for (ll i = 0; i < N - 1; i++) {
        ll a, b; cin >> a >> b;
        E[a - 1].push_back(b - 1);
        E[b - 1].push_back(a - 1);
    }
    P.resize(Q);
    for (ll i = 0; i < Q; i++) {
        ll p, x; cin >> p >> x;
        P[i] = make_pair(p - 1, x);
    }
    return true;
}

void solve() {
    for (const auto& item : P) {
        C[item.first] += item.second;
    }
    DFS(E, 0);
}

void output() {
    for (ll i = 0; i < N; i++) {
        cout << (i ? " " : "") << C[i];
    }
    cout << endl;
}

int main() {
    init();
    solve();
    output();
    return 0;
}

Measured memory_bytes: 27392
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<functional>
#include<deque>
#define rep(i,rept)	for(int i = 0; i<(ll)rept;++i)
typedef long long ll;
using namespace std;

int main() {
	int n = 0, k = 0, h[100000] = {};
	int ans = 1000000000,cnt = 0;
	vector<int> vec;
	cin >> n >> k;
	rep(i, n) {
		cin >> h[i];
	}
	sort(h, h + n);
	
	for (int i = 0; i + (k - 1) < n; i++) {

		cnt = abs(h[i] - h[i + (k - 1)]);
		ans = min(cnt, ans);
		cnt = 0;

	}



	cout << ans << endl;

		return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
    int n, m;
    while (2 == scanf("%d%d", &n, &m)) {
        printf("%d %d\n", __gcd(n, m), n / __gcd(n, m)*m);
    }
    return 0;
}

Measured memory_bytes: 3192
#include <stdio.h>
#include <string.h>

int main(void){
    char card[200], cardcp[200];
    int i, j, len, m, h;
    
    while(1) {
        scanf("%s", &card);
        if(card[0] == '-') break;
        
        len = strlen(card);
        scanf("%d", &m);
        for(i=0; i<m; i++) {
            scanf("%d", &h);
            for(j=0; j<h; j++) {
                cardcp[j] = card[j];
            }
            for(j=h; j<len; j++) {
                card[j-h] = card[j];
            }
            for(j=0; j<h; j++) {
                card[j+len-h] = cardcp[j];
            }
        }
        printf("%s\n", card);
    }
    return 0;
}


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

#define MAX 1001
#define MAXW 10000

int dp[MAXW+1];
int W, N;
int v[MAX], w[MAX];

void solve() {
    for (int i = 0; i <=W; i++) dp[i] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = W; j >= w[i]; j--) {
            dp[j] = std::max(dp[j], dp[j-w[i]] + v[i]);
        }
    }
    std::printf("%d\n", dp[W]);
}



int main()
{
    std::scanf("%d %d", &N, &W);
    for (int i = 0; i < N; i++) {
        std::scanf("%d %d", &v[i], &w[i]);
    }
    solve();
    return 0;
}



Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define def(x) cerr << #x << " is " << x << endl;
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        ll a,v,b,w,t; cin>>a>>v>>b>>w>>t;
        ll x = abs(a-b);
        if(x+t*w<=t*v) cout<<"YES";
        else cout<<"NO";
    }   
}



Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<vector<int>> g(n,vector<int>());
	rep(i,n - 1){
		int a,b;cin >> a >> b;
		a--;b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	vector<int> a(n, -1);
	a.at(0) = 1;
	a.at(n - 1) = 0;
	queue<int> q;
	q.push(0);
	q.push(n - 1);
	while(!q.empty()){
		int cur = q.front();q.pop();
		rep(i,g[cur].size()){
			int next = g[cur][i];
			if(a.at(next) != -1) continue;
			a.at(next) = a.at(cur);
			q.push(next);
		}
	}
	int cnt = 0;
	rep(i,n){
		if(a.at(i) == 1) cnt++;
	}
	if(cnt <= (n - cnt)) cout << "Snuke" << endl;
	else cout << "Fennec" << endl;
}


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

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x = x2 - x1;
    int y = y2 - y1;
    cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x << endl;
}

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

void Main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (B / A > C) cout << C << endl;
  else cout << B / A << 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: 256
use std::io;

fn main() {
    let mut cc: [i32; 9] = [0; 9];
    for i in 0..3 {
        let mut buf: String = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let buf = buf.trim().split_whitespace().collect::<Vec<_>>();
        for j in 0..3 {
            cc[3 * i + j] = buf[j].parse::<i32>().unwrap();
        }
    }
    let s = cc[0] + cc[4] + cc[8];
    if cc[1] + cc[5] + cc[6] != s {
        println!("No");
    } else if cc[2] + cc[3] + cc[7] != s {
        println!("No");
    } else if cc[0] + cc[5] + cc[7] != s {
        println!("No");
    } else if cc[1] + cc[3] + cc[8] != s {
        println!("No");
    } else if cc[2] + cc[4] + cc[6] != s {
        println!("No");
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 4352
a = int(input())
b = int(input())
c = int(input())
x = int(input())

res = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                res += 1
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 


int main() {
  string s;cin >>s ;
  int n = s.length();
  ll sum = 0;
  rep(i,n) {
    sum += s[i] - '0';
  }
  bool ok = (sum%9 == 0);
  ok();
  return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
int n, a, b, c;
int main()
{
    cin >> n;
    a = n / 100;
    c = n % 10;
    n /= 10;
    b = n % 10;
    if (b > a || c > a)
        a++;
    cout << 100 * a + 10 * a + a << endl;

    return 0;
}

Measured memory_bytes: 256
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

//#include "seq/bsearch.h"

//find largest x in [s,t) which check(x) is true
template<class T>
T bsearch_largest(T s, T t, int check(T)) {
	s--;
	while (t-s>1) {
		T m = (s+t)/2;
		if (check(m)) s = m;
		else t = m;
	}
	return s;
}

//find smallest x in [s,t) which check(x) is true
template<class T>
T bsearch_smallest(T s, T t, int check(T)) {
	s--;
	while (t-s>1) {
		T m = (s+t)/2;
		if (check(m)) t = m;
		else s = m;
	}
	return t;
}


#define MAXN 100000

long a, b;

int input() {
	if (scanf("%ld %ld", &a, &b) < 0) return 0;
	return 1;
}

void init() {
}

void maxit(long &r, long sum, long x, long s, long t) {
	long y = sum - x;
	if (x>=s && x<=t) {
		r = max(r, x*y);
	}
}
long maxp(long sum, long s, long t) {
	long r = LONG_MIN;
	if (t<s) return r;
	maxit(r, sum, s, s, t);
	maxit(r, sum, t, s, t);
	long m = sum/2;
	maxit(r, sum, m, s, t);
	maxit(r, sum, m+1, s, t);
	return r;
}
/*
	max: p=i*(s-i)
	i=[1,p): s=x+1
	i=(p,q]: s=x+2
	i=(q,x]: s=x+1
	p,q = a, x+2-b

	1,2,...a-1,a+1.........x-1,x
	x,x-1..........b+1,b-1...2,1
*/
int check(long x) {
	long r, y = x;
	if (a>x) {
		r = maxp(x+1, 1, x);
	}
	else if(b>x) {
		long r1 = maxp(x+1, 1, a-1);
		long r2 = maxp(x+2, a+1, x+1);
		r = max(r1, r2);
	}
	else {
		x++;
		if (a+b < x+1) {
			long p = a, q = x+2-b;
			long r1 = maxp(x+1,1,p-1);
			long r2 = maxp(x+2,p+1,q);
			long r3 = maxp(x+1,q+1,x);
			r = max(max(r1,r2),r3);
		}
		else if(a+b > x+1) {
			long p = x-b, q = a;
			long r1 = maxp(x+1,1,p-1);
			long r2 = maxp(x,p,q-1);
			long r3 = maxp(x+1,q+1,x);
			r = max(max(r1,r2),r3);
		}
		else {
			long p = a;
			long r1 = maxp(x+1,1,p-1);
			long r2 = maxp(x+1,p+1,x);
			r = max(r1, r2);
		}
	}
	//printf("=%ld : %d\n", y, r<a*b);
	return  r < a*b;
}

long solve() {
	if (a>b) swap(a,b);
	return bsearch_largest(1L, min(10000000000L,a*b), check);
}

void output(long ans) {
	printf("%ld\n", ans);
}

void cleanup() {
}

int main() {
	int ca; scanf("%d",&ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 128
#include <stdio.h>
 
int main(void){
int a[5];
int i,j,temp;
for(i=0;i<5;i++) scanf("%d",&a[i]);
for(i=0;i<5;i++){
for(j=i+1;j<5;j++){
if(a[i]<a[j]){
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
for(i=0;i<5;i++){
if(i!=5-1) printf("%d ",a[i]);
else printf("%d",a[i]);
}
printf("\n");
return 0;
}

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

int main(){

    int N,A,B;

    cin >> N;
    cin >> A;

    if(N /500 == 0){
        cout << "Yes" << endl;
    }else if(N % 500 <= A){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
 }

Measured memory_bytes: 256
n,m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = set(a)
sb = set(b)
if len(sa) != n or len(sb) !=m:
 print(0)
 exit()
a.sort(reverse =True)
b.sort(reverse =True)
g = n*m
if a[0] != g or b[0] != g:
 print(0)
 exit(0)
ac = 0
bc = 0
p = 1
r = 10**9+7
for I in range(g,0,-1):
 while ac < n-1and a[ac+1] >= I:
  ac += 1
 while bc < m-1 and b[bc+1] >= I:
  bc += 1
 if a[ac] == I and b[bc]  != I:
  p = (p*(bc+1))%r
 if b[bc] ==I and a[ac] != I:
  p = (p*(ac+1))%r
 if a[ac] !=I and b[bc]!=I:
  k = (ac+1)*(bc+1)-g+I 
  if k <= 0:
   print(0)
   exit()
  else:
   p = (p*k)%r
print(p)
  

Measured memory_bytes: 3188
while True:
    h,w = map(int, input().split())
    if h == 0 and w == 0:
        break
    else:
        for i in range(h):
            if i == 0 or i == h-1:
                print("#" * w)
            else:
                print("#" + "." * (w-2) + "#")
    print()


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

const int N=100005;
const int inf=1000000000;

struct node{
	int x,y,id;
}a[N];
struct E{
	int x,y,w;
	E(){}
	E(int x,int y,int w):x(x),y(y),w(w){}
}e[N<<1];
int n,m,ans,x,y;
int fa[N];

bool cmp1(node a,node b){
	return a.y<b.y;
}

bool cmp2(node a,node b){
	return a.x<b.x;
}

int find(int k){
	if (fa[k]!=k) fa[k]=find(fa[k]);
	return fa[k];
}

bool cmp(E a,E b){
	return a.w<b.w;
}

int main(){
	int i;
	scanf("%d",&n);
	for (i=1;i<=n;i++){
		scanf("%d%d",&a[i].x,&a[i].y);
		a[i].id=i;
	}
	sort(a+1,a+1+n,cmp1);
	for (i=1;i<n;i++) e[++m]=E(a[i].id,a[i+1].id,a[i+1].y-a[i].y);
	sort(a+1,a+1+n,cmp2);
	for (i=1;i<n;i++) e[++m]=E(a[i].id,a[i+1].id,a[i+1].x-a[i].x);
	sort(e+1,e+1+m,cmp);
	for (i=1;i<=n;i++) fa[i]=i;
	for (i=1;i<=m;i++){
		x=find(e[i].x); y=find(e[i].y);
		if (x!=y){
			fa[x]=y;
			ans+=e[i].w;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

#define DEBUG 1

#if (DEBUG == 1)

#endif

int main()
{
  int N;
  int M;
  cin >> N >> M;

  vector<int> num_path(N, 0);
  for (int i = 0; i < M; i++) {
    int a;
    int b;
    cin >> a >> b;

    num_path.at(a-1)++;
    num_path.at(b-1)++;
  }

  for (int i = 0; i < N; i++) {
    cout << num_path.at(i) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
N, X, M = map(int, input().split())
dp = [False]*(M+1)
dp[X] = True
S = [0]*(M+1)
S[1] = X
tmp = X
for i in range(2, min(M+1, N+1)):
    tmp = pow(tmp, 2, M)
    if dp[tmp]:
        for j in range(1, i):
            if tmp == S[j]:
                break
        ans = 0
        for k in range(j, i):
            ans += S[k]
        ans *= (N-j+1)//(i-j)
        for k in range(1, j):
            ans += S[k]
        for k in range(j, j+(N-j+1)%(i-j)):
            ans += S[k]
        print(ans)
        break
    else:
        dp[tmp] = True
        S[i] = tmp
else:
    print(sum(S))

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

const ll inf = 1LL << 60;
 
signed main(void){ 

  ll N; cin >> N;
  ll sum = 0; ll m = inf;
  for(ll i = 0; i < N; i++){ 
    ll a,b; cin >> a >> b; sum += a; 
    if ( a > b ){ m = min(m,b);}
  }
  
  if( m == inf ){ //この時、 A==Bに他ならない　
    cout << 0 << endl; return 0;
  }
  
  cout << sum-m << endl;
  
  return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    h,w = LI()
    a = [sys.stdin.readline() for i in range(h)]
    s = 0
    p = deque()
    M = w*h
    d = [[-1 for i in range(w)] for j in range(h)]
    for i in range(h):
        for j in range(w):
            if a[i][j] == "#":
                p.append((i,j))
                d[i][j] = 0
    move = [[-1,0],[1,0],[0,-1],[0,1]]
    while p:
        y,x = p.popleft()
        for dy,dx in move:
            y2 = y+dy
            x2 = x+dx
            if 0 <= y2 < h and 0 <= x2 < w:
                if d[y2][x2] < 0:
                    d[y2][x2] = d[y][x]+1
                    p.append([y2,x2])
    ans = 0
    for i in d:
        for j in i:
            if j > ans:
                ans = j
    print(ans)
    return

#B
def B():
    h,w,n = LI()
    sy,sx = LI()
    sy -= 1
    sx -= 1
    s = S()
    t = S()
    ks = list("LRUD")
    kt = list("RLDU")
    ds = [[0,-1],[0,1],[-1,0],[1,0]]
    dt = [[0,1],[0,-1],[1,0],[-1,0]]
    for i in range(4):
        y,x = [sy,sx]
        for j in range(n):
            if s[j] == ks[i]:
                y+=ds[i][0]
                x+=ds[i][1]
                if y < 0 or y >= h or x < 0 or x >= w:
                    print("NO")
                    quit()
            if t[j] == kt[i]:
                y += dt[i][0]
                x += dt[i][1]
                if y < 0:y = 0
                elif y >= h:y = h-1
                elif x < 0:x=0
                elif x >= w:x=w-1
    print("YES")
    return

#C
def C():
    def dijkstra(s):
        d = [float("inf") for i in range(n)]
        d[s] = 0
        q=[[0,s]]
        while q:
            dx,x = heappop(q)
            for y in v[x]:
                if dx+1 < d[y]:
                    d[y] = dx+1
                    heappush(q,[d[y],y])
        return d
    n = I()
    v = [[] for i in range(n)]
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    d = dijkstra(0)
    l = d.index(max(d))
    d = dijkstra(l)
    m = max(d)+1
    if m%3 == 2:
        print("Second")
    else:
        print("First")
    return

#D
def D():
    n = I()
    return

#E
def E():
    n = I()
    return

#F
def F():
    n = I()
    return

#Solve
if __name__ == "__main__":
    A()


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

using namespace std;

int my_max(int a, int b) {
    return a > b ? a : b;
}

int my_abs(int x) {
    return x < 0 ? -x : x;
}

int main() {

    double r;
    cin >> r;
    
//    printf("%lf\n", r * 2 * 3.14159265359);

    cout << r * 2 * 3.14159265359 << endl;

    return 0;
}


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

const int MAX_N = 2e5;
int dp[MAX_N+5];

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

    for(int i=0;i<n;i++){
        int p; cin >> p;
        dp[p] = dp[p-1] + 1;
    }

    cout << n - *max_element(dp+1, dp+n+1) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

int main()
{
    // number of problems
    unsigned int n;
    std::cin >> n;

    // time to solve the porblems
    std::vector<unsigned int> t(n);
    unsigned int totalTime = 0;
    for (std::size_t i = 0; i < n; ++i)
    {
        std::cin >> t[i];
        totalTime += t[i];
    }

    // number of drinks
    unsigned int m;
    std::cin >> m;

    // drinks
    std::vector<std::size_t> nbP(m);
    std::vector<unsigned int> newT(m);
    for (std::size_t i = 0; i < m; ++i)
    {
        std::cin >> nbP[i];
        std::cin >> newT[i];
    }

    // output
    for (std::size_t i = 0; i < m; ++i)
    {
        const std::size_t iProb = nbP[i] -1;
        std::cout << totalTime - t[iProb] + newT[i] << "\n";
    }
    return 0;
}

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

#define MAX_N 100005
#define mm(a,b) memset(a,b,sizeof(a))
#define ll long long

int cnt_g,cnt_p,ans;
char str[MAX_N];
int len;

int main() {
    while(~scanf("%s",str)) {
        cnt_g = 0;
        cnt_p = 0;
        ans = 0;
        len = (int)strlen(str);
        for(int i = 0; i < len; i++) {
            if(str[i] == 'g') {
                if(cnt_p < cnt_g){
                    ans++;
                    cnt_p++;
                }
                else {
                    cnt_g++;
                }
            }
            if(str[i] == 'p') {
                if(cnt_p < cnt_g){
                    cnt_p++;
                }
                else {
                    cnt_g++;
                    ans--;
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> b(n);
  for (int i = 0; i < n; i++) cin >> b[i];
  vector<int> c(n);
  for (int i = 0; i < n; i++) cin >> c[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  long long combs = 0;
  for (auto x : b) {
    int i, j;
    i = lower_bound(a.begin(), a.end(), x) - a.begin();
    j = upper_bound(c.begin(), c.end(), x) - c.begin();
    combs += (long long)i * (n - j);
  }
  cout << combs << '\n';
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <map>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

int main() {

  int n, m;
  cin >> n >> m;

  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }

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

  // for(int i = 0; i < n; i++) cout << a[i] << " ";
  // cout << endl;

  vector< pair<long int, int> > p(m);
  for(int i = 0; i < m; i++) {
    cin >> p[i].second >> p[i].first;
  }

  sort(p.rbegin(), p.rend());

  // for(int i = 0; i < m; i++) cout << p[i].second << " " << p[i].first << endl;

  int j = 0, cnt = 1;
  for(int i = 0; i < n; i++) {

    if(cnt > p[j].second) {
      cnt = 1;
      j++;
    }

    if(a[i] >= p[j].first) break;
    else {
      a[i] = p[j].first;
      cnt++;
    }
  }

  // for(int i = 0; i < n; i++) cout << a[i] << " ";

  auto sum_ll = accumulate(a.begin(), a.end(), 0LL);
  cout << sum_ll << endl;
}


Measured memory_bytes: 2176
from collections import deque

def bfs(index, ans):
    d = deque()
    ans[index] = 0
    d.append(index)
    while len(d) > 0:
        v = d.popleft()
        for node in table[v]:
            if ans[node] == -1:
                ans[node] = v
                d.append(node)
    return ans

n, m = map(int, input().split())
table = [[] for j in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    table[a-1].append(b-1)
    table[b-1].append(a-1)
ans = [-1 for i in range(n)]
ans = bfs(0, ans)
if -1 in ans:
    print('No')
else:
    print('Yes')
    for a in ans[1:]:
        print(a+1)

Measured memory_bytes: 95608
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
const int MOD=1000000007;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
/*最小公倍数*/int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int64_t, int > prime_factor(int64_t n) {map< int64_t, int > ret;for(int64_t i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
/*各桁の和*/int findSumOfDigits(int n) {int sum = 0;while (n > 0) {sum += n % 10;n /= 10;}return sum;}
/*転倒数*/ll merge_cnt(vector<int> &a) {int n = a.size();if (n <= 1) { return 0; }ll cnt = 0;vector<int> b(a.begin(), a.begin()+n/2);vector<int> c(a.begin()+n/2, a.end());cnt += merge_cnt(b);cnt += merge_cnt(c);int ai = 0, bi = 0, ci = 0;/* merge の処理*/while (ai < n) {if ( bi < b.size() && (ci == c.size() || b[bi] <= c[ci]) ) {a[ai++] = b[bi++];} else {cnt += n / 2 - bi;a[ai++] = c[ci++];}}return cnt;}
/*等差数列判定*/bool isSequence(vector<int> v){int d = v[1] -v[0];for ( int i = 1; i < v.size(); i++ ){if ( v[i] -v[i-1] != d ) return false;}return true;}
/*A_0 = 1, A_1 = 1 のフィボナッチ数列 A_n の n番目の値を返す関数*/int Fib (int n){if ( n == 0 ) return 1;if ( n == 1 ) return 1;return Fib (n - 1) + Fib (n - 2);}
vector<pair<long long, long long> > prime_factorize(long long n) {vector<pair<long long, long long> > res;for (long long p = 2; p * p <= n; ++p) {if (n % p != 0) continue;int num = 0;while (n % p == 0) { ++num; n /= p; }res.push_back(make_pair(p, num));}if (n != 1) res.push_back(make_pair(n, 1));return res;}
long long ctoll(const char c){switch(c){case '0': return 0;case '1': return 1;case '2': return 2;case '3': return 3;case '4': return 4;case '5': return 5;case '6': return 6;case '7': return 7;case '8': return 8;case '9': return 9;default : return -1;}}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(15);

    int W, H, x, y, r; cin >> W >> H >> x >> y >> r;
    if(x + r > W || y + r > H || x - r < 0 || y - r < 0) No;
    else Yes;
    return 0;
}


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

using namespace std;

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

int main() {
    int X, Y, A, B, C;
    long long int p[100000] = {}, q[100000] = {}, r[200000] = {};

    cin >> X >> Y >> A >> B >> C;
    for (int i = 0; i < A; ++i) {
        cin >> p[i];
    }
    for (int i = 0; i < B; ++i) {
        cin >> q[i];
    }
    for (int i = 0; i < C; ++i) {
        cin >> r[i];
    }

    sort(p, p + SIZE_OF_ARRAY(p), greater<>());
    sort(q, q + SIZE_OF_ARRAY(q), greater<>());
    sort(r, r + SIZE_OF_ARRAY(r), greater<>());

    long long int t[2 * (X + Y)];
    for (int i = 0; i < X; ++i) {
        t[i] = p[i];
    }
    for (int i = 0; i < Y; ++i) {
        t[i + X] = q[i];
    }
    for (int i = 0; i < X + Y; ++i) {
        t[i + X + Y] = r[i];
    }

    sort(t, t + SIZE_OF_ARRAY(t), greater<>());

    long long int res = 0;
    for (int j = 0; j < X + Y; ++j) {
        res += t[j];
    }

    cout << res;

    return 0;
}

Measured memory_bytes: 6272
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

a,b=get_i
if a>0 and b>0
    puts "Positive"
elsif a<0 and b<0
    if (b-a+1).even?
        puts "Positive"
    else
        puts "Negative"
    end
else
    puts "Zero"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N;
  cin >> N;
  ll A[N];
  rep(i,N) cin >> A[i];
  ll sum[N+1];
  sum[0] = 0;
  rep1(i,N) sum[i] = sum[i-1]+A[i-1];
  sort(sum,sum+N+1);
  //  rep(i,N+1) cout  << sum[i] <<" " ;
  ll ans=0;
  ll c=1;
  rep1(i,N){
    if(sum[i]==sum[i-1]){
      //      cout << i << endl;
      c++;
      if(i==N){
	ans += c*(c-1)/2;
      }
    }
    else if(sum[i]!=sum[i-1] && c>1 ){
      ans += c*(c-1)/2;
      c=1;
    }
    else c=1;
    //    cout << ans << endl;
  }
  cout << ans << endl;


  
  return 0;
    

}


Measured memory_bytes: 3328
s=int(input())
x=s
l=[]
if x==1:
    print(4)
else:
    for i in range(1000000):
        if x%2==0:
            l.append((x//2))
            x=x//2
            if l.count(x)==2:
                print(i+1)
                break
        else:
            l.append((3*x+1))
            x=3*x+1

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

    int N, M;
    cin >> N >> M;
    vector<int> a(N);
    vector<P> b(M);
    rep(i, N) cin >> a[i];
    rep(i, M) cin >> b[i].second >> b[i].first;
    sort(b.rbegin(), b.rend());
    sort(all(a));

    int cur = 0;
    rep(i, N) {
        if(a[i] < b[cur].first) { // 変える方が良いなら
            a[i] = b[cur].first;
            b[cur].second--; // 使った分減らす
        }
        if(b[cur].second <= 0) cur++;
        if(cur >= M) break;
    }

    cout << accumulate(all(a), 0LL) << endl;
    return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    char c[100][100];
    rep(i, h) rep(ii, w) cin >> c[i][ii];
    
    rep(i, 2 * h) {
        rep(ii, w) {
            cout << c[i / 2][ii];
        }
        
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc129/tasks/abc129_a

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

int main() 
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a+b,min(b+c,a+c));
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,j;
	for(i=1;i<=9;i++){
		printf("%dx1=%d\n",i,i);
		printf("%dx2=%d\n",i,2*i);
		printf("%dx3=%d\n",i,3*i);
		printf("%dx4=%d\n",i,4*i);
		printf("%dx5=%d\n",i,5*i);
		printf("%dx6=%d\n",i,6*i);
		printf("%dx7=%d\n",i,7*i);
		printf("%dx8=%d\n",i,8*i);
		printf("%dx9=%d\n",i,9*i);
	}
	return 0;
}

Measured memory_bytes: 524
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var MK = Sarray();
            var M = MK[0];
            var K = MK[1];

            if ((long)Pow(2, M) - 1 < K)
            {
                WriteLine(-1);
                return;
            }
            if (M == 1)
            {
                if (K != 0)
                {
                    WriteLine(-1);
                    return;
                }
                WriteLine("0 0 1 1");
                return;
            }
            var ans = new List<long>((int)Pow(2, M + 1));
            ans.Add(K);
            for(var i=0;i<(long)Pow(2,M); ++i)
            {
                if (i == K) continue;
                ans.Add(i);
            }
            ans.Add(K);
            for (var i = (long)Pow(2, M) - 1; 0 <= i; --i)
            {
                if (i == K) continue;
                ans.Add(i);
            }
            WriteLine(string.Join(" ", ans));
        }
    }
}

Measured memory_bytes: 45772