akhauriyash/Code-Regression huggingface dataset:
# 1 "a.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "a.cpp"
# 1 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 1
       
# 12 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/bits/stdc++.h" 1
 #include <bits/stdc++.h>
# 13 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/assoc_container.hpp" 1
 #include <ext/pb_ds/assoc_container.hpp>
# 14 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/tree_policy.hpp" 1
 #include <ext/pb_ds/tree_policy.hpp>
# 15 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2







using namespace std;
using namespace __gnu_pbds;

using ii = pair<long long, long long>;
using vi = vector<long long>;
using vd = vector<long double>;
using vb = vector<bool>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvd = vector<vd>;
using vvb = vector<vb>;
using vvii = vector<vii>;
# 50 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
inline long long mod(const long long n, const long long m = ((long long)1e9+7)){
    return (n%m + m)%m;
}

/**
 * Euclidean GCD.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long gcd(const long long a, const long long b){
    if(a < 0 or b < 0)
        return gcd(abs(a), abs(b));
    if(a == 0)
        return b;
    return gcd(b%a, a);
}

/**
 * Euclidean derivated LCM.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long lcm(const long long a, const long long b){
    // same as a*b/gcd(a, b) but avoiding overflow.
    return a/gcd(a, b)*b;
}
# 2 "a.cpp" 2

int32_t main(){
    (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL));
    for(long long i=0; i<5; ++i){
        long long x;
        cin >> x;
        if(x != i+1)
            cout << i+1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 3556
<?php
$input = explode(' ', trim(fgets(STDIN)));
$n = (int)$input[0];
$m = (int)$input[1];

$vs = [];
for ($i=1; $i <= $n; $i++) { 
	$vs[$i]['color'] = 'w';
	$vs[$i]['path'] = [];
}

for ($j=1; $j <= $m ; $j++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	$fr = (int)$input[0];
	$to = (int)$input[1];
	$vs[$fr]['path'][] = $to;
	$vs[$to]['path'][] = $fr;
}
// var_dump($vs);

$v_count = 1;
$vs[1]['color'] = 'b';
$count = 0;
dfs($vs[1]);

function dfs($v){
	global $vs;
	global $n;
	global $v_count;
	global $count;
	if ($n === $v_count) {
		++$count;
		return;
	}
	foreach ($v['path'] as $p) {
		if ($vs[$p]['color'] === 'w') {
			$vs[$p]['color'] = 'b';
			++$v_count;
			dfs($vs[$p]);
			$vs[$p]['color'] = 'w';
			--$v_count;
		}
	}
	return;
}

echo $count;

Measured memory_bytes: 4728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    long n = sc.nextLong();
    long a = sc.nextLong();
    long b = sc.nextLong();
    long unit = a + b;
    long sum = (n / unit) * a;
    sum += Math.min(n % unit, a);
    System.out.println(sum);
  }
}

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

using namespace std;
int kol[2005][2005][2];
int pref[2005][2005][2];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, k;
    cin >> n >> k;
    int kk = 2 * k;

    for (int i = 1; i <= n; i++)
    {
        int x, y, ind;
        char c;
        cin >> x >> y >> c;
        if (c == 'B') ind = 0;
        else ind = 1;
        kol[x % kk + 1][y % kk + 1][ind]++;
    }

    for (int i = 1; i <= 2 * k; i++)
        for (int j = 1; j <= 2 * k; j++)
            for (int z = 0; z <= 1; z++)
                pref[i][j][z] = pref[i - 1][j][z] + pref[i][j - 1][z] - pref[i - 1][j - 1][z] + kol[i][j][z];

    int ans = 0;
    for (int i = 1; i <= k + 1; i++)
        for (int j = 1; j <= k + 1; j++)
            for (int z = 0; z <= 1; z++)
            {
                int k1 = pref[i - 1][j - 1][z];
                int k2 = pref[i - 1][j + k - 1][z] - k1;
                int k3 = pref[i - 1][kk][z] - k1 - k2;
                int k4 = pref[i + k - 1][j - 1][z] - k1;
                int k5 = pref[i + k - 1][j + k - 1][z] - k1 - k2 - k4;
                int k6 = pref[i + k - 1][kk][z] - k1 - k2 - k3 - k4 - k5;
                int k7 = pref[kk][j - 1][z] - k1 - k4;
                int k8 = pref[kk][j + k - 1][z] - k1 - k2 - k4 - k5 - k7;
                int k9 = pref[kk][kk][z] - k1 - k2 - k3 - k4 - k5 - k6 - k7 - k8;

                int m1 = pref[i - 1][j - 1][z ^ 1];
                int m2 = pref[i - 1][j + k - 1][z ^ 1] - m1;
                int m3 = pref[i - 1][kk][z ^ 1] - m1 - m2;
                int m4 = pref[i + k - 1][j - 1][z ^ 1] - m1;
                int m5 = pref[i + k - 1][j + k - 1][z ^ 1] - m1 - m2 - m4;
                int m6 = pref[i + k - 1][kk][z ^ 1] - m1 - m2 - m3 - m4 - m5;
                int m7 = pref[kk][j - 1][z ^ 1] - m1 - m4;
                int m8 = pref[kk][j + k - 1][z ^ 1] - m1 - m2 - m4 - m5 - m7;
                int m9 = pref[kk][kk][z ^ 1] - m1 - m2 - m3 - m4 - m5 - m6 - m7 - m8;

                ans = max(ans, k1 + m2 + k3 + m4 + k5 + m6 + k7 + m8 + k9);
            }
    cout << ans;
    return 0;
}



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

using namespace std;
using LL = long long;
using P = pair<int,int>;
const LL mod=1e9+7;
const int Max_Num=2e5+10;

LL F[Max_Num], Finv[Max_Num];

LL modpow(LL x, LL n){
	LL r=1;
	while(n){
		if(n&1) r=r*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return r;
}

LL modinv(LL x){
	LL m=mod, u=1, v=0;
	while(m){
		LL t=x/m;
		x-=t*m; swap(x,m);
		u-=t*v; swap(u,v);
	}
	u%=mod;
	if(u<0) u+=mod;
	return u;
}

void fact(){
	F[0]=1;
	rep(i,Max_Num-1){
		F[i+1]=F[i]*(i+1);
		F[i+1]%=mod;
	}
	rep(i,Max_Num) Finv[i]=modinv(F[i]);
}

LL comb(LL n, LL k){
	LL res=F[n];
	res*=Finv[k]*Finv[n-k]%mod;
	return res%mod;
}

int main(){
	fact();
	LL N, M, K;
	cin >> N >> M >> K;
	vector<LL> dist(Max_Num);
	LL ans=0;
	for(LL dx=1; dx<=N-1; dx++){
		LL res=M*M%mod*(N-dx);
		res%=mod;
		dist[dx]+=res;
	}
	for(LL dy=1; dy<=M-1; dy++){
		LL res=N*N%mod*(M-dy);
		res%=mod;
		dist[dy]+=res;
	}
	for(LL d=1; d<Max_Num; d++){
		ans+=comb(N*M-2,K-2)*dist[d]%mod*d;
		ans%=mod;
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  VVI v(n);
  vector<bool> used(n, false);
  deque<int> dq;
  int fa, fc;
  rep(i, m)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    fa = a;
    fc = b;
    v[a].pb(b);
    v[b].pb(a);
  }
  dq.pb(fa);
  dq.pb(fc);
  used[fa] = true;
  used[fc] = true;

  while (true)
  {
    int u = dq.back();
    int count = v[u].size();
    for (auto p : v[u])
    {
      if (!used[p])
      {
        dq.pb(p);
        used[p] = true;
        break;
      }
      else
      {
        count--;
      }
    }
    if (count == 0)
    {
      break;
    }
  }
  while (true)
  {
    int u = dq.front();
    int count = v[u].size();
    for (auto p : v[u])
    {
      if (!used[p])
      {
        dq.pf(p);
        used[p] = true;
        break;
      }
      else
      {
        count--;
      }
    }
    if (count == 0)
    {
      break;
    }
  }

  out(dq.size());
  rep(i, dq.size())
  {
    cout << ++dq[i] << " ";
  }
  cout << endl;
  return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  if((B - 1) % (A - 1) == 0){
    cout << (B - 1) / (A - 1) << endl;
  }
  
  else{
    cout << (B - 1) / (A - 1) + 1 << endl;
  }
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string s1,s2;

int main()
{
	in>>s1>>s2;
	if(s1[0]==s2[2]&&s1[1]==s2[1]&&s1[2]==s2[0])
	{
		out<<"YES"<<std::endl;
	}
	else{out<<"NO"<<std::endl;}
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  if(S.at(0)==S.at(1)){
    cout << "Bad" << endl;
  }
  else if (S.at(1)==S.at(2)){
    cout << "Bad" << endl;
  }
  else if (S.at(2)==S.at(3)){
    cout << "Bad" << endl;
  }
  else{
    cout << "Good" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
//#define DEBUG


int main(void)
{
  ll K,N;
  cin >> K >> N;
  vector<ll> A(N),diffA(N);
  rep(i,N){
    cin >> A[i];
//    cout << A[i] << endl;
  }
  rep(i,N){
    if(i==N-1){
      diffA[i] = K-A[i] + A[0];
    }else{
      diffA[i] = A[i+1]-A[i];
    }
  }
  // 最小値とitrを取得
  vector<ll>::iterator iter = max_element(diffA.begin(), diffA.end());
  size_t index = std::distance(diffA.begin(), iter);
//  cout << "max=" << diffA[index];// << "iter=" << *iter << endl;
  // 最長の道を通らなければよい。
  cout << K-diffA[index];
    
  return 0;
} 

Measured memory_bytes: 3328
// D - String Formation
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)

int main(){
	string S; int Q; cin>>S>>Q;

	int st,ed,len,cnt=0;

	string a(Q,'-');
	len = S.size();
	st = Q;
	ed = st + len;
	S = a + S + a;

	rp(i,0,Q){
		int t; cin>>t;
		if(t-1){//type2
			int f; char c; cin>>f>>c;

			if(cnt%2){//odd:reverse
				if(f-1) S[--st] = c;//f2
				else S[ed++] = c;//f1
			}
			else{//even
				if(f-1) S[ed++] = c;//f2
				else S[--st] = c;//f1
			}

		}
		else cnt++;//type1
	}

	if(cnt%2) irp(i,ed-1,st-1)cout<<S[i];//odd:reverse
	else rp(i,st,ed)cout<<S[i];//even
	puts("");
}

Measured memory_bytes: 1496
/**
 *     author: qodjf
 *     created: 04.23.2020 10:54:12
 */
