akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int getDigit(int a){
  int ans = 0;
  while( a >= 1 ){
     a /= 10;
     ans += 1;
  }
  return ans;
}

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

  int ans = 0;
  for(int i=1; i<=n; i++){
      if( getDigit(i)%2 == 1 ){
        ans += 1;
      }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int N;
	List<int> c, d;
	void Solve()
	{
		N = F;
		var a = G;
		var b = G;
		var s = 0;
		for (var i = 29; i >= 0; i--)
		{
			int n = 1 << i, m = n << 1, t = 0, l1 = 0, l2 = 0, r1 = 0, r2 = 0, k = m - 1;
			if (i == 29)
			{
				c = new List<int>(a);
				d = new List<int>(b);
				c.Sort();
				d.Sort();
			}
			else
			{
				c = Sort(c, k);
				d = Sort(d, k);
				//for (var j = 0; j < N; j++) c[j] &= k;
				//for (var j = 0; j < N; j++) d[j] &= k;
			}
			for (var j = N - 1; j >= 0; j--)
			{
				var x = d[j];
				l1 = Incr(l1, n - x);
				r1 = Incr(r1, m - x);
				l2 = Incr(l2, n + m - x);
				r2 = Incr(r2, 2 * m - x);
				t += r1 - l1;
				t += r2 - l2;
				t %= 2;
			}
			if (t > 0) s ^= 1 << i;
		}
		WriteLine(s);
	}
	int Incr(int i, int v)
	{
		while (i < N && c[i] < v) i++;
		return i;
	}
	List<int> Sort(List<int> x, int mask)
	{
		var m = 0;
		while (m < N && x[m] <= mask) m++;
		for (var i = 0; i < N; i++) x[i] &= mask;
		if (m == 0 || m == N) return x;
		return Merge(x, m);
	}
	// x[0, m) , x[m, N) => sort
	List<int> Merge(List<int> x, int m)
	{
		var y = new List<int>();
		int l1 = 0, r1 = m;
		while (true)
		{
			if (x[l1] <= x[r1]) y.Add(x[l1++]);
			else y.Add(x[r1++]);
			if (l1 == m || r1 == N) break;
		}
		while (l1 < m) y.Add(x[l1++]);
		while (r1 < N) y.Add(x[r1++]);
		return y;
	}
}


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

using namespace std;

int dist[60][60];

void dfs(int x,int y,int g){
   if (dist[x][y]!=0&&dist[x][y]<=g) return;
   if (dist[x][y]==-1) return;
   dist[x][y] = g;
   dfs(x+1,y,g+1);
   dfs(x-1,y,g+1);
   dfs(x,y+1,g+1);
   dfs(x,y-1,g+1);
}

int main(){
    int h,w,cnt=0; cin >> h >> w;
   for (int i = 0; i < 55; i++)
   {
    for (int j = 0; j < 55; j++)
    {
        dist[i][j] = -1;
    }
   } 
   for (int i = 1; i <= h; i++)
   {
    for (int j = 1; j <= w; j++)
    {
        char ch;cin >>ch;
        if (ch=='.')
        {
            dist[i][j] = 0;
            cnt++;
        }
       
    }
   }      
    dist[1][1] = 0;
    dfs(1,1,0);
    if (dist[h][w]==0)
    {
       cout << -1;
    }
    else
    {
        cout << cnt-1-dist[h][w];
    }
  
    return 0;
}

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

int main()
{
	int N,num[8],s[8];
	while(scanf("%d", &N), N)
	{
		for(int i=1; i<=N; i++)
			scanf("%d%d", &num[i], &s[i]);
		
		int dp[1001]={0};
		dp[0]=1;
		
		for(int i=1; i<=N; i++)
		{
			bool c[1001]={0};
			c[0]=1;
			for(int j=0; j<s[i]; j++)
			for(int k=1000; k>=0; k--)
			{
				if(k+num[i]>1000) continue;
				if(c[k]!=0) c[k+num[i]]=1;
			}
			
			for(int k=1000; k>=0; k--)
			for(int j=1; j<1000; j++)
			{
				if(k+j>1000) continue;
				if(c[j]!=0) dp[k+j]+=dp[k];
			}
		}
		
		int M;
		scanf("%d", &M);
		while(M--)
		{
			int t;
			scanf("%d", &t);
			printf("%d\n", dp[t]);
		}
	}
}

