akhauriyash/Code-Regression huggingface dataset:
import std.container;
import std.range;
import std.algorithm;
import std.array;
import std.string;
import std.conv;
import std.stdio;
import std.container;

void main() {
	readln;
	auto a = readln.chomp.split(' ').map!(to!int).array;
	auto c = new int[10 ^^ 6 + 1];
	foreach (e;a) {
		++c[e];
	}

	auto pairwise = true;
	foreach (i;2..c.length) {
		auto count = 0;
		for (auto j = i;j < c.length;j += i) {
			count += c[j];
		}
		if (count > 1) {
			pairwise = false;
			break;
		}
	}
	if (pairwise) {
		writeln("pairwise coprime");
		return;
	}

	int gcd(int x, int y) {
		if (y == 0) return x;
		return gcd(y, x % y);
	}
	if (a.reduce!gcd == 1) {
		writeln("setwise coprime");
		return;
	}

	writeln("not coprime");
}


Measured memory_bytes: 45592
#include<stdio.h>
int main()
{
	int n,k,x,y,sum=0;
	scanf("%d%d%d%d%d",&n,&k,&x,&y);
	if(n>k)
           {     sum=(n-k)*y+k*x+sum;
	        printf("%d",sum);}
	if(n<=k)
            {    sum=n*x+sum;
	        printf("%d",sum);}
       return 0;
}



Measured memory_bytes: 128
package main

import "fmt"

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	if (b-a)%2 == 0 {
		fmt.Println((b - a) / 2)
	} else {
		fmt.Println(min(a-1, n-b) + (b-a+1)/2)
	}
}


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

using namespace std;
typedef long long ll;

double  dp[3030][3030],p[3030];

int main()
{
    int n;scanf("%d",&n);

    for(int i=1;i<=n;i++){
        scanf("%lf",&p[i]);
    }
    dp[0][0]=1.00;
    for(int i=1;i<=n;i++)
      for(int j=0;j<=i;j++){
        int x=j,y=i-j;
        if(x) dp[x][y]+=dp[x-1][y]*p[i];
        if(y) dp[x][y]+=dp[x][y-1]*(1.0-p[i]);
    }
    int l=0,r=n;
    double ans=0.0;
    while(r>l){
        ans+=dp[r][l];
        l++,r--;
    }
    printf("%.10f\n",ans);
    return 0;
}


Measured memory_bytes: 71936
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		char[] s=sc.next().toCharArray();
		
		int count1=0,count0=0;
		for(char c:s){
			if(c=='1')
				count1++;
			else
				count0++;
		}
		
		System.out.println(Math.min(count0,count1)*2);
	
	}
	
}

Measured memory_bytes: 27220
def main():
    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in [0]*m]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]

    q = [0]
    for _ in range(2):
        q2 = []
        while q:
            i = q.pop()
            for j in g[i]:
                q2.append(j)
        q = q2
    if n-1 in q:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


main()

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

