akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)

int main(){
    int N;

    cin >> N;
    vector<int> A(N);
    vector<vector<pair<int,int>>> x(N);
    int z;
    int b,c;
    rep(i,N){
        cin >> z;
        A[i] = z;
        rep(j,z){
            //cout << z << " "<<j<<endl;
            cin >> b >> c;
            b--;
            c;
            x[i].push_back(make_pair(b,c));
            //cout << "aaaaaaaaaaaaaaa"<<endl;
        }
    }
    int cnt = 0;
    for(int i=0;i < (1 << (N));i++){
        bitset<15> V(i);
        bitset<15> W(i);
        vector<int> used(N,0);
        queue<int> que;
        rep(j,N){
            if(W[j]){
                que.emplace(j);
                used[j] = 1;
            }
        }
        while(!que.empty()){
            int q = que.front();
            que.pop();
            rep(j,A[q]){
                if(used[x[q][j].first])continue;
                if(x[q][j].second){
                    W[x[q][j].first] = 1;
                    used[x[q][j].first] = 1;
                    que.emplace(x[q][j].first);
                }
            }
        }
        bool flag = false;
        
        //cout << W << endl;
        rep(j,N){
            if(!W[j]) continue;
            rep(k,A[j]){
                if(!x[j][k].second){
                    if(W[x[j][k].first]){
                        //cout << W << endl;
                        //cout << x[j][k].first << " "<< x[j][k].second << endl; 
                        flag = true;
                        break;
                    }
                }
            }
            if(flag)break;
        }
        if(!flag){
            cnt = max(int(W.count()), int(cnt));
        }

    }
    
    cout << cnt << endl;
}


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

long c2(long n) {
  return n * (n - 1) / 2;
}

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N), cnt(N + 1);
  for (int i = 0, a; cin >> a; i++) A.at(i) = a, cnt.at(a)++;

  long sum = 0;
  for (int i : cnt) sum += c2(i);

  for (int i = 0; i < N; i++) {
    int tmp = cnt.at(A.at(i));
    cout << sum - c2(tmp) + c2(tmp - 1) << "\n";
  }
}

Measured memory_bytes: 4224
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

int dx[]={1, 0, -1, 0};
int dy[]={0, -1, 0, 1};

int main(){
    int m, k; cin>>m>>k;

    if(m == 0){
        if(k == 0){
            cout << 0 << " " << 0 << endl;
            return 0;
        }
        else{
            cout << -1 << endl;
            return 0;
        }
    }

    if(m == 1 && k == 1){
        cout << -1 << endl;
        return 0;
    }

    if((1 << m) <= k){
        cout << -1 << endl;
        return 0;
    }

    if(k == 0){
        vector<int> v;
        for(int i=0; i<(1<<m); i++){
            v.eb(i);
            v.eb(i);
        }

        for(int i=0; i<v.size(); i++){
            cout << v[i] << " \n"[i == v.size() - 1];
        }
    }
    else{
        for(int i=0; i<k+1; i++){
            cout << i << " ";
        }
        for(int i=k-1; i>=0; i--){
            cout << i << " ";
        }
        for(int i=(1<<m)-1; i>=k; i--){
            cout << i << " ";
        }
        for(int i=k+1; i<(1<<m); i++){
            cout << i << " \n"[i == (1<<m)-1];
        }
    }
}

Measured memory_bytes: 2932
import math
while True:
    n = int(input())
    if n == 0:
         break
    a = list(map(int,input().split()))
    s = 0
    for i in range(n):
        s += a[i]
    S = s/n
    h = 0
    for j in range(n):
        h += ((a[j]-S)**2)/n
    c = math.fabs(math.sqrt(h))
    print(f'{c:.8f}')


Measured memory_bytes: 5716
#include<stdio.h>
int main()
{
    int n,a[100],key,i,j,l,d=0;
     scanf("%d",&n);

        for (i=0;i<n;i++)
        scanf("%d",&a[i]);
        for(i=0;i<n-1;i++)
        {
           for(j=0;j<n-i-1;j++)
           {
               if(a[j]>a[j+1])
               {
                   key=a[j];
                   a[j]=a[j+1];
                   a[j+1]=key;
                   d++;
               }
           }
        }
        printf("%d",a[0]);
        for(l=1;l<n;l++)
            printf(" %d",a[l]);
        printf("\n");
        printf("%d\n",d);
    return 0;
}


Measured memory_bytes: 2104
a, b = map(int, input().split())
dic = {1: 1, 2: 2, 3: 1, 4: 3, 5: 1, 6: 3,
       7: 1, 8: 1, 9: 3, 10: 1, 11: 3, 12: 2}
if dic[a] == dic[b]:
    print("Yes")
else:
    print("No")


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

