akhauriyash/Code-Regression huggingface dataset:
import sys
a=int(input())
b=[]
b=[input() for i in range(a)]
    
# 重複        
if len(b) != len(set(b)):
    print("No")
    sys.exit()

for x in range(a):
    if b[x]!=b[a-1]:
        
        if b[x][len(b[x])-1] != b[x+1][0]:
            print("No")
            break


else:
    print("Yes")


Measured memory_bytes: 3060
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let n: usize = read!();
    let m: usize = read!();
    
    let mut ans = vec![0; m];
    for _ in 0..n{
        let k: usize = read!();
        for _ in 0..k{
            let ki: usize = read!();
            ans[ki-1]+=1;            
        }
    }
    
    println!("{}", ans.iter().filter(|m| **m == n).count());
}

Measured memory_bytes: 2124
import fractions
from functools import reduce


def lcm(a,b):
    return (a*b)//fractions.gcd(a,b)


def lcm_list(a):
    return reduce(lcm,a)


if __name__ == '__main__':
    n = int(input())
    t = [int(input()) for i in range(n)]

    print(lcm_list(t))


Measured memory_bytes: 5304
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

// < n
vector<ll> f(ll n){
    vector<ll> cnt(40,0);
    for(int i=0;i<40;i++){
        ll a = n / (1ll << (i+1));
        ll b = n % (1ll << (i+1));
        cnt[i] = a * (1ll << i) + max(0ll , b - (1ll << i));
    }
    return move(cnt);
}

int main(){
    ll a,b; cin >> a >> b;
    if(a == 0){
        cout << b << endl;
        return 0;
    }

    ll ans = 0;

    auto va = f(a);
    auto vb = f(b+1);
    for(int i=0;i<40;i++){
        if((vb[i]-va[i])%2==1) ans |= (1ll << i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
int a,b;

scanf("%d %d", &a, &b);

if(a < b) {
printf("a < b\n");
} else if(a > b) {
printf("a > b\n");
} else {
printf("a == b\n");
}

return (0);
}

Measured memory_bytes: 580
import java.util.Scanner;
class Main{
	Scanner sc = new Scanner(System.in);
	int H;
	int W;
	
	void sp1(){
		while(true){
			H = sc.nextInt();
			W = sc.nextInt();
			if(H==0 && W==0)break;
	
			for(int i=0; i<H; i++){
				
			
				for(int j=0; j<W; j++){
					System.out.print("#");
					
				}
				System.out.println();

			}	
			System.out.println();
		}
	}
	
	
		public static void main(String[]agrs){
			new Main().sp1();
		}
	}
		

Measured memory_bytes: 26828
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define newl '\n'




bool isprime(ll a)
{
    if(a<=1)
        return false;
    if(a==2||a==3)
        return true;
    if(a%2==0||a%3==0)
        return false;
    for(ll i=5;i*i<=a;i=i+6)
    {
        if(a%i==0||a%(i+2)==0)
            return false;
    }
    return true;

}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,d;
    cin>>n>>d;
    int count=0;
    while(n--)
    {
        ll x,y;
        cin>>x>>y;
        if(sqrt((x*x)+(y*y))<=d)
        count+=1;
        else 
        continue;
    }
    cout<<count;
       

    return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);++i)
#define rep2(i,j,n) for(int i=(j);i<=(n);++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;
typedef vector<long long int> vll;

int main() {
	i64 n, a, b;
	cin >> n >> a >> b;
	if (a > b || (n == 1 && a != b)) {
		cout << 0 << endl;
		return 0;
	}
	i64 min = a * (n - 1) + b;
	i64 max = a + b * (n - 1);
	cout << max - min + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T &a, T b) {if (a < b) {a = b;return 1;}return 0;}
template<class T> inline bool chmin(T &a, T b) {if (a > b) {a = b;return 1;}return 0;}

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  bool ok = false;
  rep(i,n) {
    int a,b;
    cin >> a >> b;
    if (a == b) cnt++;
    else cnt = 0;
    if (cnt >= 3) ok = true;
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3636
#include <iostream>

 

using namespace std;

 

int main() 
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x-r >= 0 && y-r >= 0 && x+r <= w && y+r <= h)
        cout<< "Yes" << endl;
    else
        cout<< "No" << endl;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back

typedef unsigned int uint;
typedef long long ll;
typedef pair<int,int> pii;

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

