akhauriyash/Code-Regression huggingface dataset:
// C - Reconciled?

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
const ll MOD = 1e9 + 7;

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

	if (abs(N - M) > 1) {
		cout << 0 << endl;
		return 0;
	}

	ll ans = 1;

	for (int i=1; i<=N; i++) {
		ans = (ans * i) % MOD;
	}

	for (int i=1; i<=M; i++) {
		ans = (ans * i) % MOD;
	}

	if (N == M) ans = (ans * 2) % MOD;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

const int N = 1e5 + 5;
const long long INF = 1e18;
const int mod = 1000000007;//786433;//998244353;
const double Pi = acos(-1);

 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

long long a, res = 0;

int main()
{
	cin >> a;
	string b;
	cin >> b;
	res += (b[0] - '0');
	for(int i = 2; i < b.length(); i++)
	{
		res *= 10;
		res += (b[i] - '0');
	}
	cout << a * res / 100;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

int main(){
  string s; int K; cin >> s >> K;
  int n = s.size();

  vector<string> ans;
  rep(i, n) for (int j = 1; i+j <= n && j <= K; j++) {
    ans.pb(s.substr(i,j));
  }
  sort(all(ans));
  ans.erase(unique(all(ans)), ans.end());
  std::cout << ans[K-1] << '\n';
}


Measured memory_bytes: 1660
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC179C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            long ans = 0;
            for(int A = 1; A <= N; A++)
            {
                ans += N / A;
                if (N % A == 0) ans -= 1;
            }
            Console.WriteLine(ans);
        }
    }
}


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

int main() {
  char s[123];
  scanf("%s", s);
  int n = strlen(s);
  bool ok = true;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0)
      ok &= (s[i] != 'L');
    else
      ok &= (s[i] != 'R');
  }
  puts(ok ? "Yes" : "No");
  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 rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	map<vi, int> mp;

	rep(i, n) {
		string s;
		cin >> s;
		vi alph(26);
		rep(j, s.size())alph[s[j] - 'a']++;
		mp[alph]++;
	}

	ll ans = 0;
	for (auto x : mp)ans += (ll)(x.second - 1) * x.second / 2;

	cout << ans << endl;

}

Measured memory_bytes: 18944
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		long i,j;
		Scanner sc = new Scanner(in);
		long n = parseLong(sc.next());
		long k = parseLong(sc.next());
		sc.close();
		long sum=0;
		long lsum=0;
		long hsum=0;
		for (i = 0; i < k; i++) {
			lsum+=i;
			hsum+=(n-i);
		}
		for (i = k; i <= n+1; i++) {
//			out.printf("%d-%d%n", hsum,lsum);
			sum += hsum-lsum+1;
			if(sum>=MOD)sum%=MOD;
			lsum+=i;
			hsum+=(n-i);
		}
		out.println(sum);
	}
}


Measured memory_bytes: 27012
package main

import (
	"bufio"
	"fmt"
	"os"
)

const (
	initialBufSize = 10000
	maxBufSize     = 100000000
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	return sc
}()

// Input string
func scanString() (s string) {
	sc.Scan()
	return sc.Text()
}

