akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1+(key % (M-1)); }

int find(char str[]){
  long long key ,i,h;
  int x,y;

  key = getKey(str);
  x = h1(key);
  y = h2(key);
  for(i = 0; i < M; i++){
    h = (x + i * y) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  int x,y;

  key = getKey(str);
  x = h1(key);
  y = h2(key);
  for(i = 0; i < M; i++){
    h = (x + y * i) % M;
    if(strcmp(H[h],str) == 0)return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 14708
n = int(input())
count = 0
currCount = 0
ans = 0
for i in range(n+1):
    currCount = 0
    currNum = i
    while (i % 2) == 0:
        if i == 0:
            break
        i = int(i / 2)
        currCount += 1
    if count <= currCount:
        count = currCount
        ans = currNum
print(ans)

Measured memory_bytes: 3060
#include <iostream>

#include<vector>

#include<string>

#include<algorithm>

#include<cmath>

#include<cstdlib>

#include<utility> 

#include<cstdio> 

#define vii vector< pair<int,int> >

#define vi vector<int>

#define INF 1000000007

#define ff first

#define ss second

#define lli long long int

#define ulli unsigned long long int

using namespace std;

int main() {

 ios_base::sync_with_stdio(false);

    cin.tie(NULL);

  lli a,b,c,d;

  cin>>a>>b>>c>>d;

  lli a1=max(a,b)*max(c,d);

  lli b1=min(a,b)*min(c,d);

  lli d1=max(a,b)*min(c,d);

  lli c1=min(a,b)*max(c,d);

  vector<lli> v(4);

  v[0]=a1; 

  v[1]=b1; 

  v[2]=c1; 

  v[3]=d1;

  cout<<*max_element(v.begin(),v.end());

  

}

// -4 -5 6 7

Measured memory_bytes: 3600
N, L = (int(i) for i in input().split())
C = 0
S = 0

if L > 0:
	for i in range(N):
		if i > 0:
			S += L + i
elif (L+N-1) < 0:
	for i in range(N):
		if i < N-1:
			S += L + i
else:
	for i in range(N):
		S += L + i

print(S)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}
ll modinv(ll n) {
    return powmod(n, P - 2);
}

vector<int> f0, f1;
void init(int n) {
    f0.resize(n + 1);
    f0[0] = 1;
    for (int i = 1; i <= n; i++) {
        f0[i] = (ll)f0[i - 1] * i % P;
    }
    f1.resize(n + 1);
    f1[n] = modinv(f0[n]);
    for (int i = n; i > 0; i--) {
        f1[i - 1] = (ll)f1[i] * i % P;
    }
}
ll fact(int k) {
    return f0[k];
}
ll comb(int n, int k) {
    if (n < k || k < 0) return 0;
    return (ll)f0[n] * f1[k] % P * f1[n - k] % P;
}

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

    int k;
    cin >> k;

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

    init(n + k);

    //int p[26] = {};
    //for (int i = 0; i < n; i++) {
    //    p[s[i] - 'a']++;
    //}

    ll r = 0;
    for (int i = 0; i <= k; i++) {
        ll t = 0;
        t = powmod(25, k - i) * powmod(26, i) % P;
        t = t * comb(n + k - i - 1, n - 1) % P;
        r += t;
    }

    cout << r % P << endl;

    //1回も含まれていない文字のみを追加する場合は簡単
    //1回だけ含まれている文字を追加する その順番で存在しないといけないからなあ
    //i文字目まで見てj文字

    return 0;
}

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

void print(int y,int m,int d){
  cout<<y<<" "<<m<<" "<<d<<endl;
}

signed solve(string s){
  int y,m,d;
  cin>>y>>m>>d;
  if(y<31){
    cout<<s<<" ";
    print(y,m,d);
    return 0;
  }
  if(y==31&&m<4){
    cout<<s<<" ";
    print(y,m,d);
    return 0;
  }
  if(y==31&&m==4&&d<=30){
    cout<<s<<" ";
    print(y,m,d);
    return 0;
  }
  cout<<"? ";
  print(y-30,m,d);
}

signed main(){
  while(1){
    string s;
    cin>>s;
    if(s=="#") break;
    solve(s);
  }
  return 0;
}



Measured memory_bytes: 3192
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n+1-h)*(n+1-w) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
#define int long long
using namespace std;
signed main(){
	string s;
	cin>>s;
	if(s=="Sunny"){
		cout<<"Cloudy"<<endl;
		return 0;
	}
	if(s=="Cloudy"){
		cout<<"Rainy"<<endl;
		return 0;
	}
	if(s=="Rainy"){
		cout<<"Sunny"<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
class UnionFind:
  def __init__(self, n):
    self.p = [-1]*n
    # union by rank
    self.r = [1]*n
 
  def find(self, x):
    if self.p[x] < 0:
      return x
    else:
      self.p[x] = self.find(self.p[x])
      return self.p[x]

  def union(self, x, y):
    rx, ry = self.find(x), self.find(y)

    if rx != ry:
      if self.r[rx] > self.r[ry]:
        rx, ry = ry, rx
      if self.r[rx] == self.r[ry]:
        self.r[ry] += 1
      self.p[ry] += self.p[rx]
      self.p[rx] = ry

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def count_member(self, x):
    return -self.p[self.find(x)]
  
n,m,k=map(int,input().split())
uf=UnionFind(n)
ab,cd=[],[]
for i in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  uf.union(a,b)
  ab.append((a,b))
for i in range(k):
  c,d=map(int,input().split())
  c-=1
  d-=1
  cd.append((c,d))
cnt=[]
for i in range(n):
  t=uf.count_member(i)-1
  cnt.append(t)
for a,b in ab:
  if uf.same(a,b):
    cnt[a]-=1
    cnt[b]-=1
for c,d in cd:
  if uf.same(c,d):
    cnt[c]-=1
    cnt[d]-=1
print(*cnt)
    



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define inf 1e18
#define pi acos(-1.0)
#define mod 998244353

int main(void)
{
    fastio;

    string s;
    cin >> s;
    ll n=s.size(),i,ans=0,c=0;
    for(i=0;i<n;i++)
    {
        if(s[i]=='B')c++;
        else
        {
            ans=ans+c;
        }
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 3776
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <array>
#include <climits>

using namespace std;

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

const ll MOD = 10e9 + 7;
const ll INF = LLONG_MAX;
const ll MAX_V = 10e3;
const double EPS = 10e-6;
const double PI = 3.14159265359;

//int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
//int d[] = {0,1,0,-1};
//int nx = x + d[i];
//int ny = y + d[(i+1)%4]

ll n, a[200005]{}, ans = 0, sum = 0;
map<ll, ll> mp;

ll ncr(int nn, int r) {
	if (r == 0)
		return 1;
	else
		return ncr(nn, r - 1)*(nn - r + 1) / r;
}

int main() {
	mp[0]++;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] += a[i - 1];
		mp[a[i]]++;
	}
	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
		if (itr->second > 1)ans += ncr(itr->second, 2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 14336
using System;

namespace E
{
    class Program
    {
        static void Main(string[] args)
        {
            var NMK = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NMK[0]; var M = NMK[1]; var K = NMK[2];
            long MOD = 998244353;
            Combination.combInit(1000000, MOD);
            long result = 0;
            for (int i = 0; i <= K; i++)
            {
                long subtotal = M;
                subtotal *= modpow(M - 1, N - i - 1, MOD);
                subtotal %= MOD;
                subtotal *= Combination.combination(N - 1, i);
                subtotal %= MOD;
                result += subtotal;
                result %= MOD;
            }
            Console.WriteLine(result);
        }
        static long modpow(long a, long n, long mod)
        {
            long result = 1;
            while (n > 0)
            {
                if ((n & 1) > 0) result = (result * a) % mod;
                a = (a * a) % mod;
                n >>= 1;
            }
            return result;
        }
    }
    static class Combination
    {
        static long combMax;
        static long combMOD;

        static long[] factorial;
        static long[] inverse;
        static long[] factInv;

        public static void combInit(long _max, long _mod)
        {
            combMax = _max;
            combMOD = _mod;
            factorial = new long[combMax];
            inverse = new long[combMax];
            factInv = new long[combMax];

            factorial[0] = factorial[1] = 1;
            factInv[0] = factInv[1] = 1;
            inverse[1] = 1;

            for (int i = 2; i < combMax; i++)
            {
                factorial[i] = factorial[i - 1] * i % combMOD;
                inverse[i] = combMOD - inverse[combMOD % i] * (combMOD / i) % combMOD;
                factInv[i] = factInv[i - 1] * inverse[i] % combMOD;
            }
        }

        public static long combination(int n, int k)
        {
            if (n < k) return 0;
            if (n < 0 || k < 0) return 0;
            return factorial[n] * (factInv[k] * factInv[n - k] % combMOD) % combMOD;
        }
    }
}


Measured memory_bytes: 51372
#include <stdio.h>
#include <string.h>
int Method(int n);

int main(void) {

	int i,j,n,m;
	char str[100];

	fgets(str,sizeof(str),stdin);
	sscanf(str,"%d",&m);
	for(j=0;j<m;j++){
		fgets(str,sizeof(str),stdin);
		sscanf(str,"%d",&n);
		printf("Case %d:\n",j+1);
		for(i=0;i<10;i++)
			n=Method(n);
	}		
	return 0;
}

int Method(int n){
	n=n*n;
	n/=100;
	n%=10000;
	printf("%d\n",n);
	return n;
}

Measured memory_bytes: 600
# while文を使うパターン(本番では書けず、あとで修正したもの)
a, b, c, d = map(int, input().split())


turn = 0

while a >= 1 and c >= 1:
    if turn % 2 == 0:
        c -= b
    else:
        a -= d
    turn += 1

# どちらかが0以下になった時点で止まるので最後のターンがどちらかを判別
if turn % 2 != 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9112
import java.util.*;
 
public class Main {
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        int X = s.nextInt();
        int fiveHundred = X/500;
        X -= fiveHundred*500;
        int five = X/5;
        System.out.println(fiveHundred*1000+five*5);
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll h, w, n, ans;
	std::cin >> h >> w >> n;
	if (w > h) {
		swap(h, w);
	}
	ans = n / h;
	if (n % h > 0) {
		ans++;
	}
	outn(ans);
	return 0;
}


Measured memory_bytes: 256
def main():
    from collections import deque

    k = int(input())
    dq = deque()
    for i in range(1,10):
        dq.append(i)
    
    for i in range(k):
        lnln = dq.popleft()
        r = lnln%10
        if r not in (0,9):
            dq.extend([lnln*10+r-1,lnln*10+r,lnln*10+r+1])
        elif r == 9:
            dq.extend([lnln*10+r-1,lnln*10+r])
        else:
            dq.extend([lnln*10+r,lnln*10+r+1])

    print(lnln)
main()

Measured memory_bytes: 11980
#include <iostream>
#include <vector>
#include <string>

static constexpr size_t di[] = {size_t(-1), 0, 1, 0};
static constexpr size_t dj[] = {0, size_t(-1), 0, 1};

int main() {
  size_t H, W;
  std::cin >> H >> W;

  std::vector<std::string> s(H);
  for (auto& si: s) std::cin >> si;

  for (size_t i = 0; i < H; ++i) {
    for (size_t j = 0; j < W; ++j) {
      if (s[i][j] == '.') continue;
      bool valid = false;
      for (int k = 0; k < 4; ++k) {
        size_t ni = i + di[k];
        size_t nj = j + dj[k];
        if (!(ni < H && nj < W)) continue;
        if (s[ni][nj] != '#') continue;
        valid = true;
        break;
      }
      if (!valid)
        return (std::cout << "No" << std::endl), 0;
    }
  }
  std::cout << "Yes" << std::endl;
}

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

struct BinaryIndexedTree {
  BinaryIndexedTree(int n) : n(n), v(n + 1, 0) {}

  int n;
  vector<int> v;

  int sum(int k) {
    int ret = 0;
    for (; k; k -= k & -k) ret += v[k];
    return ret;
  }

  void add(int k, int x) {
    for (; k <= n; k += k & -k) v[k] += x;
  }
};

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

  BinaryIndexedTree bit(n);
  while (q--) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c) {
      cout << bit.sum(y) - bit.sum(x - 1) << endl;
    } else {
      bit.add(x, y);
    }
  }
}

Measured memory_bytes: 3144
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using namespace std;

int main(){
    int N;
    cin >> N;
    string S = "ABC";
    S += to_string(N);

    printf("%s",S.c_str());

    return 0;
}


Measured memory_bytes: 256
# 全探索の気持ちが芽生える なにを全探索する？
# Qだと2^50なので無理になる、
# Nをしたいが10^10では？と無理になる
# と思いきや条件からA[i-1]<=A[i]なのでだいぶ減りそうとなる
# 計算量の見積もりがぜんぜんできないがたぶんいけるとなる
from collections import deque
n, m, q = map(int, input().split())
queries = []
for _ in range(q):
    queries.append(tuple(map(int, input().split())))

queue = deque()
for i in range(1, m + 1):
    queue.append([i])

ans = 0


def calc(arr):
    ret = 0
    for a, b, c, d in queries:
        if arr[b - 1] - arr[a - 1] == c:
            ret += d
    return ret


while len(queue):
    qq = queue.popleft()
    if len(qq) == n:
        ans = max(ans, calc(qq))
    else:
        for i in range(qq[-1], m + 1):
            nex_qq = qq[:]
            nex_qq.append(i)
            queue.append(nex_qq)
print(ans)

Measured memory_bytes: 29040
n=int(input())
a=list(map(int, input().split()))
dp=[0]*n
dp[1]=abs(a[1]-a[0])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]))
print(dp[-1])

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