ll N;

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

  std::cin >> N;

  ll x = 1001001001001001001;

  for(ll i=1;i*i<=N;++i){
      if(N % i == 0){
          x = std::min(x, i + (N / i) - 2);
      }
  }

  std::cout << x << std::endl;
}


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

using namespace std;
#define MAX 100000000
#define Is 110
int n, k,req, a, b, c, d, e, i ,j, map[Is][Is], ans;


int dik(int s, int g){
  vector<int> cost(Is, MAX), f(Is, 0);
  cost[s] = 0;
  for(i = 0; i < Is; i++){
    f[s] = 1;
    for(j = 0; j < Is; j++) if(!f[j] && map[s][j] != MAX && cost[j] > cost[s] + map[s][j]) cost[j] = cost[s] + map[s][j];
    int min = MAX + 1;
    for(j = 0; j < Is; j++) if(!f[j] && min > cost[j]) min = cost[s = j];
  }
  return cost[g];
}

int main(){
  
  while(cin >> n >> k, n != 0 || k != 0) { 
    for(i = 0; i < Is; i++) {
      for(j = 0; j < Is; j++) {
	map[i][j] = MAX;
      }
    }
    
    while(k--){
      cin >> req;
      
      if(req){
	cin >> c >> d >> e;
	if(e < map[c][d]) map[c][d] = map[d][c] = e;
      }
      
      else{
	cin >> a >> b;
	if((ans = dik(a, b)) != MAX) cout << ans << endl;
	else cout << "-1" << endl;
      }
    }
    
  }
  return 0;
}
  
  

Measured memory_bytes: 1248
#include <stdio.h>
  
int selectionSort(int A[], int N) {
  
   int i, j, t, sw = 0, miji;
  
   for (i = 0; i < N - 1; i++) {
      miji = i;
      for (j = i; j < N; j++) {
         if (A[j] < A[miji])
           miji = j;
      }
  
   t = A[i];
   A[i] = A[miji];
   A[miji] = t;
  
   if (i != miji) sw++;
   }
  
   return sw;
}
  
  
int main() { 
  
   int A[100], N, i, sw;
  
   scanf("%d", &N);
   for (i = 0; i < N; i++) 
      scanf("%d", &A[i]);
  
   sw = selectionSort(A, N);
  
   for (i = 0; i < N; i++) {
      if (i > 0) 
         printf(" ");
         printf("%d", A[i]);
   }
     
   printf("\n");
   printf("%d\n", sw);
  
   return 0;
  
}

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

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
typedef unsigned int uint;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