Measured memory_bytes: 760
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

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

  ll dist[N][N];
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      cin >> dist[i][j];
    }
  }
  
  for (int k = 0; k < N; k++){
    for (int i = 0; i < N; i++){
      for (int j = 0; j < N; j++){
        if (dist[i][j] > dist[i][k] + dist[k][j]){
          cout << -1 << endl;
          return 0;
        }
      }
    }
  }

  priority_queue < pair<ll, Pii>, vector<pair<ll, Pii>>, greater<pair<ll, Pii>>> que;
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      que.push(make_pair(dist[i][j], make_pair(i, j)));
    }
  }

  bool checked[N][N];
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      checked[i][j] = false;
    }
  }
  
  
  ll ans = 0;
  while (!que.empty()){
    pair<ll, Pii> Q = que.top(); que.pop();
    int i = Q.second.first, j = Q.second.second;
    bool flag = false;
    for (int k = 0; k < N; k++){
      if (checked[i][k] == true && checked[k][j] == true){
        if (dist[i][k] + dist[k][j] == Q.first){
          flag = true;
        }
      }
    }
    
    if (flag == false){
      ans += Q.first;
    }

    checked[i][j] = true;
    checked[j][i] = true;
  }

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


Measured memory_bytes: 2040
n = int(input())
ls = []
for i in range(n):
    ls.append(int(input()))
maxnum = max(ls)
ind = ls.index(maxnum)
ls.remove(maxnum)
secondnum = max(ls)
ls = ls[0:ind] + [maxnum] + ls[ind:]
#print(ls)
if maxnum == secondnum:
    for i in range(n):
        print(maxnum)
    quit()
for i in range(n):
    if ls[i] == maxnum:
        print(secondnum)
    else:
        print(maxnum)

Measured memory_bytes: 14104
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int N; cin >> N;
  int x = 0;
  int res = 0;
  for (int _ = 0; _ < N; ++_) {
    char c; cin >> c;
    if (c == 'I') {
      ++x;
    } else {
      --x;
    }
    chmax(res, x);
  }
  cout << res << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();
        System.out.println(Math.min(K, A)-Math.max(K-A-B, 0));
    }

    public static void main(String[] args) {
        new Main();
    }
}

Measured memory_bytes: 35700
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
res=0
for i in range(0,n):
  lis=list(map(int,input().split()))
  count=0
  for j in range(0,m):
    count+=b[j]*lis[j]
  if count+c>0:
    res+=1
print(res)

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 3
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

