akhauriyash/Code-Regression huggingface dataset:
import math

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

n = int(input())

primes = factorization(n)
cnt = 0

for i in primes:
    if primes == [[1, 1]]:
        break
    cnt += math.floor(math.sqrt(2*i[1]+1/4)-1/2)

print(cnt)

Measured memory_bytes: 9316
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  string s;
  cin>>s;

  cout<<"2018";
  for(int i=4;i<10;i++)
  cout<<s.at(i);

  cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int a[maxn],vis[maxn],n;
ll sum=0;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<n;i++)
        sum+=abs(a[i]-a[i-1]);
    sum+=abs(a[0])+abs(a[n-1]);
    for(int i=0;i<n;i++)
    {
        if(i==0)
        {
            ll ans=sum;
            ans-=abs(a[0])+abs(a[0]-a[1]);
            ans+=abs(a[1]);
            printf("%lld\n",ans);
        }
        else if(i==n-1)
        {
            ll ans=sum;
            ans-=abs(a[n-1])+abs(a[n-1]-a[n-2]);
            ans+=abs(a[n-2]);
            printf("%lld\n",ans);
        }
        else
        {
            ll ans=sum;
            ans-=abs(a[i]-a[i-1])+abs(a[i+1]-a[i]);
            ans+=abs(a[i+1]-a[i-1]);
            printf("%lld\n",ans);
        }
    }
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

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

  cout << s.substr(0, 1) + to_string(s.size() - 2) + s.substr(s.size() - 1)
       << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std ;
int main ()
{
	int a=0 , b=0 ;
	char op ;
	while(true)
	{
		cin >> a >> op >> b ;
		if(op=='?')
		{
			break ;
		}
		else if(op=='+')
		{
			cout << a+b << endl ;
		}
		else if(op=='-')
		{
			cout << a-b << endl ;
		}
		else if(op=='*')
		{
			cout << a*b << endl ;
		}
		else if(op=='/')
		{
			cout << a/b << endl ;
		}
	}
	return 0 ;
}



Measured memory_bytes: 3076
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int N, M;
int p[100000] = {};

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int main(void) {

	cin >> N >> M;

	for (int i = 0; i < N; i++)
		cin >> p[i];

	UnionFind uf(N);

	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;

		uf.unionSet(x-1, y-1);
	}
	int count = 0;

	for (int i = 0; i < N; i++) {
		if (uf.findSet(i, p[i] - 1)) {
			count++;
		}
	}

	cout << count << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner

object Main {
  def calcResultStr(nums: (Any, Any, Any, Any), firstOperater: String, secondOperater: String, thirdOperater: String): String = nums._1.toString + firstOperater + nums._2.toString + secondOperater + nums._3.toString + thirdOperater + nums._4.toString + "=7"


  def main(args: Array[String]): Unit = {
    val input = new Scanner(System.in)
    val splitedNum: List[Char] = input.next.toList

    val a: Int = splitedNum(0).toString.toInt
    val b: Int = splitedNum(1).toString.toInt
    val c: Int = splitedNum(2).toString.toInt
    val d: Int = splitedNum(3).toString.toInt

    if (a+b+c+d == 7) {
      println(calcResultStr((a,b,c,d), "+", "+", "+"))
    } else if (a-b+c+d == 7) {
      println(calcResultStr((a,b,c,d), "-", "+", "+"))
    } else if (a+b-c+d == 7) {
      println(calcResultStr((a,b,c,d), "+", "-", "+"))
    } else if (a+b+c-d == 7) {
      println(calcResultStr((a,b,c,d), "+", "+", "-"))
    } else if (a-b-c+d == 7) {
      println(calcResultStr((a,b,c,d), "-", "-", "+"))
    } else if (a+b-c-d == 7) {
      println(calcResultStr((a,b,c,d), "+", "-", "-"))
    } else if (a-b+c-d == 7) {
      println(calcResultStr((a,b,c,d), "-", "+", "-"))
    } else if (a-b-c-d == 7) {
      println(calcResultStr((a,b,c,d), "-", "-", "-"))
    }
  }
}

Measured memory_bytes: 25772
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func gcd(x,y int) int{
	if y==0{
		return x
	} 
		return gcd(y, x%y)
}
func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	a,b := r.nextInt(),r.nextInt()

	fmt.Fprintln(stdout, a*b/gcd(a,b))
}


