akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const int MAXN = 120000;
const int MX = 450000;

int go[MX][26];
int cc[MX];
int fl[MX];
int nowcc = 1;
int gg[26][26];
int gg2;
int aa2[MAXN];
int aa[MAXN][26][26];
int n,q;

int newn() {
	fl[nowcc] = -1;
	return nowcc++;
}

void add(const string &s, int i) {
	int now = 0;
	for (int i = 0; i < (int)s.size(); ++i) {
		++cc[now];
		if (go[now][s[i] - 'a'])
			now = go[now][s[i] - 'a'];
		else
			now = go[now][s[i] - 'a'] = newn();
	}
	++cc[now];
	fl[now] = i;
}

void dfs1(int v) {
	if (fl[v] != -1) {
		memcpy(aa[fl[v]], gg, sizeof(gg));
		aa2[fl[v]] = gg2;
	}
	if (fl[v] != -1)
		++gg2;

	for (int i = 0; i < 26; ++i) {
		if (go[v][i]) {
			for (int j = 0; j < 26; ++j)
				if (go[v][j] && j != i) {
					gg[i][j] += cc[go[v][j]];
				}
			dfs1(go[v][i]);
			for (int j = 0; j < 26; ++j)
				if (go[v][j] && j != i) {
					gg[i][j] -= cc[go[v][j]];
				}
		}
	}

	if (fl[v] != -1)
		--gg2;
}

void build() {
	dfs1(0);
}
char buf[MX];
string s[MAXN];

int main() {
	scanf("%d", &n);
	fl[0] = -1;
	for (int i = 0; i < n; ++i) {
		scanf(" %s", buf);
		s[i] = buf;
		add(s[i], i);
	}
	build();
	scanf("%d", &q);
	for (int i = 0; i < q; ++i) {
		int k;
		scanf("%d%s", &k, buf);
		--k;
		int ans = 1 + aa2[k];
		for (int j = 0; j < 26; ++j)
			for (int l = j + 1; l < 26; ++l)
				ans += aa[k][buf[l] - 'a'][buf[j] - 'a'];
		printf("%d\n", ans);
	}
	return 0;
}




Measured memory_bytes: 280960
package main

import (
  "fmt"
)

func main() {
  var (
    n,m,c int
    tmp int
  )
  fmt.Scan(&n)
  fmt.Scan(&m)
  fmt.Scan(&c)
  b:=make([]int,m)
  for i:=0;i<m;i++{
    fmt.Scan(&b[i])
  }
  ans := make([]int,n)

  for i:=0;i<n;i++ {
    for j:=0;j<m;j++ {
      fmt.Scan(&tmp)
      ans[i] += tmp * b[j]
    }
    ans[i] += c
  }
  count := 0
  for i:=0;i<n;i++ {
    if ans[i] > 0 {
      count += 1
    }
  }
  fmt.Println(count)
}


Measured memory_bytes: 512
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<long double, long double>;
 
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  ll x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;



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

  ll n;
  std::cin>>n;

  std::vector<P> point(n);
  rep(i,0,n){
    long double a,b;
    std::cin>>a>>b;
    point[i]={a,b};
  }

  std::vector<ll> per(n);
  rep(i,0,n)per[i]=i;

  long double ans=0;

  do{
    rep(i,1,n){
      ans+=std::hypotl(point[per[i]].first-point[per[i-1]].first,point[per[i]].second-point[per[i-1]].second);
    }
  }while(std::next_permutation(all(per)));

  rep(i,1,n+1)ans/=(long double)i;

  std::cout<<std::setprecision(10)<<std::fixed<<ans;

  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 3010

ll inv[N], fac[N], finv[N];

void make()
{
	fac[0] = fac[1] = 1;
	inv[1] = 1;
	finv[1] = finv[0] = 1;
	for(int i = 2; i < N; ++i)
	{
		fac[i] = i * fac[i - 1] % MOD;
		inv[i] = MOD - MOD/i * inv[MOD % i] % MOD;
		finv[i] = inv[i] * finv[i - 1] % MOD;
	}
}

ll C(ll n, ll k)
{
	if(n < k || n < 0) return 0;
	return fac[n] * finv[n - k] % MOD* finv[k] % MOD;
}