func main() {
	input := scanString()

	remSumArray := make([]int, 2019)
	remSumArray[0] = 1
	var num int
	digit := 1

	for i := len(input) - 1; i >= 0; i-- {
		num += int(input[i]-48) * digit
		digit *= 10
		digit %= 2019
		//fmt.Println(num, "\t", num%2019)
		remSumArray[num%2019]++
	}

	//fmt.Println(remSumArray)
	var result int
	for _, num := range remSumArray {
		result += num * (num - 1) / 2
	}

	fmt.Println(result)
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1000000000 //
#define LINF (ll)4000000000000000000 //
#define MOD (ll)1000000007
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int n, m;
int a[50], b[50];

bool check(int cut) {
    int dist[n][n] = {};

    rep(i, n) {

        rep(j, n) {
            if (i == j) dist[i][j] = 0;
            else dist[i][j] = INF;
        }
    }

    rep(i, m) {
        if (i != cut) {
            dist[a[i] - 1][b[i] - 1] = 1;
            dist[b[i] - 1][a[i] - 1] = 1;
        }
    }

    rep(k, n) {

        rep(i, n) {

            rep(j, n) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    rep(i, n) {
        if (dist[0][i] == INF) return true;
    }
    return false;
}

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

    rep(i, m) cin >> a[i] >> b[i];

    int bridge = 0;

    rep(i, m) {
        if (check(i)) bridge++;
    }

    cout << bridge << endl;

    return 0;
}

Measured memory_bytes: 256
//ABC083B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	int ans = 0;
	for(int i=1;i<=n;i++){
		int sigma = 0;
		int num = i;
		while(num > 0){
			sigma += num%10;
			num /= 10;
		}
		if(a <= sigma && sigma <= b){
			ans += i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#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> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n,m;
    cin >> n >> m;
    ll k;
    cin >> k;
    vector<ll> a(n),b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    int ans = 0;
    rep(i,n-1) a[i+1] += a[i];
    rep(i,m-1) b[i+1] += b[i];
    rep(i,n){
        if(a[i]>k) continue;
        int left = -1,right = m;
        while(right - left > 1){
            int mid = (left + right)/2;
            if(a[i]+b[mid]<=k) left = mid;
            else right = mid;
        }
        ans = max(ans,i+1+left+1);
        //cout << ans << endl;
    }
    rep(i,m){
        if(b[i]>k) continue;
        int left = -1,right = n;
        while(right - left > 1){
            int mid = (left + right)/2;
            if(b[i]+a[mid]<=k) left = mid;
            else right = mid;
        }
        ans = max(ans,i+1+left+1);
        //cout << ans << endl;
    }
    /*
    rep(i,n) cout << a[i] << " " ;
    cout << endl;
    rep(i,m) cout << b[i] << " " ;
    cout << endl;
    */
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6420
#include<iostream>
#include<numeric>
using namespace std;
int gcd(int a, int b){
    if(a < b){
        int tmp;
        tmp = b;
        b = a;
        a = tmp;
    }
    int r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
int main(){
    int K;
    long long sum = 0;
    cin >> K;
    for(int a=1;a<=K;a++){
        for(int b=1;b<=K;b++){
            for(int c=1;c<=K;c++){
                sum += gcd(gcd(a, b), c);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,event;
    cin>>n>>event;
    
    vector<int> possessionfish(n+1, 0);
    vector<int>::iterator iter;
    
    int index, topNum = -1;
    int fishing,num;
    
    for(;event>0;--event){
        cin>>num>>fishing;
        possessionfish[num]+=fishing;
        
        if(topNum == -1)topNum = num;
        else if(fishing > 0){
            if(possessionfish[num] > possessionfish[topNum] || (topNum > num && possessionfish[num] == possessionfish[topNum]))topNum = num;
        }else if(topNum == num){
            iter = max_element(possessionfish.begin(), possessionfish.end());
            index = distance(possessionfish.begin(), iter);
            topNum = index;
        }
        
        cout<<topNum<<" "<<possessionfish[topNum]<<endl;
    }
}



Measured memory_bytes: 6788
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
#define INF 999999999
#define lint long long
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define rep0(i, n) for(int i = 0; i < (int)(n); i++)
lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}


int main(){
    string S;
    cin >> S;
    char p;
    rep0(i,3){
        if (S[i] == S[i+1]) {cout << "Bad"; return 0;} 
    }
    cout << "Good";
    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 rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
unsigned const int MOD = 1000000007;

int main(void){
    int h,w,k;
    cin >> h >> w >> k;
    if(w == 1){cout << "1" <<endl;return 0;}
    int ct[w+1];
    ct[0] = 1;ct[1]=1;
    rep(i,w-1)ct[i+2]=ct[i]+ct[i+1];
    ll dp[h+1][w];
    rep(i,h+1)rep(j,w)dp[i][j] = 0;
    dp[0][0] = 1;
    rep1(i,h+1)rep(j,w){
        if(j==0)dp[i][j]=(dp[i-1][j]*ct[w-1])+(dp[i-1][j+1]*ct[w-2]);
        else if(j==w-1)dp[i][j]=(dp[i-1][j]*ct[w-1])+(dp[i-1][j-1]*ct[w-2]);
        else if(j==1)dp[i][j] = (dp[i-1][j-1]*ct[w-2])+(dp[i-1][j]*ct[w-2])+(dp[i-1][j+1]*ct[w-3]);
        else if(h==w-2)dp[i][j] = (dp[i-1][j-1]*ct[w-3])+(dp[i-1][j]*ct[w-2])+(dp[i-1][j+1]*ct[w-2]);
        else dp[i][j] = (dp[i-1][j-1]*(ct[j-1]*ct[w-j-1]))+(dp[i-1][j]*(ct[j]*ct[w-j-1]))+(dp[i-1][j+1]*(ct[j]*ct[w-j-2]));
        dp[i][j]%=MOD;
    }
    cout << dp[h][k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 1 * 1e5 + 5;
const ll mod = 998244353;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
vi G[N];
int H[N];
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;
    ll x;
    map<ll, ii> m;
    for(ll i = 1; i <= 1000; i++){
        for(ll j = -1000; j <= i; j++){
            ll li = i * i * i * i * i;
            ll lj = j * j * j * j * j;
            m[li - lj] = {i, j};
        }
    }
    cin >> x;
    if(m.count(x))
        cout << m[x].F << " " << m[x].S << '\n';  
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}   

Measured memory_bytes: 68756
#include<stdio.h>
int main()
{
    int A,B,C,D;
    scanf("%d%d%d%d",&A,&B,&C,&D);
    if(A>=B ){
    if(C>=D)
    printf("%d\n",B+D);
    else
    printf("%d\n", B+C);}
    else if(A<=B){
    if(C>=D)
    printf("%d\n",A+D);
    else
    printf("%d\n", A+C);
    }

    return 0;
}


Measured memory_bytes: 1724
#include <stdio.h>

int a[1010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	int q;
	scanf("%d",&q);
	while(q--){
		int l,r;
		scanf("%d%d",&l,&r);
		for(int i=0;l+i<r-1-i;i++){
			int t=a[l+i];
			a[l+i]=a[r-1-i];
			a[r-1-i]=t;
		}
	}
	for(int i=0;i<n;i++)printf("%d%c",a[i],i==n-1?10:32);
}


Measured memory_bytes: 2112
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 998244353, INF = 1e16;

lint N, P;
string s;
lint dp10[200000];
lint dp[200001];
lint cnt[10000];
int main() {
	cin >> N >> P;
	cin >> s;
	if (P != 2 && P != 5) {
		dp10[0] = 10 % P;
		REP(i, N - 1) {
			dp10[i + 1] = (dp10[i] * 10) % P;
		}
		dp[0] = 0;
		cnt[0]++;
		REP(i, N) {
			dp[i + 1] = (dp[i] + (s[N - i - 1] - '0') * dp10[i]) % P;
			cnt[dp[i + 1]]++;
		}
		lint ans = 0;
		REP(i, P) {
			ans += cnt[i] * (cnt[i] - 1) / 2;
		}
		cout << ans << endl;
	}
	else if (P == 2) {
		lint ans = 0;
		REP(i, N) {
			if ((s[i] - '0') % 2 == 0) ans += i + 1;
		}
		cout << ans << endl;
	}
	else if (P == 5) {
		lint ans = 0;
		REP(i, N) {
			if ((s[i] - '0') % 5 == 0) ans += i + 1;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 6952
#include<bits/stdc++.h>
using namespace std;
int main(void){
	string s;
	int i,j;
	int x,y;
	cin>>s;
	for(i=0;i<s.size();i++){
		if(s[i]=='A'){
			x=i;
			break;
		}
	}
	for(i=s.size()-1;i>=0;i--){
		if(s[i]=='Z'){
			y=i;
			break;
		}
	}
	int cnt=0;
	for(i=x;i<=y;i++)	cnt++;
	cout<<cnt<<endl;
	return 0;
}

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

bool binarySearch(int a[], int n, int x)
{
  int mid;
  int left = 0;
  int right = n;
  while(left < right){
    mid = (left + right) / 2;
    if(a[mid] == x)
      return true;
    else if(x < a[mid])
      right = mid;
    else
      left = mid + 1;
  }
  return false;
}

int main(void){
	int n, q, sum=0;
	int S[100001], T[50001];
	
	/* input */
	
	std::cin >> n;
	for(int i=0; i<n; i++){
		std::cin >> S[i];
	}
	
	std::cin >> q;
	for(int i=0; i<q; i++){
		std::cin >> T[i];
		}
	
	for(int i=0; i<q; i++){
		if(binarySearch(S, n, T[i])){
			sum++;
		}
	}
	
	cout << sum << "\n";
	
	return 0;
}



Measured memory_bytes: 3580
#include<stdio.h>

#define N 100000
#define Q 50000

int main(){
  int i,n,q,c=0;
  int S[N],T[Q];
  int key,left,right,mid;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  
  for(i=0;i<q;i++){
    key = T[i];
    left = 0;
    right = n;
    while(left<right){
      mid=(left+right)/2;
      if(S[mid] == key){
	c++;
	break;
      }else if(key < S[mid]){
	right = mid;
      }else{
	left = mid+1;
      }
    }
  }

  printf("%d\n",c);
  
  return 0;
}



Measured memory_bytes: 2272
N, K, Q = map(int, input().split())
A = list(map(int, input().split()))

def calc(x):
    grp = [[]]
    for a in A:
        if a < x and len(grp[-1]) > 0:
            grp.append([])
        if a >= x:
            grp[-1].append(a)
    L = []
    for g in grp:
        g.sort()
        L.extend(g[:max(0, len(g) - K + 1)])
    L.sort()

    if len(L) < Q or L[0] != x:
        return 10**18
    return L[Q - 1] - x

ans = 10**18
for a in A:
    ans = min(ans, calc(a))
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt=1;
  for(int i=0;i<n-1;i++){
    if(s.at(i)!=s.at(i+1)){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
using namespace std;

int main() {
  string s;
  cin >> s;
  int num=0,result=0;
  for (size_t i = 0; i < s.length(); i++) {
    if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
      num++;
    } else {
      result = max(result,num);
      num = 0;
    }
    // cout << num << endl;
  }
  result = max(result,num);
  cout << result << endl;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    string res;
    int n; cin>>n; 
    while (n){
        int r=n%26;
        n/=26;
        if (r==0) {
          r=26;
          n--;
        }
        res += (char) (r+'a'-1);
    }
    reverse(res.begin(), res.end());
    cout << res << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3644
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,l;
	std::cin >> n >> l;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	rep(i,n-1) {
		if(a[i]+a[i+1]>=l) {
			print("Possible");
			rep(j,i) print(j+1);
			for(int j=n-2;j>i;j--) print(j+1);
			print(i+1);
			return 0;
		}
	}
	print("Impossible");
	return 0;
}


Measured memory_bytes: 1536
# coding: utf-8
# Your code here!
Q,H,S,D=map(int,input().split())
N=int(input())
temp=min(4*Q,2*H,S,D/2)

if temp!=D/2:
    print(N*temp)
else:
    if N%2==1:
        print(N//2*D+min(4*Q,2*H,S))
    else:
        print(N//2*D)

    



Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
double f(double x){
    return x * x;
}

int main(void){
    double a, b, C, rad;
    cin >> a >> b >> C;
    rad = C * M_PI / 180.0;
    cout << fixed << setprecision(8) << a * b * sin(rad) / 2 << endl;
    cout << fixed << setprecision(8) << a + b + sqrt(f(a) + f(b) - 2 * a * b * cos(rad)) << endl;
    cout << fixed << setprecision(8) << b * sin(rad) << endl;
    
    return 0;
}



Measured memory_bytes: 3516
N = int(input())
A = list(map(int, input().split()))
INF = 10**18

dp0 = [-INF] * (N + 2)
dp1 = [-INF] * (N + 2)
dp2 = [-INF] * (N + 2)
dp0[0] = 0
dp0[1] = 0
dp1[0] = 0
dp1[1] = 0

for i, a in enumerate(A, start=2):
    dp0[i] = dp0[i - 2] + a
    dp1[i] = max(dp1[i - 2] + a, dp0[i - 1])
    dp2[i] = max(dp2[i - 2] + a, dp1[i - 1], dp0[i - 2])

if N % 2 == 1:
    print(dp2[-1])
else:
    print(max(dp1[-1], dp0[-1]))


Measured memory_bytes: 50588
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        static void Main(){
            long n = ILongs()[0];
            long[] b = ILongs();

            long ans = 0;
            long[] a = new long[n];
            for(int i=0;i<n;i++){
                a[i] = -1;
            }
            a[0] = b[0];

            for(int i=0;i<n-1;i++){
                if(b[i]<a[i])a[i] = b[i];
                ans += a[i];
                a[i+1] = b[i];
            }
            ans += a[n-1];

            WriteLine(ans);
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

#include <deque>

int main(void){
    Cin(int, n, m);
    vc<int> d(n);
    Rep(m){
        Cin(int, a, b); a --, b --;
        d[a] ++, d[b] ++;
    }
    For(i, n){
        if(d[i] % 2 != 0){
            Cout("NO"); return 0;
        }
    }
    Cout("YES");
}


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

//#define cin fin
//#define cout fout
#define ld long double 
#define pb push_back
#define F first
#define S second 
#define ll long long

using namespace std;

const int N = 2e5 + 1e3 , SQ = 440 ; 

int a[N] , ps[N] ; 

vector<int> v[N] ; 

int dp[N] ; 

int add[N] , mx[N] ; 

void rebuild(int id)
{
	for(int i = id * SQ ; i < (id+1) * SQ ; i ++ ) 
		dp[i] = max(dp[i]+add[id],mx[id]) ; 
	add[id] = 0 ; 
	mx[id] = 0 ;
}

void upd(int l , int r , int x)
{
	rebuild(l/SQ) ; 
	rebuild(r/SQ) ;
	for( ; l % SQ != 0 && l < r ; l ++ ) 
		dp[l] = max(dp[l],x) ; 
	if(l==r) return ; 
	for( ; r % SQ != 0 ; r -- ) 
		dp[r-1] = max(dp[r-1],x) ; 
	for(int id = l / SQ ; id <= r / SQ ; id ++ ) 
		mx[id] = max(mx[id],x) ; 
}

void upd(int l , int r)
{
	rebuild(l/SQ) ; 
	rebuild(r/SQ) ;
	for( ; l % SQ != 0 && l < r ; l ++ ) 
		dp[l] ++  ; 
	if(l==r) return ; 
	for( ; r % SQ != 0 ; r -- ) 
		dp[r-1] ++  ; 
	for(int id = l / SQ ; id < r / SQ ; id ++ ) 
		mx[id] ++ , add[id] ++  ; 
}

int get(int i)
{
	rebuild(i/SQ) ; 
	return dp[i] ; 
}

int32_t main()
{
	ios::sync_with_stdio(0) ; cin.tie(0) ; 
	int n ; 
	cin >> n ; 
	for(int i = 0 ; i < n ; i ++ ) cin >> a[i] , ps[i+1] = ps[i] + a[i] ; 
	int m ; 
	cin >> m ; 
	for(int i = 0 ; i < m ; i ++ ) 
	{
		int l , r ; 
		cin >> l >> r ; 
		l -- , r -- ; 
		v[r].pb(l) ; 
	}
	
	upd(1,2,(a[0]==0)) ; 
	int ans = 0 ; 
	for(int i = 0 ; i < n ; i ++ ) 
	{
		if(i) upd(i+1,i+2,get(i)+(a[i]==0)) ;
		int x = (a[i]==1) ; 
		if(x) upd(0,i+1) ; 
	//	cout << i << endl ; 
	//	for(int j = 0 ; j <= i ; j ++ ) upd(j,j+1,get(j)+x) ; 
		vector<pair<pair<int,int>,int>> vv ;
		for(auto u : v[i])
		{
			int v = get(u) ; 
			ans = max(ans,v) ;
			vv.pb({{u,i+2},v}) ;
		}
		for(auto u : vv)
			upd(u.F.F,u.F.S,u.S) ; 

	}
	cout << n - get(n) << endl ; 
} 


Measured memory_bytes: 13184
import itertools
N=int(input())
S=input()
ans=0
L=dict()
R=dict()
for seq in itertools.product([0,1],repeat=N):
    T0=""
    T1=""
    T2=""
    T3=""
    for i in range(N):
        if seq[i]==0:
            T0+=S[i]
            T2+=S[-i-1]
        else:
            T1+=S[i]
            T3+=S[-i-1]
    a0=len(T0)
    a1=len(T1)
    a2=len(T2)
    a3=len(T3)
    if (T0,T1) in L:
        L[(T0,T1)]+=1
    else:
        L[(T0,T1)]=1
    if (T2,T3) in R:
        R[(T2,T3)]+=1
    else:
        R[(T2,T3)]=1
for tup in L:
    if tup in R:
        ans+=L[tup]*R[tup]
print(ans)


Measured memory_bytes: 170872
import fileinput

dic = { 'a' : 0, 'b' : 0, 'c' : 0, 'd' : 0, 'e' : 0,
        'f' : 0, 'g' : 0, 'h' : 0, 'i' : 0, 'j' : 0,
        'k' : 0, 'l' : 0, 'm' : 0, 'n' : 0, 'o' : 0,
        'p' : 0, 'q' : 0, 'r' : 0, 's' : 0, 't' : 0,
        'u' : 0, 'v' : 0, 'w' : 0, 'x' : 0, 'y' : 0, 'z' : 0}
vs = []

for line in fileinput.input():
    vs.append(line.strip())

for v in vs:
    for c in v:
        if c.lower() in dic:
            dic[c.lower()] += 1

for d in dic.items():
    print('{} : {}'.format(d[0], d[1]))



Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

pair<ll, ll> solve(string s, int ind, int N)
{
  if(ind >= N) return make_pair(0, 0);
  ll ways = N - ind <= 1 ? 0 : N - ind;
  ll value = 0;
  ll tot = 0;
  for(int i=ind; i<N; i++)
  {
    value *= 10;
    value += (ll)(s[i] - '0');
    pair<ll, ll> ris = solve(s, i+1, N);
    tot += (value * max(ris.second, 1LL) + ris.first);
    ways += max(ris.second-1, 0LL);
    //if(ind == 0) cout<<value<<" "<<ways<<" "<<ris.first<<" "<<ris.second<<endl;
  }
  return make_pair(tot, ways);
}

int main()
{
  string s;
  cin>>s;
  cout<<solve(s, 0, s.length()).first;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll X;
  cin >> X;

  if((105 % X == 0) && (X > 1))
    cout << "YES\n";
  else
    cout << "NO\n";
  
  return 0;
}


Measured memory_bytes: 3544
#import numpy as np


def acinput():
    return list(map(int, input().split(" ")))


mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact


H, W, D = acinput()
# Ad={}
Ad = [0]*(H*W+1)
for i in range(H):
    ar = acinput()
    for j, sar in enumerate(ar):
        # Ad[sar]=np.array((i,j))
        Ad[sar] = (i, j)

#dp = [[0 for j in range(H*W+1)]for i in range(H*W+1)]
d = [0]*(H*W+1)

# for x in range(1, H*W+1):
#    dp[x][x]=0

y = D+1
while True:
        if y > H*W:
            break
        # print(x,y)
        #tmp = Ad[y]-Ad[y-D]
        #S = np.sum(np.abs(tmp[0])+abs(tmp[1]))
        #tmp = Ad[y]-Ad[y-D]
        S = abs(Ad[y][0]-Ad[y-D][0])+abs(Ad[y][1]-Ad[y-D][1])

        # dp[x][y]=dp[x][y-D]+S
        d[y] = d[y-D]+S
        y += 1


# print(np.array(dp))

Q = int(input())
for i in range(Q):
    l, r = acinput()
    print(d[r]-d[l])


# print(Ad)
# print(np.array(dp))
#print(d)

Measured memory_bytes: 14396
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)

	writer := bufio.NewWriter(os.Stdout)

	r := getNextInt(scanner)
	c := getNextInt(scanner)
	n := r * c
	maze := make([]byte, n)
	steps := make([]int, n)
	queue := make([][2]int, n)
	ql := 0
	qr := 0
	for y := 0; y < r; y++ {
		s := getNextString(scanner)
		for x := 0; x < c; x++ {
			i := y*c + x
			maze[i] = s[x]
			if s[x] == '.' {
				continue
			}
			steps[i] = 1
			queue[qr][0] = i
			queue[qr][1] = 0
			qr++
		}
	}

	d := [4]int{-c, -1, 1, c}
	ans := -1
	for qr-ql > 0 {
		p := queue[ql]
		ql++
		ans = p[1]
		for i := 0; i < 4; i++ {
			ii := p[0] + d[i]
			if ii < 0 || ii >= n {
				continue
			}
			if d[i] > 0 && ii%c == 0 {
				continue
			}
			if d[i] < 0 && p[0]%c == 0 {
				continue
			}
			if maze[ii] == '#' {
				continue
			}
			if steps[ii] > 0 {
				continue
			}
			steps[ii] = 1
			queue[qr%n][0] = ii
			queue[qr%n][1] = p[1] + 1
			qr++
		}
	}

	fmt.Fprintln(writer, ans)

	writer.Flush()
}


Measured memory_bytes: 27392
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

pll operator+(pll a,pll b){
  return pll(a.first+b.first,a.second+b.second);
}
pll operator-(pll a,pll b){
  return pll(a.first-b.first,a.second-b.second);
}
pll operator*(ll a,pll b){
  return pll(b.first*a,b.second*a);
}
const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
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;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long X){
  cout<<lcm(X,360LL)/X<<endl;;
}

int main(){
  cout<<setprecision(1000);
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3596
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

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

    static class NSlimes {
        int[] a;
        long[][] dp;
        long[] acc;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            a = new int[n];
            acc = new long[n + 1];
            dp = new long[n + 1][n + 1];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                acc[i + 1] = acc[i] + a[i];
            }
            for (int i = 0; i < n + 1; i++) {
                Arrays.fill(dp[i], -1);
            }

            out.println(f(0, n));
        /*for (int i = 0; i < n + 1; i++) {
            out.println(Arrays.toString(dp[i]));
        }
        
         */

        }

        long f(int l, int r) {
            if (dp[l][r] != -1) return dp[l][r];
            if (r - l <= 1) return dp[l][r] = 0;
            long s = acc[r] - acc[l];
            long cnt = (long) 1e18;
            for (int i = l + 1; i < r; i++) {
                cnt = Math.min(cnt, f(l, i) + f(i, r));
            }
            return dp[l][r] = cnt + s;
        }

    }
}



Measured memory_bytes: 24632
//
//  main.cpp
//  A_-_Malfatti_Circles
//
//  Created by Andy on 7/5/18.
//  Copyright © 2018 Andy. All rights reserved.
//

#include <iostream>
#include <cmath>
#include <stdio.h>


double Ax, Ay, Bx, By, Cx, Cy;
double a, b, c, p, s, r;
double Ix, Iy;
double IA, IB, IC;
double r1, r2, r3;


int main(int argc, const char * argv[]) {

    while (true) {
        scanf("%lf %lf %lf %lf %lf %lf", &Ax, &Ay, &Bx, &By, &Cx, &Cy);
        if (Ax == Bx && Bx == Cx && Ax == Ay && Ay == By && By == Cy && Cy == 0) break;
        
        a = std::sqrt(pow(Bx - Cx, 2) + pow(By - Cy, 2));
        b = std::sqrt(pow(Cx - Ax, 2) + pow(Cy - Ay, 2));
        c = std::sqrt(pow(Ax - Bx, 2) + pow(Ay - By, 2));
        p = a + b + c;
        s = p / 2;
        
//        std::cout << "B: (" << Bx << "," << By << ")\n";
//        std::cout << "C: (" << Cx << "," << Cy << ")\n";
//        std::cout << "BC: " << std::sqrt(pow(Bx-Cx, 2) + pow(By-Cy, 2)) << "\n";
//        std::cout << a << " " << b << " " << c << " " << perimeter << " " << semiperimeter << "\n";
        
        Ix = ((a * Ax) + (b * Bx) + (c * Cx)) / p;
        Iy = ((a * Ay) + (b * By) + (c * Cy)) / p;

//        std::cout << "I: (" << Ix << "," << Iy << ")\n";
        
        r = (std::sqrt(s * (s - c) * (s - a) * (s - b))) / s;
        
        IA = std::sqrt(pow(Ax - Ix, 2) + pow(Ay - Iy, 2));
        IB = std::sqrt(pow(Bx - Ix, 2) + pow(By - Iy, 2));
        IC = std::sqrt(pow(Cx - Ix, 2) + pow(Cy - Iy, 2));

        r1 = (r / (2 * (s - a))) * (s - r - IB - IC + IA);
        r2 = (r / (2 * (s - b))) * (s - r - IC - IA + IB);
        r3 = (r / (2 * (s - c))) * (s - r - IA - IB + IC);

        
        printf("%.6lf %.6lf %.6lf\n", r1, r2, r3);
        
        
    }

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    return 0;
}




















































Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    char c;
    cin >> c;
    c++;
    cout << c;

    return 0;
}


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


int main() {

    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    int c = 0;
    int ans = 0;
    while (1) {
        bool odd = false;
        rep(i,n) {
            if (a[i] % 2 == 1) odd = true;
        }
        if (odd) break;
        ++ans;
        rep(i,n) a[i] /= 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {

	var n int
	var c []byte
	fmt.Scan(&n ,&c)

	cnt:=0
	redRight := n - 1
	for i := 0; i < n; i++ {
		if c[i] == 'W' {
			for j := redRight; i< j; j-- {
				redRight = j -1
				if c[j] == 'R' {
					c [i] = 'R'
					c[j] = 'W'
					cnt++
					break
				}
			}
		}
	}
	fmt.Println(cnt)

	// dp := make([]int, 200010)
	// dp[1] = abs(cs[1] - cs[0])
	// for i := 2; i < n; i++ {
	// 	dp[i] = abs(cs[1] - c[0])

	// 	// 医師を２個選んで入れ替えるか、色変え
	// 	b1:= dp[i-1] + abs(c[i] - c[i-1])
	// 	b2 := dp[i-2] + abs(c[i] - c[i-2])
	// 	if b1 < b2 {
	// 		dp[i] = b1
	// 	} else {
	// 		dp[i] = b2
	// 	}
	// }
	// fmt.Println(dp[n-1])
}
func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}



func abs(n int) int {
	y := n >> 63
	return (n ^ y) - y
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 3416
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string t;
    cin>>t;
    rep(i,t.size()){
        if(t[i]=='?') cout<<"D";
        else cout<<t[i];
    }
}

Measured memory_bytes: 3776
#include <stdio.h>
#include <string.h>
#include <math.h>

long calc(char *exp) {
    long tmp=0, ret=0;
    for (int i=0; i<strlen(exp); i++) {
        if (exp[i] != '+')
            tmp *= 10, tmp += exp[i]-'0';
        else 
            ret += tmp, tmp=0;
    }
    return ret+tmp;
}

int main() {
    char s[11] = {};
    scanf("%s", s);
    int len = strlen(s);
    long ans = 0;
    for (int i=0; i<powl(2, len-1); i++) {
        char dst[24]={};
        int k=0;
        for (int t=0 ; t<len; t++, k++) {
            if (i & (1 << (t-1)))
                dst[k++] = '+';
            dst[k] = s[t];
        }
        dst[k] = '\0';
        ans += calc(dst);
    }
    printf("%ld\n", ans);
}

Measured memory_bytes: 256
/*
Mangal bhavan amangal haari
Drabahu su Dasharath achar Bihari
Raam Siya Raam Siya Raam jai jai Raam
Raam Siya Raam Siya Raam jai jai Raam
Ho hoi hai wohi jo Raam rachi raakha
Ko kari tarak badhave saakha
Raam Siya Raam Siya Raam jai jai Raam
Ho dheeraj dharam mitra aru naari
Aapad kaal parakhiye chaari
Ho jehike jehi par satya sanehu
So tehi milay na kachhu sandehu
Ho jaaki rahi bhawana jaisi
Prabhu murati dekhi tin taisi
Ho Raghukul reet sada chali aayi
Praan jaaye par vachan na jaayi
Raam Siya Raam Siya Raam jai jai Raam, Raam
Raam Siya Raam Siya Raam jai jai Raam
Ho hari anant hari katha ananta
Kahahi sunahi bahuvidhi sab santa
Raam Siya Raam Siya Raam jai jai Raam, Raam
Raam Siya Raam Siya Raam jai jai Raam
Raam Siya Raam Siya Raam jai jai Raam
*/


#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
//auto->.
//map<int,int>::iterator i
vector<int> sieve(int n) 
{ 

    vector<bool> prime(n+1,true); 
       
    prime[0] = false; 
    prime[1] = false; 
    int m = sqrt(n); 
   vector<int> ans;

    for (int p=2; p<=m; p++) 
    { 
    
        if (prime[p]) 
        { 
         
            for (int i=p*2; i<=n; i += p) 
            prime[i] = false; 
        } 
    }  
    //vector<int> ans; 
    for (int i=0;i<n;i++) 
        if (prime[i]) 
            ans.push_back(i); 
    return ans; 
}

int gcd(int a,int b)
{
	if(b==0) return a;
	return gcd(b,a%b);
}
int mod = 1e9 + 7;
int power(int a , ll b)
{
	int res = 1;
	while(b)
	{
		if(b & 1)
			res = 1LL * res * a ;//% mod;
		a = 1LL * a * a ;//% mod;
		b >>= 1;
	}
	return res;
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
ll min(int a,ll b)
{
	if(a>b)
	return b;
	return a;
}
ll max(int a,ll b)
{
	if(a>b)
	return a;
	return b;
}
ll myXOR(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}
int conti(int x)
{
	if(x<1)
	return 0;
	if(x%4==0)
	return x;
	if(x%4==1)
	return 1;
	if(x%4==2)
	return x+1;
	if(x%4==3)
	return 0;
}
 
bool ispfsq(long double x) 
{   
  // Find floating point value of  
  // square root of x. 
  long double sr = sqrt(x); 
  
  // If square root is        an integer 
  return ((sr - floor(sr)) == 0); 
}
#define PI 3.141592653589793


vector<int > adj[200005],col[2];
bool visited[200005];
int  a[200005];
ll s[200005], ans;
map<ll, int> lst;
void solve()
{
int n;
cin>>n;
int arr[n+1];
ll ans=0;
for(int i=1;i<=n;i++)
{
	cin>>arr[i];
	if(i%2&&arr[i]%2)
	{
		ans++;
	}
}
cout<<ans;
}


int main()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
int mul=0;
if(mul==1)
{
 int t;
    cin>>t;
   while(t--)
    {
		solve();
	cout<<"\n";
    }
  
}
else
{
	solve();
}
}

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

int main(){
    int N,K;
    cin>>N>>K;
    vector<int> V(N);
    int ans=0;
    for(int i = 0;i<N;i++){
      cin>>V.at(i);
    }
    sort(V.begin(),V.end());
    reverse(V.begin(),V.end());
    for(int i = 0;i<K;i++){
        ans+=V.at(i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include<stdio.h>
int main(){
	int n,x,y1,y2,y3;
	scanf("%d%d%d%d%d",&x,&y1,&y2,&y3,&n);
	x=x*n;
	if(y2<=n)y1=y1+y3*(n-y2);
	if(x>y1)x=y1;
	printf("%d\n",x);
	return 0;
}


Measured memory_bytes: 2148
using System;
using System.Collections.Generic;


public class Contest
{
	public static void Main()
	{
		int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));

//		int[] b = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		int[] c = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		int[] d = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));

		int n = a[0];
		int[][] e = new int[n][];
		for(int i=0; i<n; i++) e[i] = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));


		Array.Sort(e,(x,y)=>x[0]-y[0]);
		int sum = e[e.Length-1][0]/2;
		for(int i=0; i<e.Length-1;i++) sum += e[i][0];

		string ans = sum.ToString();

		Console.WriteLine(ans);
	}
	
	private static int calc_main(int[] a,int[] b,int[] c,int[] d) {



		return 0;
	}




}


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

int N, F, a, cnt;
set<int> st;

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        if (a >= 3200)
            F++;
        else
            st.insert(a / 400);
    }
    cnt = st.size();
    cout << max(1, cnt) << " " << cnt + F << endl;
}

Measured memory_bytes: 256
<?php
  list($n) = explode(" ",fgets(STDIN));

  if($n <= 3){
    echo "1";
    exit;
  }

  $max = 0;
  for($i=2;$i*$i<=$n;$i++){
    $x=$i;
    while($x*$i<=$n){
      $x=$x*$i;
      $max=max($max,$x);
    }
  }
  echo $max;

Measured memory_bytes: 16096
"""
A,Bをsortする


 4 3  
44 2
31 3



"""

import sys


N,M = map(int,input().split())

A = list(map(int,input().split()))
B = list(map(int,input().split()))

A.sort()
B.sort()
A.reverse()
B.reverse()
A.append(float("-inf"))
B.append(float("-inf"))

Aind = 0
Bind = 0

able = 0
ans = 1

for i in range(N*M):

    i = N*M-i

    if A[Aind] == i and B[Bind] == i:
        Aind += 1
        Bind += 1
        able += Aind * Bind - (Aind-1)*(Bind-1) - 1

    elif A[Aind] == i:
        ans *= Bind
        able += Bind - 1
        Aind += 1

    elif B[Bind] == i:
        ans *= Aind
        able += Aind - 1
        Bind += 1

    else:
        ans *= able
        able -= 1

        if able < 0:
            print (0)
            sys.exit()

    ans %= 10**9+7

print (ans)

Measured memory_bytes: 42220
n,k,s = map(int,input().split())
A = []

for i in range(k):
    A.append(s)
for i in range(n-k):
    if s == 10**9:
        A.append(1)
    else:
        A.append(10**9)

print(" ".join([str(i) for i in A]))

Measured memory_bytes: 57120
N=int(input())
a=[int(input())-1 for i in range(N)]
b=[0 for i in range(N)]
k=0
b[0]=1
for i in range(N):
    k=a[k]
    b[k]+=1
    if b[k]>=2:
        print(-1)
        exit()
    if k==1:
        print(i+1)
        exit()


Measured memory_bytes: 7884
#include<iostream>
#include <unordered_set>

using namespace std;

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

    unordered_set<char> arareSet;
    for (int i = 0; i < N; ++i)
    {
        char c;
        cin >> c;
        arareSet.insert(c);
    }

    const char* result = arareSet.size() == 4 ? "Four" : "Three";
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 384