int main(){
	ll n,x;
	scanf("%lld%lld",&n,&x);
	ll ans=n,w=x,h=n-x;
	while(1){
		if(w>h)
			swap(w,h);
		ll g=h/w;
		ans+=g*w*2;
		h-=w*g;
		if(h==0){
			ans-=w;
			break;
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
// finish date: 2018/06/16
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <functional>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define pii pair<int,int>
const int bigmod = 1000000007;
#define INF 1050000000


int main() {
    int A, B;
    cin >> A >> B;
    if (A <= 8 && B <= 8) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}






Measured memory_bytes: 256
odd, even = map(int, input().split())
sum_odd = 0
sum_even = 0

if odd != 1:
	for i in range(1, odd):
  		sum_odd += i
else: 
  sum_odd = 0

if even != 1:
  for i in range(1, even):
  	sum_even += i
else:
  sum_even = 0
  
print(sum_odd + sum_even)

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var K = sc.nextInt();
        var D = ReadLine().Split(' ');
        for (int i = N; i <= 100000; i++) {
            var s = i.ToString();
            var b = true;
            for (int j = 0; j < s.Length; j++) {
                if (D.Contains(s[j].ToString())) b = false;
            }
            if (b) {
                WriteLine(i);
                return;
            }
        }
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13260
#include <bits/stdc++.h>
#define lint long long
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define to_stirng to_string
using namespace std;

// cout << fixed << setprecision(12)

int main(){
  for(lint i=1; i<=5; i++){
    lint x;
    cin >> x;
    if(x==0) cout << i << endl;
  }
}
 

Measured memory_bytes: 3640
import numpy as np
N, M, C = list(map(int, input().split()))
B = np.asarray(input().split(), dtype=np.int)
A = []
for i in range(N):
  A.append(list(map(int, input().split())))
A = np.asarray(A, dtype=np.int)
 
print(np.sum(np.dot(A, B.T) > (-1*C)))

Measured memory_bytes: 12496
#include <iostream>
using namespace std;
int T[110][110];
int C[110][110];
int main()
{
    int n,m;
    while(cin>>n>>m,n){
        for(int i=0;i<m;++i){
            for(int j=0;j<m;++j){
                if(i==j){
                    T[i][j]=0;
                    C[i][j]=0;
                }else{
                    T[i][j]=100000;
                    C[i][j]=100000;
                }
            }
        }
        for(int i=0;i<n;++i){
            int a,b,c,t;
            cin>>a>>b>>c>>t;
            a--;b--;
            C[a][b]=c;
            C[b][a]=c;
            T[a][b]=t;
            T[b][a]=t;
        }
        for(int k=0;k<m;++k){
            for(int i=0;i<m;++i){
                for(int j=0;j<m;++j){
                    C[i][j]=min(C[i][j],C[i][k]+C[k][j]);
                    T[i][j]=min(T[i][j],T[i][k]+T[k][j]);
                }
            }
        }
        int k;
        cin>>k;
        for(int i=0;i<k;++i){
            int p,q,r;
            cin>>p>>q>>r;
            p--;q--;
            if(!r)
                cout<<C[p][q]<<endl;
            else
                cout<<T[p][q]<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1248
using System;
using System.Text;

namespace ALDS1_5_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int N = int.Parse(input);
            input = Console.ReadLine();
            string[] num = input.Split(' ');
            int[] list = new int[N];
            for (int i = 0; i < N; i++)
            {
                list[i] = int.Parse(num[i]);
            }

            int count = mergeSort(list, 0, N);

            string output = ArrayJoin(list);
            Console.WriteLine(output);
            Console.WriteLine(count);

        }

        public static int merge (int[] list, int left, int middle, int right)
        {
            int count = 0;
            int n1 = middle - left;
            int n2 = right - middle;
            int[] L = new int[n1 + 1];
            int[] R = new int[n2 + 1];
            for (int i = 0; i < n1; i++)
            {
                L[i] = list[left + i];
            }
            for (int i = 0; i < n2; i++)
            {
                R[i] = list[middle + i];
            }

            L[n1] = int.MaxValue;
            R[n2] = int.MaxValue;

            int p = 0;
            int q = 0;
            for (int i = left; i < right; i++)
            {
                if (L[p] <= R[q])
                {
                    list[i] = L[p];
                    p++;
                } else
                {
                    list[i] = R[q];
                    q++;
                }
                count++;
            }
            return count;
        }

        public static int mergeSort (int[] list, int left, int right)
        {
            int count = 0;
            if (left + 1 < right)
            {
                int mid = (left + right) / 2;
                count += mergeSort(list, left, mid);
                count += mergeSort(list, mid, right);
                count += merge(list, left, mid, right);
            }
            return count;
        }

        public static string ArrayJoin(int[] arr)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < arr.Length; i++)
            {
                if (sb.Length > 0)
                {
                    sb.Append(" ");
                }
                sb.Append(arr[i]);
            }
            return sb.ToString();
        }
    }
}

Measured memory_bytes: 108240
n = int(input())
l = [tuple(map(int, input().split())) for _ in range(n)]
for x,y,h in l:
  if h:
    kx = x
    ky = y
    kh = h
    break

for cx in range(101):
  for cy in range(101):
    ch = kh + abs(cx-kx) + abs(cy-ky)
    for x,y,h in l:
      if max(0,ch-abs(cx-x)-abs(cy-y)) != h:
        break
    else:
      print(cx,cy,ch)
      exit(0)
  

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;
int main() {
	vector<int> over;
	int num;
	float w, h;
	while (scanf("%d,%f,%f",&num,&w,&h)!=EOF) {
		double bmi = w/pow(h,2);
		if (bmi>=25) over.push_back(num);
	}
	if (over.empty()) {
		printf("ツ該ツ督鳴づ按つオ\n");
	} else {
		for (int i=0; i<over.size(); i++) printf("%d\n",over[i]);
	}
}

Measured memory_bytes: 0
sa = input()
sb = input()
sc = input()
"""
sa = 'aca'
sb = 'accc'
sc = 'ca'   #A
sa = 'abcb'
sb = 'aacb'
sc = 'bccc' #C
"""
now = 'a'
ca = 0
cb = 0
cc = 0

RC = ''
while RC == '':
    if now == 'a':
        if ca == len(sa):
            break
        now = sa[ca]
        ca += 1

    elif now == 'b':
        if cb == len(sb):
            break
        now = sb[cb]
        cb += 1

    else:
        if cc == len(sc):
            break
        now = sc[cc]
        cc += 1

print(now.upper())


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int
find(int a, int *s, int n)
{
	int p = 0, m = n;
	if (a < s[0] || s[n-1] < a)
		return 0;

	while (m > 2) {
		m >>= 1;
		if (a == s[p])
			return 1;
		else if (a < s[p])
			p -= m;
		else
			p += m;
	}
	if (a < s[p])
		m = -1;
	else
		m = 1;

	for (;;) {
		if (a == s[p])
			return 1;
		if (m < 0 && a > s[p]) {
			return 0;
		} else if (m > 0 && a < s[p]) {
			return 0;
		}
		p += m;
	}

	return 0;
}

int
main(int argc, char **argv)
{
	int i, j, n, q, a, c = 0;
	int *s;

	scanf("%d", &n);
	if (n <= 0)
		return 1;

	s = (int *)malloc(sizeof(int) * n);
	if (s == NULL)
		return 1;

	for (i = 0; i < n; i++)
		scanf("%d", s + i);

	scanf("%d", &q);
	if (q <= 0)
		return 1;

	for (i = 0; i < q; i++) {
		scanf("%d", &a);
		if (find(a, s, n))
			c++;
	}

	printf("%d\n", c);

	return 0;
}



Measured memory_bytes: 2088
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

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

    return 0;
}


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