char c[MAX_N][MAX_N];

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

  REP(i, 3) REP(j, 3) { cin >> c[i][j]; }

  REP(i, 3) { cout << c[i][i]; }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  string W[N];
  FOR(i,0,N)cin >> W[i];
  FOR(i,0,N)FOR(j,i+1,N){
    if(W[i] == W[j]){
      cout << "No" << endl;
      return 0;
    }
  }
  FOR(i,0,N-1)if(W[i][W[i].size()-1] != W[i+1][0]){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <cassert>
#include <iostream>
using namespace std;
const int mod = 1000000007;
int main()
{
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<int>> dp(H + 1, vector<int>(W, 0));
    dp[0][0] = 1;
    for (int i = 0; i < H; ++i)
    {
        for (int j = 0; j < W; ++j)
        {
            for (int k = 0; k < 1 << (W - 1); ++k)
            {
                // 2 つの横線がつながっていないか調べる
                bool ok = true;
                for (int l = 0; l < W - 2; ++l)
                {
                    if (((k >> l) & 1) && ((k >> (l + 1)) & 1))
                    {
                        ok = false;
                    }
                }
                if (ok)
                {
                    if (j >= 1 && ((k >> (j - 1)) & 1))
                    {
                        // 左方向に横線をたどるケース
                        dp[i + 1][j - 1] += dp[i][j];
                        dp[i + 1][j - 1] %= mod;
                    }
                    else if (j <= W - 2 && ((k >> j) & 1))
                    {
                        // 右方向に横線をたどるケース
                        dp[i + 1][j + 1] += dp[i][j];
                        dp[i + 1][j + 1] %= mod;
                    }
                    else
                    {
                        // The case which goes straight
                        // 横線をたどらないケース
                        dp[i + 1][j] += dp[i][j];
                        dp[i + 1][j] %= mod;
                    }
                }
            }
        }
    }
    cout << dp[H][K - 1] << '\n';
    return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int,int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back


int main() {
  ll N; cin>>N;
  ll maxa=-3e9,mina=3e9;
  ll maxb=-3e9,minb=3e9;
  ll x,y;
  rep(i,N) {
    cin>>x>>y;
    maxa=max(maxa,x+y);
    mina=min(mina,x+y);
    maxb=max(maxb,x-y);
    minb=min(minb,x-y);
  }
  cout<<max(abs(maxa-mina),abs(maxb-minb))<<endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  double r; cin >>r;
  double res = 2 * r * M_PI;
  cout <<fixed <<setprecision(12) <<res <<endl; 
}


Measured memory_bytes: 3820
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

vector<int> as;
vector<int> ans;

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

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }

    int xor_all = 0;
    for (int i = 0; i < N; i++) {
        xor_all ^= as[i];
    }

    ans.resize(N);
    for (int i = 0; i < N; i++) {
        ans[i] = xor_all ^ as[i];
    }

    cout << ans[0];
    for (int i = 1; i < N; i++) {
        cout << " " << ans[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 4680
#include <bits/stdc++.h>
#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++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;

#define _ cin.tie(0);ios::sync_with_stdio(false);
int n,m;
int main(){ _;
  cin>>n>>m;
  vector<LP> ab(n);
  REP(i,n) cin>>ab[i].first>>ab[i].second;
  vector<LP> cd(m);
  REP(i,m) cin>>cd[i].first>>cd[i].second;

  REP(i,n){
    int ans=0;
    llong diff=INF;
    REP(j,m){
      if(abs(ab[i].first-cd[j].first)+abs(ab[i].second-cd[j].second)<diff){
	diff=abs(ab[i].first-cd[j].first)+abs(ab[i].second-cd[j].second);
	ans=j;
      }
    }
    cout<<ans+1<<endl;
  }
      
					      
	      

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

double a[10][3];//放城镇坐标
double k[10][3];//放已经去过的城镇坐标
int vis[10]={0};//去过的城镇标记
int n;
double sum;

void dfs(int pos)//pos为第几个城镇
{
    if(pos==n+1)
    {
        for(int i=2;i<=n;i++)
            sum+=sqrt(pow(k[i][1]-k[i-1][1],2)+pow(k[i][2]-k[i-1][2],2));
        return ;
    }
    for(int i=1;i<=n;i++)
    {
        k[pos][1]=a[i][1];
        k[pos][2]=a[i][2];
        if(!vis[i])
        {
            vis[i]=1;
            dfs(pos+1);
            vis[i]=0;
        }
    }
    return ;
}

int mp(int n)
{
    int z=1;
    for(int i=1;i<=n;i++)
        z*=i;
    return z;
}

int main()
{
    double x,y,ans;
    int p;
    while(~scanf("%d",&n))
    {
        sum=0;
        p=mp(n);
        for(int i=1;i<=n;i++)
        {
            scanf("%lf%lf",&x,&y);
            a[i][1]=x;
            a[i][2]=y;
        }
        dfs(1);
        ans=sum/p;
        printf("%.10lf\n",ans);
    }
    return 0;
}


Measured memory_bytes: 128
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
bool prime(int i){
  for(int j = 2; j * j <= i; j++){
    if(i % j == 0)return false;
  }
  return true;
}

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<int> vec;
  FOR(i, 2, n+1){
    if(prime(i))vec.pb(i);
  }
  vector<int> pn = vector<int>(vec.size(), 0);
  FOR(i, 2, n+1){
    int tmp = i;
    rep(j, vec.size()){
      while(tmp % vec[j] == 0){
        tmp /= vec[j];
        pn[j]++;
      }
    }
  }
  int res = 0;
  int num24 = 0;
  int num14 = 0;
  int num4 = 0;
  int num2 = 0;
  rep(i, vec.size()){
    if(pn[i] >= 74)res++;
    if(pn[i] >= 24)num24++;
    if(pn[i] >= 14)num14++;
    if(pn[i] >= 4)num4++;
    if(pn[i] >= 2)num2++;
  }
  res += num24 * (num2 - 1);
  res += num14 * (num4 - 1);
  res += num4 * (num4 - 1) / 2 * (num2 - 2);
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter
import copy

N = int(input())
D = list(map(int, input().split()))
if N == 1:
    print(min(D[0], 24-D[0]))
    exit()

D.append(0)
D.append(24) # 24-0のパターン

c = Counter(D)

times = []
p = []
for num, cnt in c.items():
    if (num == 0 or num == 12) and cnt >= 2:
        # D==24-D になるかつ時差０の組がいるので時差の最小は０で確定
        print(0)
        exit()
    elif cnt >= 3:
        # 時差０の組み合わせがある
        print(0)
        exit()
    elif cnt == 2:
        # Dと24-Dに一人ずつ
        times.append(num)
        times.append(24-num)
    elif cnt == 1:
        # D or 24-D のどちらか一方に一人だけいる状態なので別枠で確保
        p.append((num, 24-num))

num_b = len(p)
ans = 0
# D or 24-Dの可能性があるものについて全パターン試すために、2進表記を利用
for b in range(2**num_b):
    b = bin(b)[2:].zfill(num_b)
    time = copy.deepcopy(times)
    for i in range(num_b):
        if b[i] == "0":
            time.append(p[i][0])
        else:
            time.append(p[i][1])
    tmp = 24
    for i in range(len(time)):
        for j in range(i+1, len(time)):
            tmp = min(tmp, abs(time[i] - time[j]))

    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i, N) for (long long i = 0; i < N; i++)
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<string> W(N);
    rep(i, N)
    {
        cin >> W[i];
    }
    rep(i, N - 1)
    {
        string S1 = W[i], S2 = W[i + 1];
        if (S1[S1.size() - 1] != S2[0])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    set<string> A;
    rep(i, N)
    {
        if (A.find(W[i]) != A.end())
        {
            cout << "No" << endl;
            return 0;
        }
        A.insert(W[i]);
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
mod=10**9+7
g1=[1,1]
g2=[1,1]
inverse=[0,1]
h,w,a,b=map(int,input().split())
n=h+w
for i in range(2,n+1):
    g1.append((g1[-1]*i)%mod)
    inverse.append((-inverse[mod % i]*(mod//i))%mod)
    g2.append((g2[-1]*inverse[-1])%mod)
def cmb(n,r):
    return g1[n]*g2[r]*g2[n-r]%mod
 
ans=0
while a<h and b<w:
    ans=(ans+cmb(h-1-a+b,b)*cmb(w-1-b+a,a))%mod
    a+=1
    b+=1
print(ans)

Measured memory_bytes: 26964
/* YOU LOST THE GAME */
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll N;

void
add (vvl &adj, vl &val, vl &xs, ll p, ll x, ll last)
{
  x += xs[p];
  val[p] += x;
  FOR (i, 0, adj[p].size ())
  {
    if (adj[p][i] == last)
      continue;
    add (adj, val, xs, adj[p][i], x, p);
  }
  return;
}

void
sanitize (vvl &adj, ll p)
{
  FOR (i, 0, adj[p].size ())
  {
      adj[i].erase (find (all (adj[i]), p));
      sanitize (adj, i);
  }
  return;
}

int main(){
  ll Q;
  cin >> N;
  cin >> Q;

  vvl adj (N);
  vl values(N);
  FOR (i, 0, N - 1)
  {
    ll a, b;
    cin >> a >> b;
    adj[a - 1].pb (b - 1);
    adj[b - 1].pb (a - 1);
  }

  //sanitize (adj, 0);

  vl xs (N);
  FOR (j, 0, Q)
  {
    ll p, x;
    cin >> p >> x;
    xs[p - 1] += x;
  }

  add (adj, values, xs, 0, 0, 0);

  FOR (i, 0, N - 1)
  {
    cout << values[i] << " ";
  }

  cout << values[N - 1] << endl;

  return 0;
} //cin.tie(0) bei schnellem Wechseln



Measured memory_bytes: 32128
#include<bits/stdc++.h>
using namespace std;
 
//木を実装する
typedef struct _node{
    int element;
    struct _node *left;
    struct _node *right;
    struct _node *par;
}node;
 
typedef struct _tree{
    node *root;
}tree;
 
//リストを生成する関数
tree *create(){
    tree *T = (tree *)malloc(sizeof(tree));
    T->root = (node *)malloc(sizeof(node));
    T->root->left = NULL;
    T->root->right = NULL;
    T->root->par = NULL;
    T->root->element = -1;
    return T;
}
 
void make_tree(tree *T, string s){
    node *ptr = T->root;
 
    for(int i = 0; i < (int) s.size(); i++){
 
        if(s[i] == '('){
            //どっちかににノードを足す
            node *add = (node *)malloc(sizeof(node));
            add->element = -1;
            add->left = NULL;
            add->right = NULL;
            add->par = ptr;
 
            //左
            if(ptr->left == NULL){
                ptr->left = add;
                ptr = add;
            }else{
                ptr->right = add;
                ptr = add;
            }
        }else if(s[i] == ')'){
            //戻る
            ptr = ptr->par;
        }else if(s[i] == '['){
            string str;
            int j;
            for(j = i + 1; s[j] != ']'; j++) str.push_back(s[j]);
            int num = stoi(str);
            ptr->element = num;
            i = j;
        }
    }
}
 
void print_tree(node *v){
    if(v == NULL || v->element == -1){
        cout << ")";
        return;
    }
 
    cout << "(";
    print_tree(v->left);
    cout << "[" << v->element << "]";
    cout << "(";
    print_tree(v->right);
    if(v->par != NULL) cout << ")";
    return;
}
 
void sum_tree(node *v1, node *v2, node *v3){
    v3->element = v1->element + v2->element;
 
    if(v1->left != NULL && v2->left != NULL && v1->left->element != -1 && v2->left->element != -1){
        node *add = (node *)malloc(sizeof(node));
        add->element = -1;
        add->left = NULL;
        add->right = NULL;
        add->par = v3;
        v3->left = add;
        sum_tree(v1->left, v2->left, v3->left);
    }
     
    if(v1->right != NULL && v2->right != NULL && v1->right->element != -1 && v2->right->element != -1){
        node *add = (node *)malloc(sizeof(node));
        add->element = -1;
        add->left = NULL;
        add->right = NULL;
        add->par = v3;
        v3->right = add;        
        sum_tree(v1->right, v2->right, v3->right);
    }
     
    //if(v->par != NULL) cout << ")";
    return;
     
}
 
int main(){
 
    string s1, s2; cin >> s1 >> s2;
    tree *T1 = create();
    tree *T2 = create();
    tree *T3 = create();    
    make_tree(T1, s1);
    make_tree(T2, s2);
    sum_tree(T1->root, T2->root, T3->root); 
    print_tree(T3->root);
    cout << endl;
    return 0;
}


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

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;
static const long long LINF = (long long)(1e18+99);
static const int INF = 1000000099;

//かいせつ

ll n, k, to[61][200005];
 
int main(void) {
  cin >> n >> k;
  rep(i, 0, n) {
    scanf("%lld", &to[0][i]);
    to[0][i]--;
  }
  
  rep(i, 1, 61) rep (j, 0, n) {
    to[i][j] = to[i-1][to[i-1][j]];
  }
  
  ll x = 0;
  for(int i=60; i>=0; i--) {
    if (k&(1LL<<i)) {
      x = to[i][x];
    }
  }
  
    cout << x+1 << endl;
    return 0;
}


Measured memory_bytes: 99004
def is_prime(num):
    if   num == 2:
        return True
    elif num % 2 == 0:
        return False
    else:
        for i in range(3,int(num**0.5)+1,2):
            if num % i == 0:
                return False
        return True

n = int(input())
ans = 0

for _ in range(n):
    num = int(input())
    if is_prime(num):
        ans += 1
print(ans)


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

using namespace std;
typedef long long ll;

ll MOD = 1000000007;

ll fact[2001], factinv[2001];

ll modpow(ll a, ll b) {
	ll ret = 1, kakeru = a;
	while (b > 0) {
		if (b & 1)ret *= kakeru, ret %= MOD;
		kakeru *= kakeru, kakeru %= MOD;
		b >>= 1;
	}
	return ret;
}

void build() {
	fact[0] = 1;
	fact[1] = 1;
	factinv[0] = 1;
	factinv[1] = 1;
	for (int i = 2; i <= 2000; i++) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= MOD;
		factinv[i] = modpow(fact[i], MOD - 2);
	}

}

ll comb(int a, int b) {
	//if (a == b - 1)return 1;
	if (a < b)return 0;
	ll ret = fact[a] * factinv[b];
	ret %= MOD;
	return (ret * factinv[a - b]) % MOD;
}

int main() {
	build();

	int N, K;
	cin >> N >> K;
	cout << N - K + 1 << endl;
	for (int i = 2; i <= K; i++) {
		cout << comb(K - 1, i - 1) * (comb(N - K - 1, i - 2) + 2 * comb(N - K - 1, i - 1) + comb(N - K - 1, i)) % MOD << endl;
	}
	return 0;
}

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

#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int x[n],a[n],c,d;
    for(int i=0;i<n;i++){
    	cin>>x[i];
    	a[i]=x[i];
    }
    sort(a,a+n);
    c=a[(n/2)-1];
    d=a[n/2];
    for(int i=0;i<n;i++){
    	if(x[i]>=d){
    		cout <<c<<endl;
    	}
    	else{
    		cout << d<<endl;
    	}
    }


    

    return 0;
}


Measured memory_bytes: 3712
/*
 * shubhamg931 - Shubham Gupta (B.Tech - IT, 2016-2020 batch)
*/

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

#define mod 1000000007
#define MAXN 500005
#define PI 3.14159265
#define pb push_back
#define eb emplace_back
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define FILE_READ freopen("input.txt","r",stdin);
#define FILE_WRITE freopen("output.txt","w",stdout);
#define mp(a,b) make_pair(a,b)
#define mset(arr,val) memset(arr,val,sizeof arr)
#if 0
typedef long long let;
#else
typedef int let;
//Dont judge me. I am a Javascript Dev! :P
#endif
typedef unsigned long long ull;
typedef long ld;
typedef long double ldo;
typedef pair<let, let> pll;


int main(){
    FAST
    let d, m, i, j;
    cin>>m>>d;

    let ans = 0;
    for(i=22;i<=d;++i){
        let x = i/10, y = i%10;
        if(x*y <= m and x*y > 0 and x>1 and y >1){
//            cout<<x<<y;
            ans++;
        }
    }
    cout<<ans;

    return 0;
}

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

int main() {
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  ll area = (ll)h * (ll)w;
  double div = (double)area / 2.0;
  int method;
  if (2 * x == w && 2 * y == h) {
    method = 1;
  } else {
    method = 0;
  }

  printf("%.10lf %d\n", div, method);
}

Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n, l; cin >> n >> l;
	int s = 0;
	int mn = 1000;
	rep(i, n)
	{
		int a = l + i;
		s += a;
		if (abs(mn) > abs(a))mn = a;
	}
	cout << s - mn << endl;
}

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

int l[8];
int n, a, b, c;

int dfs(int depth, int aval, int bval, int cval) {
	//終端でないなら
	if (depth < n) {
		int ptrA = 0, ptrB = 0, ptrC = 0,ptrN=0;
		ptrA = aval == 0 ? dfs(depth + 1, l[depth], bval, cval) : dfs(depth + 1, aval + l[depth], bval, cval) + 10;
		ptrB = bval == 0 ? dfs(depth + 1, aval, l[depth], cval) : dfs(depth + 1, aval, bval + l[depth], cval) + 10;
		ptrC = cval == 0 ? dfs(depth + 1, aval, bval, l[depth]) : dfs(depth + 1, aval, bval, cval + l[depth]) + 10;
		ptrN = dfs(depth + 1, aval, bval, cval);
		return min(min(ptrA,ptrN), min(ptrB, ptrC));
	}

	//終端なら
	if (depth == n) {
		if (aval == 0 || bval == 0 || cval == 0) return 99999;
	return abs(aval - a) + abs(bval - b) + abs(cval - c);
	}
}

int main()
{
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	cout << dfs(0, 0,0,0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {char ch = getchar(); ll x = 0, f = 1;while(ch < '0' || ch > '9') {if(ch == '-') f = -1;ch = getchar();}while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0';ch = getchar();} return x * f;}
int fastmi(int i,int b,int p){ll ans=1,now=i;while (b)	{if (b&1)  ans=now*ans%p;now=now*now%p;b>>=1;}return ans;}
const int kcz=1e9+7;
const int N=2005;
const int M=4e6+7;
ll f[N][N],mi[M],inv[M],jv[M];
ll C(int n,int m){
	return mi[m]*jv[n]%kcz*jv[m-n]%kcz;}
int main(){
	int n=read(),k=read();
	if (k==1) {printf("1");return 0;}
	
	mi[0]=1;
	inv[0]=1;
	inv[1]=1;
	jv[1]=jv[0]=1;
	for (int i=1;i<=n*k;i++) mi[i]=mi[i-1]*i%kcz;
	for (int i=2;i<=n*k;i++) inv[i]=inv[kcz%i]*(kcz-kcz/i)%kcz;
	for (int i=2;i<=n*k;i++) jv[i]=jv[i-1]*inv[i]%kcz;
	
	
	f[0][0]=1;
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<=i;j++)
		{
			f[i][j]=(f[i][j]+f[i-1][j])%kcz;
			if (j)
				f[i][j]=(f[i][j]+f[i][j-1]*(n-j+1)%kcz*C(k-2,n-i+(n-j+1)*(k-1)-1))%kcz;
		}
	}
	printf("%lld",f[n][n]);
}


Measured memory_bytes: 125312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 * 2;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	ll out = 0;
	cout << min(a + b + 1 + b, b + c) << endl;
}


Measured memory_bytes: 3588
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = sc.nextInt();
		Arrays.sort(A);
		int count = 1;
		int ans = 0;
		for (int i = 0; i < N - 1; i++) {
			if (A[i] == A[i + 1])
				count++;
			else {
				ans += count % 2;
				count = 1;
			}
		}
		System.out.println(ans+count%2);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 23508
# -*- coding: utf-8 -*-

import heapq


class MaxHeap:
    def __init__(self, li):
        self.heap = [-e for e in li]
        heapq.heapify(self.heap)

    def push(self, val):
        heapq.heappush(self.heap, -val)

    def pop(self):
        return -heapq.heappop(self.heap)

    def __len__(self):
        return len(self.heap)


n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort()

h = MaxHeap([])

i = 0
ans = 0
for day in range(1, m + 1):
    while i < n and ab[i][0] <= day:
        h.push(ab[i][1])
        i += 1
    if len(h) == 0:
        continue
    ans += h.pop()

print(ans)


Measured memory_bytes: 31684
#ifndef LOCAL
#pragma GCC optimize ("O3")
#endif
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define mor > muu & operator << (
#define R22(r) sim > typename \
  enable_if<1 r sizeof dud<c>(0), muu&>::type operator<<(c g) {
sim > struct rge { c b, e; };
sim > rge<c> range(c h, c n) { return {h, n}; }
sim > auto dud(c* r) -> decltype(cerr << *r);
sim > char dud(...);
struct muu {
#ifdef LOCAL
stringstream a;
~muu() { cerr << a.str() << endl; }
R22(<) a << boolalpha << g; ris; }
R22(==) ris << range(begin(g), end(g)); }
sim, class b mor pair < b, c > r) { ris << "(" << r.first << ", " << r.second << ")"; }
sim mor rge<c> u) {
  a << "[";
  for (c i = u.b; i != u.e; ++i)
    *this << ", " + 2 * (i == u.b) << *i;
  ris << "]";
}
#else
sim mor const c&) { ris; }
#endif
muu & operator()() { ris; }
};
#define imie(r...) "[" #r ": " << (r) << "] "
#define imask(r...) "[" #r ": " << bitset<8 * sizeof(r)>(r) << "] "
#define arr(a, i) "[" #a imie(i) ": " << a[i] << "] "
#define arr2(a, i, j) "[" #a imie(i) imie(j) ": " << a[i][j] << "] "
#define debug (muu() << __FUNCTION__ << "#" << __LINE__ << ": ")

const int N = 1e5 + 7;
int h[N];
int dp[N];
int n;

int main() {
    dp[0] = 1e9 + 7;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &h[i]);
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        if (i > 1) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        else dp[i] = 0;
    }
    printf("%d\n", dp[n]);
    return 0;
}