long long GCD(long long x, long long y){
  if (y == 0) return x;
  else return GCD(y, x % y);
}

int main(){
  int K;
  cin >> K;
  long long res = 0;
  for (int a = 1; a <= K; ++a){
    for (int b = 1; b <= K; ++b){
      for (int c = 1; c <= K; ++c){
        res += GCD(GCD(a, b), c);
      }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
	int N;
	cin >> N;
	int tenant[4][3][10];
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				tenant[i][j][k] = 0;
			}
		}
	}
	for (int i = 0; i < N; i++) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		tenant[b - 1][f - 1][r - 1] += v;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout << " " << tenant[i][j][k];
			}
			cout << endl;
		}
		if(i!=3)cout << "####################" << endl;
	}
	return 0;
}


Measured memory_bytes: 3080
#include "bits/stdc++.h"
using namespace std;
using ll = long long;


int main() {
    int n, k;
    cin >> n >> k;
    vector< int> x(n), y(n);
    vector< int> xary(n), yary(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        xary[i] = x[i];
        yary[i] = y[i];
    }
    sort(begin(xary), end(xary));
    sort(begin(yary), end(yary));

    ll ans = 1LL * (xary[n - 1] - xary[0]) * (yary[n - 1] - yary[0]);
    for(int xi = 0; xi < n; ++xi) 
        for(int xj = xi + 1; xj < n; ++xj) 
            for(int yi = 0; yi < n; ++yi) 
                for(int yj = yi + 1; yj < n; ++yj) {

                    int num = 0;
                    ll lx = xary[xi], rx = xary[xj];
                    ll by = yary[yi], uy = yary[yj];

                    for(int i = 0; i < n; ++i) {
                        if(lx <= x[i] and x[i] <= rx and by <= y[i] and y[i] <= uy) num++;
                    }

                    if(num >= k) ans = min(ans, 1LL * (rx - lx) * (uy - by));
                }


    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
    ll A, B;
    cin >> A >> B;
    vector<ll> a, b;
    for (ll i = 1; i * i <= A; ++i) {
        if (A % i == 0) {
            a.push_back(i);
        }
        if (A % i == 0 && i * i != A) {
            a.push_back(A / i);
        }
    }
    for (ll i = 1; i * i <= B; ++i) {
        if (B % i == 0) {
            b.push_back(i);
        }
        if (B % i == 0 && i * i != B) {
            b.push_back(B / i);
        }
    }

    vector<ll> c;
    sort(all(a));
    sort(all(b));
    set_intersection(all(a), all(b), inserter(c, c.end()));

    int ans = 1;
    for (auto au: c) {
        if (IsPrime(au)) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;


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

	cin >> N >> M >> K;
	N = abs(N);
	long long int num = N / K;
	if (num >= M) {
		cout << N - M * K << endl;
		return 0;
	}
	H = N % K;
	if ((M - num) & 1) {
		cout << K - H << endl;
	}
	else {
		cout << H << endl;
	}
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	int ans = INF;
	
	cin>>N;
	
	for(int i = 1; i*i <= N; i++){
		if(N%i == 0){
			ans = min((long long)max(to_string(i).size(),to_string(N/i).size()), ans);
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // This will work only for g++ compiler. 
using namespace std;
#define fo(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define fon(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
//short hand for usual tokens
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
#define INF (int)1e9
// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
// traversal function to avoid long template definition. Now with C++11 auto alleviates the pain.
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)// find if a given value is present in a container. Container version. Runs in log(n) for set and map
#define present(c,x) ((c).find(x) != (c).end())
//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())
// Avoiding wrap around of size()-1 where size is a unsigned int.
#define sz(a) int((a).size())
// Shorthand for commonly used types
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    int n,k;
    cin>>n>>k;
    vi v;
    fo(i,n){
        int x;
        cin>>x;
        v.pb(x);  
    }
    sort(v.begin(),v.end());
    int sum = 0;
    fo(i,k){
        sum += v[i];
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 3588
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b!=c){
        cout<<"Yes"<<endl;
    }
    else if(a==c&&a!=b){
        cout<<"Yes"<<endl;
    }
    else if(b==c&&b!=a){
        cout<<"Yes"<<endl;
    }   
    else{
        cout<<"No"<<endl;
    } 
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <bitset>
#include <assert.h>

using namespace std;
typedef long long ll;
typedef set<int>::iterator ssii;

#define Cmp(a, b) memcmp(a, b, sizeof(b))
#define Cpy(a, b) memcpy(a, b, sizeof(b))
#define Set(a, v) memset(a, v, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define _forS(i, l, r) for(set<int>::iterator i = (l); i != (r); i++)
#define _rep(i, l, r) for(int i = (l); i <= (r); i++)
#define _for(i, l, r) for(int i = (l); i < (r); i++)
#define _forDown(i, l, r) for(int i = (l); i >= r; i--)
#define debug_(ch, i) printf(#ch"[%d]: %d\n", i, ch[i])
#define debug_m(mp, p) printf(#mp"[%d]: %d\n", p->first, p->second)
#define debugS(str) cout << "dbg: " << str << endl;
#define debugArr(arr, x, y) _for(i, 0, x) { _for(j, 0, y) printf("%c", arr[i][j]); printf("\n"); }
#define _forPlus(i, l, d, r) for(int i = (l); i + d < (r); i++)
#define lowbit(i) (i & (-i))
#define MPR(a, b) make_pair(a, b)

pair<int, int> crack(int n) {
    int st = sqrt(n);
    int fac = n / st;
    while (n % st) {
        st += 1;
        fac = n / st;
    }

    return make_pair(st, fac);
}

inline ll qpow(ll a, int n) {
    ll ans = 1;
    for(; n; n >>= 1) {
        if(n & 1) ans *= 1ll * a;
        a *= a;
    }
    return ans;
}
// ================================================ //

const int n = 5;

int prework() {
    int sum = 0;
    _rep(i, 1, n) sum += i;
    return sum;
}

int main() {
    int sum = prework();

    int cnt = 0;
    _rep(i, 1, n) {
        int x;
        cin >> x;
        cnt += x;
    }

    int ans = sum - cnt;
    cout << ans << endl;
}

Measured memory_bytes: 3568
#include <iostream>
using namespace std;
int main(){
	int data[2]={0},c,d;
	cin>>data[0]>>data[1]>>c;
	for (int i=0;i<c;i++){
		if(data[i%2]%2==1)data[i%2]--;
		data[i%2]=data[i%2]/2; 
		data[(1+i)%2]+=data[i%2];
	}
	cout<<data[0]<<" "<<data[1]<<endl;
	return 0;
}

Measured memory_bytes: 256
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
// failed to generate code

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

using LL=long long;
#ifdef DEBUG
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

const int MAXN=1000000;
char s[MAXN+10];
int cnt[MAXN+10];
LL a[MAXN+10],b[MAXN+10],c[MAXN+10];
LL sa[MAXN+10],sb[MAXN+10],sc[MAXN+10];
int main(){	
#ifdef WAAUTOMATON
	freopen("in.txt","r",stdin);
#endif
	ios::sync_with_stdio(false);
	int n,q;	
	scanf("%d",&n);
	scanf("%s",s+1);
	scanf("%d",&q);
	for(int i=1; i<=n; ++i) {
		if (s[i]=='D') a[i]++;
	}
	for(int i=1; i<=n; ++i) {
		sa[i]=sa[i-1]+a[i];
	}
	for(int i=1; i<=n; ++i) {
		if (s[i]=='M') b[i]=sa[i];
	}
	for(int i=1; i<=n; ++i) {
		sb[i]=sb[i-1]+b[i];
	}
	for(int i=1; i<=n; ++i) {
		if (s[i]=='M') c[i]=1;
	}
	for(int i=1; i<=n; ++i) {
		sc[i]=sc[i-1]+c[i];
	}
	for(int i=1; i<=q; ++i) {
		int k;
		scanf("%d",&k);
		LL ans=0;
		for(int j=1; j<=n; ++j) {
			if (s[j]=='C') {
				ans+=sb[j];
				if (j>=k) ans-=sb[j-k]+sa[j-k]*(sc[j-1]-sc[j-k]);
			}	
		}
		printf("%lld\n",ans);
	}
}



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

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
		
	int a,b;

	cin >> a >> b;

	if(b==1)
	{
		cout << 0 << '\n';
	}
	else
	{
		for(int i=1;i<=100;i++)
		{
			if(a*i - (i-1) >= b)
			{
				cout << i << '\n';
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  map<ll,ll>M;
  ll n,x,y;cin>>n>>x>>y;
  for(ll i=1;i<=n-1;i++){
    for(ll j=i+1;j<=n;j++){
      ll p=abs(x-i);
      ll q=abs(y-j);
      //cout<<i<<" "<<j<<" "<<y-x+p+q<<endl;
      M[min(j-i,p+q+1)]++;
    }
  }
  for(ll i=1;i<n;i++)cout<<M[i]<<endl;
}
      

Measured memory_bytes: 384
result = []
while True:
    my_value = input()
    my_value_list = []
    my_value_list = ([int(x) for x in my_value.split()])
    my_value_list.sort()
    result.append(my_value_list)
    if my_value_list[0] == 0 and my_value_list[1] == 0:
        result.pop()
        break

for i in range(0, len(result)):
    print("{} {}".format(result[i][0], result[i][1]))

Measured memory_bytes: 8248
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const int INF=1000100010;
int main(){
int n,m;cin>>n>>m;
int a[n];
int sum=0;
vector<int> select;
rep(i,n){
    cin>>a[i];
    sum+=a[i];
}
sort(a,a+n,greater<int>());
if(a[m-1]<(sum+(4*m)-1)/(4*m))cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3628
// Problem : A - Air Conditioner
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


#include<bits/stdc++.h>
#define 	ll		    long long
#define 	rep(i,a,n)  for(int i=a;i<n;i++)
#define 	MOD 		1000000007
#define 	vp 			vector<pair<int,int> >
#define 	ff 			first
#define 	ss 			second
#define 	pb 			push_back
#define 	all(x) 		(x.begin(),x.end())
#define 	dg(x)		cerr<<"--- x = "<<x<<"\n"
#define 	endl		"\n"


using namespace std;
const int N = 1e5;
ll ar[N];

void solve(){
	int x; cin >> x;
	if(x >= 30)
		cout << "Yes";
	else
		cout << "No";
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
}


Measured memory_bytes: 3636
#include<stdio.h>
#define N  500

int main (void){
  int A[N],num,i=0;
  
  scanf("%d",&num);
  for (i=1;i<=num;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=num;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i!=1)printf("parent key = %d, ",A[i/2]);
    if(i*2<=num)printf("left key = %d, ",A[i*2]);
    if(i*2+1<=num)printf("right key = %d, ",A[i*2+1]);
    printf("\n");
  }
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h> 
#define ll long long 
#define pb push_back
#define vec vector<int>
#define fo(i,n) for (int i = 0; i < n; i++)
#define so(v) sort(v.begin(), v.end())
#define fi first
#define se second
using namespace std;  




int main()
{
  int n,x,t;
  cin>>n>>x>>t;
   
          cout<<((n+x-1)/x)*t;
    

}



   

Measured memory_bytes: 3628
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;
bool ifv[51][51]={0};
bool pic[51][51];
int dir[4][2]={0,1,0,-1,1,0,-1,0};
int m,n;
struct State{
    int x;
    int y;
    int step;
};
State a;

bool checkState(State s)
{
    int x=s.x,y=s.y;
    if((x>=0&&y>=0&&x<m&&y<n)&&(!ifv[x][y])&&pic[x][y])
        return 1;
    else
        return 0;
}

int bfs(State St)
{
    queue<State> q;
    State now,next;
    St.step = 0;
    q.push(St);
    ifv[St.x][St.y]=1;
    while(!q.empty())
    {
        now=q.front(); // 取队首元素进行扩展
        if(now.x==m-1&&now.y==n-1) // 出现目标态，此时为Step_Counter 的最小值，可以退出即可
        {
            return now.step;
        }
        for(int i=0;i<4;i++)
        {
            next.x=now.x+dir[i][0]; // 按照规则生成下一个状态
            next.y=now.y+dir[i][1];
            next.step=now.step+1; // 计数器加1
            if(checkState(next)) // 如果状态满足约束条件则入队
            {
                q.push(next);
                ifv[next.x][next.y]=1; //访问标记
            }
        }
        q.pop(); // 队首元素出队
    }
    return -1;
}




int main()
{
    int i,j,w=0,b=0;
    char s;
    cin>>m>>n;
    for(i=0;i<m;i++)
    {
        for(j=0;j<n;j++)
        {
            cin>>s;
            switch(s)
            {
                case '.':pic[i][j]=1;
                        if(!((i==0&&j==0)||(i==m-1&&j==n-1)))
                            w++;
                        break;
                case '#':pic[i][j]=0;
                           b++;
                        break;
            }
        }
    }
    a.x=0;a.y=0;
    i=bfs(a);
    if(i==-1)
        cout<<i<<endl;
    else
        cout<<w-i+1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
struct UnionFind {
  int *data;
  UnionFind(int *_data, int size) : data(_data) {
    for(int i = 0; i < size; i++) data[i] = -1;
  }
  bool unionSet(int x, int y) {
    x = find(x); y = find(y);
    if (x != y) {
      if (data[y] < data[x]) std::swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  int find(int x) {
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }
  int size(int x) {
    return -data[find(x)];
  }
};
int main(int argc, char *argv[])
{
  // kruskal with x being unused.
  // assumption: es is sorted
  auto kruskal = [](int n, const vector<pair<int,pair<int,int>>> &es, int x, vector<bool> &used) {
    vector<int> ufdata(n);
    UnionFind uf(&(ufdata[0]), n);
    int sum = 0;
    for(int i = 0; i < es.size(); i++) {
      if(i == x) continue;
      const int u = es[i].second.first;
      const int v = es[i].second.second;
      if(uf.find(u) != uf.find(v)) {
        used[i] = true;
        uf.unionSet(u, v);
        sum += es[i].first;
      }
    }
    return sum;
  };
  int n, m;
  vector<pair<int,pair<int,int>>> es;
  cin >> n >> m;
  for(int i = 0; i < m; i++) {
    int s, d, c;
    cin >> s >> d >> c;
    es.push_back(make_pair(c, make_pair(s-1, d-1)));
  }
  sort(es.begin(), es.end());
  vector<bool> used(m, false);
  int mn = kruskal(n, es, -1, used);
  int sum = 0;
  int cnt = 0;
  for(int i = 0; i < m; i++) {
    if(!used[i]) continue;
    int mni = kruskal(n, es, i, used);
    if(mni != mn) {
      cnt ++;
      sum += es[i].first;
    }
  }
  cout << cnt << " " << sum << endl;
  return 0;
}




Measured memory_bytes: 3816
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int n;
  long long int k;
  cin >> n >> k;
  vector<pair<int,int> > v;
  for(int i = 0;i < n;i++)
  {
    int a,b;
    cin >> a >> b;
    v.push_back(make_pair(a,b));
  }
  sort(v.begin(),v.end());
  long long int ans = 0;
  int i  = 0;
  while(ans < k)
  {
    ans += v[i].second;
    i++;
  }
  cout << v[i - 1].first << "\n";

  return 0;
}

Measured memory_bytes: 1400
#include<cstdio>
using namespace std;
typedef long long LL;
const int maxn=200005;
int n,A[maxn],p=1,len,idx[maxn];LL K;
inline int read()
{
	int ret=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){ret=ret*10+ch-'0';ch=getchar();}
	return ret*f;
}
int main()
{
	n=read();scanf("%lld",&K);
	for(int i=1;i<=n;i++) A[i]=read();
	while(!idx[p]&&K){idx[p]=++len;K--;p=A[p];}
	K%=(len+1-idx[p]);
	for(int i=1;i<=K;i++) p=A[p];
	printf("%d\n",p);
	return 0;
}

Measured memory_bytes: 3284
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    vector<vector<int>> d(h,vector<int>(w));
    vector<int> di={-1,0,1,0},dj={0,-1,0,1};
    queue<P> q;
    ll ans=0;
    rep(i,h) {
        rep(j,w) {
            if (d[i][j]==0) {
                d[i][j]=1;
                q.push({i,j});
                pair<ll,ll> pp={0,0};
                if (s[i][j]=='.') ++pp.first;
                else ++pp.second;
                while (!q.empty()) {
                    P p=q.front();
                    q.pop();
                    int ci=p.first,cj=p.second;
                    rep(k,4) {
                        int ni=ci+di[k],nj=cj+dj[k];
                        if (ni>=0 && ni<h && nj>=0 && nj<w) {
                            if (s[ci][cj]!=s[ni][nj] && d[ni][nj]==0) {
                                d[ni][nj]=1;
                                q.push({ni,nj});
                                if (s[ni][nj]=='.') ++pp.first;
                                else ++pp.second;
                            }
                        }
                    }
                }
                ans+=pp.first*pp.second;
            }
        }
    }
    cout << ans << endl;

    return 0; 
}


Measured memory_bytes: 4372
#include<iostream>
#include<cstdio>
#include<map>
#include<cstring>
#define inf 1<<30
#define maxn 30000005
using namespace std;
int main()
{
    int x,t;
    cin>>x>>t;
    if(x-t>0)
        cout<<x-t<<endl;
    else
        cout<<"0"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str;
  cin>>str;
  for(int i=0;i<str.size();i++){
    if(str[i]>='D'&&str[i]<='Z')
      str[i]=str[i]-3;
    else if(str[i]>='A'&&str[i]<='C')
      str[i]=str[i]+23;
  }
  cout<<str<<endl;
  return 0;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
int ps[100005],ps2[100005];
vector<int>v[100005],com[100005];
main()
{
	int t,p,st,ed;
    scanf("%d%d",&t,&p);
    for(int i = 1;i <= t;i++)
    {
        scanf("%d",&ps[i]);
    }
    for(int i = 0;i < p;i++)
    {
        scanf("%d%d",&st,&ed);
        v[st].push_back(ed);
        v[ed].push_back(st);
    }
    int ck=1,cs=0;
    queue<int>q;
    for(int i = 1;i <= t;i++)
    {
        if(ps2[i]==0)
        {
            q.push(i);
            ps2[i]=ck;
            while(!q.empty())
            {
                int cur=q.front();
                com[ck].push_back(ps[cur]);
                for(int j = 0;j < v[cur].size();j++)
                {
                    int go=v[cur][j];
                    if(ps2[go]==0)
                    {
                        ps2[go]=ck;
                        q.push(go);
                    }
                }
                q.pop();
            }
            for(int i = 0;i < com[ck].size();i++)
            {
                int cur=com[ck][i];
                if(ck==ps2[cur])
                cs++;
            }
            ck++;
        }
    }
    printf("%d",cs);
}


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

using ll=long long;
using namespace std;

#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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

const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

char BigAlphaToSmall(char a){
    if (a >= 65 && a <= 90){
        return a + 32;
    }
    return a;
}

char SmallAlphaToBig(char a){
    if (a >= 97 && a <= 122){
        return a - 32;
    }
    return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n; cin >> n;
    vector<int> hoge(n);
    rep_i(i, n) cin >> hoge[i];
    
    int q; cin >> q;
    int b, m, e;
    rep_i(i, q){
        cin >> b >> m >> e;
        rotate(&hoge[b], &hoge[m], &hoge[e]);
    }
    
    rep_i(i, n){
        if(i == n - 1){
            cout << hoge[i] << endl;
            break;
        }
        cout << hoge[i] << " ";
    }
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 112345;
ll a[MAX_N];
ll b[MAX_N];


ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  ll res = a / gcd(a, b) * b;
  res = min(res, 2000000000LL);
  return res;
}
pair<int,int> f(int n) {
  int t = 0;
  while (n % 2 == 0) {
    t++;
    n /= 2;
  }
  return {n, t};
}

int main2() {
  int N = nextInt();
  ll M = nextInt();
  REP(i, N) a[i] = nextInt();

  int t = f(a[0]).second;
  REP(i, N) {
    auto p = f(a[i]);
    if (t != p.second) {
      cout << 0 << endl;
      return 0;
    }
    b[i] = p.first;
  }
  ll L = b[0];
  for (int i = 1; i < N; i++) L = lcm(L, b[i]);
  L <<= (t-1);
  ll ans = M / L;
  ans = (ans + 1) / 2;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	while(true)
	    {
		int w=scan.nextInt();
		if(w==-1)break;
		int s[]={125,140,160};
		
		int fee=1150;
		
		int i=0;
		while(true)
		    {
			
			if(w<=10 && i==0)break;
			w-=10;
			
			if(w<=10 || i==2)
			    {
				fee+=w*s[i];
				break;
			    }
			
			else if(w>10)
			    {
				
				fee+=10*s[i];
				
			    }
			
			i++;
		    }
		System.out.println(4280-fee);
	    }
    }
}

Measured memory_bytes: 18584
#include "bits/stdc++.h"
using namespace std;

long long dp[51][5001];
int main() {
	int N, A;
	cin >> N >> A;
	vector<int>X(N);
	for (int i = 0; i < N; ++i) {
		cin >> X[i];
		X[i] -= A;
	}
	dp[0][2500] = 1;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 5001; ++j) {
			if (0 != dp[i][j]) {
				dp[i + 1][j] += dp[i][j];
				dp[i + 1][j + X[i]] += dp[i][j];
			}
		}
	}
	cout << dp[N][2500] - 1 << endl;
	return 0;
}

Measured memory_bytes: 4204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX=1e16;
const int INF=1e6+100;
int main()
{
    int n,a,b;
    cin>>n;
    ll x=1,y=1;
    ll r,l,mid;
    for(int i=0; i<n; i++){
        cin>>a>>b;
        mid=max(x/a,y/b);
        while(mid*a<x || mid*b<y) mid++;
        x=mid*a;
        y=mid*b;
    }
    cout<<x+y<<endl;
    return 0;
}

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

int main(){

	int q;
	double x;
	
	while(cin >> q){
		if(q == -1) break;
		
		x = 0.5 * q;
		while(abs(pow(x, 3) - q) >= 0.00001 * q){
			x -= (pow(x, 3) - q) / (3 * pow(x, 2));
		}
		printf("%.6lf\n", x);
	}

	return 0;

}

Measured memory_bytes: 1192
h, w = map(int, input().split())
color = []
count = 0
for i in range(h):
    tmp = input()
    if "#" in tmp:
        count +=1
        color.append(tmp)

column_count = [0] * w
for i in range(count):
    for j in range(w):
        if color[i][j] ==".":
            column_count[j]+=1

show_index = [i for i in range(len(column_count)) if column_count[i]<count]            
for i in range(count):
    content = ""
    for j in show_index:
        content += color[i][j]
    print(content)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
int main()
{
    ios;
    int n;
    string s;
    cin>>n>>s;
        for(int i=0;i<n&&s[i];i++)
        cout<<s[i];
        int l=s.size();
    if(l>n)
        cout<<"...";

    cout<<endl;
}



Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    double r; cin >> r;
    double ans = r * 2 * 3.14159265358979;
    printf("%.10f\n",ans);
}


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

using namespace std;

const int64_t INF = INT64_C(1) << 60;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int64_t A, B, N;
  cin >> A >> B >> N;
  int64_t mx = -INF;
  int64_t lo = 0, hi = N + 1;
  while (lo < hi) {
    int64_t mi = (lo + hi) / 2;
    if (chmax(mx, A * mi / B - A * (mi / B))) {
      lo = mi + 1;
    } else {
      hi = mi - 1;
    }
  }
  cout << mx << '\n';
  return 0;
}


Measured memory_bytes: 3640
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)
# ----------------------------------------------------------- #

s = input()
print(s[:3])

Measured memory_bytes: 72100