#include <bits/stdc++.h>
using namespace std;

#define mst(x, a) memset(x, a, sizeof(x))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
constexpr ll MOD = 1e9 + 7;

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

int N;
vector<int> a;

bool check() {
  map<int, int> cnt;
  for (int i = 0; i < N; i++) {
    cnt[a[i]]++;
  }

  if (cnt.size() > 2) {
    return false;
  }

  if (cnt.size() == 1) {
    int C = cnt.begin()->first;
    return C == N - 1 || N >= C * 2;
  }

  int minVal = cnt.begin()->first;
  int maxVal = cnt.rbegin()->first;
  if (maxVal != minVal + 1) {
    return false;
  }

  int C = maxVal;
  return C > cnt.begin()->second &&
         N >= (C - cnt.begin()->second) * 2 + cnt.begin()->second;
}

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

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

  if (check()) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int a[MAXN];
bool cmp(int a,int b)
{
    return a > b;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    long long sum = 0;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a,a+n,cmp);
    if(n == 2)
        sum = a[0];
    else{
        sum = a[0];
        for(int i = 1; i < n/2; i++)
        {
            sum += a[i] * 2;
//            cout << "sum" << sum << endl;
        }
        if(n%2==1)
            sum += a[n/2];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4376
X = int(input())
a = 0
while True:
    a5 = a**5
    d  = X-a5
    if d >= 0:
        c  = d**0.2
        b1 = int(c)
        b2 = b1+1
        if a5 + b1**5 == X:
            print(a,-b1)
            break
        if a5 + b2**5 == X:
            print(a,-b2)
            break
    else:
        c = ((-d)**0.2)
        b1 = int(c)
        b2 = b1+1
        if a5 - b1**5 == X:
            print(a,b1)
            break
        if a5 - b2**5 == X:
            print(a,b2)
            break
    a += 1

Measured memory_bytes: 9304
import heapq
import sys
input = sys.stdin.readline


def dijkstra(start: int, graph: list) -> list:
    """dijkstra法: 始点startから各頂点への最短距離を求める
    計算量: O((E+V)logV)
    """
    INF = 10 ** 18
    n = len(graph)
    dist = [INF] * n
    dist[start] = 0
    q = [(0, start)] # q = [(startからの距離, 現在地)]
    while q:
        d, v = heapq.heappop(q)
        if dist[v] < d:
            continue
        for nxt_v, cost in graph[v]:
            if dist[v] + cost < dist[nxt_v]:
                dist[nxt_v] = dist[v] + cost
                heapq.heappush(q, (dist[nxt_v], nxt_v))
    return dist
  

n, m, s = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]
INF = 10 ** 18