Measured memory_bytes: 1024
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll mod9 = 1000000009;

signed main(){
    ll n;
    cin>>n;
    string a;
    if(n%10==3) a = "bon";
    else if((n%10 == 0) || (n%10 == 1) || (n%10 == 6) || (n%10 == 8)) a = "pon";
    else a = "hon"; 
    cout<<a<<endl;
}


Measured memory_bytes: 3628
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a,b,c;
  cin>>a>>b>>c;
  int si,si2,si3;
  si=a.size();
  si2=b.size();
  if(a[si-1]==b[0] && b[si2-1]==c[0]){
    cout<<"YES"<<'\n';
  }
  else{
    cout<<"NO"<<'\n';
  }
  return(0);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int H,W,i,j,ans1,ans2;
	for(;;){
		cin>>H>>W;
		if(H==0&&W==0){
			break;
		}
		for(i=1;i<=H;i++){
			ans1=i/2*2;
			for(j=1;j<=W;j++){
				ans2=j/2*2;
				if((ans1!=i)!=(ans2!=j)){
					cout<<".";
				}else{
					cout<<"#";
				}
			}
			cout<<endl;
		}
		cout<<endl;
	}
		return 0;
	}

Measured memory_bytes: 3084
n,m = map(int,input().split())
a = set([int(input()) for _ in range(m)])
dp=[0]*(n+1)
dp[0]=1
dp[1]=0 if 1 in a else 1
for i in range(2,n+1):
  dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
  if i in a: dp[i]=0