ll gcd(ll a, ll b)
{
	if(b == 0)
		return a;
	return gcd(b, a % b);
}
string s, t;
int n1, n2;
int dp[N][N];
int p[N][N];
int dpf(int i, int j)
{
	if(i == n1 || j == n2)
		return 0;
	if(dp[i][j] >= 0)
		return dp[i][j];
	if(s[i] == t[j])
	{
		dp[i][j] = 1 + dpf(i + 1, j + 1);
		p[i][j] = 2;
	}
	else
	{
		int k1, k2;
		dp[i][j] = max(k1 = dpf(i + 1, j), k2 = dpf(i, j + 1));
		if(dp[i][j] == k1)
			p[i][j] = 1;
		else
			p[i][j] = 3;
	}
	return dp[i][j];
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	memset(dp, 0, sizeof(dp));
	// memset(s, -1, sizeof(s));
	cin >> s >> t;
	n1 = s.size(), n2 = t.size();

	int i = 0, j = 0;
	for (i = 0; i < n1; ++i)
	{
		if(s[i] == t[0])
		{
			dp[i][0] = 1, p[i][0] = 2; 
			break;
		}
	}
	while(i < n1)
		dp[i][0] = 1, p[i][0] = 2, i++;
	for (i = 0; i < n2; ++i)
	{
		if(t[i] == s[0])
		{
			dp[0][i] = 1, p[0][i] = 2;break;
		}
	}

	while(i < n2)
		dp[0][i] = 1, p[0][i] = 2, i++;
	for (int i = 1; i < n1; ++i)
	{
		for (int j = 1; j < n2; ++j)
		{
			if(s[i] == t[j])
				dp[i][j] = 1 + dp[i-1][j-1], p[i][j] = 2;
			else
			{
				dp[i][j] = max({dp[i-1][j], dp[i][j-1]});
				if(dp[i][j] == dp[i-1][j])
					p[i][j] = 1;
				else
					p[i][j] = 3;
			}
			// cout << dp[i][j] << " ";
		}
		// cout << "\n";
	}
	i = n1 - 1, j = n2 - 1;

	string an;
	while(i >= 0 && j >= 0)
	{
		if(p[i][j] == 1)
		{
			i--;
		}
		else if(p[i][j] == 2)
		{
			an += s[i];
			i--;
			j--;
		}
		else
		{
			// cout << i << " " <<  j <<"\n";
			j--;
		}
			// cout << i << " " <<  j <<"\n";
	}
	reverse(an.begin(), an.end());
	// cout << dp[n1-1][n2-1] << '\n';
	cout << an << "\n";
	return 0;
}

Measured memory_bytes: 71040
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;
    
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {
           int k;
           cin >> k;
           
           int a = 7 % k;
           
           for(int i = 1 ; i <= k; i++)
           {
                if(a % k == 0)
                {
                    cout << i << endl;
                    return 0;
                }
                a *= 10 ;
                a += 7;
                a %= k;
           }
           cout << -1 << endl;
        }
    }



Measured memory_bytes: 3628
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N;

  std::string S, T;

  std::cin >> N >> S;

  char cc = -1;

  for (const auto& c : S)
    if (c != cc)
      T.push_back(cc = c);

  std::cout << T.size() << std::endl;

  return 0;
}


Measured memory_bytes: 592
fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    val s= readLine()!!

    var x=0
    var max=0
    s.forEach {
        if(it=='I'){
            x++
            max=Math.max(max,x)
        }else{
            x--
        }
    }
    println(max)
}

Measured memory_bytes: 31908
_ = input()
A = list(map(int, input().strip().split(' ')))

def gcd(a,b):
  if b < a:
    a,b = b,a
  if b%a == 0:
    return a
  else:
    return gcd(b%a, a)

now_gcd = A[0]
for a in A[1:]:
  now_gcd = gcd(now_gcd, a)
  if now_gcd == 1:
    break
print(now_gcd)

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

#define f first
#define s second
#define ll long long
#define pb push_back
#define mp make_pair
#define inp(x) cin>>x
#define print(x) cout<<x
#define pii pair<int,int>
#define pll pair<ll,ll>
#define gcd(a,b) __gcd(a,b)
#define reset(d,val) memset(d,val,sizeof(d))
#define sort(v) sort(v.begin(),v.end())
#define sort_arr(arr,i,f) sort(arr+i,arr+f)
#define pq priority_queue<int,vector<int>,greater<int> >
#define pq1 priority_queue<pll,vector<pll>,greater<pll> >

const int mod = 1e9+7;



int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int k;
	cin>>k;
	ll sm = 0;
	for (int i = 0; i < k; ++i)
	{
		for(int j=0;j<k;j++){
			for(int x=0;x<k;x++) {
				int t = 0;
				t = gcd(j+1,t);
				t = gcd(t,x+1);
				t = gcd(t,i+1);
				sm += t;
			}
		}
	}
	cout<<sm;
	return 0;
}


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

vector<int> computePD(const vector<int>& s) {
  stack<pair<int, int> > st;  // value, index
  vector<int> PD;
  for (int i = 0, size = s.size(); i < size; i++) {
    pair<int, int> top;
    while (st.size() != 0) {
      top = st.top();
      if (top.first <= s[i]) {
        break;
      }
      st.pop();
    }

    if (st.size() == 0) {
      PD.push_back(0);
    } else {
      PD.push_back(i - top.second);
    }
    st.push(make_pair(s[i], i));
  }
  return PD;
}

int main(void) {
  int N;
  cin >> N;
  vector<int> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }
  vector<int> res = computePD(P);
  cout << count(res.begin(), res.end(), 0) << endl;
  return 0;
}

Measured memory_bytes: 3444
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 30 17:18:51 2015