Measured memory_bytes: 640
N, K, Q = map(int, input().split(" "))    # N:人数, K:初期スコア, Q:問題数
A = [int(input()) for i in range(Q)]    # 正解者のリスト
B = [0 for i in range(N)]    # 正解数

for i in range(Q):
    num_ans_person = A[i] - 1
    B[num_ans_person] += 1

# 得点は, 最初の点数 - 他人の正解数
# 他人の正解数は, 問題数 - 自分の正解数
# 得点は, 最初の点数 - 問題数 + 自分の正解数
# 得点 > 0 であれば, "Yes"
for i in range(N):
    if K - Q + B[i] > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8644
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n, k;
	int x[100];
	int ans = 0;
	
	cin >> n >> k;
	
	for (int i = 0; i < n; i++) cin >> x[i];
	
	for (int i = 1; i <= n; i++) {
		ans += min(x[i-1], abs(x[i-1] - k));
	}
	
	cout << ans * 2 << endl;
	
	return (0);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int p[n];
  int ans = 0;
  for(int i=0; i<n; i++){
    cin >> p[i];
  }
  for(int i=0; i<n; i++){
    if(i == 0) continue;
    if(i == n-1) continue;
    if(p[i-1] < p[i] && p[i] < p[i+1]){
      ans++;
    }
    if(p[i-1] > p[i] && p[i] > p[i+1]){
      ans++;
    }
  }
  cout << ans << endl;
}


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


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int a,b;
    cin>>a>>b;
    for(int i=0;i<100000;i++){
        int t = (int)i*0.08;
        if(t!=a)continue;
        t = (int)i*0.1;
        if(t!=b)continue;
        cout << i << endl;
        return 0;
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

void add(ll& a, ll b){a = (a+b) % MOD;}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W;
    cin>>H>>W;
    vector<vector<string>> S(H,vector<string>(W));
    REP(i,H) REP(j,W) cin>>S[i][j];
    REP(i,H) REP(j,W){
        if(S[i][j]=="snuke"){
            cout<<(char)(j+'A')<<i+1<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n';
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
ll ans[1 << 20];
ll cnt[1 << 20];
ll a[1 << 20];
ll b[1 << 20];
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,q;
    IOS;
    fi>>n>>q;
    for (int i = 1;i <= q;++i)
        fi>>a[i];
    reverse(a+1,a+1+q);
    ll prev = 1e18 + 55555;
    int nr = 0;
    for (int i = 1;i <= q;++i)
    {
        if (a[i] < prev)
            prev = a[i],b[++nr] = a[i];
    }
    if (!nr || b[nr] > n) b[++nr] = n;
    q = nr;
    reverse(b+1,b+1+q);
    cnt[q] = 1;
    for (int i = q;i;--i)
    {
        ll k = b[i],with = cnt[i];
        int w = i;
        while (1 && k)
        {
            for (int cur = 1 << 17;cur;cur /= 2)
                if (w - cur >= 1 && b[w - cur] >= k)
                    w -= cur;
            --w;
            if (w < 1) break;
            cnt[w] += (k / b[w]) * with;
            k %= b[w];
        }
        if (k) ans[k] += with;
    }
    for (int i = n - 1;i;--i)
        ans[i] += ans[i+1];
    for (int i = 1;i <= n;++i)
        fo << ans[i] << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}

Measured memory_bytes: 4864
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;
    using System.Text.RegularExpressions;

    class Program
    {
        static void Main()
        {
            //try
            //{
            //    var count = decimal.Parse(Console.ReadLine());

            //    var ins = Console.ReadLine().Split(" ");

            //    var result = (decimal)1;

            //    var nums = ins.Select(x => decimal.Parse(x)).OrderBy(x => x);

            //    var m = (decimal)Math.Pow(10, 18);

            //    if (nums.Contains(0))
            //    {
            //        Console.WriteLine((0).ToString());
            //        return;
            //    }

            //    foreach (var num in nums)
            //    {
            //        result *= num;
            //        if (result > m)
            //        {
            //            Console.WriteLine((-1).ToString());
            //            return;
            //        }
            //    }

            //    Console.WriteLine(result.ToString());
            //    return;
            //}
            //catch
            //{
            //    Console.WriteLine((-1).ToString());
            //    return;
            //}

            try
            {
                var n = int.Parse(Console.ReadLine());
                var a = System.Console.ReadLine().Split(' ').Select((x) => decimal.Parse(x)).OrderBy(x => x);
                decimal ans = 1m;

                if (a.Any(x => x == 0m))
                {
                    Console.WriteLine("0");
                    return;
                }
                foreach (var item in a)
                {
                    ans *= item;
                    if (ans > (decimal)Math.Pow(10, 18))
                    {
                        Console.WriteLine("-1");
                        return;
                    }
                }
                Console.WriteLine(ans.ToString());
            }
            catch
            {
                Console.WriteLine((-1).ToString());
                return;
            }
        }
    }

Measured memory_bytes: 49380
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  ll odd=0,even=0;
  for(int i=0;i<n;i++){
    ll a;cin>>a;
    if(a%2)odd++;
    else even++;
  }
  if(odd==0||even==0){
    cout<<0<<endl;
    return 0;
  }
  ll ans=0;
  if(odd%2==0){
    cout<<n-2<<endl;
  }else{
    cout<<n-1<<endl;
  }
  return 0;
}



Measured memory_bytes: 3216
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<LD,LD> Pt;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/

void build(){

}
#define N 101010
int n , a[ N ];
void init(){
  scanf( "%d" , &n );
  for( int i = 0 ; i < n ; i ++ )
    a[ i ] = getint();
  sort( a , a + n );
}
void solve(){
  if( n & 1 ){
    for( int i = 0 ; i < n ; i ++ )
      if( a[ i ] != ( i + 1 ) / 2 * 2 ){
        puts( "0" );
        Bye;
      }
  }else{
    for( int i = 0 ; i < n ; i ++ )
      if( a[ i ] != i / 2 * 2 + 1 ){
        puts( "0" );
        Bye;
      }
  }
  int ans = 1;
  for( int l = 0 , r = n - 1 ; l < r ; l ++ , r -- )
    ans = mul( ans , 2 );
  printf( "%d\n" , ans );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int n;
  cin >> n;
  ll old = 1, old2 = 2;
  ll res = old;
  for (int i = 2; i <= n; ++i) {
    res = old + old2;
    old2 = old;
    old = res;
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        String s = std.next();

        int[][] dp = new int[n + 1][2];
        Arrays.fill(dp[0], Integer.MAX_VALUE);
        Arrays.fill(dp[1], Integer.MAX_VALUE);
        dp[0][0] = 0;
        dp[n][1] = 0;

        int ans = Integer.MAX_VALUE;

        for (int i = 0; i <= n; i++) {
            if (i > 0) {
                char leftC = s.charAt(i - 1);
                if (leftC == 'W') {
                    dp[i][0] = dp[i - 1][0] + 1;
                } else {
                    dp[i][0] = dp[i - 1][0];
                }
            }
        }
        
        for (int i = n - 1; i >= 0; i--) {
            char rightC = s.charAt(i);
            if (rightC == 'E') {
                dp[i][1] = dp[i + 1][1] + 1;
            } else {
                dp[i][1] = dp[i + 1][1];
            }
        }

        for (int i = 0; i <= n; i++) {
            ans = Math.min(dp[i][0] + dp[i][1], ans);
        }

        System.out.println(ans);
    }
}

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

int main() {
  int N,count = 0;
  cin >> N;
  string S;
  cin >> S;

  for(int i=0;i<N;i++){
    if(S[i] == 'A'){
      if(S[i+1] == 'B' && (i+1) < N){
        if(S[i+2] == 'C' && (i+2) < N){
          count++;
        }
      }
    }
  }

  cout << count << endl;
}


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

int main() {
  int N;
  int sum;
  int m;
  cin >> N;
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  int min = *min_element(vec.begin(), vec.end());
  int max = *max_element(vec.begin(), vec.end());


  for (int i = min; i <= max; i++) {
    int sum = 0;
    for (int j = 0; j < N; j++) {
      sum += pow(vec[j] - i, 2.0);
    }
    if (i == min) m = sum;
    if (sum < m) m = sum;
  }

  cout << m << endl;
}

Measured memory_bytes: 3520
from collections import defaultdict
import itertools
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    D = defaultdict(int)
    for _ in range(N):
        S = input()
        D[S[:1]] += 1
    
    ans = 0
    for initials in itertools.combinations(['M','A','R','C','H'], 3):
        a = 1
        for i in initials:
            a *= D[i]
        ans += a
    
    print(ans)


if __name__ == '__main__':
    main()

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> C(H, vector<char>(W));
  rep(i, H) rep(j, W) cin >> C[i][j];

  rep(i, H) {
    rep(k, 2) {
      rep(j, W) putchar(C[i][j]);
      putchar('\n');
    }
  }
}