print(dp[n])

Measured memory_bytes: 13216
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

import sys
sys.setrecursionlimit(4100000)
rl = sys.stdin.readline

A,B,C,K  =Ints()

if K<=A:
    print(K)
elif A < K and K<=A+B:
    print(A)
else:
    print(2*A+B-K)

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

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

int main() {
  int h,w;
  cin >> h >> w;
  
  vector<int> skipH;
  vector<int> skipW;  
  skipH.push_back(999);
  skipW.push_back(999);
  
  vector<vector<string>> vec(h, vector<string>(w));
  for(int i = 0; i < h; i++){
    string str;
    cin >> str;
    for(int j = 0; j < w; j++){
      vec.at(i).at(j) = str.substr(j,1);
    }
  }
  
  bool chk = true;
  for(int i = 0; i < h; i++){
    chk = true;
    for(int j = 0; j < w; j++){
      if(vec.at(i).at(j) == "#"){
        chk = false;
        break;
      }
    }
    
    if(chk == true){
      skipH.push_back(i);
    }      
  }
  
  for(int i = 0; i < w; i++){
    chk = true;
    for(int j = 0; j < h; j++){
      if(vec.at(j).at(i) == "#"){
        chk = false;
        break;
      }
    }
    
    if(chk == true){
      skipW.push_back(i);
    }
  }
    
  bool exists;
  for(int i = 0; i < h; i++){
    exists = find(skipH.begin(), skipH.end(), i) != skipH.end();
    if(exists == true){
      continue;
    }
    
    for(int j = 0; j < w; j++){
      exists = find(skipW.begin(), skipW.end(), j) != skipW.end();
      if(exists == true){
        continue;
      }
      cout << vec.at(i).at(j);
    }
    cout << endl;
  }
}


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