graph = [[] for i in range(n)]
for a, b, cost in info:
    graph[a].append((b, cost))

dist = dijkstra(s, graph)
for i in range(n):
    if dist[i] == INF:
        print("INF")
    else:
        print(dist[i])


Measured memory_bytes: 163044
#import sys
#input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, K = map(int, input().split())
S = list(input())
S = [int(i) for i in S]

L = [0]
R = [0]

for i in range(N):
	if S[i] == 0:
		if i == N - 1:
			L.append(i + 1)
		elif S[i + 1] == 1:
			L.append(i + 1)
	if S[N - i -1] == 0:
		if i == N - 1:
			R.append(i + 1)
		elif S[N - i -2] == 1:
			R.append(i + 1)

ans = 0
M = len(L) - K

if M <= 0:
	ans = N
	
for i in range(M):
	tmp = N - L[i] - R[M - i - 1]
	if tmp > ans:
		ans = tmp

print(ans)


Measured memory_bytes: 51064
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <unordered_set>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
#define ll long long
#define pi (acos(-1))
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
int main()
{
    int x, n;
    cin >> x >> n;
    vec<int> v(n);
    rep(i, n) { cin >> v[i]; }
    int d = 0;
    int ans;
    while (true)
    {
        if (v.end() == find(all(v), x - d))
        {
            ans = x - d;
            break;
        }
        else if (v.end() == find(all(v), x + d))
        {
            ans = x + d;
            break;
        }
++d;
    }
    cout<<ans<<endl;


    return 0;
}

ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, pl> lpl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