int main()
{
    double r;
    cin >> r;
    cout.precision(5);
    cout << fixed;
    cout << r * r * M_PI;
    cout << " ";
    cout << r * 2 * M_PI;
    cout << endl;

    return 0;
}

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

int main() {

    int n;
    cin >> n;

    int t[n];
    int sum = 0;

    for(int i = 0; i < n; i++){
        cin >> t[i];
        sum += t[i];
    }

    int m;
    cin >> m;

    int p[m];
    int x[m];
    int sumd[m];

    for (int i = 0; i < m; i++) {
        cin >> p[i];
        cin >> x[i];
    }

    for(int i = 0; i < m; i++){
        sumd[i] = sum - t[p[i] - 1] + x[i];
        cout << sumd[i] << endl;
    }

    return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 100000;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(T &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int w,h;
  while(cin >> w >> h && w){
    vector<vector<vector<ll>>> v(w+4, vector<vector<ll>>(h+4,vector<ll>(8,0)));
    v[0][0][0] = 1;
    v[0][0][3] = 1;
    v[0][1][1] = -1;
    v[1][0][4] = -1;
    rep(j,h){
      rep(i,w){
        v[i+1][j][0] += v[i][j][0] % mod;
        v[i][j+1][1] += v[i][j][0] % mod;
        v[i][j+1][2] += v[i][j][1] % mod;
        v[i][j+1][3] += v[i][j][2] % mod;
        v[i+1][j][4] += v[i][j][2] % mod;

        v[i][j+1][3] += v[i][j][3] % mod;
        v[i+1][j][4] += v[i][j][3] % mod;
        v[i+1][j][5] += v[i][j][4] % mod;
        v[i+1][j][0] += v[i][j][5] % mod;
        v[i][j+1][1] += v[i][j][5] % mod;
      }
    }
    ll ans = 0;
    rep(i,6){
      ans += v[w-1][h-1][i] % mod;
    }
    cout << ans % mod<< endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
    vector <int> vec;
    vec.clear();
    int n,k,z,c=0;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>> z;
        vec.push_back(z);
    }
    sort(vec.begin(),vec.end());
    for(int i=0;i<k;i++){
        c+=vec[i];
    }
    cout << c ;
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 3576
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	if (N % 2 == 1) {
		cout << 0 << endl;
		return 0;
	}

	int ans = 0;
	for (int i = 10; N / i; i *= 5) {
		ans += N / i;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

fn gcd(a: i64, b: i64) -> i64 { if b == 0 { a } else { gcd(b, a % b) } }

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let m: i64 = sc.cin();
    let xs: Vec<i64> = sc.vec(n);
    let qs: Vec<i64> = xs.iter().map(|&x| x / 2).collect();

    let mut lcm = 1;
    for i in 0..n {
        lcm = lcm * qs[i] / gcd(lcm, qs[i]);
    }

    for &q in qs.iter() {
        if (lcm / q) % 2 == 0 {
            put!(0);
            return;
        }
    }

    let mut g = lcm;
    let mut ans = 0;
    while g <= m {
        ans += 1;
        g += 2 * lcm;
    }
    put!(ans);

}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 12324
#include<stdio.h>
 
int main(void)
{
  int i,j,k,N,v[50],a[50];
  double b[50];
  scanf("%d\n",&N);
  for(i=0;i<=N-1;i++){
    scanf("%d",&v[i]);
  }
  
  for(i=0;i<=N-1;i++){
    a[i]=1001;
    k=50;
    for(j=0;j<=N-1;j++){
      if(a[i]>v[j]){
        a[i]=v[j];
        k=j;
      }
    }
    v[k]=1001;
  }
  
  for(i=0;i<=N-1;i++){
    b[i]=(double)a[i];
  }
  
  for(i=1;i<=N-1;i++){
    b[i]=(b[i-1]+b[i])/2;
  }
  
  printf("%lf",b[N-1]);
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>

typedef struct {
  double x;
  double y;
} P;

void koch(int n,P a,P b){
  if(n == 0) return;

  double rad;
  P s,t,u;

  rad = 3.14159265358932384 * 60/180;

  s.x = (2.0*a.x + 1.0*b.x) / 3.0;
  s.y = (2.0*a.y + 1.0*b.y) / 3.0;
  t.x = (1.0*a.x + 2.0*b.x) / 3.0;
  t.y = (1.0*a.y + 2.0*b.y) / 3.0;
  u.x = (t.x - s.x)*cos(rad) - (t.y - s.y)*sin(rad) + s.x;
  u.y = (t.x - s.x)*sin(rad) + (t.y - s.y)*cos(rad) + s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}

int main(){
  P a,b;
  int n;

  scanf("%d",&n);

  a.x = a.y = b.y = 0;
  b.x = 100;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}



Measured memory_bytes: 2088
#include<stdio.h>
int main()
{
  int a,b;
  scanf("%d %d",&a,&b);
  int ans;
  if(a>=13) printf("%d\n",b);
  if(a>=6&&a<=12) printf("%d\n",b/2);
  if(a<=5) printf("0\n");
  return 0;
}

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

using namespace std;

char a[1005][1005];
int vis[1005][1005];
int n, c, cnt;

int main() {
  cin >> n >> c;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= c; j++) {
      cin >> a[i][j];
    }
  }
  queue<pair<int, int>> q;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= c; j++) {
      if (a[i][j] == '#') {
        q.push({i, j});
        vis[i][j] = 1;
      }
    }
  }
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop();
    int x = p.first;
    int y = p.second;
    if (x - 1 >= 1 && vis[x - 1][y] == 0) {
      vis[x - 1][y] = vis[x][y] + 1;
      q.push({x - 1, y});
    }
    if (x + 1 <= n && vis[x + 1][y] == 0) {
      vis[x + 1][y] = vis[x][y] + 1;
      q.push({x + 1, y});
    }
    if (y - 1 >= 1 && vis[x][y - 1] == 0) {
      vis[x][y - 1] = vis[x][y] + 1;
      q.push({x, y - 1});
    }
    if (y + 1 <= c && vis[x][y + 1] == 0) {
      vis[x][y + 1] = vis[x][y] + 1;
      q.push({x, y + 1});
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= c; j++) {
      cnt = max(cnt, vis[i][j]);
    }
  }
  cout << cnt - 1 << '\n';
}