@author: hirose
"""

#Repetitive Processing - Print Test Cases
i = 1
while 1:
    n = int(raw_input())
    if(n != 0):
        print 'Case %(1)d: %(2)d'  % {'1':i, '2':n}
        i += 1
    else:
        break

Measured memory_bytes: 4204
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#define _GLIBCXX_DEBUG
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int rui[240001];

int main() {
    int N; cin >> N;
    vector<int> ans;
    while(N != 0){
        vector<P> retu(N);
        for(int i = 0;i<240001;i++)rui[i] = 0;
        for(int i = 0;i<N;i++){
            string S,T;cin >> S >> T;
            string h = S.substr(0,2);
            string m = S.substr(3,2);
            string s = S.substr(6,2);
            int Hour = stoi(h)*10000;
            int Min = stoi(m)*100;
            int Sec = stoi(s);
            retu.at(i).first = Hour+Min+Sec;

            h = T.substr(0,2);
            m = T.substr(3,2);
            s = T.substr(6,2);
            Hour = stoi(h)*10000; Min = stoi(m)*100; Sec = stoi(s);
            retu.at(i).second = Hour+Min+Sec;
        }
        int count = 0;
        for(int i = 0;i<N;i++){
            rui[retu.at(i).first]++;
            rui[retu.at(i).second]--;
        }
        for(int i = 1;i<240001;i++){
            rui[i] += rui[i-1];
            count = max(count,rui[i]);
        }
        ans.push_back(count);
        cin >> N;
    }

    for(int i = 0;i<ans.size();i++)cout << ans.at(i) << endl;


    // PLEASE GIVE ME THE "ACCEPTED" !
}


Measured memory_bytes: 4216
#include <bits/stdc++.h>
#define MN 100010
using namespace std;
typedef long long LL;
int n,a[3*MN];
LL sum,ans=-(1e16+7),l[3*MN],r[3*MN];
priority_queue<int,vector<int>,greater<int> > pq;
priority_queue<int,vector<int>,less<int> > pq2;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=3*n;i++)scanf("%d",&a[i]);
    sum=0;
    for(int i=1;i<=3*n;i++)
    {
        sum+=a[i];
        pq.push(a[i]);
        while(pq.size()>n)
        {
            sum-=pq.top();
            pq.pop();
        }
        l[i]=sum;
    }
    sum=0;
    for(int i=3*n;i>=1;i--)
    {
        sum+=a[i];
        pq2.push(a[i]);
        while(pq2.size()>n)
        {
            sum-=pq2.top();
            pq2.pop();
        }
        r[i]=sum;
    }
    for(int i=n;i<=2*n;i++)
    {
        ans=max(ans,l[i]-r[i+1]);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 7032
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a[4][3][10]={0};
    int b,f,r,v,n,i,j,k;
    
    scanf("%d",&n);
    
    for (i=0; i<n; i++) {
        scanf("%d %d %d %d",&b,&f,&r,&v);
        a[b-1][f-1][r-1]+=v;
    }
    for (i=0; i<4; i++) {
        for (j=0; j<3; j++) {
            for (k=0; k<10; k++) {
                printf(" %d",a[i][j][k]);
            }
            printf("\n");
        }
        if (i!=3) {
            printf("####################\n");
        }
    }
    return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
long long ar[100010][3];
int main()
{
	long long n,i,j;
	scanf("%lld",&n);
	for(i=0;i<n;i++)
	{
		for(j=0;j<3;j++)
			scanf("%lld",&ar[i][j]);
	}
	long long dp[100010][3];
	dp[n-1][0]=ar[n-1][0];
	dp[n-1][1]=ar[n-1][1];
	dp[n-1][2]=ar[n-1][2];
	for(i=n-2;i>=0;i--)
	{
		dp[i][0]=max(dp[i+1][1]+ar[i][0],dp[i+1][2]+ar[i][0]);
		dp[i][1]=max(dp[i+1][0]+ar[i][1],dp[i+1][2]+ar[i][1]);
		dp[i][2]=max(dp[i+1][0]+ar[i][2],dp[i+1][1]+ar[i][2]);
	}
	printf("%lld\n",max(dp[0][0],max(dp[0][1],dp[0][2])));
}


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

int main(){
 string s = "keyence";
  string t;
  cin >> t;
  int num;
  
  for(int i = 0; i < 8; i++){
    num = 0;
    for(int j = 0; j < 7; j++){
      if( j < i ){
        if( t[j] != s[j]){
          num = 1;
        }
      }else{
        if( t[j + t.size() - 7 ] != s[j] ){
          num = 1;
        }
      }
    }
    if(num == 0){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
    
}

Measured memory_bytes: 256
import bisect

n = int(input())
l = list(map(int, input().split()))
l.sort()
l_copy = l.copy()
l_copy = l_copy[::-1]

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        rest = l_copy[i] - l_copy[j]
        ind = bisect.bisect_right(l, rest)
        ind = n - ind - 1
        if ind <= j:
            break
        else:
            ans += ind - j

print(ans)

Measured memory_bytes: 3188
x = int(input())

if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
elif 1800 <= x <= 1999:
    print(1)

Measured memory_bytes: 9188
import Data.List
import Debug.Trace

ans :: Int -> IO Double
ans 0 = return 0
ans n = do
  [x',u] <- words <$> getLine
  let x = read x' :: Double
  pre <- ans (n-1)
  if u == "JPY" then return $ x + pre
    else return $  x*380000 + pre


main :: IO ()
main = do
    n <- read <$> getLine :: IO Int
    answer <- ans n
    print answer


Measured memory_bytes: 636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
 
int main() {
    int N, M;
    cin >> N >> M;
 
    long int sum = 0;
    priority_queue <int> pq;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
 
        sum += a;
        pq.push(a);
    }

    // 引換券の数だけ繰り返す
    for (int i = 0; i < M; i++) {
        int a = pq.top(); pq.pop();
        pq.push(a / 2);
        sum += a / 2 - a;
    }
 
    cout << sum << endl;
 
    return 0;
}

Measured memory_bytes: 892
s = input()
n = len(s)
t = True
for i in range(n):
    if i%2 == 0:
        if s[i] == 'L':
            t = False
            break
    else:
        if s[i] == 'R':
            t = False
            break

if t:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int color[n];
    int cnt=1;
    int output=0;
    for(int i=0;i<n;i++){
        cin>>color[i];
        if(i>0&&color[i]==color[i-1]){
            cnt++;
        }else if(i>0&&color[i]!=color[i-1]){
            output=output+cnt/2;
            cnt=1;
        }
    }
    output=output+cnt/2;
    cout<<output<<endl;
    return 0;
}

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

using namespace std;

int main() {
    std :: ios :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ///cout << "debug" << endl;
    int ans = 0;
    string s, t;
    cin >> s >> t;
    for(int i = 0 ; i < s.size() ; ++i) {
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
signed main(){
  double b=0,c=0,d=1,e,f=1000000,t,g[100000];
  int a;
  cin>>a>>b>>c;
  for(int i=0;i<a;i++){
    cin>>g[i];
    e=b-(g[i]*0.006);
    if(abs(e-c)<f){
      f=abs(e-c);
      t=i+1;
    }
  }
  cout<<t<<"\n";}


Measured memory_bytes: 256
'''
Created on 2020/08/20

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  A,B,C=map(int,pin().split())
  if A==B and B==C:
    print("Yes")
    return 
  print("No")
  return 

main()

Measured memory_bytes: 9180
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def list_lcm(number_list):
    lcm_number = 1
    for j in range(len(number_list)):
        lcm_number = lcm(lcm_number, number_list[j])

    return lcm_number


if __name__ == '__main__':
    number_count = int(input())
    numbers = []
    for i in range(number_count):
        numbers.append(int(input()))
    print(int(list_lcm(numbers)))


Measured memory_bytes: 3060
// problem: "https://atcoder.jp/contests/abc159/tasks/abc159_a"

#include<bits/stdc++.h>

using namespace std;

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

    cout<<n * (n-1)/2 + m * (m-1)/2;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 100005, MAXM = 2003, Mod = 1000000007 , MAXLog = 20;

int memo[MAXM][MAXM];
int nCr(int n, int r) {
    int &ret = memo[n][r];
    if (r == 0 || r == n)
        return ret = 1;
    if (n < r)
        return ret = 0;
    if (~ret)
        return ret;
    ret = (nCr(n - 1, r - 1) + nCr(n - 1, r)) % Mod;
    return ret;
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    int n, k;
    cin >> n >> k;
    memset(memo, -1, sizeof memo);

    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            nCr(i, j);
        }
    }

    for (int i = 1; i <= k; ++i) {
//        cout << i << ' ' << memo[k - 1][i - 1] << ' ' << memo[n - k + 1][i] << '\n';
        cout << 1LL * memo[k - 1][i - 1] * memo[n - k + 1][i] % Mod << '\n';
    }

    return 0;
}

Measured memory_bytes: 16000
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
static const int INF = 2147483647;
static const int MAX_N = 1 << 18;

int n, dat[2 * MAX_N - 1];

void init(int n_){
	n = 1;
	while(n < n_) n *= 2;

	for(int i = 0; i < 2 * n - 1; i++) dat[i] = INF;
}

void update(int k, int a){
	k += n - 1;
	dat[k] = a;
	while(k > 0){
		k = (k - 1) / 2;
		dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
	}
}

int query(int a, int b, int k, int l, int r){
	if(r <= a || b <= l) return INF;

	if(a <= l && r <= b) return dat[k];
	else{
		int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
}

int main(){
	int n_, q;
	scanf("%d %d", &n_, &q);
	init(n_);
	for(int i = 0; i < q; i++){
		int com, x, y;
		scanf("%d %d %d", &com, &x, &y);
		if(com == 0) update(x, y);
		if(com == 1) printf("%d\n", query(x, y + 1, 0, 0, n));
	}
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define INF 2000000000
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n,a,b,t,ans=INF;
	cin >> n>>t;
	rep(i, n) {
		cin >> a >> b;
		if (b <= t) {
			ans = min(ans, a);
		}
	}
	if (ans == INF) {
		cout << "TLE" << endl;
	}
	else {
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
#define INF 1000000001
#define MOD 1000000007

bool dbgflag = false; //debug

struct fieldPoint {
  char c;
  int path = -1;
};

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

  int h, w;
  cin >> h >> w;
  vector<vector<fieldPoint>> field(h, vector<fieldPoint>(w));

  int black = 0;
  for (int y = 0; y < h; y++) {
    string s;
    cin >> s;
    for (int x = 0; x < w; x++) {
      field[y][x].c = (char)s[x];
      if (s[x] == '#') black++;
    }
  }

  vector<int> dx = {-1, 0, 0, 1}, dy = {0, 1, -1, 0};
  queue<pii> que;
  que.push(pii(0, 0));
  field[0][0].path = 1;

  while (que.size() != 0) {
    pii p = que.front();
    que.pop();
    int px = p.first, py = p.second;

    for (int i = 0; i < 4; i++) {
      int x = px + dx[i], y = py + dy[i];
      if ((x >= 0) && (x < w) && (y >= 0) && (y < h) && (field[y][x].c == '.') && (field[y][x].path == -1)) {
        field[y][x].path = field[py][px].path + 1;
        que.push(pii(x, y));
      }
    }
  }

  cout << ((field[h-1][w-1].path == -1) ? -1 : (w * h) - field[h-1][w-1].path - black) << endl;
}


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

bool judge(string s1,string s2,int i,int len){
	reverse(s1.begin(),s1.begin()+i);
	reverse(s1.begin()+i,s1.begin()+len);
	reverse(s1.begin(),s1.begin()+len);
	if(s1 == s2){
		return true;
	}else{
		return false;
	}
}

int main(){
//	freopen("in.txt","r",stdin);
	string s1, s2;
	cin>>s1>>s2;
	bool flag = false;
	for(int i=0;i<=s1.length();i++){
		if(judge(s1,s2,i,s1.length())){
			flag = true;
			break;
		}
	}
	if(flag){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
//	cout<<s1<<s2<<endl;
	
	return 0;
}

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

int main() {
     ll T;
     cin>>T;
     ll TT=T;
     ll sum=0;
      while (T != 0)
    {
        sum = sum + T% 10;
        T = T / 10;
    }
    
    if(TT % sum ==0)
    cout<<"Yes"<<endl;
   
    else
    cout<<"No"<<endl;
    
return 0;
}

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

int main() {
  int N, Y;
  cin >> N >> Y;
  int x=-1, y=-1, z=-1, maxx=Y/10000, maxy=Y/5000;
  for (int i=0; i<=maxx; i++){
    for (int j=0; j<=maxy-2*i; j++){
      if(i*10000+j*5000+(N-i-j)*1000==Y) {x=i; y=j; z=N-x-y; break;}
    }
  }
  cout << x << " " << y << " " << z << "\n";
  return 0;  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main(){
    int N, K;
    string S;
    cin >> N >> K;
    cin >> S;
    int score = 0;
    rep(i,N-1){
        if(S[i]==S[i+1]) score++;
    }
    int ans = min(score+2*K, N-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
	long long int h, w; cin >> h >> w;

	if(h % 3 == 0 || w % 3 == 0){
		cout << 0 << endl;
	}else{
		long long int ans = h * w;
		if(w % 2){
			for(long long int i = 1; i < h; ++i){
				if(max(abs(i * w - (h - i) * (w / 2)), abs(i * w - (h - i) * (w / 2 + 1))) < ans){
					ans = max(abs(i * w - (h - i) * (w / 2)), abs(i * w - (h - i) * (w / 2 + 1)));
				}
			}
		}else{
			for(long long int i = 1; i < h; ++i){
				if(abs(i * w - (h - i) * (w / 2)) < ans){
					ans = abs(i * w - (h - i) * (w / 2));
				}
			}
		}

		if(h % 2){
			for(long long int i = 1; i < w; ++i){
				if(max(abs(i * h - (w - i) * (h / 2)), abs(i * h - (w - i) * (h / 2 + 1))) < ans){
					ans = max(abs(i * h - (w - i) * (h / 2)), abs(i * h - (w - i) * (h / 2 + 1)));
				}
			}
		}else{
			for(long long int i = 1; i < w; ++i){
				if(abs(i * h - (w - i) * (h / 2)) < ans){
					ans = abs(i * h - (w - i) * (h / 2));
				}
			}
		}

		for(int i = 1; i < h; ++i){
			if((h - i) % 2){
				if(max(abs(w * i - w * ((h - i) / 2)), abs(w * i - w * ((h - i) / 2 + 1))) < ans){
					ans = max(abs(w * i - w * ((h - i) / 2)), abs(w * i - w * ((h - i) / 2 + 1)));
				}
			}else{
				if(abs(w * i - w * ((h - i) / 2)) < ans){
					ans = abs(w * i - w * ((h - i) / 2));
				}
			}
		}
		for(int i = 1; i < w; ++i){
			if((w - i) % 2){
				if(max(abs(h * i - h * ((w - i) / 2)), abs(h * i - h * ((w - i) / 2 + 1))) < ans){
					ans = max(abs(h * i - h * ((w - i) / 2)), abs(h * i - h * ((w - i) / 2 + 1)));
				}
			}else{
				if(abs(h * i - h * ((w - i) / 2)) < ans){
					ans = abs(h * i - h * ((w - i) / 2));
				}
			}
		}
	
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 5002
using namespace std;
int read(){
	int nm=0,fh=1; char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
int n,m,F[M][202],pre[M][202],suf[M][202],q[M],hd,tl;
LL P[M][M],D[M],ans;
void add(int x,int y,int xx,int yy,int num){
	P[x][y]+=num,P[xx+1][y]-=num,P[x][yy+1]-=num,P[xx+1][yy+1]+=num;
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),m=read();
	for(int i=2;i<=n;i++) D[i]=read(),D[i]+=D[i-1];
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) F[i][j]=read();
	for(int i=1;i<=m;i++){
		hd=tl=0;
		for(int now=1;now<=n;now++){
			while(hd<tl&&F[q[tl-1]][i]<F[now][i]) tl--;
			q[tl++]=now,pre[now][i]=(tl==hd+1?1:q[tl-2]+1);
		}
		hd=tl=0;
		for(int now=n;now;now--){
			while(hd<tl&&F[q[tl-1]][i]<F[now][i]) tl--;
			q[tl++]=now,suf[now][i]=(tl==hd+1?n:q[tl-2]-1);
		}
	}
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) add(pre[i][j],i,i,suf[i][j],F[i][j]);
	for(int i=1;i<=n;i++){
	    for(int j=1;j<=n;j++){
		    P[i][j]+=P[i-1][j]+P[i][j-1]-P[i-1][j-1];
	    	if(i<=j) ans=max(ans,P[i][j]-(D[j]-D[i]));
		}
	}
	printf("%lld\n",ans); return 0;
}

Measured memory_bytes: 207616
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int a = int.Parse(Console.ReadLine());
            Console.WriteLine(a % 2 == 0 ? a : a * 2);
        }
    }
}



Measured memory_bytes: 11092
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
long long int myfun(long long int a,long long int x);
int main()
{
    long long int n,k,ans;
    scanf("%lld %lld", &n,&k);
    ans=ceil(myfun(n,k));
    printf("%lld", ans+1);
    return 0;
}
long long int myfun(long long int n,long long int k)
{
    return log(n)/log(k);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef tuple<long double,ll,ll> T;
const ll mod=1e9+7,INF=mod*mod*3;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define f first
#define s second
#define pb push_back
#define mp make_pair

ll N,M,Q;
vector<ll> V[505];

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N>>M>>Q;
rep(i,M){
	ll L,R;
	cin>>L>>R;
	V[L].pb(R);
}
rep1(i,N+1){
	if(V[i].size()) sort(V[i].begin(),V[i].end());
}
rep(i,Q){
	ll ans=0;
	ll p,q;
	cin>>p>>q;
	for(ll j=p;j<=q;j++){
		ll sz=V[j].size();
		ll k=upper_bound(V[j].begin(),V[j].end(),q)-V[j].begin();
		ans+=k;
	}
	cout<<ans<<endl;
}



}
	

Measured memory_bytes: 6036
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    vector<int> data(10000);
    for(int i=0;i<10000;i++){
        cin >> data.at(i);
        if(data.at(i)==0){
            break;
        }
    }
    
    for(int i=0;i<10000;i++){
        if (data.at(i)==0){
            break;
        }
        cout << "Case " << i+1 << ": " << data.at(i) << endl;
    }
}


Measured memory_bytes: 3104
n = int(input())
a = [int(i) for i in input().split()]
ans = [0,0]
total = 0
for i in range(n):
    total += a[i]
    if i%2==0:
        if total<=0:
            ans[0] += abs(total)+1
            total = 1
    else:
        if total>=0:
            ans[0] += abs(total)+1
            total = -1

total = 0
for i in range(n):
    total += a[i]
    if i%2==1:
        if total<=0:
            ans[1] += abs(total)+1
            total = 1
    else:
        if total>=0:
            ans[1] += abs(total)+1
            total = -1 

print(min(ans))


Measured memory_bytes: 63344
#include <bits/stdc++.h>
using namespace std;
  
// Function that returns true if n  
// is prime else returns false  
bool isPrime(int n)  
{  
    // Corner cases  
    if (n <= 1)  return false;  
    if (n <= 3)  return true;  
    
    // This is checked so that we can skip   
    // middle five numbers in below loop  
    if (n%2 == 0 || n%3 == 0) return false;  
    
    for (int i=5; i*i<=n; i=i+6)  
        if (n%i == 0 || n%(i+2) == 0)  
           return false;  
    
    return true;  
}  
  
// Function to return the smallest 
// prime number greater than N 
int nextPrime(int N) 
{ 
  
    // Base case 
    if (N <= 1) 
        return 2; 
  
    int prime = N; 
    bool found = false; 
  
    // Loop continuously until isPrime returns 
    // true for a number greater than n 
    while (!found) { 
        prime++; 
  
        if (isPrime(prime)) 
            found = true; 
    } 
  
    return prime; 
} 
  
// Driver code 
int main() 
{ 
    int N;
    cin >> N;
    if(isPrime(N)) cout << N << endl;
    else
    {
        cout << nextPrime(N) << endl;
    }
  
    return 0; 
}

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

int main(void){
    int N;
    string S;

    cin >> N;
    cin >> S;

    int res = 0;
    for(int i=0; i<N-2; i++){
        if(S.substr(i,3)=="ABC")res++;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
v = [int(i) for i in input().split()]

ans = 0
v.sort()

tmp = 0.5 * (v[0] + v[1])

if n == 2:
    print(tmp)
    exit()

for i in range(n-2):
    tmp = (tmp + v[i+2]) * 0.5


print(tmp)

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

int main() {
  int N, sum;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int A, count = 0;
    cin >> A;
    if (A % 2) {
      sum = 0;
      break;
    }
    else {
      while (A % 2 == 0) {
        A /= 2;
        count++;
      }
    }
    if (i == 0) sum = count;
    else if (sum > count) sum = count;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
vint adj[100001];
bool visited[100001]={};
int shutu[100001]={};
int vcolor[100001]={};
int ans[100001];
map<pint,int> ed;
void dfs(int u){
	visited[u]=1;
	int nowcolor=1;
	rep(i,adj[u].size()){
		int v=adj[u][i];
		if(visited[v]==0){
			if(vcolor[u]==nowcolor) nowcolor++;
			ans[ed[{u,v}]]=nowcolor;
			vcolor[v]=nowcolor;
			nowcolor++;
			dfs(v);
		}
	}
}
int main(){
	int N;
	int K=0;
	scan(N);
	rep(i,N-1){
		int a,b;
		scan(a>>b);
		a--; b--;
		ed[{a,b}]=i;
		ed[{b,a}]=i;
		shutu[a]++, shutu[b]++;
		adj[a].push_back(b);
		adj[b].push_back(a);
		K=max(K,max(shutu[a],shutu[b]));
	}
	prin(K);
	dfs(0);
	rep(i,N-1){
		prin(ans[i]);
	}
	return 0;
}


Measured memory_bytes: 19840
#include <iostream>
#include <string>

using namespace std;

int main(void) {

	string Str;
	int i;

	cin >> Str;
	
	for (i = 0; i < Str.size(); i++) {
		if (i % 2 == 1 && Str[i] == 'R') { //even

			cout << "No" << endl;

			return 0;
			
		}

		else if(i % 2 == 0 && Str[i] == 'L') {  //odd

			cout << "No" << endl;

			return 0;
			
		}

	}

	cout << "Yes" << endl;

	return 0;

}

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

// constexpr long mod = 998244353;
constexpr long mod = 1000000007;
vector<long> fact, inv;

long mpow(long a, long b) {
  long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return res;
}

void init(int n) {
  fact.push_back(1);
  inv.push_back(1);
  for (int i = 0; i < n; i++) {
    fact.push_back(fact.at(i) * (i + 1) % mod);
    inv.push_back(mpow(fact.at(i + 1), mod - 2));
  }
}

long qcom(long n, long r) {
  return fact.at(n) * inv.at(r) % mod * inv.at(n - r) % mod;
}

long com(long n, long r) {
  long x = 1, y = 1;
  for (int i = 1; i <= r; i++) {
    x = x * (n - i + 1) % mod;
    y = y * i % mod;
  }
  return x * mpow(y, mod - 2) % mod;
}

int main() {
  long N, A, B;
  cin >> N >> A >> B;
  long ans = mpow(2, N);
  ans--;
  ans -= com(N, A);
  ans -= com(N, B);
  while (ans < 0) ans += mod;
  cout << ans << "\n";
}

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

using namespace std;

int inhand[15];

bool Rec(int i, int l, int r)
{
    if ((l==0) && (r==14)) return i==1;

    bool Res1, Res2;
    if (inhand[l]==i) Res1=Rec(3-i,l-1,r); else Res1=(i==2);
    if (inhand[r]==i) Res2=Rec(3-i,l,r+1); else Res2=(i==2);
    if ((inhand[l]!=i) && (inhand[r]!=i)) return Rec(3-i,l,r);

    if (i==1) return Res1 || Res2; else return Res1 && Res2;
}

int main()
{
    //freopen("Sevens.inp","r",stdin);
    //freopen("Sevens.out","w",stdout);

    int n;
    cin >> n;
    while (n--)
    {
        for (int i=1; i<=13; i++) inhand[i]=2; inhand[7]=0; inhand[0]=0; inhand[14]=0;
        for (int i=1; i<=6; i++)
        {
            int u;
            cin >> u;
            inhand[u]=1;
        }

        bool Res=Rec(1,6,8);
        if (Res) cout << "yes\n"; else cout << "no\n";
    }
}



Measured memory_bytes: 3072
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>
#include <cfloat>
#include <array>



bool is_acceptable(long long int n, long long int k) {
	while (n % k == 0) {
		n /= k;
	}
	return n % k == 1;
}
int main() {
	long long int n; std::cin >> n;
	if (n == 2) {
		std::cout << "1\n";
		return 0;
	}
	int count{ 2 };
	for (long long int k = 2; k * k <= n; ++k) {
		if (n % k == 0) {
			if (is_acceptable(n, k)) ++count;
			if (k * k != n && is_acceptable(n, n / k)) ++count;
		}
		else if ((n - 1) % k == 0) {
			++count;
			const auto div = (n - 1) / k;
			if (std::sqrt(n) + 1 < div || div * div > n) ++count;
		}
	}
	std::cout << count << std::endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif
 
#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
                  a = b;
                      return true;
                        }
            return false;
    }
template <class T> bool chmin(T &a, const T &b) {
      if (a > b) {
              a = b;
                  return true;
                    }
        return false;
}
signed main() {
      cin.tie(0);
      ios::sync_with_stdio(false);
      cout << fixed << setprecision(12);

      string s;
      cin>>s;
      sort(all(s));
      cout<<(s=="abc"?"Yes":"No")<<endl;


      return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
int substr_count(string s, string substr)
{
	int count =0;
	size_t pos = s.find(substr);
	while(pos != string::npos)
	{
		count++;
		pos = s.find(substr,pos+1);
	}
	return count;
}
int main(void)
{
	string s;
	cin >> s;
	int nc = substr_count(s,"N");
	int sc = substr_count(s,"S");
	int ec = substr_count(s,"E");
	int wc = substr_count(s,"W");
	if( (sc > 0 && nc==0) || (sc==0 && nc > 0))
	{
		cout << "No" << endl;
	}
	else if( (ec > 0 && wc==0) || (ec==0 && wc > 0))
	{
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n;
	cin >> n;
	vllint a(n);
	rep(i, n) {
		cin >> a[i];	
	}
	sort(a.begin(), a.end(), check);
	llint x = 0, y = 0;
	rep(i, n - 1) {
		if (a[i] == a[i + 1]) {
			if (x == 0) {
				x = a[i];
				i++;
			}
			else {
				y = a[i];
				break;
			}
		}
	}
	cout << x*y << endl;
	return 0;
}


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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int a[m], b[m];

    unordered_map<int, set<int>> buckets;

    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        buckets[a[i]].insert(b[i]);
        buckets[b[i]].insert(a[i]);
    }

    bool visited[n] = {false};
    int ans = 1;
    for (int i = 0; i < n; i++) {
        if (visited[i]) {
            continue;
        }
        int count = 1;
        queue<int> open = {};
        open.push(i + 1);
        visited[i] = true;
        while (!open.empty()) {
            int u = open.front();
            for (int v : buckets[u]) {
                if (!visited[v - 1]) {
                    visited[v - 1] = true;
                    count++;
                    open.push(v);
                }
            }
            open.pop();
        }
        ans = max(ans, count);
    }

    cout << ans << "\n";
}

Measured memory_bytes: 41620
#include <bits/stdc++.h>
using namespace std;
int main(){
string N;
  cin>>N;
 for(int i=0;i<3;i++){
 if(N.at(i)=='1'){
cout<<"9";
 }
   else if(N.at(i)=='9'){
   cout<<"1";
   }
 }

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
  int n,f,sum=0;
  cin>>n;
  f=n;
  while(f){
    sum+=f%10;
    f/=10;
  }
  if(n%sum==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;
int main()
{
   
   
    int a, b;
    cin >> a >> b;
    if (a > 9 || b > 9) {
        cout << -1 << endl;

    }
    else cout << a * b << endl;
    return 0;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl

int a[50],b[50],c[50],d[50];
int n,q,m;
vector<int>ans;
int best,cur;

void backtrack(int pos){


 if(ans.size()==n){
   cur=0;
   for(int i=0;i<q;i++){
      if(ans[b[i]]-ans[a[i]]==c[i]){
         cur+=d[i];
      }
   }
  best=max(best,cur);
  return;
 }
 
 for(int i=pos;i<=m;i++){
   ans.push_back(i);
   backtrack(i);
   ans.pop_back();
 }

}



int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>n>>m>>q;

  for(int i=0;i<q;i++){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
    a[i]--;
    b[i]--;
 
   }  
   cur=0,best=0;
   backtrack(1);

  cout<<best<<endl;


  return 0;
}


Measured memory_bytes: 3620
class Card
  def initialize(mark, number)
    @mark = mark
    @number = number.to_i
  end

  def to_s
    "#{mark} #{number}"
  end

  attr_accessor :number, :mark
end

def partition(array, p, r)
  x = array[r].number
  i = p - 1
  p.upto(r - 1) do |index|
    if array[index].number <= x
      i += 1
      array[i], array[index] = array[index], array[i]
    end
  end
  array[r], array[i + 1] = array[i + 1], array[r]
  i + 1
end

def quick_sort(array, p, r)
  if p < r
    q = partition array, p, r
    quick_sort array, p, q - 1
    quick_sort array, q + 1, r
  end
  array
end

def merge(left_array, right_array)
  return_array = []
  left_index, right_index = 0, 0
  left_array << Card.new('', 10**9)
  right_array << Card.new('', 10**9)
  0.upto(left_array.length + right_array.length - 3) do
    if left_array[left_index].number <= right_array[right_index].number
      return_array << left_array[left_index]
      left_index += 1
    else
      return_array << right_array[right_index]
      right_index += 1
    end
  end
  return_array
end

def merge_sort(target_array)
  right = target_array.length
  mid = target_array.length / 2
  left_array = target_array[0...mid]
  right_array = target_array[mid...right]
  return target_array if target_array.length == 1
  merge(merge_sort(left_array), merge_sort(right_array))
end

def stable?(merge, sorted)
  merge.each_with_index do |element, index|
    return false if element.mark != sorted[index].mark
  end
  true
end

n = gets.to_i
input_array = []
n.times do
  input = gets.split(' ')
  input_array << Card.new(input[0], input[1])
end

input_array2 = Marshal.load(Marshal.dump(input_array))
merge = merge_sort input_array
quick = quick_sort input_array2, 0, n - 1

if stable? merge, quick
  puts 'Stable'
else
  puts 'Not stable'
end

puts quick.map(&:to_s)


Measured memory_bytes: 43912