akhauriyash/Code-Regression huggingface dataset:
public class Main {

  private static void solve() {
    int a = ni();
    int b = ni();

    int ret = Integer.MIN_VALUE;
    ret = Math.max(ret, a + b);
    ret = Math.max(ret, a * b);
    ret = Math.max(ret, a - b);

    System.out.println(ret);

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 21204
#include <iostream>

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

ll f(ll b, ll n){
    if(n < b){
        return n;
    }else{
        return f(b, n / b) + n % b;
    }
}

int main(){
    ll n, s;
    cin >> n >> s;
    if(s > n){
        cout << -1 << endl;
        return 0;
    }else if(s == n){
        cout << n + 1 << endl;
        return 0;
    }

    for(ll b = 2; b * b <= n; ++b){
        if(f(b, n) == s){
            cout << b << endl;
            return 0;
        }
    }

    ll minb = -1;
    for(ll p = 1; p * p <= n; ++p){
        if((n - s) % p != 0){
            continue;
        }
        ll b = (n - s) / p + 1;
        if(f(b, n) == s){
            if(minb == -1 || b < minb){
                minb = b;
            }
        }
    }
    cout << minb << endl;

    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = in.nextInt();
        }
        int[] m = new int[n];
        m[0] = 0;
        for(int i=0; i<n; i++) {
            m[0] += a[i] * (i%2==0 ? 1 : -1);
        }
        for(int i=1; i<n; i++) {
            m[i] = 2*(a[i-1]-(m[i-1]/2));
        }
        for(int i=0; i<n; i++) {
            System.out.print(m[i]);
            if(i<n-1) {
                System.out.print(' ');
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 69820
#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;
    deque<int> a;
    REP(i,n) {
        int x;
        cin >> x;
        if ( i%2==0 ) a.push_back(x);
        else a.push_front(x);
    }
    if ( n%2 ) {
        while ( a.size() ) {
            cout << a.back() << " ";
            a.pop_back();
        }
    } else {
        while ( a.size() ) {
            cout << a.front() << " ";
            a.pop_front();
        }
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>

using namespace std;

class range {
private:
  struct Iterator {
    int val;
    int operator*() {return val;}
    bool operator!=(Iterator &itr) {return val < itr.val;}
    void operator++() {++val;}
  };
  Iterator i, n;
public:
  range(int n) : i({0}), n({n}) {}
  range(int i, int n) : i({i}), n({n}) {}
  Iterator &begin() {return i;}
  Iterator &end() {return n;}
};

template<class T> T at(vector<T> v, int i) {return v[(i % (int)v.size() + v.size()) % v.size()];}

int main() {
  int v, e;
  cin >> v >> e;
  char a[v];
  for (int i : range(v)) cin >> a[i];
  vector<int> edge[v];
  for (int i : range(e)) {
    int s, t;
    cin >> s >> t;
    edge[s].emplace_back(t);
    edge[t].emplace_back(s);
  }
  for (int i : range(v)) {
    if (a[i] != '?') continue;
    int bit = 0;
    for (const auto j : edge[i]) bit |= 1 << (a[j] - 'a');
    for (int j : range(26)) if (!(bit & 1 << j)) {
      a[i] = (char)(j + 'a');
      break;
    }
  }
  for (int i : range(v)) cout << a[i];
  cout << endl;
}


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

int GCD(int m,int n){
    int big,small;
    int p=-1;
    big=max(m,n);
    small=min(m,n);

    while(1){
        p=big%small;
        if(p==0)break;
        big=small;
        small=p;
    }
    
    return small;
}

int main(){
    int ans=0,MIN=1e9+1;
    int n;
    cin >> n;
    int data[n];

    cin >> data[0];
    for (int i = 1; i < n; i++){
        cin >>data[i];
        MIN = min(MIN,GCD(data[i-1],data[i]));
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << MIN << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

const int maxn = 1e5 + 5;
char a[maxn];
char last = 'a';
int n, k;
int tot = 0;

int main(){
	scanf("%d%d",&n,&k);
	scanf("%s",a+1);
	for(int i=1;i<=n;i++) if(a[i] != last) last = a[i], tot ++;
	tot = tot - 2 * k;
	if(tot <= 0) tot = 1;
	printf("%d",n - tot);
	return 0;
}

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

const int A = 1e6 + 1;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> c(A, 0);
  rep(i, n) {
    cin >> a.at(i);
    c.at(a.at(i))++;
  }

  bool pairwise = true;
  for (int i = 2; i < A; i++) {
    int cnt = 0;
    for (int j = i; j < A; j += i) {
      cnt += c.at(j);
    }
    if (cnt > 1) {
      pairwise = false;
      break;
    }
  }

  if (pairwise) {
    cout << "pairwise coprime" << endl;
    return 0;
  }

  int g = 0;
  rep(i, n) g = __gcd(g, a.at(i));
  if (g == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
  return 0;
}

Measured memory_bytes: 11112
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if ((a == b && b == c) || (a != b && b != c && c != a))
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define N 100005
#define M 1000000007
#define mod 998244353
using namespace std;


int main()
{
    __

    double l,a=0.0,b=0.0,c=0.0,ans=0.0;

    cin >> l;

    a = l/3.0;

    b = (l-a)/2.0;

    c = l-a-b;

    ans = a*b*c;

    printf("%.12f",ans);

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var o = ReadString();
            var e = ReadString();
            for (int i = 0; i < o.Length; i++)
            {
                Console.Write(o[i]);
                if (i < e.Length)
                {
                    Console.Write(e[i]);
                }
            }
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 11092
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())

    ans = float("inf")

    for a in range(1, N):
        b = N - a
        tmp = 0
        for s in str(a):
            tmp += int(s)
        for s in str(b):
            tmp += int(s)

        ans = min(ans, tmp)

    print(ans)



if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
  int n,m,A[1000][1000],b[1000],c,i,j;
  scanf("%d %d",&n,&m);
  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++){
      A[i][j] = 0;
      b[j] = 0;
    }
  }
  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++){
      scanf("%d",&A[i][j]);
    }
  }
  for(j = 0; j < m; j++){
    scanf("%d",&b[j]);
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++){
      c += A[i][j] * b[j];
    }
    printf("%d\n",c);
    c = 0;
  }
  return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n, m;
  cin >> n >> m;
  vi ans(n, -1);
  rep(i,m) {
    int s, c;
    cin >> s >> c;
    s--;
    bool ok = true;
    if(ans[s] != -1 && ans[s] != c) ok = false;
    if(s == 0 && c == 0 && n != 1) ok = false;
    if(!ok) {
      cout << -1 << endl;
      return 0;
    }
    ans[s] = c;
  }
  rep(i,n) {
    if(ans[i] == -1 && i == 0 && n != 1) cout << 1;
    else if(ans[i] == -1 && i == 0 && n == 1) cout << 0;
    else if(ans[i] == -1 && i != 0) cout << 0;
    else cout << ans[i];
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> s;
typedef long long int ll;

int abs(int x){
  return x > 0 ? x : -x;
}

int length(char c[]){
  int cnt=0;
  for(cnt=0;c[cnt]!='\0';cnt++){
  }
  return cnt;
}

int n,m;
int f[60][60];
int a[60],b[60],cnt=0;

queue<int> qu;
bool used[60];

void bfs(){
  while(!qu.empty()){
    int now = qu.front();
    qu.pop();
    used[now]=true;
    REP(i,n){
      if(f[now][i]==0)continue;
      if(used[i]==true)continue;
      qu.push(i);
    }
  }
  return;
}

int main(){
  scanf("%d %d",&n,&m);
  REP(i,m){
    scanf("%d %d",&a[i],&b[i]);
    a[i]--;b[i]--;
    f[a[i]][b[i]]=f[b[i]][a[i]]=1;
  }
  REP(i,m){
    f[a[i]][b[i]]=f[b[i]][a[i]]=0;
    REP(j,n)used[j]=false;
    qu.push(0);
    bfs();
    REP(j,n){
      if(used[j]==false){
        cnt++;
        break;
      }
    }
    f[a[i]][b[i]]=f[b[i]][a[i]]=1;
  }
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<list>
#include<cstring>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define FF first
#define SS second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define PLL pair<ll, ll>
#define inf 100000001
#define mod 1000000007
#define LP lower_bound
#define UP upper_bound
#define MP make_pair
#define rep1 for(i=1;i<=n;i++)
#define VLL vector<ll>
#define ef else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(), A.end());
#define REVERSE(A) reverse(A.begin(), A.end());
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define UMP unordered_map
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll myXOR(unsigned long long int x, unsigned long long int y)
{
    return (x|y)&(~x|~y);
}
ll powerLL(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    }
    return result; 
}
int main()
{
    fastio
    ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r, t,u,w,x,y,z;
    string str, ss, str1;
    /*
    **  author : mahiman12
    **  created : 2020-05-06 15:14 
    */
    cin>>n;
    ll arr[n];
    ll dp[n];
    rep(i,0,n)
    {
        cin>>arr[i];
        dp[i] = MAX;
    }
    dp[0]=0;
    rep(i,0,n)
    {
        if(i+1<n)
        {
            dp[i+1] = min(dp[i+1], dp[i] + abs(arr[i+1]-arr[i]));
        }
        if(i+2<n)
        {
            dp[i+2] = min(dp[i+2], dp[i] + abs(arr[i+2]-arr[i]));
        }
    }
    // rep(i,0,n){
    //     cout<<dp[i]<<" ";
    // }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  Int q;
  cin>>q;
  for(Int i=0;i<q;i++){
    Int b,e;
    cin>>b>>e;
    reverse(a.begin()+b,a.begin()+e);
  }
  for(Int j=0;j<n;j++){
    if(j) cout<<" ";
    cout<<a[j];
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3068
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cassert>
#include<map>
#include<set>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define fk(a, b) for(int k=a;k<b;++k)
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
/////////////////





void solve(){
	vector<int> a;
	ll ans = 0;
	int n;
	scanf("%d",&n);
	fi(0, n * 3){
		int v;
		scanf("%d",&v);
		a.pb(v);
	}
	sort(a.begin(), a.end());
	fi(1, n+1){
		ans += a[3 * n - i * 2];
	}
	printf("%lld\n",ans);
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

Measured memory_bytes: 2420
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
from math import pi, ceil, floor
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
from bisect import bisect_left, bisect_right, insort_left, insort_right
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def main():
    n, k = map(int, input().split())
    ans = 0
    for i in range(1, n+1):
        score = i
        p = 1 / n
        while score < k:
            p *= 1 / 2
            score *= 2
        ans += p
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 12456
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int[] H = new int[N+1];
		int[] MaxH = new int[N+1];
		for(int i = 0;i < N;i++) {
			int h = scn.nextInt();
			H[i+1] = h;
			MaxH[i+1] = Math.max(h, MaxH[i]);
		}
		int ans = 0;
		for(int i = 0;i < N;i++) {
			if(MaxH[i] <= H[i+1]) {
				ans++;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21716
// 2011/09/26 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;
		if(n==0&&m==0)
			break;

		int C[100] = {0};
		for(int i=0; i<n; i++)
			for(int j=0; j<m; j++){
				int t;
				cin >> t;
				C[j] += t;
			}

		int N[100];
		for(int i=0; i<m; i++)
			N[i] = i+1;

		for(int i=0; i<m-1; i++)
			for(int j=i+1; j<m; j++)
				if(C[i]<C[j]||(C[i]==C[j]&&N[i]>N[j])){
					int tmp = C[i];
					C[i] = C[j];
					C[j] = tmp;
					tmp = N[i];
					N[i] = N[j];
					N[j] = tmp;
				}

		for(int i=0; i<m; i++){
			cout << N[i];
			if(i!=m-1)
				cout << ' ';
			else
				cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 864
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

struct dijksra {

	ll N;
	vector<vector<edge>> g;
	ll s;

	vector<ll> ans;

	dijksra(ll N0, ll s, vector<vector<edge>> g0) {
		N = N0;
		g = g0;

		ans.assign(N + 1, INF);

		
		priority_queue<pair<ll,ll>> q;//(-キョリ、頂点)
		
		ans[s] = 0;
		q.push({ 0,s });
		
		while (!q.empty()) {
			auto x = q.top();
			q.pop();

			ll dis = -x.first;
			ll v = x.second;

			if (dis > ans[v]) {continue;}

			
			for (edge e : g[v]) {
				ll w = e.to;
				if (dis + e.d < ans[w]) {
					ans[w] = dis + e.d;
					q.push({ -ans[w], w });
				}
			}


		}
	}

	ll d(ll t) {
		return ans[t];
	}
	

};



int main() {

	ll H, W;
	cin >> H >> W;

	char s[51][51];

	repn(i, H) repn(j, W) cin >> s[i][j];

	vector<vector<edge>> g(H*W + 1);

	repn(i, H - 1)repn(j, W) {
		if (s[i][j] == '.'&&s[i + 1][j] == '.') {
			g[(i - 1)*W + j].push_back({0,0,i*W + j,1});
			g[i*W + j].push_back({ 0,0,(i - 1)*W + j,1 });
		}
	}

	repn(i, H)repn(j, W - 1) {
		if (s[i][j] == '.'&&s[i][j + 1] == '.') {
			g[(i - 1)*W + j].push_back({ 0,0,(i - 1)*W + j + 1,1 });
			g[(i - 1)*W + j + 1].push_back({ 0,0,(i - 1)*W + j,1 });
		}
	}
	
	dijksra dij(H*W, 1, g);

	ll path = dij.d(H*W);

	if (path == INF) { cout << -1; }

	else {
		ll num = 0;
		repn(i, H) repn(j, W) { if (s[i][j] == '.') { num++; } }

		cout << num - path - 1;
	}
	

	system("PAUSE");

	

}


Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N;
  cin>>N;
  vector<ll>A(N+1,0);
  ll sum=0;
  for(ll i=1;i<=N;i++){
    cin>>A[i];
    sum+=A[i];
  }
  sum=sum/2;
  for(ll i=1;i<N;i++){
    if(i%2!=0)sum-=A[i];
  }
  //cout<<sum<<endl;
  ll x=A[N]-sum;
  cout<<2*x<<" ";
  for(ll i=1;i<N;i++){
    cout<<2*(A[i]-x)<<" ";
    x=A[i]-x;
  }
}

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

int main(void) {
  int N, cnt=0;
  cin >> N;
  
  for(int i=1; i<=N; i++){
    if(i%2!=0) cnt++;
  }
  
  cout << (float)cnt/N << endl;
  
  return 0;
}

Measured memory_bytes: 256
n, d = gets.chomp.split(' ').map(&:to_i)

arr = []
n.times do
  l = gets.chomp.split(' ').map(&:to_i)
  arr.push(l.to_a)
end

k = arr.length
count = 0
k.times do |i|
  k.times do |j|
    next if i <= j

    tmp = 0
    d.times do |a|
      tmp += (arr[i][a] - arr[j][a])**2
    end

    count += 1 if ((tmp**(1 / 2.0)) % 1).zero?
  end
end
print count


Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
template<class T = int> using V = vector<T>;

int main() {
    int r, n;
    while (cin >> r >> n, r) {
        V<> a(40);
        while (n--) {
            int l, r, h; cin >> l >> r >> h;
            l += 20, r += 20;
            for (int i = l; i < r; ++i) a[i] = max(a[i], h);
        }
        auto chk = [&](double t) -> bool {
            for (int x = 20 - r + 1; x < 20 + r; ++x) {
                double y = min(a[x - 1], a[x]) + r - t;
                if (sqrt(r * r - (x - 20) * (x - 20)) > y) return false;
            }
            return true;
        };
        double ok = 0, ng = 100;
        for (int _ = 0; _ < 100; ++_) {
            double mid = (ok + ng) / 2;
            (chk(mid) ? ok : ng) = mid;
        }
        cout << fixed << setprecision(15) << ok << '\n';
    }
}


Measured memory_bytes: 3176
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
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 main(){
    string s;
    cin >> s;
    string res;
    if(s=="ARC"){
        res = "ABC";
    }else{
        res = "ARC";
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;

int N;
double x[105], y[105];
const double pi = 3.14159265358979;

int main(void)
{
cin >> N;
for(int i = 1; i <= N; i++) cin >> x[i] >> y[i];

for(int i = 1; i <= N; i++){
bool flag = false;
double max_th, min_th, lth, uth;
double ans = 1;

for(int j = 1; j <= N; j++){
if(i == j) continue;

//cout << i << j << endl;

double th = atan2(y[j]-y[i], x[j]-x[i]);
uth = th;
lth = th-pi;

if(!flag){
flag = true;
max_th = uth;
min_th = lth;
}
else{
while(!(uth >= min_th && uth < min_th + 2*pi)){
if(uth < min_th) uth += 2*pi, lth += 2*pi;
else uth -= 2*pi, lth -= 2*pi;
}

max_th = min(max_th, uth);
min_th = max(min_th, lth);
}

	if(max_th <= min_th){
		ans = 0;
		break;
	}

	}
	if(ans > 0.5){
		ans = (max_th - min_th) / (2*pi);
}
printf("%.12f\n", ans);
		//cout << ans << endl;
}

return 0;
}

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

int divisors(int n)
{
	int result = 0;
	for (int i = 1; i <= n; i++)
	{
		if (n % i == 0)
		{
			result++;
		}
	}
	return result;
}

int main()
{
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i+=2)
	{
		if (divisors(i) == 8)
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

template<typename T> 
void show(T a){
  for(auto i : a){ cout << i << " "; }
  cout << endl;
}


int main(int argc, char *argv[]){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin >> n;
  vector<int> a(n);
  for(int& i : a){
    cin >> i;
  }
  
  int maxn = a[0];
  for(int i = 0; i < n; i++){
    maxn = max(maxn, a[i]);
  }
  
  // n x n
  int count = 0;
  for(int i = 0; i < maxn; i++){
    for(int j = 0; j < n; j++){
      if(a[j] > 0){
        count++;
        while(++j < n){
          if(a[j] <= 0) break;
        }
      }
    }
    for(int j = 0; j < n; j++) a[j] -= 1;
  }
  
  //show(a);
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
using namespace std;
const int INF=1e17+5;
const int maxn=1e5+5;
int n,m,a[maxn],b[maxn],ans,sum;

int32_t main()
{
    IOS;
    string k;
    cin>>k;
    fu(i,1,k.length()-1)
    {
        if(k[i]==k[i-1]){
            cout<<"Bad";
            return 0;
        }
    }
    cout<<"Good";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll n, k;

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

  ll ans = 0;

  for(int i = k + 1; i <= n; i++) {
    ans += (i - k) * (n / i) + max(0ll, n % i - k + 1);
  }
  if(k == 0) ans = n * n;
  cout << ans << endl;

  return 0;
}


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

std::string str;
int input[51][51], memo[60][60], hoge[5], mx = 0, o = 0;

void makes(){
    std::string tmp = "";
    int cnt = 0;
    o = 0;
    for(int i = 0; i < str.size(); i++){
        if(str[i] == ','){
            hoge[cnt] = std::atoi(tmp.c_str());
            cnt++;
            o++;

            tmp = "";
            continue;
        }

        tmp += str[i];
    }
    hoge[cnt] = std::atoi(tmp.c_str());
    for(int i = cnt + 1; i < 5; i++){
        hoge[i] = 0;
    }
}

int main(){
    int u = 0;
    while(getline(std::cin, str)){

        makes();
        mx = std::max(mx, o + 1);
        o++;

        for(int i = 0; i < o; i++){
            input[mx - i - 1][mx - o + i] = hoge[i];
        }
    }

    memo[0][0] = input[0][0];
    for(int i = 0; i < mx; i++){
        for(int j = 0; j < mx; j++){
            if(memo[i][j] > 0){
                    memo[i][j + 1] = std::max(memo[i][j + 1], memo[i][j] + input[i][j + 1]);
                    memo[i + 1][j] = std::max(memo[i + 1][j], memo[i][j] + input[i + 1][j]);
                }else{
                    memo[i][j + 1] = memo[i][j] + input[i][j + 1];
                    memo[i + 1][j] = memo[i][j] + input[i + 1][j];
                }
        }
    }


    std::cout << memo[mx - 1][mx - 1] << std::endl;

    return 0;
}

Measured memory_bytes: 3172
def main():
  H, W = [int(i) for i in input().split()]
  matrix = [input() for i in range(H)]
  for i in range(H):
    for j in range(W):
      if matrix[i][j] == '#':
        neighbors = [
          matrix[i-1][j] if i > 0 else '.',
          matrix[i+1][j] if i < H-1 else '.',
          matrix[i][j-1] if j > 0 else '.',
          matrix[i][j+1] if j < W-1 else '.',
        ]
        if '#' not in neighbors:
          print('No')
          return
  print('Yes')

main()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>

using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){

  int n;
  cin >> n;

  int y,m,d;
  int day=0;

  REP(i,n){

	cin >> y >> m >> d;

	if(y%3!=0&&m%2==0){
	  day=19-d+1;
	}else{
	  day=20-d+1;
	}

	//cout << y%3 << endl;//
	//cout << m%2 << endl;//

	m++;
	if(m>10){
	  m=1;
	  y++;
	}
	while(m<=10&&y<1000){
	  if(y%3!=0&&m%2==0){
		day += 19;
	  }else{
		day += 20;
	  }
	  m++;
	  //cout << y%3 << endl;//
	  //cout << m%2 << endl;//

}

	y++;

	//cout << y <<endl;//

	while(y<1000){
	  if(y%3==0){
		day+=(20*10);
	  }else{
		day+=(19*5+20*5);
	  }
	  y++;
	}

	cout << day << endl;

  }

}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>

using namespace std;

bool isSumExist(vector<int>& A, int pos, int digit)
{	
	if (digit == 0)
	{
		return(true);
	}
	if (pos >= A.size() || digit < 0)
	{
		return(false);
	}
	return(isSumExist(A, pos + 1, digit - A[pos]) || isSumExist(A, pos + 1, digit));
}

void solve()
{
	int n;
	cin >> n;
	vector<int> A(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> A[i];
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; ++i)
	{
		int m;
		cin >> m;
		if(isSumExist(A, 0, m))
		{
			cout << "yes" << endl;
		}
		else
		{
			cout << "no" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1188
OH = [[[0]*10 for i in range (0,3)] for k in range (0,4)]
odd = int(input())
for loop in range(odd):
    house_id,floor,room,add = map(int,input().split())
    OH[house_id-1][floor-1][room-1] += add
for t in range(4):
  for g in range(3):
    for i in range(10):
      if i == 9 :
          print(" %d"%(OH[t][g][i]))
      else:
       print(" %d"%(OH[t][g][i]),end="")
  if t < 3:
   print("#"*20)


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

void move( int& x, int& y, int n, int flag ){
	if ( !flag ){
		x += 1;
		y += 1;
	}else{
		x -= 1;
		y += 1;
	}
	if ( x < 0 ) x = n - 1;
	else if ( x >= n ) x = 0;
	if ( y < 0 ) y = n - 1;
	else if ( y >= n ) y = 0;
}

int main(){
	int n;
	while ( cin >> n && n ){
		int* table = new int[ ( n * n ) ]();
		int x = n / 2, y = n / 2 + 1;
		for ( int i = 0; i < n * n; ++i ){
			if ( table[ y * n + x ] ){
				move( x, y, n, 1 );
			}
			table[ y * n + x ] = i + 1;
			move( x, y, n, 0 );
		}

		for ( int j = 0; j < n; ++j ){
			for ( int i = 0; i < n; ++i ){
				cout << setw( 4 );
				cout << table[ j * n + i ];
			}
			cout << endl;
		}

		delete[] table;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint h, w, k; cin >> h >> w >> k;
  lint n = h - 1;

  vector<vector<lint>> a(h, vector<lint> (w, 0));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char c; cin >> c;
      if (c == '1') a[i][j] = 1;
    }
  }

  lint ans = inf;
  for (int bit = 0; bit < (1 << n); bit++) {
    lint m = __builtin_popcount(bit) + 1;
    vector<vector<lint>> dat(m, vector<lint> (w, 0));
    
    int id = 0;
    for (int j = 0; j < w; j++) {
      dat[0][j] += a[0][j];
    }
    for (int i = 1; i < h; i++) {
      if (bit & (1 << (i - 1))) id++;

      for (int j = 0; j < w; j++) {
        dat[id][j] += a[i][j];
      }
    }

    bool dame = false;
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < w; j++) {
        if (dat[i][j] > k) {
          dame = true;
        }
      }
    }

    if (dame) continue;


    vector<lint> cnt(m, 0);
    lint cost = m - 1;
    for (int i = 0; i < m; i++) {
      cnt[i] += dat[i][0];
    }

    for (int j = 1; j < w; j++) {
      // くわえて見る
      for (int i = 0; i < m; i++) {
        cnt[i] += dat[i][j];
      }

      // 一つでも k を超えたら
      bool ok = true;
      for (int i = 0; i < m; i++) {
        if (cnt[i] > k) {
          ok = false;
        }
      }

      if (!ok) {
        cost++;
        for (int i = 0; i < m; i++) {
          cnt[i] = dat[i][j];
        }
      }
    }
    ans = min(ans, cost);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
m, d = map(int, input().split())

ans = 0
for j in range(1, m + 1):
    for i in range(22, d + 1):
        d1, d10 = i // 10, i % 10
        if d1 >= 2 and d10 >= 2 and d1 * d10 == j:
            ans += 1
print(ans)


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

int main(){
  int flag = 1;
  int n,x;
  cin >> n;
  if(n==0) return 0;
  while(flag){
    int max = -1;
    int min = 1001;
    int sum = 0;
    for(int i=0;i<n;i++){
      cin >> x;
      if(x >= max){
        //sum += max;
        max = x;
      }//else sum += x;
      if(x <= min){
        //sum += min;
        min = x;
      }/*else*/ sum += x;
    }
//    sum -= 1000;
    sum = sum - min - max;
    sum = sum / (n - 2);
    cout << sum << endl;
    cin >> n;
    if(n == 0) flag = 0;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

vector<int> to[200010];
vector<int> ans;

void dfs(int v, int p = -1) {
    for(int u : to[v]) {
        if(u == p) {
            continue;
        }
        ans[u] += ans[v];
        dfs(u, v);
    }
}

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

    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    ans.resize(n);
    rep(i, q) {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }

    dfs(0);

    rep(i, n) {
        cout << ans[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 23552
import os,re,sys,operator
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy
import heapq

setrecursionlimit(10**6)
while 1:
    n,m=map(int,stdin.readline().rstrip().split())
    if (n,m)==(0,0):
        break
    a=[list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]
    print(max(sum(i) for i in zip(*a)))


Measured memory_bytes: 8608
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	if ((s[0] == s[1]) && (s[1] == s[2])) cout << "Yes\n";
	else if ((s[1] == s[2]) && (s[2] == s[3])) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>

#define MAX_N 100'000

typedef long long ll;

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> V;
  for (int i = 0; i < N; ++i) {
    int a, b;
    cin >> a >> b;
    V.emplace_back(vector<int>{a, b});
  }
  sort(V.begin(), V.end());
  ll res = 0;
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    res += (ll)V[i][0] * V[i][1];
    cnt += V[i][1];
    if (cnt > M) {
      res -= V[i][0] * (cnt - M);
      break;
    }
  }
  printf("%lld\n", res);
}

Measured memory_bytes: 8300
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	string S;
	cin >> S;
	int N = S.size();
	int tigau = 0;

	char C = S[0];
	rep(i, N) {
		if (C != S[i]) tigau = 1;
	}
	if (!tigau) {
		co(N);
		co(1);
		return 0;
	}

	int Z[500000];
	Z[0] = N;
	int i = 1;
	int j = 0;
	while (i < N) {
		while (i + j < N && S[j] == S[i + j]) j++;
		Z[i] = j;
		if (j == 0) {
			i++;
			continue;
		}
		int k = 1;
		while (i + k < N && k + Z[k] < j) {
			Z[i + k] = Z[k];
			k++;
		}
		i += k;
		j -= k;
	}
	bool mae[500000] = {};
	rep1(i, N - 1) {
		for (int j = i + i - 1; j < Z[i] + i; j += i) {
			//そうなの解説さん？
			if (mae[j]) break;
			mae[j] = 1;
		}
	}
	if (!mae[N - 1]) {
		co(1);
		co(1);
		return 0;
	}
	Z[0] = N;
	i = 1;
	j = 0;
	while (i < N) {
		while (i + j < N && S[N - 1 - j] == S[N - i - j - 1]) j++;
		Z[i] = j;
		if (j == 0) {
			i++;
			continue;
		}
		int k = 1;
		while (i + k < N && k + Z[k] < j) {
			Z[i + k] = Z[k];
			k++;
		}
		i += k;
		j -= k;
	}

	bool ato[500000] = {};
	rep1(i, N - 1) {
		for (int j = i + i - 1; j < Z[i] + i; j += i) {
			if (ato[N - j - 1]) break;
			ato[N - j - 1] = 1;
		}
	}
	int kotae = 0;
	rep(i, N - 1) {
		if (!mae[i] && !ato[i + 1]) kotae++;
	}
	co(2);
	co(kotae);


	Would you please return 0;
}

Measured memory_bytes: 3740
#include <stdio.h>
#include <algorithm>

using namespace std;

void test(int* start, int n){
  for(int i=0; i < n; i++){
    printf("%d/", *(start + i));
  }
  printf("\n");
}

int main(){
  long x[1001];
  long y[1001];
  long z[1001];
  int n, m;

  // Reading
  scanf("%d %d\n", &n, &m);
  for(int i=0; i < n; i++){
    scanf("%ld %ld %ld\n", x+i, y+i, z+i);
    
  }


  // Flip signs
  long best = 0;

  for(int i=0; i < 8; i++){
    long table[1001] = {};    
    int fx = (i >> 2)%2 ? -1 : 1;
    int fy = (i >> 1)%2 ? -1 : 1;
    int fz = i%2 ? -1 : 1;
    //    printf("%d %d %d\n", fx, fy, fz);
    // Make table
    for(int j=0; j < n; j++){
      table[j] = fx*x[j] + fy*y[j] + fz*z[j];
    }
    //    test(table, n);
    // Sort
    partial_sort(table, table + n, table + n);
    //    test(table, n);
    // Take sum
    long s = 0;
    for(int j=0; j < m; j++){
      s += table[n - 1 - j];
    }
    best = max(s, best);

  }

  printf("%ld\n", best);
  
  return 0;
}


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

int main() {
	int N, K; cin >> N >> K;
	if(N<3) cout << 0 << endl;
	else{
	    N -= 2;
	    int P=(N-(N%11))/11*5;
	    for(int i=0; i<N%11; ++i){
	        int T=(8*i+4)%11;
	        for(int j=0; j<5; ++j){
	            if(T==K) ++P;
	            T=(T+9)%11;
	        }
	    }
	    cout << P << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include<algorithm>
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll dep(ll a,ll b){
	if(b==0){
		return a;
	}
	return dep(b,a%b);
}
int main() {
	ll n,m;
	cin>>n>>m;
	ll ch[100010];
	for(ll i=0;i<n;i++){
		ll now;cin>>now;
		now/=2;
		ch[i]=now;
	}
	ll ch2[100010]={};
	for(ll i=0;i<n;i++){
		ll now=ch[i];
		ll j=0;
		while(now%2==0){
			j++;
			now/=2;
		}
		ch2[i]=j;
		ch[i]=now;
	}
	for(ll i=0;i<n-1;i++){
		if(ch2[i]!=ch2[i+1]){
			cout <<0;
			return 0;
		}
	}
	ll cn=ch2[0];
	while(cn!=0){
		cn--;
		m/=2;
	}
	ll lcm=ch[0];
	for(ll i=1;i<n;i++){
		ll gcd=dep(max(lcm,ch[i]),min(lcm,ch[i]));
		lcm=lcm/gcd*ch[i];
		if(lcm>m){
			cout << 0;
			return 0;
		}
	}
	cout << (m/lcm-1)/2+1;
	// your code goes here
	return 0;
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
#define ll long long
#define MAXN 100010
using namespace std;
int DP[MAXN];
int N;
int main () {
cin >> N;
for (int i=1; i<=N; i++) {
DP[i] = DP[i - 1] + 1;
int coin = 6;
while (i >= coin) {
DP[i] = min(DP[i], DP[i - coin] + 1);
coin *= 6;
}
coin = 9;
while (i >= coin) {
DP[i] = min(DP[i], DP[i - coin] + 1);
coin *= 9;
}
}
cout << DP[N] << "\n";
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct pole
{
    int x, y;
};

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

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    int odp = 0;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            if (a[i][j] == '.')
            {
                queue<pole> Q;
                vector< vector<int> > odl(n, vector<int>(m, -1));
                Q.push({i, j});
                odl[i][j] = 0;
                while (!Q.empty())
                {
                    pole akt = Q.front();
                    Q.pop();
                    for (int q = 0; q < 4; ++q)
                    {
                        pole nowy = {akt.x + dx[q], akt.y + dy[q]};
                        if (nowy.x >= 0 && nowy.x < n && nowy.y >= 0 && nowy.y < m && odl[nowy.x][nowy.y] == -1 && a[nowy.x][nowy.y] == '.')
                        {
                            Q.push(nowy);
                            odl[nowy.x][nowy.y] = odl[akt.x][akt.y] + 1;
                        }
                    }
                }
                for (int k = 0; k < n; ++k)
                    for (int l = 0; l < m; ++l)
                        odp = max(odp, odl[k][l]);
            }
        }
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int A,B,N;
int main(){
	int i,j,k;
	scanf("%d%d%d",&N,&A,&B);
	if(B-A<=2){
		printf("%d\n",1+N);
	}
	else{
		int fs=A-1;
		if(N<=fs+1){
			printf("%d\n",1+N);
		} 
		else{
			N-=fs;
			int d=N/2;
			LL t=(LL)d*(LL)(B-A)+(LL)A;
			N-=d*2;
			if(N) ++t;
			printf("%lld\n",t);
		}
	}
	return 0;
}

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

typedef long long int ll;
typedef pair<ll,ll> P;

//最大公約数
ll gcd(ll a,ll b){
    if(b){return gcd(b,a%b);}else{return a;}
}


int main(){
    ll n,k;
    cin>>n>>k;
    ll mmax=n;
    for(int i=0;i<100;i++){
        n%=k;
        mmax=min(mmax,n);
        n=abs(n-k);
    }
    cout<<mmax;

    return 0;
}

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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	string s, t;
    cin>>s>>t;

cout<<t<<s<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<complex>
#include<iomanip>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define pi 3.14159265358979

int g(int x,int y){
	int a=max(x,y),b=min(x,y);
	if(a%b==0) return b;
	else return g(b,a%b);
}

int main(void){

	int x,y;
	while(cin >> x >> y){

		cout << g(x,y) << endl;

	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define N 101

ll matrix[N][100001];	// matrix to store the dp values

ll solve(vector<pll> a,ll w,ll x,ll i){
	if(x>w || i==a.size())	return 0;
	ll res1=0,res2=0;
	if(x+a[i].first<=w){
		res1 = solve(a,w,x+a[i].first,i+1)+a[i].second;
	}
	res2 = solve(a,w,x,i+1);
	return max(res1,res2);
}

ll knapsack(vector<pll> a,ll w,ll n){	//i is the index
	for(int i=0;i<=w;i++)	matrix[0][i] = 0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=w;j++){
			// cout<<matrix[i][j]<<' ';
			if(a[i-1].first<=j){
				matrix[i][j] = max(matrix[i-1][j],a[i-1].second+matrix[i-1][j-a[i-1].first]);
			}
			else{
				matrix[i][j] = matrix[i-1][j];
			}
			// cout<<matrix[i][j]<<' ';
		}
		// cout<<endl;
	}
	return matrix[n][w];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,w;
	cin>>n>>w;
	vector<pll> a(n);
	for(ll i=0;i<n;i++){
		cin>>a[i].first>>a[i].second;
	}
	ll x=0,i=0;
	cout<<knapsack(a,w,n)<<endl;
}


Measured memory_bytes: 79232
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define N 200012
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define pb push_back
#define fs first
#define sc second
#define sz(x) ((int)((x).size()))
#define oo 1000000123
#define mod 1000000007

using namespace std;

string s;
int v[N], ra[N], rb[N], p10[N];
ll f[2500];

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(0);
    cin >> s;
    int n = sz(s);
    p10[0] = 1;
    for(int i = 1; i <= n; ++i){
        p10[i] = (p10[i-1] * 10) % 2019;
    }
    s = "0" + s;
    for(int i = 1; i <= n; ++i){
        v[i] = (int)(s[i] - '0');
        ra[i] = (ra[i-1]*p10[n - i] + v[i]) % 2019;
    }
    f[0] = 1;
    for(int i = n; i >= 1; --i){
        rb[i] = (rb[i+1] + v[i]*p10[n-i]) % 2019;
        f[rb[i]]++;
    }
    /* 
    for(int i = 0; i <= n; ++i){
        cout << setw(4) << v[i] << ' ';
    }
    cout << '\n';
    for(int i = 0; i <= n; ++i){
        cout << setw(4) << ra[i] << ' ';
    }
    cout << '\n';
    for(int i = 0; i <= n; ++i){
        cout << setw(4) << rb[i] << ' ';
    }
    cout << '\n';
    */
    ll ans = 0;
    for(int i = 0; i <= 2019; ++i){
        ans += (f[i] * (f[i] - 1LL)) / 2LL;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 6872
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_string().chars().collect::<Vec<char>>();

    if line[0] < line[2]{
        println!("<");
    }else if line[0] > line[2]{
        println!(">");
    }else{
        println!("=");
    }
}


Measured memory_bytes: 4352