Measured memory_bytes: 13328
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
#define FL(i,a,b) for(int i = a;i<b;i++)
typedef vector<int> vi;

int inf = numeric_limits<int>::max();

int main(){ 
    int n;
    scanf("%d",&n);
    vector<int> dp(3);
    for(int day=0;day<n;++day){
        vector<int> new_dp(3,0);
        vector<int> c(3);
        for(int i = 0;i<3;++i){
            scanf("%d",&c[i]);
        }
        for(int i = 0;i<3;++i){
            for(int j = 0;j<3;++j){
                if(i!=j){
                    new_dp[j] = max(new_dp[j],dp[i]+c[j]);
                }
            }
        }
        dp = new_dp;
    }
    int ma = 0;
    FL(i,0,3){
        ma = max(ma,dp[i]);
    }
    cout<<ma;
    
    
  
}






Measured memory_bytes: 256
d = int(input())
s = input()

count = 0
if d < 3:
    print(0)
else:
	for i in range(d-2):
		if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
		    count += 1
	print(count)

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


int main() {
  long long T,N,M,A,B;
	cin>>T;
	rep(i,T){
	  cin>>N>>M>>A>>B;
		cout<<floor_sum(N,M,A,B)<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int n;
const int N = 200000;
vector <int> bi[N];
int dep[N], fa[N], fp[N];
int siz[N], mxc[N], lst[N], inl[N], tot;
void dfs1(int t, int f = 0, int d = 1)
{
    siz[t] = 1; dep[t] = d; fa[t] = f;
    for (int i = 0; i < bi[t].size(); ++ i)
        if (bi[t][i] != f)
        {
            dfs1(bi[t][i], t, d + 1);
            siz[t] += siz[bi[t][i]];
            if (siz[bi[t][i]] > siz[mxc[t]]) mxc[t] = bi[t][i];
        }
}
void dfs2(int t, int p = 1)
{
    lst[++ tot] = t; inl[t] = tot; fp[t] = p;
    if (mxc[t]) dfs2(mxc[t], p);
    for (int i = 0; i < bi[t].size(); ++ i)
        if (bi[t][i] != fa[t] && bi[t][i] != mxc[t])
            dfs2(bi[t][i], bi[t][i]);
}
int lb[N], rb[N], lc[N], rc[N], na[N], nb[N], ta[N];
int build(int l, int r)
{
    int t = ++ tot;
    lb[t] = l; rb[t] = r;
    if (l != r)
    {
        lc[t] = build(l, (l + r) / 2);
        rc[t] = build((l + r) / 2 + 1, r);
    }
    return t;
}
void psdw(int t)
{
    na[lc[t]] += ta[t]; ta[lc[t]] += ta[t];
    na[rc[t]] += ta[t]; ta[rc[t]] += ta[t];
    ta[t] = 0;
    nb[lc[t]] += nb[t]; nb[rc[t]] += nb[t];
    nb[t] = 0;
}
void upd(int t)
{
    na[t] = min(na[lc[t]], na[rc[t]]);
}
void cg(int t, int l, int r, int a, int b)
{
    if (l <= lb[t] && rb[t] <= r)
    {
        ta[t] += a;
        na[t] += a;
        nb[t] += b;
        return;
    }
    psdw(t);
    if (l <= rb[lc[t]]) cg(lc[t], l, r, a, b);
    if (r >= lb[rc[t]]) cg(rc[t], l, r, a, b);
    upd(t);
}
int ask(int t)
{
    int w;
    if (lb[t] == rb[t])
    {
        na[t] += 1000000;
        return nb[t];
    }
    psdw(t);
    if (na[lc[t]] < na[rc[t]]) w = ask(lc[t]);
    else w = ask(rc[t]);
    upd(t);
    return w;
}
void put(int u, int v, int a, int b)
{
    // cerr << u << " " << v << endl;
    while (u != v)
    {
        if (fp[u] == fp[v])
        {
            if (dep[u] > dep[v]) swap(u, v);
            cg(1, inl[u] + 1, inl[v], a, b);
            return;
        }
        if (dep[fp[u]] < dep[fp[v]]) swap(u, v);
        cg(1, inl[fp[u]], inl[u], a, b);
        u = fa[fp[u]];
    }
}
int A[N], B[N];
int main()
{
    cin >> n;
    for (int i = 1; i < n; ++ i)
    {
        int a, b;
        cin >> a >> b;
        bi[a].push_back(b);
        bi[b].push_back(a);
    }
    dfs1(1);
    dfs2(1);
    tot = 0;
    build(2, n);
    for (int i = 1; i < n; ++ i)
    {
        cin >> A[i] >> B[i];
        put(A[i], B[i], 1, i);
    }
    for (int i = 1; i < n; ++ i)
    {
        if (na[1] != 1)
        {
            cout << "NO" << endl;
            return 0;
        }
        else
        {
            int d = ask(1);
            put(A[d], B[d], -1, -d);
        }
    }
    cout << "YES" << endl;
}


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

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = Integer.parseInt(sc.next());
    int[] s = new int[n];
    int sum = 0;

    for (int i = 0; i < n; i++) {
      s[i] = Integer.parseInt(sc.next());
      sum += s[i];
    }

    Arrays.sort(s);

    boolean flag = false;
    if (sum % 10 == 0) {
      for (int i = 0; i < n; i++) {
        if (s[i] % 10 != 0) {
          sum -= s[i];
          flag = true;
          break;
        }
      }
    } else {
      flag = true;
    }

    if (flag) {
      System.out.println(sum);
    } else {
      System.out.println(0);
    }

    sc.close();
  }
}


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

