akhauriyash/Code-Regression huggingface dataset:
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define mod 1000000007
#define N 500055
//#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,a[N],f[N],fa[N];
int nedge,Next[N*2],head[N],to[N*2],in1[N];
#define V to[i]
void add(int a,int b){
	Next[++nedge]=head[a];head[a]=nedge;to[nedge]=b;
}
void add_ne(int a,int b){add(a,b);add(b,a);in1[a]++;in1[b]++;}
void ret(){puts("NO");exit(0);}
void dfs(int x){
	f[x]=a[x];
	int sum=0,ma=-1;
	go(i,x){
		if (V==fa[x]) continue;
		fa[V]=x;dfs(V);sum+=f[V];ma=max(ma,f[V]);
	}
	if (ma==-1) return;
	if (sum<a[x]) ret();
	if (sum>a[x]*2) ret();
	f[x]=a[x]-(sum-a[x]);
	if (sum-a[x]>sum-ma) ret();
	if (fa[x]==-1&&a[x]*2!=sum) ret();
}
signed main(){
	n=read();F(i,1,n) a[i]=read();
	F(i,1,n-1) add_ne(read(),read());
	if (n==2){
		if (a[1]==a[2]) puts("YES");
		else puts("NO");
		return 0;
	}
	F(i,1,n){
		if (in1[i]>=2){
			fa[i]=-1;dfs(i);break;
		}
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 19072
// https://atcoder.jp/contests/abc124/tasks/abc124_c

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

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

    for (int first_color = 0; first_color < 2; first_color++)
    {
        int cf = first_color;
        int cnt = 0;
        for (int i = 0; i < s.size(); i++)
        {
            int j = s[i] - '0';
            if (j != cf)
            {
                cnt++;
            }
            cf ^= 1;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3764
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, X, M = map(int, readline().split())
    L = [X]
    A = X
    # used: 何回目で出てきたか
    used = [-1] * M
    used[X] = 0
    i = 1
    while True:
        i += 1
        A = A * A % M
        if used[A] == -1:
            used[A] = i
            L.append(A)
        else:
            i
            break
    i2 = L.index(A) + 1
    l = len(L)
    if l >= N:
        ans = sum(L[:N])
    else:
        ans = sum(L)
        ans += sum(L[i2 - 1:]) * ((N - l) // (i - i2))
        ans += sum(L[i2 - 1:i2 - 1 + ((N - l) % (i - i2))])
    print(ans)


if __name__ == '__main__':
    main()


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

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

    int h[n];

    int ans;

    for (int i=0; i<n; i++){
        int t;
        cin >> t;
        if (t>=k){
            ans++;
        }

    }

    cout << ans << endl;


//    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a[102], b[102];
  cin >> a >> b;
  int x = strlen(a);
  string c, d;
  c=a;
  d=b;
  if(c==d){
    cout << "Yes\n";
    return 0;
  }
  for(int i=0; i<x; i++){
    char firstLetter=a[x-1];
    char te=a[0];
    for(int j=0; j<x-1; j++){
      char te2;
      te2=a[j+1];
      a[j+1]=te;
      te=te2;
    }
    a[0]=firstLetter;
    string w=a;
    if(w==b){
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  
}

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

int main() {
  vector<vector<int>> C(3, vector<int>(3));

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> C.at(i).at(j);
    }
  }

  vector<int> X(3);
  vector<int> Y(3);
  X.at(0) = 0;
  for (int i = 0; i < 3; i++) Y.at(i) = C.at(0).at(i) - X.at(0);
  for (int i = 0; i < 3; i++) X.at(i) = C.at(i).at(0) - Y.at(0);

  bool good = true;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (X.at(i) + Y.at(j) != C.at(i).at(j)) good = false;
    }
  }

  if (good)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{

  int i, j , flag = 0 , count = 0,A[100],swap,N;

  scanf("%d",&N);
  for(i = 0 ; i<N ; i++) scanf("%d",&A[i]);
    
  for(i = 0;i <N; i++)
    {
      for(j = N-1 ; j >i ; j--)
	{
	  
	  if (A[j] < A[j -1]  )
	    {
	      swap = A[j];
	      A[j] = A[j -1];
	      A[j -1] = swap;
	      count++;
	    }
	  
	}

    }
  for(i =0 ; i <N ; i++)
    {
      if(i ==  N-1)
	{
	  printf("%d\n%d\n",A[i],count);
	  break;
	}
      printf("%d " , A[i]);
    }
}



Measured memory_bytes: 2064
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	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 getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	xx := make([]int, n)
	for i := 0; i < n; i++ {
		xx[i] = getNextInt(scanner)
	}
	sort.Ints(xx)
	ans := math.MaxInt32
	for x := 1; x <= 100; x++ {
		sum := 0
		for i := 0; i < n; i++ {
			sum += (x - xx[i]) * (x - xx[i])
		}
		if ans > sum {
			ans = sum
		}
	}
	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 640
import bisect

n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

a, b, c = [sorted(x) for x in [a, b, c]]

ans = 0

for x in b:
    aa = bisect.bisect_left(a,x)
    bb = bisect.bisect_right(c,x)
    ans += aa * (len(b) - bb)

print(ans)

Measured memory_bytes: 23232
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = Long.parseLong(scanner.nextLine());
        long sqrt = (long)Math.sqrt(n);
        long result = 1;
        for (long i = sqrt - 1; i <= sqrt + 1; i++) {
            long candidate = i * i;
            if (candidate > result && candidate <= n) {
                result = candidate;
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int N;
int main() {
    cin >> N;
    int l, r = 0;
    int sum = 0;
    for(int i = 0; i < N; ++i) {
        cin >> l >> r;
        sum += (r-l)+1;
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>
 
using namespace std;
 
#define all(x) x.begin(),x.end()
int INF = 1e9;
 
class hopcroft_karp{
public:
    vector<vector<int> > graph; //linked list
    vector<int> dist,match;
    vector<bool> used,vv;

    hopcroft_karp(int n,int m) : graph(n),match(m,-1),used(n) {}

    void add_edge(int u,int v){
        graph[u].push_back(v);
    }

    void bfs(){
        dist.assign(graph.size(),-1);
        queue<int> que;
        for(int i = 0; i < graph.size(); i++){
            if (!used[i]){
                que.push(i);
                dist[i] = 0;
            }
        }

        while(!que.empty()){
            int a = que.front();
            que.pop();
            for(int i = 0 ; i < graph[a].size(); i++){
                int b = graph[a][i];
                int c = match[b];
                if(c >= 0 && dist[c] == -1){
                    dist[c] = dist[a]+1;
                    que.push(c);
                }
            }
        }
    }

    bool dfs(int a){
        vv[a] = true;
        for(int i = 0; i < graph[a].size(); i++){
            int b = graph[a][i];
            int c = match[b];
            if(c < 0 || (!vv[c] && dist[c] == dist[a]+1&& dfs(c))){
                match[b] = a;
                used[a] = true;
                return true;
            }
        }
        return false;
    }

    int bipartite_matching(){
        int ret = 0;
        while(1){
            bfs();
            vv.assign(graph.size(),false);
            int flow = 0;
            for(int i = 0; i < graph.size(); i++){
                if(!used[i] && dfs(i)) flow++;
            }
            if(flow == 0) return ret;
            ret += flow;
        }

        return ret;
    }

    void output(){
        for(int i = 0; i < match.size(); i++){
            if (~match[i]){
                cout << match[i] << " " << i << endl;
            }
        }
    }

};
 
int main(){
    int n;
    cin >> n;
    hopcroft_karp din(n,n);

    vector<int> a(n),b(n),c(n),d(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    for(int i = 0; i < n; i++){
        cin >> c[i] >> d[i];
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(a[i] < c[j] && b[i] < d[j]){
                din.add_edge(i,j);
            }
        }
    }

    //din.bipartite_matching();
    cout << din.bipartite_matching() << endl;

    //din.output();

}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Text;
class Program {
    static void Main(string[] args) {
#if LOCAL_ENVIRONMENT
        var stdin = new System.IO.StreamReader("stdin.txt");
        System.Console.SetIn(stdin);
#endif
        SimpleScanner sc = new SimpleScanner();
        int A = sc.NextInt(), B = sc.NextInt(), C = sc.NextInt();
        Console.WriteLine(A+B>=C ? "Yes" :"No");
    } //Main

    public class SimpleScanner {
        private int cnt;
        private string[] items;
        public SimpleScanner() {
            this.cnt = 0;
            var sb = new StringBuilder();
            var s = Console.ReadLine();
            while (s != null) {
                sb.Append(s + " ");
                s = Console.ReadLine();
            }
            this.items = sb.ToString().Split(' ');
#if LOCAL_ENVIRONMENT
    Console.Error.WriteLine("SimpleScanner.items: {0}" , this.items.ToStringA());
#endif
        }
        public void SetCnt(int n) { this.cnt = n; }
        public int NextInt() {
            return int.Parse(this.items[this.cnt++]);
        }
        public long NextLong() {
            return long.Parse(this.items[this.cnt++]);
        }
        public string NextString() {
            return this.items[this.cnt++];
        }
        public int[] NextIntArray(int n) {
            if (n < 1) throw new IndexOutOfRangeException("引数は1以上であること！");
            var result = new int[n];
            for (var i = 0; i < n; i++) result[i] = this.NextInt();
#if LOCAL_ENVIRONMENT
            Console.Error.WriteLine("{0}", result.ToStringA());
#endif
            return result;
        }
        public long[] NextLongArray(int n) {
            if (n < 1) throw new IndexOutOfRangeException("引数は1以上であること！");
            var result = new long[n];
            for (var i = 0; i < n; i++) result[i] = this.NextLong();
#if LOCAL_ENVIRONMENT
            Console.Error.WriteLine("{0}", result.ToStringA());
#endif
            return result;
        }
        public string[] NextStringArray(int n) {
            if (n < 1) throw new IndexOutOfRangeException("引数は1以上であること！");
            var result = new string[n];
            for (var i = 0; i < n; i++) result[i] = this.NextString();
#if LOCAL_ENVIRONMENT
            Console.Error.WriteLine("{0}", result.ToStringA());
#endif
            return result;
        }
        public int[][] NextInt2Col(int n) {
            const int M = 2;
            if (n < 1) throw new IndexOutOfRangeException("引数は1以上であること！");
            int[][] result = new int[M][] {
                new int[n],
                new int[n],
            };
            for (var i = 0; i < n; i++) {
                result[0][i] = this.NextInt();
                result[1][i] = this.NextInt();
            }
#if LOCAL_ENVIRONMENT
            Console.Error.WriteLine("NextInt2Col: [");
            for (var i = 0; i < M; i++)
                Console.Error.WriteLine("  {0},", result[i].ToStringA());
            Console.Error.WriteLine("]");
#endif
            return result;
        }
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int SURP = 1000000007;

int keta_sum(int i){
	int sum = 0;
	while(i > 0){
		sum += i%10;
		i = i/10;
	}
	return sum;
}

int main(){
	long long int X,Y;
	cin >> X >> Y;

	long long int i = X;
	long long int ret = 1;
	while(i <= Y){
		i = i*2;
		ret++;
	}
	ret--;

	cout << ret << endl;
	return 0;

}

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

int main() 
{
	int n, k;
	cin >> n >> k;
	vector<int> hv(n);
	for (auto& h : hv) {
		cin >> h;
	}

	sort(hv.begin(), hv.end(),std::greater<int>());
	
	long long ret = 0;
	for (int i = k; i < n; ++i) {
		ret += hv[i];
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
#define endl '\n'
#define fori(s,n) for(int i=s;i<n;i++) 
#define forj(s,n) for(int j=s;j<n;j++) 
#define vii vector<int>
int mod = 1e9 + 7;
int t = 1, n, m;
vector<vector<char>> grid;
int dp[1001][1001];
int solve(int i, int j) {
	if (i >= n || j >= m || grid[i][j] == '#') return 0;//validation
	if (i == n - 1 && j == m - 1) return 1;
	int& ret = dp[i][j];
	if (~ret) return ret;
	int r1 = solve(i + 1, j);
	int r2 = solve(i, j + 1);
	return ret=(r1 + r2)%mod;
}
signed main()
{
	fast;
	//cin>>t;
	while (t--)
	{
		memset(dp, -1, sizeof dp);
		cin >> n >> m;
		grid = vector<vector<char>>(n, vector<char>(m));
		fori(0, n) forj(0, m) cin >> grid[i][j];
		cout << solve(0, 0) << endl;
	}
}

Measured memory_bytes: 12148
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,res;
    cin>>n>>k;
    string s;
    cin>>s;
    res = 0;
    for(int i=1;i<s.size();i++){
        if(s[i]==s[i-1]){
            res++;
        }
    }
    res = min(res+2*k,n-1);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline

mod = 10**9+7
n, k = map(int, input().split())
A = tuple(tuple(map(int, input().split())) for _ in range(n))
def matmul(X, Y):
  Z = [[0]*n for _ in range(n)]
  for i in range(n):
    for j in range(n):
      for k in range(n):
        Z[i][j] += X[i][k] * Y[k][j]
        Z[i][j] %= mod
  return Z
  
def matpow(k):
  if k == 1:
    return A
  if k%2:
    return matmul(A, matpow(k-1))
  X = matpow(k//2)
  return matmul(X, X)

B = matpow(k)
ans = 0
for i in range(n):
  for j in range(n):
    ans += B[i][j]
    ans %= mod
print(ans)

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

#define ll long long

using namespace std;

int chk[105] = { 1 };

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

	for (int i = 4; i <= 100; i+=4) chk[i] = 1;
	for (int i = 7; i <= 100; i++) {
		if (chk[i - 7] != 0) chk[i] = 1;
	}
	int n; cin >> n;
	if (chk[n] == 0)cout << "No";
	else cout << "Yes";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <utility>
#include <map>
int needleX[4] = { -1,0,1,0 };
int needleY[4] = { 0,1,0,-1 };

int main(void) {
    int n;
    std::cin >> n;

    while(n!=0){
    int ans =0;
        for(int i=2;i<=n;i++){
            if((2*n%i)==0&&i%2==1){
                ans++;
            }
        }
        std::cout << ans <<std::endl;
        std::cin >> n;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,l;
    cin >> n >> l;
    string a[n];
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a,a+n);
    for (int i = 0; i<  n; i++) cout << a[i];
}


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

using namespace std;

int main () {
  int N;
  cin >> N;
  int A[N];
  int absA[N];
  long long absum = 0;
  int count_neg = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] < 0) {
      count_neg++;
      absA[i] = -A[i];
    }
    else absA[i] = A[i];
    absum += absA[i];
  }


  if (count_neg %2 == 0) cout << absum;
  else {
    sort(absA, absA+N);
    absum -= 2*absA[0];
    cout << absum;
  }
  
}


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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

class Solution
{
private:
public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        int n, m;
        cin >> n >> m;
        ll ggcd = 1;
        vector<ll> vv;
        db(n, m);
        for (size_t i = 0; i < n; i++)
        {
            ll x;
            cin >> x;
            vv.pb(x);
            ggcd = ggcd / __gcd(ggcd, x) * x;
            db(x, ggcd);
            if (ggcd > 2 * m)
            {
                db("abcd");
                cout << 0 << '\n';
                return;
            }
        }
        sort(all(vv));
        vv.resize(unique(all(vv)) - vv.begin());
        ll xy = 1LL << 32;
        ll a = -1;
        for (auto &x : vv)
        {
            ll g = __gcd(xy, x);
            if (a == -1)
                a = g;
            else if (a != g)
            {
                db(g, x, xy);
                cout << 0 << '\n';
                return;
            }
        }
        db(vv);
        ggcd /= 2;
        ll res = m / ggcd;
        res--;
        res /= 2;
        db(bitset<30>(res), bitset<30>(ggcd), bitset<30>(m));
        db(res, ggcd, m);
        while ((2 * res + 1) * ggcd <= m)
            res++;
        cout << res << '\n';
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

int main() {
  int N;
  cin >> N;
  vector<string> input(N);
  for (int i = 0; i < N; i++) cin >> input[i];

  for (int i = 0; i < N; i++) {
    input.push_back(input[i]);
  }
  int cnt = 0;

  for (int z = 0; z < N; z++) {
    bool ok = true;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (input[z + i][j] != input[z + j][i]) ok = false;
      }
    }
    if (ok) cnt++;
  }
  cout << cnt * N << endl;
  return 0; 
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>

using std::min;

const int MAXN=200011;

int N;
char input[MAXN];
int A[MAXN], S[MAXN];

int main(){
	
	scanf("%d", &N);
	scanf("%s", input);
	
	for(int i=1;i<=N;++i)	A[i]=input[i-1]=='#';
	
	for(int i=1;i<=N;++i)	S[i]=S[i-1]+A[i];
	
	int Ans=min(S[N], N-S[N]);
	
	for(int i=1;i<N;++i)
		Ans=min(Ans, S[i]+(N-i)-(S[N]-S[i]));
	
	printf("%d\n", Ans);
	
	return 0;
}

Measured memory_bytes: 1920
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int A[100010];
    rep(i, N) cin >> A[i];
    int tmp = 1;
    int ans = 0;
    int sum = 0;
    rep(i, N) sum += A[i];
    int cost = 0;
    int z = pow(2, 45);
    while(tmp <= z) {
        int X = 0;
        int Y = 0;
        rep(i, N) {
            X += (A[i] & tmp);
            Y += (A[i] & tmp) ^ tmp;
            //cout << (A[i] & tmp) << " " << ((A[i] & tmp) ^ tmp) << endl;
        }
        if (X < Y && cost + tmp <= K) {
            cost += tmp;
            ans += Y;
        }
        else ans += X;
        tmp *= 2;
    }
    int ans2 = 0;
    int cost2 = 0;
    while(tmp > 0) {
        int X = 0;
        int Y = 0;
        rep(i, N) {
            X += (A[i] & tmp);
            Y += (A[i] & tmp) ^ tmp;
            //cout << (A[i] & tmp) << " " << ((A[i] & tmp) ^ tmp) << endl;
        }
        if (X < Y && cost2 + tmp <= K) {
            cost2 += tmp;
            ans2 += Y;
        }
        else ans2 += X;
        tmp /= 2;
                //cout << cost2 <<endl;
    }
    //cout << cost << " " << cost2 << endl;
    cout << max({ans, sum, ans2}) << endl;
    //cout << ans << " " << ans2 << " " << sum << endl;

    return 0;
}


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int n;
    cin >> n;
    vector<pair<int,int>> p(n);
    for(auto& x : p){
        int a, b;
        cin >> a >> b;
        x = make_pair(a, b);
    }
    sort(p.begin(), p.end(), greater<pair<int,int>>());
    cout << p[0].first + p[0].second << endl;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] list = str.split(" ");

		if(list[0].endsWith(list[1].substring(0, 1)) && list[1].endsWith(list[2].substring(0, 1))){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}


}


Measured memory_bytes: 22484
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n;
    char a[60];
    scanf("%d",&n);
    scanf("%s",a);
    int ans=0;
    for(int i=2;i<n;i++)
    {
        if(a[i]=='C')
            if(a[i-1]=='B')
                if(a[i-2]=='A')
                    ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)


int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    n=n/2+(n%2==1);
    if(n>=k)printf("YES\n");
    else printf("NO\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e9;

int main(){
	int n,l;
  	cin >> n >> l;
	auto s = vector<string>(n);
	for(int i=0;i<n;i++){
		cin >> s[i];
	}
	sort(s.begin(),s.end());
	for (auto i:s)
	{
		cout << i;
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // スペース区切りの整数の入力(HとW)
        int H = sc.nextInt();
        int W = sc.nextInt();
        // スペース区切りの整数の入力(hとw)
        int h = sc.nextInt();
        int w = sc.nextInt();
        // 出力
        System.out.println((H-h)*(W-w));
    }
}

Measured memory_bytes: 22868
A = int(input())                     
B = int(input())                     
C = int(input())                     
X = int(input())                     
                                     
pat = 0                              
for i in range(A+1):                 
    for j in range(B+1):             
        for k in range(C+1):         
            if i*500+j*100+k*50 == X:
                pat = pat + 1        
                                     
print(pat)                           

Measured memory_bytes: 40176
using System;
namespace ConsoleApplication1{
    class Program{
        static void Main(string[] args){
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++) {
                String[] str = Console.ReadLine().Split();
                int[] a = new int[3];
                for (int j = 0; j < 3; j++) {
                    a[j] = int.Parse(str[j]) * int.Parse(str[j]);
                }
                Array.Sort(a);
                Console.WriteLine(a[0] + a[1] == a[2] ? "YES" : "NO");
            }
        }
    }
}

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

int main() {
  int n, y, ans[5] = {-1, -1, -1, -1, -1};
  cin >> n >> y;
  for (int i = n; i >= 0; i--) {
    for (int j = n - i; j >= 0; j--) {
      if (10000 * i + 5000 * j + 1000 * (n - i - j) == y) {
        ans[0] = i;
        ans[1] = j;
        ans[2] = n - i - j;
      }
    }
  }
  cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << endl;
}

Measured memory_bytes: 256
/*
  Contest 073
  A - September 9
  Rakesh Kumar --> 11/09/2020
 */

#include <bits/stdc++.h>

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

    std::string s;
    std::getline(std::cin, s);
    std::string r = "No";
    for (char c : s){
        if (c == '9') {
            r = "Yes";
            break;
        }
    }
    std::cout << r << std::endl;

    return 0;
}


Measured memory_bytes: 3580
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = 310;

int n;
int a[maxn][maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      scanf("%d", a[i] + j);
    }
  }
  return 1;
}

typedef unsigned long long type;
const int maxk = (maxn + 63) / 64;

type b[maxn][maxk];

int used[maxn];

int dp[maxn][maxn];
int two[maxn];


void solve() {
  two[0] = 1;
  for (int i = 1; i <= n; ++i) {
    two[i] = two[i - 1];
    add(two[i], two[i]);
  }
  memset(dp, 0, sizeof(dp));
  for (int a = 0; a <= n; ++a) {
    dp[a][0] = 1;
    for (int take = 0; take < n; ++take) {
      for (int r = min(take, a); r >= 0; --r) {
        int &cur = dp[a][r];
        if (cur) {
          int k0 = two[n - a + r];
          int k1 = two[n];
          add(k1, mod - k0);
          add(dp[a][r + 1], mult(cur, k1));
          cur = mult(cur, k0);
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    used[i] = 0;
  }

  int k = (n + 63) / 64;
  for (int i = 0; i < n; ++i) {
    for (int j = 0, p = 0; j < k; ++j) {
      auto &cur = b[i][j];
      cur = 0;
      for (int iter = 0; iter < 64 && p < n; ++iter) {
        cur ^= ((type) a[i][p++] << iter);
      }
    }
  }
  int rank = 0;
  for (int c = 0; c < n; ++c) {
    int r = -1;
    for (int i = 0; i < n; ++i) {
      if (used[i] || !(b[i][c >> 6] & ((type) 1 << (c & 63)))) {
        continue;
      }
      r = i;
      break;
    }
    if (r == -1) {
      continue;
    }
    ++rank;
    used[r] = 1;
    for (int i = 0; i < n; ++i) {
      if (i == r) {
        continue;
      }
      if (b[i][c >> 6] & ((type) 1 << (c & 63))) {
        for (int j = 0; j < k; ++j) {
          b[i][j] ^= b[r][j];
        }
      }
    }
  }
  eprintf("rank = %d\n", rank);
  int res = 0;
  for (int a = 0; a <= n; ++a) {
    add(res, mult(mult(dp[a][rank], dp[n][a]), myPower(dp[n][rank], mod - 2)));
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

// using Matrix = vector< vector<int> >;
int mat[30][30];
const int INF = 1 << 30;
int W, H, ans = 0;

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

void dfs(int turn, int x, int y) {
   if (turn > 10) return;

   for (int i = 0; i < 4; i++) {
      int nx = x + dx[i], ny = y + dy[i];
      if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
      if (mat[nx][ny] == 1) continue;

      nx -= dx[i], ny -= dy[i];
      while (1) {
         nx += dx[i], ny += dy[i];
         if (nx < 0 || nx >= H || ny < 0 || ny >= W) {
            break;
         } else if (mat[nx][ny] == 3) {
            ans = min(ans, turn);
            break;
         } else if (mat[nx][ny] == 1) {
            mat[nx][ny] = 0;
            dfs(turn+1, nx-dx[i], ny-dy[i]);
            mat[nx][ny] = 1;
            break;
         }
      }
   }
}

int main() {
   while (cin >> W >> H, W) {
      ans = INF;

      int x = 0, y = 0;
      for (int i = 0; i < H; i++) {
         for (int j = 0; j < W; j++) {
            cin >> mat[i][j];
            if (mat[i][j] == 2) {
               x = i, y = j;
            }
         }
      }

      dfs(1, x, y);
      cout << (ans == INF ? -1 : ans) << endl;
   }

   return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M1 					1000000007
#define M2 					998244353
#define ll 					long long int
#define pll 				pair<ll,ll>
#define mll 				map<ll,ll>
#define F 					first
#define S 					second
#define PB 					push_back
#define mp 					make_pair
#define lb 					lower_bound
#define ub 					upper_bound
#define V(a) 				vector<a>
#define endl 				'\n'
#define test(t) 			while(t--)
#define PI 					acos(-1.0)
#define rep(i,a,b) 			for(ll i=a;i<b;i++)
#define repp(i,b,a) 		for(ll i=b-1;i>=a;i--)
#define clr(ar, val)		memset(ar, val, sizeof(ar))
#define setbits(x) 			__builtin_popcountll(x)
#define zrobits(x) 			__builtin_ctzll(x)
#define ps(y) 				fixed << setprecision(y)
#define all(x) 				begin(x),end(x)
#define allr(x) 			rbegin(x),rend(x)
const int inf= 				0x3f3f3f3f;
const ll INF= 				0x3f3f3f3f3f3f3f3f;
const int dx[4]= 			{ 0, -1, 0, 1 };
const int dy[4]= 			{ -1, 0, 1, 0 };

unsigned  int  randInt (){ 
    static  unsigned  int  tx  =  123456789 ,  ty = 362436069 ,  tz = 521288629 ,  tw = 88675123 ; 
    unsigned  int  tt  =  ( tx ^ ( tx << 11 )); 
    tx  =  ty ;  ty  =  tz ;  tz  =  tw ; 
    return  (  tw = ( tw^ ( tw >> 19 )) ^ ( tt ^ ( tt >> 8 ))  ); 
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll floor_div(ll a, ll b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
ll ceil_div(ll a, ll b){
    return a / b + (((a ^ b) >= 0) and a % b);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

void solve()
{
    ll a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    ll ans = a*x + b*y;
    ll z = 0;
    for(ll i=2;i<=2*max(x,y);i+=2){
        ans = min(ans,a*(max(z,x-i/2)) + b*max(z,y-i/2) + c*i);
    }
    cout << ans << endl;   

}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    test(t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<fstream>

#define F firstg
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
using namespace std;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    int i,j,k=0,p=1,q=1;
    long n,m,tmp;
    int count=1;;
    int a[500050];
    string str;
    char c;
    ll sum=0;
    int strr[200005];
    cin>>str;
    
    for(i=0;str[i]!='\0';i++){
        if(i==0){
            c=str[0];
        }else{
            if(c==str[i]){
                count++;
            }else{
                a[k]=count;
                k++;
                c=str[i];
                count=1;
            }
        }
        if(str[i+1]=='\0') q=i;
    }
    //cout<<q<<endl;
    int f=0;
    a[k]=count;
    if(str[0]=='>'){
        rep(i,a[0]+1){
            sum=sum+i;
        }
        f=1;
    }
    j=(k+1-f)/2;
    int lp=0;
    //cout<<sum<<endl;
    for(i=f;lp<j;i=i+2,lp++){
        if(a[i]>a[i+1]){
            p=a[i+1];
            a[i+1]=a[i];
            a[i]=p;
        }
        rep(l,a[i+1]+1){
            sum=sum+l;
        }
        rep(l,a[i]){
            sum=sum+l;
        }
        //cout<<sum<<" ";
    }
    //cout<<"j"<<j<<endl;
    if(str[q]=='<'){
        rep(i,a[k]+1){
            sum=sum+i;
        }
    }


    //rep(i,k+1){
        //cout<<a[i]<<" ";
    //}
    //cout<<endl;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1820
#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
struct wo{
	long long x;
	long long y;
}a[10001];
long long ans,n,t;
int main(){
    cin>>n>>t;
    for(int i=1;i<=n;i++){
    	cin>>a[i].x>>a[i].y;
	}
	ans=9111111111111111111;
	long long b,c,d,e;
	long long sum=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				for(int l=1;l<=n;l++){
					b=a[i].x,c=a[j].x,d=a[k].y,e=a[l].y;
					sum=0;
					if(b>c)swap(b,c);
					if(d>e)swap(d,e);
					for(int m=1;m<=n;m++){
						if(b<=a[m].x&&c>=a[m].x&&d<=a[m].y&&e>=a[m].y){
							sum++;
						}
					}
					if(sum>=t)ans=min(ans,(c-b)*(e-d));
				}
			}
		}
	}
    cout<<ans;
}

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

namespace Contest
{
    

    class Program
    {

        static void Main(string[] args)
        {

            var input = Console.ReadLine().Split();
            for(int i = 0; i < input.Length; i++)
            {
                if(input[i] == "0")
                {
                    Console.WriteLine(i + 1);
                    break;
                }
            }
        }
    }
}




Measured memory_bytes: 25952
class Rect:
    def __init__(self, a, b):
        self.a = a
        self.b = b


N, H, W = map(int, input().split())
rects = []
for _ in range(N):
    a, b = map(int, input().split())
    rects.append(Rect(a, b))


cnt = 0
for rect in rects:
    if rect.a >= H and rect.b >= W:
        cnt += 1
print(cnt)


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

int main(){
  int n;
  cin >> n;
  map<int,int> mp;
  for (int i = 0; i < n-1; i++)
  {
    int a;
    cin >> a;
    mp[a]++;
  }

  for (int i = 1; i <= n; i++)
  {
    cout << mp[i] << endl;
  }  
}

Measured memory_bytes: 13016
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        int H = in.nextInt();
        int W = in.nextInt();
        long[][] c = new long[10][10];
        for (int i=0;i<10;i++) {
            for (int j=0;j<10;j++) {
                c[i][j] = in.nextInt();
            }
        }
        int[] cnt = new int[10];
        for (int i=0;i<H;i++) {
            for (int j=0;j<W;j++) {
                int a = in.nextInt();
                if (a!=-1) {
                    cnt[a]++;
                }
            }
        }

        for (int k=0;k<10;k++) {
            for (int i=0;i<10;i++) {
                for (int j=0;j<10;j++) {
                    c[i][j] = Math.min(c[i][j], c[i][k]+c[k][j]);
                }
            }
        }
        long ans = 0L;
        for (int i=0;i<10;i++) {
            ans += cnt[i]*c[i][1];
        }
        out.println(ans);
        out.close();
    }

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

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

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

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

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

    }
}


Measured memory_bytes: 25556
N, M = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

is_ok = as.map do |a|
  ret = 0
  n = a
  while n % 2 == 0
    n = n / 2
    ret += 1
  end
  ret
end.uniq.size == 1

if !is_ok
  puts 0
  exit 0
end

lcm = as.map { |a| a / 2 }.reduce { |acc, a| acc.lcm(a) }
puts (M + lcm) / (lcm * 2)

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

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

#############
# Main Code #
#############

A,B,C = inputIL()

if A<=C<=B:
  print("Yes")
  
else:
  print("No")

Measured memory_bytes: 63980
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0;  i< n; i++) cin >> v[i];
    int T;
    cin >>T;
    while (T--) {
        int b, e, k;
        cin >> b >> e >> k;
        cout << count(v.begin()+b, v.begin()+e, k) << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
import java.util.Arrays;
import java. util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int k = scan.nextInt();
		Integer a[] = new Integer[n];

		for(int i=0;i<n;i++) {
			a[i] = scan.nextInt();
		}

		Arrays.sort(a);

		int total = 0;

		for(int i=0;i<k;i++) {
			total = total + a[i];
		}
		System.out.println(total);

	}

}


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

int main(){
    int N;
    vector<int> X;
    vector<int> S;
 
    cin >>N;
    for(int i=0;i<N;++i){
        int tmp;
        cin >> tmp;
        X.push_back(tmp);
    } 

    auto itr = max_element(X.begin(),X.end());
    int max_val = *itr;

    /*
    cout << "max_val " << max_val << endl;
    */

    int index = 0;
    for(int i=0;i<max_val;++i){
        int tmp=0;
        for(int j=0;j<N;++j){
            tmp += pow(X[j] - i -1, 2);         
            //  cout << "i=" << i << " Xi=" << X[j]<< " Dis=" << tmp << endl;
        }
        S.push_back(tmp);
        index++;
    }

    itr = min_element(S.begin(),S.end());

    cout << *itr << endl; 


}

Measured memory_bytes: 256
#include <stdio.h>


int main () {
	long long int N;
	scanf("%lld", &N);
	char nama[100];
	int i = 0;
	
	while ( N != 0) {
		N--;
		int M = N % 26;
		nama[i] = 'a' + M;
		N /= 26;
		i++;
	}
	
	for (int j = i - 1 ; j >= 0 ; j--) {
		printf("%c", nama[j]);
	}
	
	return 0;
}

Measured memory_bytes: 1660
fun main(args: Array<String>) {
    val (n, q) = readLine()!!.split(' ').map { it.toInt() }

    val s = readLine()!!
    val p = IntArray(n)
    var cnt = 0
    p[0] = 0
    for (i in 1 until n) {
        if (s[i-1] == 'A' && s[i] == 'C') cnt++
        p[i] = cnt
    }

    repeat(q) {
        val (l, r) = readLine()!!.split(' ').map { it.toInt()-1 }
        println(p[r] - p[l])
    }

}


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

#define lli long long int
#define pb push_back
#define in insert
#define pi pair<int, int>
#define pd pair<double, int>
#define pii pair<int, pi>
#define mp make_pair
#define fir first
#define sec second
#define MAXN 200001
#define mod 1000000007

signed main()
{
  lli n, m;
  cin >> n >> m;
  lli ans = 0;
  for (int i = m; i <= n + 1; i++)
    ans = (ans + (i * (n + 1 - i) + 1)) % mod;
  cout << ans << endl;
}

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

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if(U==S) A--;
  else B--;
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256