#define int long long
signed main(){
    long n,l;
    long ans;
    double x;
    cin >>n>>x;
    l=n;
    ans=0;
    while(x!=0){
        if(x == pow(2,l+2)-3){
            ans+=long(pow(2,l+1))-1;
            break;
        }
        if(x<pow(2,l+1)-1){
            x-=1;
            l-=1;
        }else{
            x-=pow(2,l+1)-1;
            ans+=long(pow(2,l));
            l-=1;

        }
    }
    cout << ans;
    return 0;

  
    
}

Measured memory_bytes: 512
function main()
  
  (L,R) = map(x -> parse(Int,x), split(readline()))
  
  ans = 10^10
  
  if R-L+1 >= 2019
    ans = 0
  else
    for i in L:R-1
      for j in i+1:R
        ans = min(ans,(i*j) % 2019)
      end
    end
  end
  
  println(ans)
  
end

main()

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

int main() {
  int n;
  cin >> n;
  int m;
  set<int> d;
  for(int i=0; i<n; i++){
    cin >> m;
    d.insert(m);
  }
  cout << d.size() << endl;
  return 0;
}


Measured memory_bytes: 256
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for _ in range(D)]

last=[0]*26


for d in range(1,D+1):
    ans=[]
    for choice in range(1,27):
        ans_tmp=0
        ans_tmp+=s[d-1][choice-1]
        for i in range(26):
            if i+1==choice:
                continue
            ans_tmp-=c[i]*(d-last[i])*(10+(D-d)//36)
        ans.append((ans_tmp,choice))
    _,case=max(ans)
    last[case-1]=d
    print(case)



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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int total_h = h2 - h1, total_m = m2 - m1;
	total_m += (total_h * 60);
	total_m -= k;
	cout << total_m << '\n';
	
	return 0;
}