ll N, K;
ll ans[100000][3];
lpl hoge[100000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    rep(i,N) {
        ans[i][1] = K+N+i;
        ans[i][0] = K+N-1-i;
    }
    ll st = 0, en = (N-1)/2;
    while (st < en) {
        swap(ans[st][0], ans[en][0]);
        st++; en--;
    }
    st = (N-1)/2+1; en = N-1;
    while (st < en) {
        swap(ans[st][0], ans[en][0]);
        st++; en--;
    }
    rep(i,N) {
        hoge[i] = lpl(ans[i][0]+ans[i][1], pl(ans[i][0],ans[i][1]));
    }
    sort(hoge, hoge+N);
    rep(i,N) {
        if (hoge[i].first > K+2*N+i) {
            cout << -1 << endl;
            return 0;
        }
    }
    rep(i,N) {
        cout << hoge[i].second.first << " " << hoge[i].second.second  << " " << K+2*N+i << endl;
    }
}

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

int main(){
    string s, t;
    cin >> s >> t;

    int count = 0;
    for(int i=0; i<3; i++){
        if(s[i] == t[i]) count += 1;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const ll MOD = 1e9+7;
const ll N = 1e6+5;

ll fastpow(ll n, ll p){
	ll res = 1;
	while(p){
		if(p&1) res = (res * n) % MOD;
		n = (n * n) % MOD;
		p>>=1;
	}
	return res;
}
int main()
{
    fio;
    ll n;
	cin >> n;
	cout << (((fastpow(10,n)+fastpow(8,n)+MOD)%MOD-fastpow(9,n)+MOD)%MOD-fastpow(9,n)+MOD)%MOD << "\n";
    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<bitset>
using namespace std;

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

    vector<vector<int>> s(N, vector<int>());
    for (int i = 0; i < M; i++) {
        int k;
        cin >> k;

        for (int j = 0; j < k; j++) {
            int n;
            cin >> n;

            n--;

            s[n].push_back(i);
        }
    }
    
    vector<int> p(M);
    for (int i = 0; i < M; i++)
        cin >> p[i];
    
    int ans = 0;
    for (int i = (1 << N) - 1; i >= 0; i--) {
        bitset<10> state(i);
        vector<int> cnt(M, 0);
        for (int j = 0; j < N; j++) {
            if (state[j] == false)
                continue;

            for (auto index : s[j])
                cnt[index]++;
        }

        bool ok = true;
        for (int j = 0; j < M; j++) {
            ok &= (cnt[j] % 2 == p[j]);
        }

        if (ok == true)
            ans++;
    }

    cout << ans << endl;

    return 0;
}


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

int a, b, m;
int am, bm;
int A[100005], B[100005];
void input() {
    am = bm = 1e9;
    cin >> a >> b >> m;
    for (int i = 1; i <= a; i++) {
        cin >> A[i];
        am = min(am, A[i]);
    }
    for (int i = 1; i <= b; i++) {
        cin >> B[i];
        bm = min(bm, B[i]);
    }
    int ans = am + bm;
    for (int i = 1; i <= m; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        ans = min(ans, A[x] + B[y] - c);
    }
    cout << ans;
}

void calc() {
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    input();
    calc();
    return 0;
}

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

int main(){
    string S, Smul;
    string S1, S2;
    cin >> S;
    S1 = "s";
    S2 = "es";
    int len = S.length();
    if (S[len - 1] != 's') {
        Smul = S + S1;
    } else {
        Smul = S + S2;
    }
    cout << Smul;
    return 0;
}

Measured memory_bytes: 3588
N = int(input())
li = list()
for i in range(N):
    Ai = int(input())
    Alist = list()
    for j in range(Ai):
        x,y = map(int,input().split())
        Alist.append([x-1,y])
    li.append(Alist)
num =(2**(N))
while True:
    ok = True
    num -=1
    numlist = format(num, 'b')
    #print(list(numlist))
    zero = str()
    if N != len(numlist):
        for i in range(N-len(numlist)):
            zero += "0"

        numlist = zero + numlist
    #print(numlist)
    for i in range(len(numlist)):
        if numlist[i] == "1":
            for j in range(len(li[i])):
                if int(numlist[li[i][j][0]]) != li[i][j][1]:
                    ok = False
                    break
        if ok == False:
            break
    if ok == True:
        print(numlist.count("1"))
        break
    if num == 0:
        print(0)
        break


Measured memory_bytes: 3064
from itertools import *
def f(s):
 if sum(s)==10:return"((({} + {}) + {}) + {})".format(*s)
 for a,b,c,d in permutations(s):
  for x,y,z in permutations('+-*'*2,3):
   for t in[f"({a} {x} {b}) {y} ({c} {z} {d})",f"(({a} {x} {b}) {y} {c}) {z} {d}",f"({a} {x} ({b} {y} {c})) {z} {d}"]:
    if eval(t)==10:return'('+t+')'
 else:return 0
for e in iter(input,'0 0 0 0'):print(f(list(map(int,e.split()))))


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, l;
    cin >> n >> l;

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    for (auto i : irange(0L, n - 1)) {
        if (a[i] + a[i + 1] >= l) {
            cout << "Possible" << endl;
            for (auto j : irange(0L, i)) {
                cout << j + 1 << "\n";
            }
            for (auto j : irange(i + 1, n - 1) | reversed) {
                cout << j + 1 << "\n";
            }
            cout << i + 1 << endl;
            return 0;
        }
    }

    cout << "Impossible" << endl;
}

Measured memory_bytes: 1664
/*---------------------------*\
____________Mari000____________         
________Mostafa  Shehab________    
\*---------------------------*/
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
typedef long long ll;
typedef long double ld;
//template <class Type>
 
ll power(ll x,ll y,ll p);
int Bit(ll x);
 
void Fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}
 
inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}
 
const int N=1e6 + 5;
int arr[N];
bool visit[N];
 
ll n,m,k,a,b,c,cnt,sz,len;
ll l,r,mid;
ll MN,MX,SU;
 
 
ll GCD(ll a,ll b){
	return b ? GCD(b,a%b) : a;
}
 
vector<int> vec;
void seive(){
	visit[1]=true;
	for(int i=2;i<N;++i){
		if(visit[i])
			continue;
		for(ll j=1ll*i*i;j<N;j+=i)
			visit[j]=true;
	}
}


 
int main(){
	scanf("%d%d%d",&n,&m,&k);
	puts(n+m >= k ? "Yes" : "No");
}
 
 
 
 
 
 
 
 
 
ll power(ll x,ll y,ll p){ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
    while (y > 0){ 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;
    }
    return res; 
}
 
 
int Bit(ll x){
	if(!x)
		return 0;
	return 1+Bit(x>>1);
}
 
// 408

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

#define rep(i, n) for (int i=0; i< (n); ++i)
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;

int main() {
    string s;

    cin >> s;

    rep(i, s.length()) cout << "x";
    cout << endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0; i<N; i++) cin >> d[i];
    
    sort(d.begin(), d.end());
    d.erase(unique(d.begin(),d.end()), d.end());
    
    cout << d.size() << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <map>

long long euclid(long long a, long long b){
  long long red = a % b;
  if (red == 0){
    return b;
  } else {
    return euclid(std::max(red, b),std::min(red, b));
  }
}

bool is_prime(long long a){
  bool ans = false;
  if (a==1){
    return ans;
  }
  for (long long i=2; i<=sqrt(a); i++){
    if (a%i==0){
      ans = false;
    }
  }
  return ans;
}