Measured memory_bytes: 256
S=input()

if S=="SUN":
    print(7)
elif S=="MON":
    print(6)
elif S=="TUE":
    print(5)
elif S=="WED":
    print(4)
elif S=="THU":
    print(3)
elif S=="FRI":
    print(2)
elif S=="SAT":
    print(1)


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

int main(){
    string S;
    cin>>S;
    if(S=="Sunny"){
        cout<<"Cloudy"<<endl;
    }
    else if(S=="Cloudy"){
        cout<<"Rainy"<<endl;
    }
    else {
        cout<<"Sunny"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
a = [0] + list(map(int, input().split()))

ans = 0
for i in range(1, n+1):
    if a[i-1] + a[i] > x:
        diff = (a[i-1] + a[i]) - x
        ans += diff
        a[i] -= diff
print(ans)

Measured memory_bytes: 14052
#include<stdio.h>

int main(void){
        int alp[26] = {0};
        char c;
        while((c=getchar()) != EOF){
                if('a'<=c && c<='z') alp[c-'a']++;
                if('A'<=c && c<='Z') alp[c-'A']++;
        }

        for(int i=0; i<26; i++) printf("%c : %d\n", i+'a', alp[i]);
        return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n;
vector<long long> A(200200, 0);

int main() {
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> A.at(i);

    int right = 0;
    long long Axor = 0;
    long long Asum = 0;
    long long cnt = 0;
    for(int left = 0; left < n; ++left) {
        while((right < n) && ((Asum + A.at(right)) == (Axor ^ A.at(right)))) {
            Asum += A.at(right);
            Axor ^= A.at(right);
            ++right;
        }

        cnt += (right - left);
        if(right == left) ++ right;
        else {
            Asum -= A.at(left);
            Axor ^= A.at(left);
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(vector<int>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

//CODE
void solve(void)
{
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  cout<<(int)(A+B+C - max(A,max(B,C)) + (int)max(A,max(B,C))*pow(2,K))<<endl;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
cin>>n;
for(int i = 1;i<=9;i++)
{
for(int j =1;j<=9;j++)
{
if(i*j==n){
cout<<"Yes"<<endl;
return 0;}
}
}
cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
//ここから始めよう
map<P,string>v;
signed main(){
    int n,m;cin>>n>>m;
    P num[114514];P copy[114514];
    rep(i,0,m)cin>>num[i].first>>num[i].second;
    rep(i,0,m){
        copy[i]=num[i];
    }
    sort(num,num+m);
    int cnt=1;
    rep(i,0,m){
        string ss={};
        if(i==0){
            string s=to_string(num[i].first);
            rep(i,0,6-s.size())ss+='0';
            ss+=s;ss+="000001";
        }
        else {
            if(num[i].first==num[i-1].first)cnt++;else cnt=1;
            string s=to_string(num[i].first);
            rep(i,0,6-s.size())ss+='0';ss+=s;
            string t=to_string(cnt);
            rep(i,0,6-t.size())ss+='0';ss+=t;
        }
        v.insert(make_pair(num[i],ss));
    }
    rep(i,0,m){
        cout<<v[copy[i]]<<endl;
    }
    return  0;
}

Measured memory_bytes: 17536
#include <stdio.h>

int main(void){
	
	int x,y;
	
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0 && y==0) break;
		
		if(x<y){
			printf("%d %d\n",x,y);
		}else{
			printf("%d %d\n",y,x);
		}
	}
	return 0;
	
}

Measured memory_bytes: 1028
n = int(input())

n = n - 1

root = 26
p = 1


while n >= root:
	n -= root
	root *= 26
	p += 1


res = ['a'] * p

while n > 0:
	r = n % 26
	res[p - 1] = chr(ord('a') + r)
	n = n // 26
	p -= 1

print(''.join(res))

Measured memory_bytes: 9192
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from math import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

# def gcd3(*numbers):
#     return reduce(gcd, numbers)

# def gcd3_list(numbers):
#     return reduce(gcd, numbers)

n = int(input())
numbers = list(myinput())

numbers.sort()
a = numbers[0]
b = numbers[1]
g = gcd(a,b)

if len(numbers)==2:
    ls = []
    for i in range(1,g+1):
        if a%i==0 and b%i==0:
            ls.append(i)
    for i in range(len(ls)):
        print(ls[i])
else:
    c = numbers[2]
    ls = []
    for i in range(1,g+1):
        if a%i==0 and b%i==0 and c%i==0:
            ls.append(i)
    for i in range(len(ls)):
        print(ls[i])


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

int main(){
    int n;
    cin >> n;
    string s[n];
    map<string, int> anss;
    for(int i=0;i<n;i++){
        cin >> s[i];
        anss[s[i]]++; 
    }

    int ans = anss.size();

    cout << ans << endl;

}

Measured memory_bytes: 25400
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);++i)
#define rep2(i,a,b) for (int i=(a);i<(b);++i)
#define rrep(i,n) for (int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;--i)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) cout<<(#_v)<<":";for(auto(_x):(_v)){cout<<" "<<(_x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1e9;
const int mod = 1e9 + 7;
// using Graph = vector<vector<int>>;

struct edge {
    int to, cost;
    edge(){}
    edge(int _to, int _cost) : to(_to), cost(_cost) {}
    bool operator<( const edge& o ) const {
        if (to != o.to) return to < o.to;
        return cost < o.cost;
    }
};
using Graph = vector<vector<edge>>;

// undirected
void addEdge(Graph& G, int x, int y, int c) {
    G[x].emplace_back(y, c);
    G[y].emplace_back(x, c);
}
auto dijkstra(const Graph& G, int s, int g = -1) {
    int n = G.size();
    using State = pair<int, int>;
    priority_queue<State, vector<State>, greater<State>> pq;   // cost, vertex
    vector<int> d(n, inf);
    d[s] = 0;
    pq.push(State(0, s));

    while (!pq.empty()) {
        auto p = pq.top(); pq.pop();
        int v = p.second;
        if (v == g) break;
        if (d[v] < p.first) continue;
        for (const auto& e : G[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                pq.push(State(d[e.to], e.to));
            }
        }
    }
    return d;
}

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

    int n, m;
    cin >> n >> m;
    Graph G(n);
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        addEdge(G, a, b, c);
    }

    set<Pii> notcand;
    rep(i, n) {
        auto d = dijkstra(G, i);
        rep(v, n) {
            for (auto e : G[v]) {
                if (d[v] + e.cost == d[e.to]) {
                    notcand.insert(Pii(v, e.to));
                }
            }
        }
    }

    cout << m - (int)notcand.size() / 2 << endl;
}


Measured memory_bytes: 384
s = input()

if s[0] == "A" and "C" in s[2:-1]:
    d = s[2:-1].index("C")
    A = s[1:d+2] + s[d+3:]
    B = [j for j in range(ord("a"), ord("z") + 1)]
    t = 0
    for i in A:
        if ord(i) not in B:
            t = 1
            break
    if t == 0:
        print("AC")
    else:
        print("WA")
else:
    print("WA")

Measured memory_bytes: 38384
#include <stdio.h>
#include <limits.h>

#define MAX_N 500000
#define INF INT_MAX

int mergeSort(int,int,int,int*);
int merge(int,int,int,int*);

int main(){
  int N,A[MAX_N],i,cnt;
  scanf("%d",&N);
  for(i = 0 ; i < N ; i++){
    scanf("%d",&A[i]);
  }
  cnt = mergeSort(0,N,N,A);
  for(i = 0 ; i < N ; i++){
    printf("%d%c",A[i],(i < N-1 ? ' ' : '\n'));
  }
  printf("%d\n",cnt);
  return 0;
}

int mergeSort(int left,int right,int N,int *A){
  int mid,res = 0;
  if(left + 1 < right){
    mid = (left + right) / 2;
    res += mergeSort(left,mid,N,A);
    res += mergeSort(mid,right,N,A);
    res += merge(left,mid,right,A);
  }
  return res;
}

int merge(int left,int mid,int right,int *A){
  int i,j,k,n1 = mid-left,n2 = right-mid;
  int L[n1+1],R[n2+1],res = 0;
  for(i = 0 ; i < n1 ; i++){ L[i] = A[left+i]; }
  for(i = 0 ; i < n2 ; i++){ R[i] = A[mid+i]; }
  L[n1] = R[n2] = INF;
  i = j = 0;
  for(k = left ; k < right ; k++){
    if(L[i] <= R[j]){ A[k] = L[i++]; }
    else{ A[k] = R[j++]; }
    res++;
  }
  return res;
}

Measured memory_bytes: 4504
<?php
  $res = 0;
  $min = 10;
  for($i=0;$i<5;$i++) {
    $input = rtrim(fgets(STDIN));
    $last = intval(substr($input,-1));
    if($last === 0) {
      $res += intval($input) / 10;
    }
    else {
      $min = intval($last) < $min ? $last : $min; 
      $res += ceil(intval($input) / 10);
    }
  }
  $res = ($res * 10) + $min - 10;
  echo $res;
?>

Measured memory_bytes: 4604
N = int(input())
A = list(map(int, input().split()))
counts = [0] * (N + 1)
ball_counts = 0
balls = []
for i in range(N-1, -1, -1):
    if sum(counts[::i+1][1:]) % 2 != A[i]:
        ball_counts += 1
        balls.append(i+1)
        counts[i+1] = 1
print(ball_counts)
if ball_counts > 0:
    print(*balls)


Measured memory_bytes: 14584
#include <bits/stdc++.h>
#define lol long long
using namespace std;
int main(){
    int a,n,ans=1e9,b;
    string s,t;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        b=0;
        while(a%2==0){
            b++;
            a/=2;
        }
        ans=min(b,ans);
    }
    cout<<ans<<"\n";
    return(0);
}

Measured memory_bytes: 3600
//team yglance+xhwl+TTD
#include<bits/stdc++.h>
typedef long long ll;
const ll mod=1e9;
const ll maxn=1e5+7;
const double pi=acos(-1);
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll mx=mod*mod*-1;
    mx=max(mx,b*d);
    mx=max(mx,a*d);
    mx=max(mx,a*c);
    mx=max(mx,b*c);
    cout<<mx<<endl;
 	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <string>

std::string words[4] = {"maerd", "remaerd", "resare", "esare"};

int main()
{
  std::string s;
  std::cin >> s;
  std::reverse(s.begin(), s.end());

  bool can = true;
  for (int i = 0; i < s.size();) {
    bool can2 = false;
    for (int j = 0; j < 4; j++) {
      std::string d = words[j];
      if (s.substr(i, d.size()) == d) {
        can2 = true;
        i += d.size();
      }
    }
    if (!can2) {
      can = false;
      break;
    }
  }
  if (can) {
    std::cout << "YES\n";
  } else {
    std::cout << "NO\n";
  }
  return 0;
}


Measured memory_bytes: 512
N = int(input())

def SumDigits(num):
    sum = 0
    while True:
        sum += num % 10
        num //= 10
        if num == 0:
            break
    return sum

infinity = float('inf')
min = infinity

for x in range(1, N):
    if SumDigits(x) + SumDigits(N - x) < min:
        min = SumDigits(x) + SumDigits(N - x)
print(min)


Measured memory_bytes: 3060
#include<stdio.h>
int main() {
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	for(int i=1;i<=b;++i)
		if(a*i%b==c) {
			puts("YES");
			return 0;
		}
	puts("NO");
	return 0;
}

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

#define maxn 1010
typedef long long ll;
char s[maxn];
bool vis[maxn];
int main()
{
	scanf("%s", s + 1);
	int K, n; scanf("%d", &K); n = strlen(s + 1);
	int l = 1;
	while (l <= n && s[l] == s[1]) ++l;
	if (l > n) printf("%lld\n", 1ll * n * K / 2);
	else
	{
		int r = n;
		while (s[r] == s[1]) --r;
		ll ans = 0;
		for (int i = 1, j = 1; i <= n; i = j)
		{
			while (j <= n && s[j] == s[i]) ++j;
			ans += 1ll * (j - i) / 2 * K;
		}
		int a = l - 1, b = n - r;
		ans -= 1ll * a / 2 * (K - 1);
		ans -= 1ll * b / 2 * (K - 1);
		ans += 1ll * (a + b) / 2 * (K - 1);
		printf("%lld\n", ans);
	}
	return 0;
}

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

typedef long long int ll;

int main()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    while(k > 0){
        if(a >= b){
            b *= 2;
        }
        else if(b >= c){
            c *= 2;
        }
        else{
            break;
        }
        k--;
    }

    if(a < b && b < c){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
int main(void){
	int H,W;
	int i,j;
	for(;;){
		scanf("%d %d",&H,&W);
		if((H == 0)&&(W == 0))break;
		for ( i = 1; i <= H; i++ ){
			for ( j = 1; j <= W; j++ ){
				if((i > 1)&&(j > 1)&&(i < H)&&(j < W)){
					printf(".");
				} else {
					printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2020
H, W = map(int, input().split())
A = [input() for _ in range(H)]
# 0-indexed

dp = [[0 for _ in range(W)] for _ in range(H)]
dp[0][0] = 1

for h in range(H):
  for w in range(W):
    if h == w == 0:
      continue
    if A[h][w] != "#":
      dp[h][w] = dp[h-1][w] + dp[h][w-1]
      dp[h][w] %= 10**9 + 7

print(dp[-1][-1])

Measured memory_bytes: 56028
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long n,k,i,a;
	cin>>n>>k;
	priority_queue<long long>q;
	for(i=0;i<n;i++)
	{
		cin>>a;
		q.push(a);
	}
	for(i=0;i<k;i++)
	{
		a=q.top();
		q.pop();
		q.push(a/2);
	}
	long long ans=0;
	while(q.size())
	{
		ans+=q.top();
		q.pop();
	}
	cout<<ans<<'\n';
}


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

#define int long long 


int pow(int a, int b, int mod = 1000000000 + 7, int r = 1) {
	for(int i = b; i; i >>= 1, a = (1LL * a * a) % mod) if(i & 1) r = (1LL * r * a) % mod;
	return r;
}


const int mod = 1e9 + 7;


int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;

	cout << ((pow(10, n, mod) - 2 * pow(9, n, mod) + pow(8, n, mod)) % mod + mod) % mod << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    ll n, m;
    cin >> n >> m;
    vector<ll> v(n);
    ll lcm = 1;
    fore(i,0,n) {
        cin >> v[i];
        v[i] /= 2;
        lcm = v[i]/__gcd(v[i], lcm)*lcm;
    }
    bool ok = true;
    fore(i,0,n) {
        if (!((lcm/v[i])&1)) {
            ok = false;
            break;
        }
    }
    if (ok) {
        cout << ((m/lcm)+1)/2 << endl;
    } else {
        cout << "0\n";
    }
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>

using namespace std;

int const N = 51;

long long dp[N][N][N*N];
int n, a[N], A;

int main(){
	scanf("%d%d",&n,&A);
	dp[0][0][0] = 1;
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
	}

	for(int i=1;i<=n;++i){
		for(int j=0;j<i;++j){
			for(int s=0;s<N*N;++s){
				dp[i][j][s] += dp[i-1][j][s];
			}
		}
		for(int j=0;j<i;++j){
			for(int s=0;s<N*N;++s){
				if(dp[i-1][j][s]){
					dp[i][j+1][s+a[i]] += dp[i-1][j][s];
				}
			}
		}
	}

	long long ans = 0;
	for(int i=1;i<=n;++i){
		for(int s=0;s<N*N;++s){
			if(A*i == s){
				ans += dp[n][i][s];
			}
		}
	}

	printf("%lld\n",ans);


	return 0;
}

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

// input
int N;


void input() {
    cin >> N;
}


int main() {
    input();
    int ans = N / 3;
    cout << ans << endl;
}


Measured memory_bytes: 3592
#include<stdio.h>

int main()
{
	int s, i, x[10000];

	for (i = 0;; i++)
	{
		scanf("%d", &x[i]);
		s = i;
		if (x[i] == 0)break;
	}
	for (i = 0; i < s; i++)
	{
		printf("Case %d: %d\n", i + 1, x[i]);
	}

	return(0);

}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	static List<List<Integer>> fullLIst;
	
	static void perm(List<Integer> seed) {
		List<Integer> list = new ArrayList<>(seed);
		boolean[] used = new boolean[seed.size()];
		build(seed, list, used, 0);
	}
	
	static void build(List<Integer> seed, List<Integer> list, boolean[] used, int index) {
		if (index == seed.size()) {
			fullLIst.add(new ArrayList<>(list));
			return;
		}
		
		for (int i = 0; i < seed.size(); i++) {
			if (used[i]) {
				continue;
			} else {
				list.set(index, seed.get(i));
				used[i] = true;
				build(seed, list, used, index + 1);
				used[i] = false;
			}
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> list = new ArrayList<>();
		List<Integer> sortedList = new ArrayList<>();
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			list.add(sc.nextInt());
			sortedList.add(list.get(i));
		}
		fullLIst = new ArrayList<>();
		Collections.sort(sortedList);
		perm(sortedList);
		int index = -1;
		for (int i = 0; i < fullLIst.size(); i++) {
			boolean flag = true;
			
			for (int j = 0; j < fullLIst.get(i).size(); j++) {
				if (fullLIst.get(i).get(j) != list.get(j)) {
					flag = false;
					break;
				}
			}
			
			if (flag) {
				index = i;
				break;
			}
		}
		
		if (index > 0) {
			for (int i = 0; i < fullLIst.get(index - 1).size() - 1; i++) {
				System.out.print(fullLIst.get(index - 1).get(i) + " ");
			}
			System.out.println(fullLIst.get(index - 1).get(fullLIst.get(index - 1).size() - 1));
		}
		
		for (int i = 0; i < fullLIst.get(index).size() - 1; i++) {
			System.out.print(fullLIst.get(index).get(i) + " ");
		}
		System.out.println(fullLIst.get(index).get(fullLIst.get(index).size() - 1));
		
		if (index < fullLIst.size() - 1) {
			for (int i = 0; i < fullLIst.get(index + 1).size() - 1; i++) {
				System.out.print(fullLIst.get(index + 1).get(i) + " ");
			}
			System.out.println(fullLIst.get(index + 1).get(fullLIst.get(index + 1).size() - 1));
		}
	}
}



Measured memory_bytes: 87692
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/















int N;
//---------------------------------------------------------------------------------------------------
string buf = "";
void dfs(int cu) {
	if (cu == N) {
		printf("%s\n", buf.c_str());
		return;
	}

	char biggest = 'a';
	while (buf.find(biggest) != string::npos) biggest++;
	biggest--;

	for (char c = 'a'; c <= biggest + 1; c++) {
		buf.push_back(c);
		dfs(cu + 1);
		buf.pop_back();
	}
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;

	dfs(0);
}







Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
bool pal(string cad){
    for(int i = 0 ; i < cad.size() ; i++){
        if(cad[i]!=cad[cad.size()-i-1]) return false;
    }
    return true;
}
int main(){
    string s;
    cin>>s;
    int a,b;
    a = ((s.size()-1)/2);
    b = ((s.size()+3)/2)-1;
    string x = s.substr(0,a);
    string y = s.substr(b,s.size());
    //cout<<x<<" "<<y<<endl;
    if(pal(x) and pal(y) and pal(s)) cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>


int main(){

  int n, x, i, j, k, cnt;

  while(1){
    scanf("%d %d", &n, &x);
    if(n==0 && x==0) break;
    cnt=0;
    for(i=1;i<n;i++){
      for(j=i+1;j<n;j++){
	for(k=j+1;k<=n;k++){
	  if(i+j+k==x) cnt++;
	}
      }
    }
    printf("%d\n", cnt);
  }

  
  return 0;
  
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  long n;
  cin >> n;
  vector<long> a(n);
  vector<vector<long>> data(n);
  long maxi = 0;
  rep(i,n){
    cin >> a.at(i);
    maxi = max(a.at(i),maxi);
    data.at(a.at(i)).push_back(i);
  }
  long ans = 6;
  if(data.at(0).size() == 1){
    //cout << 3 << endl;
    ans = 3;
    //return 0;
  }else if(data.at(0).size() == 0 || data.at(0).size() >= 4){
    cout << 0 << endl;
    return 0;
  }
  rep(i,maxi+1){
    if(data.at(i).size() >= 4){
      cout << 0 << endl;
      return 0;
    }
  }
  rep(i,maxi){
    if(data.at(i).size() < data.at(i+1).size()){
      cout << 0 << endl;
      return 0;
    }
  }
  //cout << maxi << endl;
  for(long i=1;i<=maxi;i++){
    long color = data.at(i-1).size();
    long minus = 0;
    long m = data.at(i).size();
    for(long x : data.at(i)){
      long id = data.at(i-1).size();
      rep(j,data.at(i-1).size()){
        if(x < data.at(i-1).at(j)){
          //if(i == 6) cout << "j is " << j << endl;
          id = j;
          if(id == 0){
            cout << 0 << endl;
            return 0;
          }
          break;
        }
      }
      /*if(i >= 9 ){
        cout << "i:" << i << endl;
        cout << "x:" << x << endl;
        cout << "id:" << id << endl;
        cout << "color:" << color << endl;
      }*/
      long mul = id-minus;
      ans *= mul;
      ans %= MOD;
      color--;
      minus++;
      //if(i==9) cout << "p" << ans << endl;
    }
  }
  if(ans < 0) ans = 0;
  cout << ans << endl;
}


Measured memory_bytes: 6528