Measured memory_bytes: 3656
input()
def gg(a):
	if len(a)==0:
		return 0
	m=0
	s = min(a)
	for i in range(len(a)):
		a[i] -= s
		if a[i] == 0:
			m=i
	return s + gg(a[:m]) + gg(a[m+1:])
print(gg(list(map(int,input().split()))))

Measured memory_bytes: 3060
def calc(T, x):
  return T - x * 0.006

N = int(input())
T, A = map(int, input().split())
L = list(map(int, input().split()))
l = []
for i in L:
  l.append(abs(A - calc(T, i)))

mi = min(l)
print(l.index(mi)+1)

Measured memory_bytes: 9236
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
        
        int32_t main() {
            
            ios::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
           
            vector<int > v(6);
            for(int i=1;i<6;i++){
                int x;cin>>x;
                v[x]=1;
            }
            for(int i=1;i<6;i++){
                if( v[i]==0 ){
                    cout<<i<<endl;
                    return 0;
                }
            }
            return 0;
        }

 

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

int main(int argc, char const *argv[]) {
  int N;
    std::cin >> N;
  std::vector<int> vec(N);

  for (size_t i = 0; i < N; i++) {
    std::cin >> vec.at(i);/* code */
  }
  sort(vec.begin(),vec.end());
  std::cout << vec.at(N-1)-vec.at(0) << '\n';
  return 0;
}


Measured memory_bytes: 256