int main(){
  long long A, B;
  scanf("%lld %lld",&A, &B);
  long long c = euclid(std::max(A,B),std::min(A,B));
  /*if (is_prime(c)){
    printf("2\n");
    return 0;
  }*/
  //printf("c=%d\n",c);
  long long ans=1; //1は回答の前提としておく
  long long root_c = (long long)(sqrt(c))+1;
  //printf("root_c+1=%lld\n",root_c+1);
  for (long long i=2; i<=std::min(c,root_c); i++){
      //printf("i=%lld\n",i);
      if (c%i==0){
        //printf("i=%lld\n",i);
        ans++;
        c = c/i;
        while(c%i==0){
          c = c/i;
       }
      }
  }
  
  if (c!=1){
    ans++;
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {

    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
    }

    sort(all(a));
    reverse(all(a));

    ll ans = 0;
    rep(i, n){
        if(k > 0){
            k--;
        }
        else{
            ans += a[i];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
string s;
ll k;
vector<ll> x;
int main(){
    cin>>s>>k;
    for(int i=0;i<(int)s.size();i++){
        int j=i;
        while(j<(int)s.size() && s[i]==s[j]) j++;
        x.pb(j-i);
        i=j-1;
    }
    if(x.size()==1){
        cout<<(int)s.size()*k/2<<endl;
        return 0;
    }
    if(s[0]==s[(int)s.size()-1]){
        ll ans=0;
        for(int i=1;i<(int)x.size()-1;i++)
            ans+=k*(x[i]/2);
        ans+=(k-1)*((x[0]+x[(int)x.size()-1])/2);
        ans+=x[0]/2+x[x.size()-1]/2;
        cout<<ans<<endl;
    }
    else{
        ll ans=0;
        for(int i=0;i<(int)x.size();i++)
            ans+=k*(x[i]/2);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
 
s = [ i for i in S]
flag = True
 
if N % 2 == 1:
    print("No")
    flag = False
else:
    for j in range(int(N/2)):
        if s[j] != s[j+int(N/2)]:
            print("No")
            flag = False
if flag:
    print("Yes")

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	int pn = 1;
	if (*ci == '-') {
		pn = -1;
		ci++;
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return pn * tmp;
}

int L[200001], R[200001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();

	rep(i, N) {
		L[getint() + 100000]++;
		R[getint() + 100000]++;
	}

	ll kotae = -200000, kotae2 = 0;
	int l = 200000;
	int r = 0;

	while (l > r) {
		kotae += (l - r);
		while (r <= 200000 && !R[r]) r++;
		while (l >= 0 && !L[l]) l--;
		R[r]--;
		L[l]--;
		if (kotae2 < kotae + max(100000 - r, l - 100000)) {
			kotae2 = kotae + max(100000 - r, l - 100000);
		}
	}

	printf("%lld\n", 2 * max(kotae, kotae2));

	Would you please return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int A[n];
	for (int i = 0; i < n; i++)
		cin >> A[i];
	for (int i = 0; i < n/2; i++)
		swap(A[i], A[n-1-i]);
	for (int i = 0; i < n; i++)
	{
		cout << A[i];
		if (i < n - 1) 
			cout << " ";
	}
	cout << endl;
	return 0;
}




Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, L;
    cin >> N >> L;
    ll zero = 1e9;
    ll sum = 0;
    for(int i = 1; i <= N; i++) {
        ll a = L + i - 1;
        if(abs(zero) > abs(a)) zero = a;
        sum += a;
    }
    cout << sum - zero << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define vout(v) for(int i=0;i<(int)v.size()-1;i++){cout<<v[i]<<" ";}cout<<v[v.size()-1]<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define debg(a) cerr<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
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;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
vector <ll> dp;


void solve(long long ABCD){
    ll a=ABCD/1000,b=ABCD%1000/100,c=ABCD%100/10,d=ABCD%10;
    if(a+b+c+d==7) { cout << a << '+' << b << '+'  << c << '+' << d << "=7" << "\n"; return;}
    if(a+b+c-d==7) { cout << a << '+' << b << '+'  << c << '-' << d << "=7" << "\n"; return;}
    if(a+b-c+d==7) { cout << a << '+' << b << '-'  << c << '+' << d << "=7" << "\n"; return;}
    if(a+b-c-d==7) { cout << a << '+' << b << '-'  << c << '-' << d << "=7" << "\n"; return;}
    if(a-b+c+d==7) { cout << a << '-' << b << '+'  << c << '+' << d << "=7" << "\n"; return;}
    if(a-b+c-d==7) { cout << a << '-' << b << '+'  << c << '-' << d << "=7" << "\n"; return;}
    if(a-b-c+d==7) { cout << a << '-' << b << '-'  << c << '+' << d << "=7" << "\n"; return;}
    if(a-b-c-d==7) { cout << a << '-' << b << '-'  << c << '-' << d << "=7" << "\n"; return;}
}

int main(){
    long long ABCD;
    scanf("%lld",&ABCD);
    solve(ABCD);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
 public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  int a = Integer.parseInt(sc.next());
  int b = Integer.parseInt(sc.next());
  sc.close();

  System.out.println( a*b + " " + (2*a + 2*b) );
 }
}


Measured memory_bytes: 25760
import datetime
while True:
    y1,m1,d1,y2,m2,d2=map(int,raw_input().split())
    if y1==m1==d1==y2==m2==d2==-1:break
    a=datetime.datetime(y1,m1,d1)
    b=datetime.datetime(y2,m2,d2)
    print (b-a).days

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

using namespace std;

int main() {
    string s;
    int cnt = 1e9;
    cin >> s;
    int ss = s.size();
    for(int i = 0; i < 2; i++) {
        int tmp = 0;
        for(int j = 0; j < ss; j++) {
            if(j % 2 == 0) {
                if(s[j] == '0' + i) tmp++;
            } else {
                if(s[j] == '0' + (i ^ 1)) tmp++;
            }
        }
        cnt = min(cnt, tmp);
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >> N;
	int flag = false;
	for(int i = 1; i<=sqrt(N); i++){
		if(N%i == 0){
			int an = N/i;
			if(an>0 && an<=9 && i>0 && i<=9){
				flag = true;
			}
		}
	}
	if(flag) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
N = int(input())
s = list(map(int, input().split()))
index1 = 0
value1 = 0
index2 = 0
value2 = 0
count = 0

for i in range(N):
    if s[i]!=(i+1):
        count = count + 1
    
if count ==2 or count == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(stdR.readLine());
        String[] str = stdR.readLine().split(" ");
        String[] str2 = stdR.readLine().split(" ");
        int res = 0;
        for(int i = 0 ; i < N ; i++) {
            int V = Integer.parseInt(str[i]);
            int C = Integer.parseInt(str2[i]);
            if(V > C) {
                res += V - C;
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 22612
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BMysteriousLight solver = new BMysteriousLight();
        solver.solve(1, in, out);
        out.close();
    }

    static class BMysteriousLight {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n, x;
            n = in.nextLong();
            x = in.nextLong();
            out.println(3 * (n - gcd(n, x)));
        }

        public long gcd(long n, long x) {
            if (n == 0) return x;
            return gcd(x % n, n);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 21332
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[60];
int num[30];
set<int> U;


signed main(){
	cin>>N;
	num[0]=1;
	REP(i,N){
		cin>>A[i];
		num[A[i]]++;
		if(num[A[i]]==3||num[0]==2||num[12]==2){
			cout<<0<<endl;
			return 0;
		}
	}
	int ans=0;
	REP(Bit,1LL<<12LL){
		vector<int> v={0,24};
		for(int i=1;i<=12;i++){
			if(num[i]==2){
				v.push_back(i);
				v.push_back(24-i);
			}
			else if(num[i]==1){
				if(Bit&(1LL<<i)){
					v.push_back(i);
				}
				else{
					v.push_back(24-i);
				}
			}
		}
		sort(v.begin(),v.end());
		int m=INF;
		REP(i,v.size()-1){
			m=min(m,v[i+1]-v[i]);
		}
		ans=max(m,ans);
	}
	cout<<ans<<endl;
	return 0;
}


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

const int MaxN = 10000 + 5;
const int MaxD = 100 + 5;
const int Mod = 1000000007;

int N, D;
char K[MaxN];
int Dp[MaxN][MaxD][2];
bool Vis[MaxN][MaxD][2];

inline int add(int x, int y) { return (x += y) >= Mod ? x - Mod : x; }
inline int sub(int x, int y) { return (x -= y) < 0 ? x + Mod : x; }
inline void inc(int &x, int y = 1) { x = add(x, y); }

void init() {
  scanf("%s", K + 1);
  N = strlen(K + 1);
  scanf("%d", &D);
}

int dfs(int x, int s, bool limit) {
  if (x > N) return s == 0;
  if (Vis[x][s][limit] == true) return Dp[x][s][limit];
  Vis[x][s][limit] = true;
  int mx = 9;
  if (limit == true) mx = K[x] - '0';
  for (int d = 0; d <= mx; ++d) {
    bool new_lim = limit && (d == mx);
    int new_s = (s + d) % D;
    inc(Dp[x][s][limit], dfs(x + 1, new_s, new_lim));
  }
  return Dp[x][s][limit];
}

void solve() {
  printf("%d\n", sub(dfs(1, 0, 1), 1));
}

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

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int dp[s.size()+1][t.size()+1];
	for(int i=0;i<=s.size();i++)
	{
		for(int j=0;j<=t.size();j++)
		{
			if(i==0 or j==0)
				dp[i][j]=0;
			else if(s[i-1]==t[j-1])
				dp[i][j]=1+dp[i-1][j-1];
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	//int max_len=dp[s.size()][t.size()];
	int i=s.size(),j=t.size();
	string substr;
	while(i>=1 and j>=1)
	{
		if(s[i-1] == t[j-1])
		{
			substr.push_back(s[i-1]);
			i--;j--;
		}
		else
		{
			if(dp[i-1][j]>dp[i][j-1])
				i--;
			else
				j--;
		}
	}
	reverse(substr.begin(),substr.end());
	cout<<substr;
	return 0;
}

Measured memory_bytes: 35456
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author parsa bahrami
 */

#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sz(x)                       (ll) x.size()
#define jjoin(x)                    for (auto i : x) cout << i << endl;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define sep                         ' '
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define kill(x)                     return cout << x << endl , 0;
#define Hkill(x)                    cout << x << endl; exit(0);
#define endl                        '\n'

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 2e5 + 10;
const ll MAXA = 1010;
const ll INF = 8e18;
const ll MOD = 998244353; //1e9 + 7
const ld PI = 4 * atan((ld) 1);
const ll LOG = 15;
ll cost[MAXA], SUB[MAXA][MAXA], dp[1LL << LOG], T[MAXA];

int main() {
    fast_io;
    set_random;
    ll n, m;
    cin >> n >> m;
    for (ll i = 0; i < m; i++) {
        ll b, mask = 0;
        cin >> cost[i] >> b;
        for (ll j = 0; j < b; j++) {
            cin >> SUB[i][j];
            mask |= (1LL << (SUB[i][j] - 1));
        }
        T[i] = mask;
    }
    fill(dp, dp + (1LL << LOG), INF);
    dp[0] = 0;
    for (ll i = 0; i < m; i++) {
        for (ll mask = 0; mask < (1LL << n); mask++) {
            dp[mask | T[i]] = min(dp[mask | T[i]] , dp[mask] + cost[i]);
        }
    }
    cout << (dp[(1LL << n) - 1] == INF ? -1 : dp[(1LL << n) - 1]) << endl;
    return 0;
}



Measured memory_bytes: 7552
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

typedef long long int ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


using namespace std;

int main() {
   
   int N;
   string S;
   vector <string> ans;
   cin >> N;

   REP(i,N){
      cin >>S;
      ans.push_back(S);
   }

   cout << "AC x "<< count(ALL(ans), "AC") << endl;
   cout << "WA x "<< count(ALL(ans), "WA") << endl;
   cout << "TLE x "<< count(ALL(ans), "TLE") << endl;
   cout << "RE x "<< count(ALL(ans), "RE") << endl;

}

Measured memory_bytes: 7456
#include<bits/stdc++.h>
#define endl enjoy_codeforces
int main(){
    int n;std::cin>>n;
    std::vector<int>sz={n/3,(n+2)/3,(n+1)/3};
    std::vector<std::vector<int>>g(n);
    for(int i=0;i<n-1;i++){
        int u,v;std::cin>>u>>v;u--,v--;
        g.at(u).push_back(v);
        g.at(v).push_back(u);
    }
    std::vector<int>a(n,-1);
    std::queue<int>que;
    que.push(0);
    a.at(0)=0;
    while(!que.empty()){
        int x=que.front();que.pop();
        for(int y:g.at(x)){
            if(a.at(y)==-1){
                a.at(y)=!a.at(x);
                que.push(y);
            }
        }
    }
    std::vector<int>b,c;
    for(int i=0;i<n;i++)(a.at(i)?b:c).push_back(i);
    std::vector<int>p(n);
    for(int x:{1,2}){
        if(b.size()<c.size())std::swap(b,c);
        for(int i=x;i<=n;i+=3){
            p.at(b.back())=i;
            b.pop_back();
        }
    }
    for(int i=0,j=3;i<n;i++){
        if(p.at(i)==0){
            p.at(i)=j;
            j+=3;
        }
    }
    for(int i=0;i<n;i++){
        std::cout<<(i?" ":"")<<p.at(i);
    }
    std::cout<<'\n';
}
/*
二部グラフです。
余りが 1 同士、2 同士が対岸にこないようにします。
大きい方に 1 を入れて、残りの内大きい方に 2 を入れれば良いです。
*/


Measured memory_bytes: 16884