int main(){
	int N;
	cin >> N;
	ll ans = 1;
	ll mod = 1e+9+7;
	for (int i = 1; i <= N; i++) {
		ans = (ans*i)%mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
N=int(input())
A=list(map(int,input().split()))

def LCM(x,y):
    X=max(x,y)
    Y=min(x,y)
    while X%Y!=0:
        X,Y=Y,X%Y
    return x*y//Y

cnt=A[0]
for i in range(1,N):
    cnt=LCM(cnt,A[i])
#print(cnt)

ans=0
for i in range(N):
    ans+=(cnt-1)%A[i]
print(ans)

Measured memory_bytes: 3316
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	a := ""
	for i := 0; i < len(s); i++ {
		if s[i] != 'B' {
			a += string(s[i])
		} else if len(a) > 0 {
			a = a[:len(a)-1]
		}
	}
	fmt.Println(string(a))
	return
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  ll n;cin>>n;
  string s;
  while(n){
    n--;
    s+=(char)('a'+n%26);
    n/=26;
  }
  reverse(all(s));
  cout<<s<<endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int k,n;
    cin>>n;
    string s;
    cin>>s;
    cin>>k;
    for(int i=0;i<n;i++)
        if(s[i]!=s[k-1])
        s[i]='*';
        cout<<s<<'\n';
        return 0;
}


Measured memory_bytes: 256
/**
 @Author -> saurabhP
**/

#include <iostream>
#include <vector>

#define print(arr, n) for(int i = 0; i < n; i++) std::cout << arr[i] << " ";
#define read(arr, n) for(int i = 0; i < n; i++) std::cin >> arr[i];

typedef long long int lld;

using namespace std;

void fast(){
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0); std::cout.tie(0);
}

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

    for(int i = 0; i < s.size(); i++){
        s[i] = 'x';
    }

    cout << s;

    return 0;
}


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