int ac_pos[100'000];
int len;

int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    int N, Q;
    cin >> N >> Q;
    string input;
    cin >> input;

    int pos = 0;
    while ((pos = input.find("AC", pos)) != string::npos)
    {
        ac_pos[len++] = pos;
        pos += 2;
    }

    while (Q--)
    {
        int l, r;
        cin >> l >> r;
        l--; r--;
        int diff = lower_bound(ac_pos, ac_pos + len, r) - lower_bound(ac_pos, ac_pos + len, l);
        cout << diff << '\n';
    }
    return 0;
}

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

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

    string s;
    cin >> s;

    int ans = 0;
    for(int i = 0; i < 1000; i++){
        int z[3];
        z[0] = i / 100;
        z[1] = i % 100 / 10;
        z[2] = i % 100 % 10;
        int flag = 0;
        for(int j = 0; j < n; j++){
            if(s[j] == (char)(z[flag] + '0')){
                flag++;
            }

            if(flag == 3){
                break;
            }
        }

        if(flag == 3){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

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

var N int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	s := make([]int, N)
	sum := 0
	for i := 0; i < N; i++ {
		s[i] = nextInt()
		sum += s[i]
	}

	if sum%10 > 0 {
		fmt.Println(sum)
		return
	}

	sort.Ints(s)
	for i := 0; i < N; i++ {
		if s[i]%10 == 0 {
			continue
		}
		fmt.Println(sum - s[i])
		return
	}

	fmt.Println(0)
}


Measured memory_bytes: 1780
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <fstream>
#include <memory.h>
#include <iomanip>
#include <omp.h>
#include <bitset>
#include <string>
#include <list>

using namespace std;

#define right asfdsg
#define left asfdsvs
#define MAXN 1000000000
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define x1 asicvlid
#define y1 ascnsdkn

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

char s[200500];
int pred[200500];
int nxt[200500];
int n;

int getPred(int p) {
    return pred[p] == p ? p : pred[p] = getPred(pred[p]);
}

int getNext(int p) {
    return nxt[p] == p ? p : nxt[p] = getNext(nxt[p]);
}

void del(int v) {
    pred[v] = getPred(v - 1);
    nxt[v] = getNext(v + 1);
}

int main() {
    scanf ("%s", s + 1);
    n = strlen(s + 1);
    for (int i = 1; i <= n + 1; i ++) pred[i] = i, nxt[i] = i;
    int b = 1;
    int e = 2;
    int cnt = 0;
    while ( e <= n ) {
        if (s[b] == 'S' && s[e] == 'T') {
            del(b);
            del(e);
            b = pred[b];
            e = nxt[e];
            cnt += 2;
            if (b == 0) {
                b = e;
                e = getNext(e + 1);
            }
        } else {
            b = getNext(b + 1);
            e = getNext(e + 1);
        }
    }
    cout << n - cnt;
    return 0;
}


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

int main(){
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  int ans = K;
  for(int i = 0; i < N; ++i){
    // cerr << i << " " << ((A[i]-A[(i+1)%N])%K+K)%K << endl;
    ans = min(ans, K-((A[(i+1)%N]-A[i])%K+K)%K);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <bitset>
#include <queue>
using namespace std;
using ll = long long int;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
const ll INF = 1LL << 60;
ll mod = 1000000007;

vector<int> num(100005,0);

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    rep(i,n) {
        cin >> a[i];
        num[a[i]]++;
        sum += a[i];
    }
    ll q;
    cin >> q;
    rep(i,q) {
        ll b, c;
        cin >> b >> c;
        sum = sum - num[b] * b + num[b] * c;
        num[c] += num[b];
        num[b] = 0;
        cout << sum << endl;
    }
    return 0;
}


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

int main()
{
string a,b;
cin>>a>>b;
 a=a+b;

int in=stoi(a);

if(  floor(sqrt(in))==ceil(sqrt(in)) )
    cout<<"Yes";
else
    cout<<"No"; 

return 0;
}


Measured memory_bytes: 256
import fractions

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

left = [0]*(N+1)
for i in range(1,N+1):
    left[i] = fractions.gcd(left[i-1],A[i-1])

right = [0]*(N+1)
right[N-1] = A[N-1]
for i in range(N-2,-1,-1):
    right[i] = fractions.gcd(right[i+1],A[i])

ans = 0
for i in range(N):
    ans = max(ans,fractions.gcd(left[i],right[i+1]))
print(ans)


Measured memory_bytes: 16132
s=input()
n=len(s)
if(s==s[::-1]):
    if((s[:(n-1)//2]==s[:(n-1)//2][::-1]) and (s[(n+4)//2-1:]==s[(n+4)//2-1:][::-1])):
        print('Yes')
    else:
        print('No')
else:
    print("No")

Measured memory_bytes: 61820
#include <stdio.h> 
int main(void) 
{ 
    int a, b, k, i, n[10000], j=0;
    
    scanf("%d%d%d",&a,&b,&k);
    
    for(i=0;i<k;i++){
        n[i]=a+i;
        if(a+i==b){
            for(i=0;i<=b-a;i++) printf("%d\n",n[i]);
            return 0;
        }
    }
    
    for(i=0;i<k;i++){
        if(n[i+k-1-j]<b+i-k+1){
            n[i+k-j]=b+i-k+1;
        }
        else j++;
    }
    
    for(i=0;i<k*2-j;i++){
        printf("%d\n",n[i]);
    }
	return 0;
}

Measured memory_bytes: 1704
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int a2 = a * a;
			int b2 = b * b;
			int c2 = c * c;
			if (a2 == b2 + c2 || b2 == a2 + c2 || c2 == a2 + b2) {
				System.out.println("YES");
			} else
				System.out.println("NO");
		}
		sc.close();
	}
}

Measured memory_bytes: 33800
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct card{
	char card_type;
	int card_number;
} card_t;

void swap_operation( card_t *swap_card, int number1, int number2 )
{
	card_t tmp_card;

	tmp_card = swap_card[number1];
	swap_card[number1] = swap_card[number2];
	swap_card[number2] = tmp_card;

}

int main()
{
	int size;
	int roop_i, roop_j;
	card_t Card[36], Card_copy[36];
	int minj;
	char tmp;
	int flag;

	scanf( "%d", &size );
	for ( roop_i = 0 ; roop_i < size ; roop_i++ )
	{
		scanf( "%*c%c%d", &Card[roop_i].card_type, &Card[roop_i].card_number );
		Card_copy[roop_i].card_type = Card[roop_i].card_type;
		Card_copy[roop_i].card_number = Card[roop_i].card_number;
	}
	/* Bubble Sort */
	for ( roop_i = 0 ; roop_i < size ; roop_i++ )
	{
		for ( roop_j = size - 1 ; roop_j > roop_i ; roop_j-- )
		{
			if ( Card[roop_j].card_number < Card[roop_j - 1].card_number )
			{
				swap_operation( Card, roop_j, roop_j - 1 );
			}
		}
	}

	for ( roop_i = 0 ; roop_i < size ; roop_i++ )
	{
		if ( roop_i != size - 1 )
		{
			fprintf( stdout, "%c%d ", Card[roop_i].card_type, Card[roop_i].card_number );
		}
		else
		{
			fprintf( stdout, "%c%d\n", Card[roop_i].card_type, Card[roop_i].card_number );
			fprintf( stdout, "Stable\n" );
		}
	}

	/* Selection Sort */
	flag = 0;
	for ( roop_i = 0 ; roop_i < size ; roop_i++ )
	{
		minj = roop_i;
		for ( roop_j = roop_i ; roop_j < size ; roop_j++ )
		{
			if ( Card_copy[roop_j].card_number < Card_copy[minj].card_number )
			{
				minj = roop_j;
			}
		}
		swap_operation( Card_copy, roop_i, minj );
	}

	/* IsStabel */
	for ( roop_i = 0 ; roop_i < size ;roop_i++ )
	{
		if ( Card[roop_i].card_type != Card_copy[roop_i].card_type )
		{
			flag = 1;
		}
	}

	for ( roop_i = 0 ; roop_i < size ; roop_i++ )
	{
		if ( roop_i != size - 1 )
		{
			fprintf( stdout, "%c%d ", Card_copy[roop_i].card_type, Card_copy[roop_i].card_number );
		}
		else
		{
			fprintf( stdout, "%c%d\n", Card_copy[roop_i].card_type, Card_copy[roop_i].card_number );
			if ( flag == 1 )
			{
				fprintf( stdout, "Not stable\n" );
			}
			else 
			{
				fprintf( stdout, "Stable\n" );
			}
		}
	}

	return 0;
}

Measured memory_bytes: 604
N, M = map(int, input().split())
sc= [list(input().split()) for i in range(M)]
ans = -1
for i in range(10**N):
    if len(str(i)) != N:
        continue
    else:
        cnt = 0
        s = str(i)
        for j in range(M):
            if s[int(sc[j][0])-1] == sc[j][1]:
                cnt += 1
        if cnt == M:
            ans = i
            break
print(ans)

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long n, a, b;
    cin >> n >> a >> b;
    if((b-a)%2 == 0){
        cout << (b-a)/2 << endl;
    }
    else{
        long long c, d;
        if(n-b <= a-1){
            d = n;
            c = a + (n-b) + 1;
            cout << (n-b+1) + (d-c)/2 << endl;
        }
        else{
            c = 1;
            d = b - a;
            cout << a + (d-c)/2 << endl;
        }
    }
    return 0;
}

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

int main(){
    string a,b;
    istringstream ss;
    cin >> a >> b;
    ss = istringstream(a+b);
    double ans;
    ss >> ans;
    ans = sqrt(ans);
    if(ans / (int)ans == 1.0) cout << "Yes\n";
    else cout << "No\n";
}

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

using namespace std;

int a[10][10];
int n;
int b[110];
int ho[10][10];

int main(void)
{
	for(int i = 0 ; i < 3 ; i++)
	{
		for(int j = 0 ; j < 3 ; j++)
			scanf("%d", &a[i][j]);
	}
	
	scanf("%d", &n);
	
	for(int i = 0 ; i < n ; i++)
		scanf("%d", &b[i]);
	
	for(int i = 0 ; i < n ; i++)
	{
		for(int j = 0 ; j < 3 ; j++)
		{
			for(int k = 0 ; k < 3 ; k++)
			{
				if(a[j][k] == b[i])
				{
					ho[j][k] = 1;
				}
			}
		}
	}
	
	int ff = 0;
	
	for(int i = 0 ; i < 3 ; i++)
	{
		if(ho[i][0] == 1 && ho[i][1] == 1 && ho[i][2] == 1)
			ff = 1;
		if(ho[0][i] == 1 && ho[1][i] == 1 && ho[2][i] == 1)
			ff = 1;
	}
	
	if(ho[0][0] == ho[1][1] && ho[1][1] == ho[2][2] && ho[2][2] == ho[0][0] && ho[0][0] == 1)
		ff = 1;
	if(ho[0][2] == 1 && ho[1][1] == 1 && ho[2][0] == 1)
		ff = 1;
	
	if(ff == 1)
		printf("Yes");
	else
		printf("No");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;


template<int MOD> struct Fp {  
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;

mint Permutation(ll n,ll k){
	mint ret = 1;
	for(ll i = 0; i < k; ++i){
		ret *= (n - i);
	}
	return ret;
}

mint Combination(ll n,ll k){
	mint ret = 1;
	mint div = 1;
	for(ll i = 0; i < k; ++i){
		ret *= (n - i);
		div *= (i + 1);
	}
	ret /= div;
	return ret;
}


signed main(){
	//cout << fixed << setprecision(10);
	mint ans = 1;
	ll n,m; cin >> n >> m;
	for(ll i = 2; i * i <= m; ++i){
		if(m % i == 0){
			ll cnt = 0;
			while(m % i == 0){
				cnt++;
				m /= i;
			}
			ans *= Combination(cnt + n - 1,cnt);
		}
	}
	if(m != 1){
		ans *= Combination(n,1);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3616
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            string s = "APPROVED";
            for (int i = 0; i < N; i++)
            {
                if(A[i] % 2 == 0)
                {
                    if(A[i] % 3 == 0 || A[i] % 5 ==0)
                    {
                        s = "APPROVED";
                    }
                    else
                    {
                        s = "DENIED";
                        break;
                    }
                }
            }
            Console.WriteLine(s);
        }
    }
}

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

class main{
    public static void Main(String[] args){
        int[] a = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);

        Console.WriteLine(gcd(a[0],a[1]));
    }

    internal static int gcd(int x,int y){
        if(x < y){
            Swap(x,y);
        }

        while(y > 0){
            int r = x % y;
            x = y;
            y = r;
        }

        return x;
    }

    internal static void Swap(int a, int b) {
        var t = a;
        a = b;
        b = t;
    }
}

Measured memory_bytes: 9080
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

ll gcd(ll x, ll y){
	if(x>y) swap(x, y);
	while(1){
		y %= x;
		swap(x, y);
		if(x==0) return y;
	}
}

int main(){
	ll N, M; cin >> N >> M;
	ll A[N];
	rep(i, N){
		cin >> A[i]; A[i] /= 2;
	}
	ll ans = A[0];
	rep(i, N){
		if(ans > M){
			cout << 0 << endl;
			return 0;
		}
		ans = (A[i]*ans)/gcd(A[i], ans);
	}
	int f = 0;
	rep(i, N){
		if((ans/A[i])%2==0) f = 1;
	}
	if(!f){
		ll aa = M/ans;
		cout << (1+aa)/2 << endl;
	}else{
		cout << 0 << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/


const int N = 1111;
bool prime[N + 1];
vector<int> primes;

void hurui()
{
	memset(prime, true, sizeof(prime));
	prime[0] = prime[1] = false;
	for (int i = 2; i*i < N; i++)
	{
		if (!prime[i]) continue;
		for (int j = i; i*j < N; j++)
		{
			prime[i*j] = false;
		}
	}
	REP(i, N + 1)
	{
		if (prime[i]) primes.push_back(i);
	}
}


int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	hurui();
	int n;
	cin >> n;
	map<int, int> mp;
	FOR(i, 1, n + 1)
	{
		int t = i;
		for(auto j: primes)
		{
			while (t % j == 0)
			{
				t /= j;
				mp[j]++;
			}
		}
	}
	ll res = 1;
	for (auto i : mp)
	{
		res *= (i.second + 1);
		res %= MOD;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());

			var hashSet = new HashSet<string>();

			for(var i = 0; i < n; i++)
			{
				hashSet.Add(Console.ReadLine());
			}

			Console.WriteLine(hashSet.Count);
		}
	}
}