ll a[3];

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

	while (true)
	{
		ll t[3];
		rep(i, 0, 3)
		{
			cin >> t[i];
		}
		sort(t, t + 3);
		if (t[0] + t[1] <= t[2])
		{
			printf("%lld %lld %lld %lld\n", accumulate(a, a + 3, 0LL), a[0], a[1], a[2]);
			break;
		}
		else
		{
			ll tv = t[0] * t[0] + t[1] * t[1] - t[2] * t[2];
			if (tv==0LL)
			{
				a[0]++;
			}
			else if (tv > 0LL)
			{
				a[1]++;
			}
			else
			{
				a[2]++;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3264
#include<stdio.h>
int main(void){
int L,M,N,all,cou,i,j;
for(;;){
all=0,cou=0;
scanf("%d",&L);
if(L==0)break;
for(i=0;i<12;i++){
    scanf("%d %d",&M,&N);
    all=all+M-N;
    if(L>all){
        cou++;
    }
}
if(L<=all)printf("%d\n",cou+1);
else printf("NA\n");
}
return 0;
}

Measured memory_bytes: 612
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);

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

    ll t;
    vector<pair<ll, int> > a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first;
        t = a[i].first;
        int j;
        for (j = 0; t > 0; j++) t >>= 1;
        a[i].second = j;
    }

    for (int i = 30; m > 0 && i >= 0; i--) {
        sort(a.begin(), a.end());
        for (int j = n - 1; j >= 0; j--) {
            if (a[j].second == i) {
                a[j].first /= 2;
                a[j].second--;
                if (--m == 0) {
                    break;
                }
            }
        }
    }

    ll res = 0;
    for (int i = 0; i < n; i++) {
        res += a[i].first;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	cout << (N + 1) / 2 << endl;
	return 0;
}

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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const int MOD = 1000000007;
        private static Dictionary<long, long> trialDivResult = new Dictionary<long, long>();
        static void Solve()
        {
            var abc = ReadAndParseIntArr();
            int a = abc[0];
            int b = abc[1];
            int c = abc[2];
            int ans = 0;
            if( a + b >= c - 1)
            {
                ans = b + c;
            }
            else
            {
                ans = (b + a + 1) + b;
            }
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13152
#include<bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<class T> void getVector(vector<T>& v) {
	for (int i = 0; i < v.size(); ++i)
		cin >> v[i];
}

std::string revString(std::string s) {
	string ret;
	auto it = s.rend();
	while (it != s.rbegin()) {
		ret.push_back(*it);
		++it;
	}
	return ret;
}

signed main() {
	while (true) {
		makei(h);
		makei(w);
		if (h == 0 && w == 0)break;
		string s;
		rep(w)s.push_back('#');
		rep(h)cout << s << endl;
		cout << endl;
	}
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define DEBUG true
#define $(x) {if (DEBUG) {cout << #x << " = " << (x) << endl;}}


int main() {
    LL N, M, K;
    cin >> N >> M >> K;
    REP(i, N + 1) {
        REP(j, M + 1) {
            if (i * M + j * N - i * j * 2 == K) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
	
    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE MultiWayIf #-}
import Data.List (sort,group)
import Control.Arrow ((&&&))

main = do
  n <- read <$> getLine :: IO Int
  as <- map (head&&&length).group.sort.map read.words <$> getLine :: IO [(Int,Int)]
  putStrLn $ case as of
    [(m,_)] -> if | m == 1 -> "Yes"
                  | m == n-1 -> "Yes"
                  | n `div` m > 1 -> "Yes"
                  | otherwise -> "No"
    [(s,i),(t,_)] -> if | s == t-1 && s<i -> "No"
                        | s == t-1 && (n-i)`div`(s-i+1) > 1 -> "Yes"
                        | otherwise -> "No"
    _ -> "No"


Measured memory_bytes: 29052
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
sys.setrecursionlimit(10 ** 9)



INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()
A = LI()
graph = [[] for _ in range(n)]
for u, v in LIR(n - 1):
    graph[u - 1] += [v - 1]
    graph[v - 1] += [u - 1]

if n == 2:
    x, y = A
    answer = 'YES' if x == y else 'NO'
    print(answer)
    exit()


def dfs(v, parent=None):
    x = A[v]
    if len(graph[v]) == 1:
        return x
    s = 0
    for w in graph[v]:
        if w == parent:
            continue
        ret = dfs(w, v)
        if ret == None:
            return None
        if x < ret:
            print('NO')
            exit()
        s += ret
    if 2 * x - s > s:
        print('NO')
        exit()
    if 2 * x < s:
        print('NO')
        exit()
    return 2 * x - s


v=0
while len(graph[v]) == 1:
    v += 1

if not dfs(v):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 196400
#include<cstdio>
using namespace std;

int main(){
  int N, L;
  int ansT = 0;

  scanf("%d %d", &N, &L);

  if (L > 0){
    for(int i = 1; i < N; i++){
      ansT += L + i;
    }
  }
  else if (L < - N + 1){
    for(int i = 0; i < N - 1; i++){
      ansT += L + i;
    }
  }
  else{
    for(int i = 0; i < N; i++){
      ansT += L + i;
    }
  }

  printf("%d\n", ansT);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



int main()
{
    int N;cin >> N;
    ve<int> D(N);
    in(N,D);
    
    sor(D);
    
    int a=0,b=0;
    
    int ans = 100;
    
    rep(i,N){
        ans = min(ans,D[i]);
        int aa = abs(a-D[i]);
        int bb = abs(b-(24-D[i]));
        
        if(aa > bb){
            a = D[i];
            ans = min(aa,ans);
            ans = min(ans,abs(b-a));
        }else{
            b = 24-D[i];
            ans = min(bb,ans);
            ans = min(ans,abs(b-a));
        }
    }

    
    out(ans);
    


    return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int N = Integer.parseInt(br.readLine());
		
		if(N%2 == 0)
			System.out.println(N / 2);
		else
			System.out.println(N / 2 + 1);
	}

}

Measured memory_bytes: 32540
package main

import "fmt"

func main() {
	var N, A, B int
	fmt.Scan(&N, &A, &B)
	ans := 0
	for i := 1; i <= N; i++ {
		sum := 0
		v := i
		for v > 0 {
			sum += v % 10
			v /= 10
		}
		if A <= sum && sum <= B {
			ans += i
		}
	}
	fmt.Println(ans)
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<i64>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { cout << p.first << ' ' << p.second; return os; }

#define int i64
#define endl '\n'

void solve() {
  int n; cin >> n;
  vi32 a(n); cin >> a;
  
  vi32 sums(n + 1);
  partial_sum(all(a), sums.begin() + 1);
  
  auto sum = [&](int l, int r) {
    if (l <= r) return sums[r] - sums[l];
    return sums[n] - sums[l] + sums[r];
  };

  auto ssum = [&](int l, int m, int r) {
    if (l == m || m == r) return (int) 1e18;
    return abs(sum(l, m) - sum(m, r));
  };

  auto inc = [&](int i) { return (i + 1) % n; };
  auto dec = [&](int i) { return (i + n - 1) % n; };

  int ans = 1e18;

  rep(i, 1) {
    int l = inc(i);
    int j = inc(l);
    int r = inc(j);

    for (int end = dec(i); j != end; j = inc(j)) {
      while (ssum(i, l, j) > ssum(i, l + 1, j)) l = inc(l);
      while (ssum(j, r, i) > ssum(j, r + 1, i)) r = inc(r);
      auto mm = minmax({
        sum(i, l), sum(l, j), sum(j, r), sum(r, i)
      });
      amin(ans, mm.second - mm.first);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3328
/*author - Aryan Mittal*/
#include<bits/stdc++.h>
using namespace std;

#pragma GCC push_options
#pragma GCC optimize ("unroll-loops")

#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"

#define ll long long

int main() {

	// Use ctrl+shift+b ( second option )
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt" , "w" , stderr);
#endif

	// int a,b;
	// cin>>a>>b;

	// cout << a << " " << b << "\n";
	// cout << "Aryan" << "\n";
	// cerr << "Aryan " << a;

	// while(1){
	// 	cout<<"Aryan"<<"\n";
	// }

	ll k;
	cin >> k;

	string s;
	cin >> s;

	ll len = s.length();

	if (len <= k) {
		cout << s << "\n";
	} else {
		for (ll i = 0; i < k; i++) {
			cout << s[i];
		} cout << "...";
	}



	return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

string checkGroup(int z) {
	vi a{ 1,3,5,7,8,10,12 }, b{ 4,6,9,11 }, c{ 2 };
	if (z == 2)return "c";
	else if (z == 4 || z == 6 || z == 9 || z == 11)return "b";
	else return "a";
}

int main()
{
	int x, y;
	cin >> x >> y;

	if (checkGroup(x) == checkGroup(y)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;

typedef vector<int> vi;

#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define ALL(a) (a).begin(),a.end()
#define MAXE(a) *max_element(ALL(a))
#define MINE(a) *min_element(ALL(a))

int main(){
	char po[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','d','t','u','v','w','x','y','z'};
	string s;
	cin >>s;
	int v[26] = {0};
	int vmax[26] = {0};
	REP(i,s.length()){
		REP(j,26){
			if(s[i]!=po[j]){
				v[j] ++;
				if(v[j] > vmax[j]){
					vmax[j] = v[j];
				}
			}
			else {
				v[j]=0;
			}
		}
	}


	int min = 100;
	REP(i,26){
		if(vmax[i] < min){
		min = vmax[i];
		}
	}

	cout << min << endl;
}

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


int main(){
    string S;
    cin >> S;
    string ans = "No";
    for (int i = 0; i < 3; i++){
        if (S.at(i) == '7') {
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
#define OPTIMISE ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

int a,b,c,n;
const int M = 1e5+100;
string s[M];
char ans[M];

void dfs(int i, int a, int b, int c) {
	if (i == n) {
		cout << "Yes\n";
		for (int i = 0; i < n; i++)
			cout << ans[i] << "\n";
		exit(0);
	}
	if (s[i] == "AB") {
		if (a) ans[i] = 'B', dfs(i+1,a-1,b+1,c);
		if (b) ans[i] = 'A', dfs(i+1,a+1,b-1,c);
	}
	if (s[i] == "BC") {
		if (b) ans[i] = 'C', dfs(i+1,a,b-1,c+1);
		if (c) ans[i] = 'B', dfs(i+1,a,b+1,c-1);
	}
	if (s[i] == "AC") {
		if (a) ans[i] = 'C', dfs(i+1,a-1,b,c+1);
		if (c) ans[i] = 'A', dfs(i+1,a+1,b,c-1);
	}
}

int main() {
	OPTIMISE;

	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	dfs(0,a,b,c);
	cout << "No";
}

Measured memory_bytes: 16272
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <bitset>

#define First 0x01
#define Second 0x01 << 1
#define Third 0x01 << 2
#define Run 0x01 << 3

using namespace std;

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string str;
		int out = 0, score = 0;
		unsigned field = 0;
		while (out < 3) {
			cin >> str;
			if (str == "HIT") {
				field = field << 1;
				field |= First;
				if (field & Run) {
					score++;
					field &= ~(Run);
				}
			}
			else if (str == "HOMERUN") {
				score++;
				if (field & First) score++;
				if (field & Second) score++;
				if (field & Third) score++;
				field = 0;
			}
			else if (str == "OUT") {
				out++;
			}
		}
		cout << score << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include<iostream>

using namespace std;

int main(){
	int H,W,i,j;
	for(;;){
		cin>>H>>W;
		if(H==0 && W==0){
			break;
		}else{
			for(i=1;i<=H;i++){
				for(j=1;j<=W;j++){
					cout<<"#";
				}
				cout<<endl;
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define F(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define f(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define file(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
using namespace std;

template<typename T>bool chkmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool chkmin(T &a,T b){return (a>b)?a=b,1:0;}

inline int read() {
 int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}
int n,m;
int cnt;
int fa[1000005],a[1000005],b[1000005];
int main () {
#ifndef ONLINE_JUDGE
//file("agc001d");
#endif
    n=read();
	m=read();
	F(i,1,m){
		a[i]=read();
		if(a[i]&1)cnt++;
	}
    if(m==1){
		printf("%d\n",a[1]);
	   if(a[1]==1)printf("1\n1\n");
	   else printf("2\n%d %d\n",a[1]-1,1);
	   return 0;
	}
	if(cnt>2){
	   puts("Impossible");
	   return 0;
	}
	F(i,1,m){
	   if(a[i]%2==1){
	      swap(a[i],a[1]);
		  break;
	   }
	}
	f(i,m-1,2)if(a[i]%2==1){
	   swap(a[i],a[m]);
	   break;
	}
	F(i,1,m)printf("%d%c",a[i],i==m?'\n':' ');
	b[1]=a[1]+1;
	F(i,2,m-1)b[i]=a[i];
	b[m]=a[m]-1;
	if(b[m]==0)m--;
    printf("%d\n",m);
	F(i,1,m)printf("%d%c",b[i],i==m?'\n':' ');
    return 0;
}

Measured memory_bytes: 2304
//author: zekigurbuz (Zeki Gurbuz) 2020
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define all(x) begin(x),end(x)

const int N = 1e5 + 10;
const int M = 1e9 + 7;

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

template<class T>void ckmin(T&a,T b){a=min(a,b);}
template<class T>void ckmax(T&a,T b){a=max(a,b);}

void precomp() {

}


void solve() {
	int n; cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) cin >> a[i];
	map<int, int> m;
	for (int i = 1; i < n; i++) m[i - a[i]]++;
	ll ans = 0LL;
	for (int i = 0; i < n; i++) {
		if (i > 0) m[i - a[i]]--;
		ans += m[i + a[i]];
	}
	cout << ans << endl;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	precomp();
	int t = 1; // cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve();
	}
	return 0;
}



Measured memory_bytes: 21496
N = int(input())
D = list(map(int, input().split()))

MOD = 998244353

from collections import defaultdict

count = defaultdict(int)

if D[0] != 0:
    print (0)
    exit()

for d in D:
    count[d] += 1

tmp = 0
ans = 0
check = 0
for i in range(N):
    if i == 0:
        if count[i] == 1:
            ans = 1
            tmp = 1
            check += 1
        else:
            print (0)
            exit()
    else:
        ans *= pow(tmp, count[i], MOD)
        tmp = count[i]
        check += count[i]
    # print (i)
    ans %= MOD

    if check == N:
        break
    
    if count[i] == 0:
        print (0)
        exit()

print (ans % MOD)


Measured memory_bytes: 18932
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const int  MAX = (int)1e15;

double snuke(int n) {
	int m = n;
	int k = 0;
	while(m > 0) {
		k += m % 10;
		m /= 10;
	}
	return n / (double) k; 
}

double mn;
vector<int> v;

void dfs(int n, int d) {
	if(d == 0) {
		if(n == 0) return;
		v.push_back(n);
		mn = min(mn, snuke(n));
		return;
	}
	for(int i = 9; i >= 0; --i) {
		int m = n + (i - 9) * d;
		double s = snuke(m);
		if(s > mn) return;
		dfs(m, d / 10);
	}
}

signed main(){
	int K;
	cin >> K;

	mn = MAX;
	dfs(MAX - 1, MAX / 10);
	reverse(ALL(v));
	for(int i = 0; i < K; ++i) {
		cout << v[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;

  if (K <= A) cout << K << endl;
  else if (K <= A + B) cout << A << endl;
  else cout << A - (K - (A + B)) << endl;

  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
char mp[N][N];int n,m,a,b;
int main(){
    scanf("%d%d%d%d",&n,&m,&a,&b);
    for(int i=1;i<=b;i++)for(int j=1;j<=m;j++)mp[i][j]=1;
    for(int i=1;i<=n;i++)for(int j=1;j<=a;j++)mp[i][j]^=1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;++j)putchar(mp[i][j]+'0');
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
long long H,attack_count;
int loop_count;

int main(){
    cin >> H;
    while( H > 0){
        attack_count += pow(2,loop_count++);
        H = H/2;
    }
    cout << attack_count <<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict


words_dict = defaultdict(int)
n = int(input())
for i in range(n):
    words_dict[input()] += 1

m = int(input())

for i in range(m):
    words_dict[input()] -= 1

ans = max(words_dict.values())
if ans < 0:
    ans = 0
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main()
{
    queue<pair<int, int>> que;
    int ans[100005];
    unordered_multimap<int, int> route;
    int room_count, route_count;
    cin >> room_count >> route_count;
    for (int i = 0; i < route_count; i++)
    {
        int room_from, room_to;
        cin >> room_from >> room_to;
        route.emplace(room_from, room_to);
        route.emplace(room_to, room_from);
    }
    for (int i = 0; i < room_count; i++)
    {
        ans[i + 1] = 0;
    }
    ans[1] = -1;

    {
        auto rita = route.equal_range(1);
        for (auto rit = rita.first; rit != rita.second; ++rit)
        {
            que.push(pair<int, int>(rit->second, 1));
        }
    }
    while (!que.empty())
    {
        const auto next_value = que.front();
        que.pop();
        if (ans[next_value.first] != 0)
        {
            continue;
        }

        {
            auto rita = route.equal_range(next_value.first);
            for (auto rit = rita.first; rit != rita.second; ++rit)
            {
                que.push(pair<int, int>(rit->second, next_value.first));
            }
            ans[next_value.first] = next_value.second;
        }
    }
    printf("Yes\n");
    for (int i = 1; i < room_count; i++)
    {
        printf("%d\n", ans[i + 1]);
    }
    return 0;
}


Measured memory_bytes: 22960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<int,int> p;
int a[20001];
int b[20001];

int main(){
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    p[tmp] = i;
  }
  int tt = p[1];
  for (auto &pp: p) {
    pp.second -= tt;
  }
  int bmin = 0;
  int amax = 0;
  for (int i = 1; i < n; i++) {
    int tmpb = bmin - 1;
    int tmpa = amax + 1;
    int sum = p[i + 1];
    if (sum - tmpb < tmpa) {
      a[i] = tmpa;
      b[i] = sum - tmpa;
    } else {
      b[i] = tmpb;
      a[i] = sum - tmpb;
    }
    amax = a[i];
    bmin = b[i];
  }
  for (int i = 0; i < n; i++) {
    cout << a[i] - bmin + 1;
    if (i != n - 1) cout << " ";
  }
  cout << endl;
  for (int i = 0; i < n; i++) {
    cout << b[i] - bmin + 1;
    if (i != n - 1) cout << " ";
  }
  cout << endl;
  return 0;
}


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

typedef long long ll;
typedef pair <int, int> pii;

const int N = 2e5 + 5;

ll n, a[N], x[N], m, f[N], ans[N];
bool mark[N];
ll k;

vector <int> adj[N], vec;

void dfs(int v) {
	vec.push_back(v);
	mark[v] = true;
	for (auto u : adj[v])
		if(!mark[u])
			dfs(u);
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);	
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	cin >> m >> k;
	for (int i = 0; i < n - 1; i++)
		x[i] = a[i + 1] - a[i], f[i] = i;
	for (int i = 0; i < m; i++) {
		int pos;
		cin >> pos;
		pos--;
		swap(f[pos], f[pos - 1]);
	}
	for (int i = 0; i < n - 1; i++)
		adj[i].push_back(f[i]);
	for (int v = 0; v < n - 1; v++)
		if(!mark[v]) {
			dfs(v);
			ll len = vec.size();
			for (int i = 0; i < len; i++)
				ans[vec[i]] = vec[(k + i) % len];
			vec.clear();
		}
	for (int i = 0; i < n - 1; i++) {
		cout << a[i] << "\n";
		a[i + 1] = a[i] + x[ans[i]];
	}
	cout << a[n - 1] << "\n";
}


Measured memory_bytes: 19960
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
typedef long long ll;
inline void Fail(){printf("0");exit(0);}

const int maxn=16;
int n,m,ans,sum;
vector<pii>edge[maxn];
int dp[maxn][1<<maxn],val[1<<maxn],dis[maxn][maxn];

inline void upd(int &a,int b){if(b>a)a=b;}
 
int main(){
	scanf("%d%d",&n,&m);
	rep(i,n)rep(j,n)dis[i][j]=INF;
	rep(i,m){
		int u,v,c;
		scanf("%d%d%d",&u,&v,&c);
		u--;v--;
		edge[u].pb(mp(v,c));
		edge[v].pb(mp(u,c));
		dis[u][v]=dis[v][u]=c;
		sum+=c;
	}
	rep(mask,1<<n){
		rep(i,n)for(int j=i+1;j<n;j++){
			if((mask&(1<<i))&&(mask&(1<<j))&&dis[i][j]!=INF)val[mask]+=dis[i][j];
		}
	}
	rep(i,n)rep(mask,1<<n)dp[i][mask]=-INF;
	rep(mask,1<<n)if(mask&1)dp[0][mask]=val[mask];
	rep(mask,1<<n)rep(i,n){
		int cur=dp[i][mask];
		if(cur==-INF)continue;
//		cout<<i<<" "<<mask<<" "<<cur<<endl;
		rep(j,edge[i].size()){
			pii x=edge[i][j];
			int rest=((1<<n)-1)^mask;
			for(int nmask=rest;nmask;nmask=(nmask-1)&rest){
				if(nmask&(1<<x.first))upd(dp[x.first][mask|nmask],cur+x.second+val[nmask]);
			}
		}
	}
	rep(mask,1<<n)ans=max(ans,dp[n-1][mask]);
	printf("%d",sum-ans);
	return 0;
}

/*
Input:
-----------------
Output:
*/

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

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
// #define int long long 

using namespace std;

int32_t main()
{
	fio;
	int n;
	cin>>n;
	while(n)
	{
		if(n%10==7)
		{
			cout<<"Yes"<<endl;
			break;
		}
		n=n/10;
	}

	if(n==0)
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3600
// !Start && !End 
//  0 se divide

// { Tu jab paida hua tha na tabhi ye code likh diya tha --Ranvijay }

#pragma optimise GCC(-O2)
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define pii pair<ll,ll>
#define ve(x) vector<x>
#define f(a,b,c) for(ll a=b;a<c;a++)
#define foto(x,v) for(auto x:v)
#define read(t) ll t; cin>>t;
#define reads(t) string t; cin>>t;
#define readarr(arr,n) ll arr[n]; f(i,0,n) cin>>arr[i];
#define forstl(i,v) for(auto &i: v)
#define ln endl
#define Endl endl
#define dbg(x) cout<<#x<<" = "<<x<<ln;
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<ln;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it<<ln;} cout<<ln;
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cout<<ln;
#define dbgarr(v,s,e) cout<<#v<<" = "; f(i,s,e) cout<<v[i]<<", "; cout<<ln;
#define addEdge(tr,k) f(i,0,k) { ll x,y; cin>>x>>y, tr[x].push_back(y), tr[y].push_back(x);}
#define all(v) v.begin(),v.end()

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) { uniform_int_distribution<int> uid(0, lim - 1); return uid(rang); }

//														GLOBAL VARS
ll INF =LLONG_MAX;
const ll M= 1000000007;

//														USEFUL FUNCTIONS
ll powm(ll ,ll);

//                                                      DSU 
// vector<int> parent, rank;
// void make_set(int v) { parent[v] = v; rank[v] = 0;}
// int find_set(int v) { if (v == parent[v]) return v; return parent[v] = find_set(parent[v]);}
// void union_sets(int a, int b) { a = find_set(a);  b = find_set(b); if (a != b) { if (rank[a] < rank[b]) swap(a, b); parent[b] = a; if (rank[a] == rank[b]) rank[a]++; }}

//                                                     LCA by Binary Lifting      l=ceil(log2(n)) dfs(root,root)
// ll dp[200005][21] ; ve(ll) tin(200005), tout(200005); ll tim = 0 , l;
// void dfs(int n , int par ){  tin[n] = ++tim; dp[n][0] = par; f(i,1,l+1) dp[n][i] = dp[dp[n][i-1]][i-1];
//    foto(x,tr[n]) if(x==par) continue; else dfs(x , n);        tout[n] = ++tim;  }
// bool is_ancestor(ll u , ll v) { return tin[u]<=tin[v] && tout[u]>=tout[v] ;}1
// ll lca(ll u , ll v){ if(is_ancestor(u,v)) return u ; if(is_ancestor(v,u)) return v;
//    for(int j = l ; j>=0 ; j--) if(!is_ancestor(dp[u][j] , v)) u = dp[u][j];    return dp[u][0];}


// 														MAIN
int32_t main()
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    //It gets easier day by day, but the hard part is to........
    read(a) read(b) read(c) read(k)
    if(k<=a) {cout<<k; return 0 ;}
    if(k<=a+b) {cout<<a; return 0 ;}
    cout<<a - (k-(a+b));
}










//													FUNCTIONS DECLARATIONS
ll powm(ll a, ll b) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%M;
		a=(a*a)%M;
		b>>=1;
	}
	return res;
}


Measured memory_bytes: 3652
from math import sqrt

N = int(input())


def f(x):
    n = N
    while n % x == 0:
        n //= x
    return n % x == 1


ans = 1
for k in range(2, int(sqrt(N)) + 1):
    res = N % k
    if res == 0:
        k1, k2 = k, N // k
        ans += 1 if f(k1) else 0
        ans += 1 if k1 != k2 and f(k2) else 0
    elif res == 1:
        ans += 1 if k == (N - 1) // k else 2
if N >= 3:
    ans += 1

print(ans)


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, ans = INT_MAX;
	cin >> n;
	vector<string> a(n), b(n);
	vector<int> rn(n);
	vector<bool> can(n, 0);
	bool flag = false;

	for(int i = 0; i < n; i++) {
		cin >> a[i];
		for(int j = 0; j < n; j++) {
			rn[i] += a[i][j] == '.';
			can[j] = can[j]|(a[i][j] == '#');
			flag |= (a[i][j] == '#');
		}
	}
	if(!flag) cout << -1, exit(0);
	for(int i = 0; i < n; i++) ans = min(rn[i]+!can[i], ans);
	for(int j = 0; j < n; j++) {
		bool flag = false;
		for(int i = 0; i < n; i++) if(a[i][j] == '.') flag = true;
		ans += flag;
	}
	cout << ans;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long 
#define double long double
#define MAX 1010
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = INF;
ll modulo = pow(10,9)+7;
vector<int> bfs;
char arr[MAX][MAX];
int dist[MAX*MAX];
int dx[4] = {-1, 1, 0, 0};
int dy[4] = { 0, 0, 1,-1};
int hsh(int x,int y){
	return x*MAX + y;
}
void hash_back(int& x, int& y, int ans){
	x = ans/MAX;
	y = ans%MAX;
}
void deal(){
	fori(MAX*MAX)
		dist[i] = inf;
	int w,h;
	cin>>w>>h;
	fori(w)
		forj(h)
			cin>>arr[i][j];
	fori(w)
		forj(h)
			if(arr[i][j] == '#')
				bfs.pb(hsh(i,j)), dist[hsh(i,j)] = 0;
	fori(bfs.size()){
		int hd = bfs[i];
		int x ,y;
		hash_back(x,y, hd);
	//	cout<<x<<" "<<y<<endl;
		forj(4){
			int x1 = x + dx[j], y1 = y + dy[j];
		//	cout<<"the j "<<j<<" "<<dx[j]<<" "<<dy[j]<<endl;
		//	cout<<"we at "<<x1<<" "<<y1<<" "<<x<<" "<<y<<endl;
			int the_hash = hsh(x1,y1);
			if(x1 > -1 && y1>-1&& x1<w && y1<h && dist[hd] + 1 < dist[the_hash])
				dist[the_hash] = dist[hd] + 1, bfs.pb(the_hash);
		}
	}
	int mx = 0;
	fori(w)
		forj(h)
			mx = max(mx, dist[hsh(i,j)]);
	cout<<mx;
}
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}



























Measured memory_bytes: 11504
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
	int n;
	vector<int> input;
	int cnt[4]={};
	cin>>n;
	int temp=n;


	while(temp--) {
		int x;
		cin >> x;
		input.push_back(x);
	}
	
	for(int i=0;i<n;i++){
		if(input[i]%4==0)
			cnt[0]++;
		else if(input[i]==1)
			cnt[1]++;
		else if(input[i]%2==0){
			cnt[2]++;
		}
		else
			cnt[3]++;
	}
	
	if(cnt[2]==0){
		if((cnt[0])>=(cnt[3]+cnt[1]-1))
			cout<<"Yes";
		else 
			cout<<"No";
	}
	else if(cnt[2]==1){
		if((cnt[0])>=(cnt[3]+cnt[1]+cnt[2]-1))
			cout<<"Yes";
		else 
			cout<<"No";
	}
	else{
		if((cnt[0])>=(cnt[3]+cnt[1]))
			cout<<"Yes";
		else 
			cout<<"No";
	}


	

	return 0;

}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define ll long long
#define eps 1e-7
using namespace std;

#define MAX 100005
#define NIL -1
struct Node { int p, l, r, s; };
Node T[MAX];
int D[MAX], H[MAX];
int n, u, vl, vr;
int mm;
void print(int i) {
	printf("node %d: ", i);
	printf("parent = %d, ", T[i].p);
	printf("sibling = %d, ", T[i].s);
	int num = 0;
	if (T[i].l != -1) ++num;
	if (T[i].r != -1) ++num;
	printf("degree = %d, ", num);
	printf("depth = %d, ", D[i]);
	printf("height = %d, ", H[i]);
	if (T[i].p == -1) cout << "root" << endl;
	else if (!num) cout << "leaf" << endl;
	else cout << "internal node" << endl;
}
void depth(int u, int ans) {
	D[u] = ans;
	if (T[u].l != -1) depth(T[u].l, ans + 1);
	if (T[u].r != -1) depth(T[u].r, ans + 1);
}
void height(int u, int ans) {
	if (ans > mm) mm = ans;
	if (T[u].l != -1) height(T[u].l, ans + 1);
	if (T[u].r != -1) height(T[u].r, ans + 1);
}
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) T[i].p = T[i].l = T[i].r = T[i].s = -1;
	for (int i = 0; i < n; ++i) {
		cin >> u >> vl >> vr;
		T[u].l = vl, T[u].r = vr;
		T[vl].p = T[vr].p = u;
		T[vl].s = vr, T[vr].s = vl;
	}
	int root = -1;
	for (int i = 0; i < n; ++i) if (T[i].p == -1) root = i;
	depth(root, 0);
	for (int i = 0; i < n; ++i) {
		mm = 0;
		height(i, 0);
		H[i] = mm;
	}
	for (int i = 0; i < n; ++i) print(i);
}


Measured memory_bytes: 3236