n= int(input())
s = input()
R = []
G = []
B = []
import bisect
def func(l1,l2,l3,l3set):
  res =0
  for i in l1:
    for j in l2[bisect.bisect_left(l2,i):]:
      a = l3[bisect.bisect_left(l3,j):]
      res += len(a)
      if j*2-i in l3set:
        res -=1
  return res

for i in range(n):
  if s[i] == 'R':
    R.append(i+1)
  elif s[i] == 'G':
    G.append(i+1)
  else:
    B.append(i+1)
    
    
R_set = set(R)
G_set = set(G)
B_set = set(B)
ans = func(R,G,B,B_set)+func(R,B,G,G_set)+func(G,R,B,B_set)+func(G,B,R,R_set) + func(B,R,G,G_set)+func(B,G,R,R_set)
print(ans)

Measured memory_bytes: 90412
#include <stdio.h>
const int N=1e6+10;
int n,a[N],ans=0,temp,last=-1;
bool went[N],in[N];
void dfs(int now){
    in[now]=went[now]=true;
    if(!went[a[now]])dfs(a[now]);
    else if(in[a[now]])last=a[now];
    if(last!=-1){
        ans++;
        if(last==now)last=-1;
    }
    in[now]=false;
    return ;
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&temp);
        went[i]=false;
        in[i]=false;
        a[i]=(i+temp)%n;
    }
    for(int i=0;i<n;i++)if(!went[i])dfs(i);
    printf("%d\n",ans);
}


Measured memory_bytes: 6276
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define loop(a,b) for(int i=a; i<b; i++)
#define loopr(a,b) for(int i=a;i>=b;i--)
void solve()
{
	double a,b;cin>>a>>b;
	double ans=a*b;
	int an=(int)ans;
	cout<<an;
	return;
}
int32_t main() 
{ 
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0; 
}