Measured memory_bytes: 42988
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    int N;
    cin >> N;
    vector<pair<string,int>> data(N);
    rep(i, N) {
        cin >> data[i].first >> data[i].second;        
    }
    string X;
    cin >> X;

    int ans = 0;
    bool sleeping = false;
    rep(i, N) {
        if (sleeping) {
            ans += data[i].second;
        } else if (data[i].first == X) {
            sleeping = true;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
 multiset<int> s;
  int n,a,b,c;
  cin >> n;
  while(n--){
    cin >> a>>b;
    if(!a){
      s.insert(b);
      cout << s.size() <<endl;
    }
    else if(a==1)cout << s.count(b) << endl;
    else if(a==2)s.erase(b);
    else{
      cin >> c;
      auto it=s.lower_bound(b),end=s.upper_bound(c);
      for(;it!=end;it++){
        cout << *it<<endl;
      }
    }
}
}


Measured memory_bytes: 12364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

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

    int N,M; cin >> N >> M;
    vector<l_l> a(N);
    rep(i,N) cin >> a[i].fs >> a[i].sc;

    sort(all(a));
    int cnt = 0;
    ll sum = 0;
    while(M>0){
        if(M <= a[cnt].sc){
            sum += M * a[cnt].fs;
            M = 0;
        }
        else{
            sum += a[cnt].fs * a[cnt].sc;
            M -= a[cnt].sc;
        }
        cnt++;
    }

    cout << sum << endl;
    return 0;
    
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
using namespace std;
int main() {
	string s;
	bool flg[3] = {
		false,false,false
	};

	cin >> s;

	for (int i = 0; i < 3; i++)
	{
		flg[s[i] - 'a'] = true;
	}

	bool ans = true;

	for (int i = 0; i < 3; i++)
	{
		if (flg[i] == false) {
			ans = false;
		}
	}

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

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;

int main() {
    int v,E;
    cin >> v >> E;
    vector<int> a(v+1,inf);
    rep(i,E){
        int f,g,h;
        cin >> f >> g >> h;
        if (f==1) a[g]=h;
        if (g==1) a[f]=h;
    }
    int t;
    cin >> t;
    int b,c;
    bool k=true;
    rep(i,t){
        int n;
        cin >> n;
        rep(j,n){
            int f,g;
            cin >> f >> g;
            if (k && a[g]!=inf){
                b=g;
                k=false;
                c=i+1;
            }
        }
    }
    while(true){
        if (c!=0){
            cout << -1 << endl;
            c--;
        }
        else if (c==0 && a[b]!=0){
            cout << b << endl;
            a[b]--;
        }
        else cout << -1 << endl;
        t--;
        if (t==0) break;
    }
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define itr(r,v) for(auto r=v.begin();r!=v.end();r++)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfr(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto sttart = high_resolution_clock::now()
#define etime auto sttop = high_resolution_clock::now()
#define go_t ll testcases; cin>>testcases; for(ll caseno= 1 ;caseno <= testcases; caseno++)
#define ptime auto z1z = duration_cast<microseconds>(sttop-sttart); cout<<"\nTime taken : "<<z1z.count()<<" microseconds\n"
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';

using namespace std;
using namespace std::chrono;

const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
const ll maxN = 1e3 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

ll powerM(ll x, ll y, ll M = MOD) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

ll dp[maxN][maxN];
ll in[maxN][maxN];

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	FIO
	ll n, m; cin >> n >> m;
	string s;

	FOR(i, n) {
		cin >> s;
		for (ll j = 0; j < m; j++) {
			if (s[j] == '.') in[i][j] = 1;
			else in[i][j] = 0;
		}
	}
	for (ll i = 0; i < n; i++) {
		if (!in[i][0]) break;
		dp[i][0] = 1;
	}
	for (ll j = 0; j < m; j++) {
		if (!in[0][j]) break;
		dp[0][j] = 1;
	}
	for (ll i = 1; i < n; i++) {
		for (ll j = 1; j < m; j++) {
			if (in[i][j]) dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
		}
	}
	cout << dp[n - 1][m - 1];
	return 0;
}


Measured memory_bytes: 19188
using System;

namespace abc170
{
    class Program
    {
        static int[] ReadNumList()
        {
            var line = Console.ReadLine().Split(' ');
            var numList = new int[line.Length];
            for (var i = 0; i < line.Length; ++i)
            {
                numList[i] = int.Parse(line[i]);
            }
            return numList;
        }
        static void Main()
        {
            var xList = ReadNumList();
            for (var i = 0; i < xList.Length; ++i)
            {
                if (xList[i] == 0)
                {
                    Console.WriteLine(i + 1);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 27544
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,0,n) cin>>a[i];
    
    ll ans=0;
    rep(i,0,n){
        if(i==0){
            if(a[i]!=0){
                cout<<-1<<endl;
                return 0;
            }
        }
        else{
            if(a[i]-a[i-1]>1){
                cout<<-1<<endl;
                return 0;
            }
            else if(a[i]-a[i-1]<1){
                ans+=(ll)a[i-1];
            }
        }
    }
    ans+=(ll)a[n-1];
    
    cout<<ans<<endl;
    
}


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

int main() {
  int N;
  ll current;
  ll step = 0;
  ll last = 0;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> current;
    if (last > current) {
      step += last - current;
    } else {
      last = current;
    }
  }
  cout << step << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>

int po(int x,int n){int ans=1;while(n--)ans*=x;return ans;}

int main(){
	int n;
	scanf("%d",&n);
	int ans=1;
	int dame=1;
	for(int i=0;i<n;i++){
		int t;
		scanf("%d",&t);
		if(t%2==0)dame*=2;
		ans*=3;
	}
	printf("%d",ans-dame);
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) { cin >> A[i]; }

    int ans = 1;
    int mode = 3;

    for (int i = 1; i < N; i++) {
        if (mode == 1 && A[i] < A[i - 1]) {
            ans++;
            mode = 3;
        } else if (mode == 2 && A[i] > A[i - 1]) {
            ans++;
            mode = 3;
        } else if (mode == 3 && A[i] > A[i - 1]) {
            mode = 1;
        } else if (mode == 3 && A[i] < A[i - 1]) {
            mode = 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3796
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;
	bool flag = true;
	for(int i = 0; i < s.size(); i++)
	{
		if(s[a] != '-') flag = false;
		if(i == a) continue;
		if(s[i] - '0' >= 0 && s[i] - '0' <= 9)
			continue;
		flag = false;
	}
	cout << (flag ? "Yes" : "No") << endl;
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int64_t s;
  cin>>s;
  int64_t a=(int64_t)sqrt((double)s)+1;
  int64_t d=a;
  if(a*d-s==0){
    cout<<0<<" "<<0<<" "<<a<<" "<<0<<" "<<0<<" "<<d<<endl;
  }else if(s==1000000000000000000){
    cout<<0<<" "<<0<<" "<<1000000000<<" "<<0<<" "<<0<<" "<<1000000000<<endl;
    return 0;
  }
  for(int64_t b=1;b<=std::pow(10,9);b++){
    if((a*d-s)%b==0){
      int64_t c=(a*d-s)/b;
      if(c>1000000000) continue;
      cout<<0<<" "<<0<<" "<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
      return 0;
    }
  }



  return 0;
}


Measured memory_bytes: 256
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         String a = infile.readLine();
         String b = infile.readLine();
         if(a.equals(b.substring(0, a.length())))
            System.out.println("Yes");
         else
            System.out.println("No");
      }
   }

Measured memory_bytes: 32732
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;

int n, m;
char A[110][110];
int st[220], en[50050], nxt[50050], flow[50050], ce = 1;
void addE(int s, int e, int f){
	++ce; nxt[ce] = st[s]; st[s] = ce; en[ce] = e; flow[ce] = f;
	++ce; nxt[ce] = st[e]; st[e] = ce; en[ce] = s; flow[ce] = f;
}

int ST, EN;
int chk[220];

int dfs(int x, int f) {
	if(x == EN) return f;
	chk[x] = 1;
	for(int i=st[x];i;i=nxt[i]) if(flow[i] > 0) {
		int t;
		if(chk[en[i]] == 0 && (t = dfs(en[i], min(f, flow[i]))) > 0) {
			flow[i] -= t;
			flow[i^1] += t;
			return t;
		}
	}
	return 0;
}

void solve(){
	scanf("%d%d", &n, &m);
	ST = n + m + 1, EN = ST + 1;
	rep(i, n){
		scanf("%s", A[i]);
		rep(j, m) {
			if(A[i][j] == 'S' || A[i][j] == 'o' || A[i][j] == 'T') {
				addE(i + 1, n + 1 + j, 1);
			}
			if(A[i][j] == 'S') addE(ST, i + 1, 1e8), addE(ST, n + 1 + j, 1e8);
			if(A[i][j] == 'T') addE(i + 1, EN, 1e8), addE(n + 1 + j, EN, 1e8);
		}
	}
	int ans = 0;
	while(1){
		memset(chk, 0, sizeof chk);
		int t;
		if((t = dfs(ST, ~0u>>1)) > 0) ans += t;
		else break;
	}
	if(ans > n * m) puts("-1");
	else printf("%d\n", ans);
}

int main(){
	int Tc = 1; // scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
};


Measured memory_bytes: 512
H,N = map(int,input().split())
M=[list(map(int,input().split())) for _ in range(N)]

DP=[float('inf')]*(H+1)
DP[0]=0
for i in range(H):
    for a,b in M:
        DP[min(i+a,H)] = min(DP[min(i+a,H)],DP[i]+b)
print(DP[-1])


Measured memory_bytes: 44124
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using lint = long long int;

int H, W, N;
vector<P> p;

int count(int x, int y)
{
    if (x <= 0 || y <= 0 || x >= H-1 || y >= W-1) return 0;
    int ans = 0;
    for (int i=-1; i<=1; i++)
    {
        for (int j=-1; j<=1; j++)
        {
            ans += binary_search(p.begin(), p.end(), P(x+i, y+j));
        }
    }
    return ans;
}

int main()
{
    cin >> H >> W >> N;
    for (int i=0; i<N; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        p.push_back(P(a, b));
    }
    sort(p.begin(), p.end());

    vector<set<P>> ans(9);

    for (int i=0; i<N; i++)
    {
        for (int x=-1; x<=1; x++)
        {
            for (int y=-1; y<=1; y++)
            {
                int n = count(p[i].first+x, p[i].second+y);
                if (n) ans[n-1].insert(P(p[i].first+x, p[i].second+y));
            }
        }
    }
    lint ans0 = (lint)(H-2) * (W-2);
    for (auto v : ans) ans0 -= v.size();
    cout << ans0 << endl;
    for (auto v : ans) cout << v.size() << endl;
}


Measured memory_bytes: 85364
function main(input) {
    const args = input.split(' ');
    const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);
  
  a * b % 2 === 0 ? console.log('Even') : console.log('Odd');
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29532
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

vvi G;

P dfs(int v,int p = -1) {
    int ret = 0,ind = v;
    for(int u : G[v]) {
        if(u == p) continue;
        auto d = dfs(u,v);
        if(chmax(ret,d.first+1)) ind = d.second;
    }
    return {ret,ind};
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    G.resize(n);
    rep(_,n-1) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    int len = dfs(dfs(0).second).first;
    cout << (len%3 == 1 ? "Second\n" : "First\n");
}

Measured memory_bytes: 26612
import glob


# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\159\\A'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        tmp = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
        data = tmp.split(",")

        N = int(self.input_data())

        print(str(data[N-1]))



solver = Solver(REL_PATH)
solver.exec_resolve()


Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < n;i++)
using namespace std;
 
int main(){
    string s; cin >> s;
    vector<string> days {"SAT","FRI","THU","WED","TUE","MON","SUN"};
    rep(i,7){
        if(s == days.at(i)){
            cout << i + 1 << endl;
        }
    }

}

Measured memory_bytes: 256
from collections import deque
N, K = map(int, input().split())
S = input()

L = deque([])
R = deque([])

now = S[0]
count = 0
for val in S:
    if now != val:
        if now == "L":
            L.append(count)
        else:
            R.append(count)
        
        now = val
        count = 1
    else:
        count += 1

if now == "L":
        L.append(count)
else:
        R.append(count)

while(K):
    if len(L) == 1 or len(R) == 1:
        break
    
    L[1] += L[0]
    R[1] += R[0]

    L.popleft()
    R.popleft()

    K -= 1

if K:
    if len(L) >= len(R):
        L = [N]
        R = []
    else:
        L = []
        R = [N]

ans = sum([val - 1 for val in L]) + sum([val - 1 for val in R])
print(ans)



Measured memory_bytes: 4632
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        k: i32,
        a: i32, b: i32,
    }

    println!(
        "{}",
        if a % k == 0 || b % k == 0 || ((a / k) + 1) * k <= b {
            "OK"
        } else {
            "NG"
        }
    );
}


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

bool ifPrime(int x){
    if(x == 2){
        return true;
    }
    else if(x < 2 || x % 2 == 0)
    {
        return false;
    }
    else
    {
        int i = 3;
        while(i <= sqrt(x)){
            if(x % i == 0) return false;
            i = i + 2;
        }
    }
    
    return true;
}

int main(){
    int n, num, sum;
    cin >> n;
    sum = 0;
    
    for(int i = 0; i < n; i++){
        cin >> num;
        sum += ifPrime(num);  
    } 
    
    cout << sum << endl;
}


Measured memory_bytes: 3092
from collections import defaultdict
import sys
def input() -> str:
    return sys.stdin.readline()
n = int(input())
s = [input() for _ in range(n)]
cnt = defaultdict(int)
for si in s:
    cnt["".join(sorted(si))] += 1
ans = 0
for v in cnt.values():
    ans += sum(range(1, v))
print(ans)


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll p, q, r;
    cin >> p >> q >> r;
    ll pq = p + q;
    ll qr = q + r;
    ll rp = r + p;
    cout << min({pq, qr, rp}) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
 
template <typename T> T gcd(T a, T b) {
	if (b == 0) return abs(a);
	T r; while ((r = a % b) != 0) a = b, b = r;
	return abs(b);
}
ll modpow(ll b, ll x, ll mod) {
    if (x == 0)
        return 1;
    if (x & 1) {
        return modpow(b*b % mod, x/2, mod) * b % mod;
    } else {
        return modpow(b*b % mod, x/2, mod);
    }
}
#define MOD 1000000007
int main()
{
    int N; cin >> N;
    vector<pll> AB(N);
    map<pll, int> cnt;
    for (auto& ab : AB) {
        cin >> ab.first >> ab.second;
        if (ab.first == 0 && ab.second == 0){
        } 
        else if (ab.first == 0)
        {
            ab.second = -1;
        } 
        else if (ab.second == 0) {
            ab.first = 1;
        } 
        else
        {
            ll g = gcd(ab.first, ab.second);
            ab.first /= g;
            ab.second /= g;
            if (ab.first < 0)
            {
                ab.first = -ab.first;
                ab.second = -ab.second;
            }
        }
        cnt[ab]++;
    }
 
    ll ans = 1;
 
    map<pll, bool> done;
 
    for (const auto& kv : cnt) {
        const auto& ab = kv.first;
        const auto& c = kv.second;
        if (done[ab] || (ab.first==0 && ab.second==0)) continue;
 
        ll a = 1;
        pll abr = make_pair(abs(ab.second), ab.first);
        if (ab.second >= 0) abr.second = -abr.second;
        if (cnt.count(abr) > 0) {
            ll c_abr = cnt[abr];
            a = (modpow(2, c, MOD) + modpow(2, c_abr, MOD) - 1) % MOD; 
            done[abr] = true;
        } else {
            a = modpow(2, c, MOD);
        }
        ans = ans * a % MOD;
        done[ab] = true;
    }
    ans--;
    ans = (ans + cnt[make_pair(0LL, 0LL)]) % MOD;
    if (ans < 0) ans += MOD; 
 
    cout << ans << endl;
}

Measured memory_bytes: 31424