Measured memory_bytes: 3744
def resolve():
    A, B, C, D = map(int, input().split())
    d = D
    c = C
    gcd = 0
    while gcd == 0:
        if d % c == 0:
            gcd = c
        else:
            e = d%c
            d = c
            c = e
    lcm = C*D//gcd
    A = A-1
    print((B-B//C-B//D+B//lcm)-(A-A//C-A//D+A//lcm))
resolve()

Measured memory_bytes: 3064
import sys
from functools import reduce
from collections import defaultdict
def input(): return sys.stdin.readline().rstrip()


mod = 10**9+7


def prime(x):
    pf = defaultdict(int)
    for i in range(2, int(x**0.5)+1):
        while x % i == 0:
            pf[i] += 1
            x //= i
    if x > 1:
        pf[x] = 1
    return pf


def lcm(x, y):
    xx=x.copy()
    yy=y.copy()
    for k, v in yy.items():
        xx[k] = max(xx[k], v)
    return xx


def main():
    n = int(input())
    a = list(map(int, input().split()))
    a2 = list(map(prime, a))
    lcms = reduce(lcm, a2)
    lcmss = 1
    for k, v in lcms.items():
        lcmss = (lcmss*(k**v)) % mod
    ans = 0
    for aa in a:
        ans += lcmss*pow(aa,-1,mod)
    print(ans % mod)


if __name__ == '__main__':
    main()

Measured memory_bytes: 13772
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) {rep(i,x.size()) cout << x[i] << " "; cout << endl;}
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    int n = s.size();
    if (n <= 25) {
        for (char i = 'a'; i <= 'z'; i++) {
            bool ok = true;
            rep(j,n) if (s[j] == i) ok = false;
            if (ok) {
                s += i;
                cout << s << endl;
                return 0;
            }
        }
    } else {
        while (!s.empty()) {
            for (char j = s.back()+1; j <= 'z'; j++) {
                bool ok = true;
                rep(k,s.size()-1) if (s[k] == j) ok = false;
                if (ok) {
                    s.pop_back();
                    s.push_back(j);
                    cout << s << endl;
                    return 0;
                }
            }
            s.pop_back();
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3600
/**
 * auther: m0r1r1n
 */

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second

int main(int argc, char* argv[]) {
  
  string S;
  
  cin >> S;
  
  if ( S == "111" ) {
    
    cout << 3 << endl;
  }
  
  else if ( S == "110" ) {
    
    cout << 2 << endl;
  }
  
  else if ( S == "101" ) {
    
    cout << 2 << endl;
  }
  
  else if ( S == "011" ) {
    
    cout << 2 << endl;
  }
  
  else if ( S == "100" ) {
    
    cout << 1 << endl;
  }
  
  else if ( S == "010" ) {
    
    cout << 1 << endl;
  }
  
  else if ( S == "001" ) {
    
    cout << 1 << endl;
  }
  
  else {
    
    cout << 0 << endl;
  }

    return 0;
}





Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <map>
#include <stack>
using namespace std;

#define null -1

void DFS(vector<int> rVal[], map<int, int> &uColor_m, int idOrSs) {
	stack<int> stack;
	stack.push(idOrSs);
	uColor_m[idOrSs] = idOrSs;

	while (!stack.empty()) {
		int curUVal = stack.top();
		stack.pop();
		for (int i = 0; i < (signed)rVal[curUVal].size(); i++) {
			int curV = rVal[curUVal][i];
			if (uColor_m[curV] != null) continue;
			uColor_m[curV] = idOrSs;
			stack.push(curV);
		}
	}
}

void assignColor(int uNum, vector<int> rVal[], map<int, int> &uColor_m) {
	for (int i = 0; i < uNum; i++)
		uColor_m[i] = null;
	for (int i = 0; i < uNum; i++) {
		if (uColor_m[i] == null) DFS(rVal, uColor_m, i);
	}
}

int main() {
	int userNum;
	int relationNum;
//	int uColor_map[100000]; //<?????????, ??°??????????????????>
	map<int, int> uColor_m;
	//??????????????¨????????????
	vector<int> relationVal[100000];
	//int userColor[100000];

	cin >> userNum >> relationNum;
	for (int i = 0; i < relationNum; i++) {
		int userVal1, userVal2;
		cin >> userVal1 >> userVal2;
		relationVal[userVal1].push_back(userVal2);
		relationVal[userVal2].push_back(userVal1);
		uColor_m[i] = null;
	}

	assignColor(userNum, relationVal, uColor_m);

	int qNum;
	cin >> qNum;
	for (int i = 0; i < qNum; i++) {
		int uV1, uV2;
		cin >> uV1 >> uV2;
		if (uColor_m[uV1] == uColor_m[uV2])
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
	return 0;
}

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

using namespace std;

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

//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    int a[n], cnt[33] = {0}, c[n][33], answ[n][33];

    for(int i = 0; i < n; i++)
        for(int j = 0; j < 33; j++)
            c[i][j] = 0, answ[i][j] = 0;

    for(int i = 0; i < n; i++) {
        cin >> a[i];
        bitset<64> t(a[i]);
        for(int j = 0; j < 33; j++)
            if(t[j])
                cnt[j]++, c[i][j] = 1;
    }
    for(int i = 0; i < 33; i++) {
        if(cnt[i]) {
            if(cnt[i]%2) {
                for(int j = 0; j < n; j++)
                    if(!c[j][i])
                        answ[j][i] = 1;
            }
            else {
                for(int j = 0; j < n; j++)
                    if(c[j][i])
                        answ[j][i] = 1;
            }
        }
    }

    for(int i = 0; i < n; i++) {
        long long sum = 0;
        for(int j = 0; j < 33; j++)
            if(answ[i][j])
                sum += pow(2, j);
        cout << sum << ' ';
    }

    return 0;
}


Measured memory_bytes: 56372
def solve():
    N, K = map(int, input().split())

    ans = 0
    dice = 1
    
    while dice <= N:
        p = 1/N
        score = dice
    
        while score < K:
            score *= 2
            p /= 2

        ans += p
        dice += 1
        
    print ("%.10f" % (ans))
    
if __name__ == "__main__":  
    solve()

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


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

    int X;
    int flag =1;

    rep(i,50000){
        if(int(i*1.08) == N){
            cout << i;
            exit;
            flag = 0;
        }
    }
    if(flag)
    cout << ":(";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(ll i=j;i<k;i+=in)
#define DF(i,j,k,in) for(ll i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); it++)
#define fitr(it,it1,itr2,in) for(auto it=itr1;it!=itr2;it+=in)
#define Dfeach(it,l) for (auto it = l.end()-1; it != l.begin()-1; it--)
#define Dfitr(it,it1,itr2,in) for(auto it=itr1;it!=itr2-1;it-=in)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define ins insert
#define mkp make_pair
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,k;
cin>>n>>k;
vll h(n);
vll mi(n);
F(i,0,n,1) cin>>h[i];
mi[0]=0;
F(i,1,n,1){
    mi[i]=INT_MAX;
    F(j,1,k+1,1) {
        if((i-j)>=0)
        mi[i]=min(mi[i-j]+abs(h[i]-h[i-j]),mi[i]);
    }
}
cout<<mi[n-1]<<endl;
return 0;
}


Measured memory_bytes: 1792
// インクルード
#include <bits/stdc++.h>

// 名前空間省略
using namespace std;

// メイン関数
int main()
{
	// 標準入出力　高速化
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n, m;
	int a;

	cin >> n >> m;

	for(int i=0;i<m;i++){
		cin >> a;
		n -= a;
	}

	if(n<0) cout << -1 << endl;
	else cout << n << endl;
}


Measured memory_bytes: 3580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] grid = new char[H][];
		for (int i = 0; i < grid.length; i++) {
			grid[i] = sc.next().toCharArray();
		}
		short[][][][] max = new short[17][W][H][H];
		int tmp;
		for (int from2 = W-1; from2 >= 0; from2--) {
			for (int from1 = 0; from1 < H; from1++) {
				max[0][from2][from1][from1] = (short)(from2 + 1);
				if (from2 + 1 < W && grid[from1][from2] == grid[from1][from2 + 1]) {
					max[0][from2][from1][from1] = max[0][from2 + 1][from1][from1];
				}
			}
			for (int from1 = 0; from1 < H; from1++) {
				for (int to1 = from1 + 1; to1 < H; to1++) {
					max[0][from2][from1][to1] = (short)from2;
					if (grid[to1-1][from2] == grid[to1][from2]) {
						max[0][from2][from1][to1] = (short)Math.min(max[0][from2][from1][to1-1], max[0][from2][to1][to1]);
					}
				}
			}
		}
		for (int i = 1; i < 17; i++) {
			for (int from2 = 0; from2 < W; from2++) {
				for (int from1 = 0; from1 < H; from1++) {
					int med = from1;
					for (int to1 = from1; to1 < H; to1++) {
						tmp = max[i-1][from2][from1][to1];
						max[i][from2][from1][to1] = tmp < W ? max[i-1][tmp][from1][to1] : (short)W;
						int cur = med + 1 <= to1 ? Math.min(max[i-1][from2][from1][med], max[i-1][from2][med+1][to1]) : -1, next;
						while (med + 2 <= to1 && (next = Math.min(max[i-1][from2][from1][med+1], max[i-1][from2][med+2][to1])) >= cur) {
							med++;
							cur = next;
						}
						if (cur != -1) max[i][from2][from1][to1] = (short)Math.max(max[i][from2][from1][to1], cur);
					}
				}
			}
		}
		int ans;
		for (ans = 0; ans < 17; ans++) {
			if (max[ans][0][0][H-1] >= W) break;
		}
		out.println(ans);
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 287608