akhauriyash/Code-Regression huggingface dataset:
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

using ll = int64_t;

int main(int, const char**)
{
    int n, m;
    cin >> n >> m;
    auto b = m / n;
    int ans = 1;
    for(int i = 1; i * i <= m; ++i)
    {
        if(m % i == 0)
        {
            int dd[] = {i, m / i};
            for(auto d : dd)
            {
                if(d <= b)
                {
                    ans = max(ans, d);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
<?php
fscanf(STDIN, '%d %d %d', $N, $A, $B);
fscanf(STDIN, "%s", $str);

$passed = $A + $B;
$countPassed = 0;
$countB = 0;

for ($i = 0; $i < $N; $i++) {
	if ($str[$i] === 'a' && $countPassed < $passed) {
		$countPassed++;
		echo 'Yes'. PHP_EOL;
	} else if ($str[$i] === 'b' && $countPassed < $passed && $countB < $B) {
		$countPassed++;
		$countB++;
		echo 'Yes'. PHP_EOL;
	} else {
		echo 'No'. PHP_EOL;
	}
}

Measured memory_bytes: 4984
#include<iostream>
#include<string>
#include<map>

using namespace std;

int main(){
    string w;
    cin >> w;
    map<char, int> str;
    for(int i = 0; i < w.size(); i++){
        str[w[i]]++;
    }

    map<char,int>::iterator ite;
    for(ite = str.begin(); ite != str.end(); ++ite){
        if(ite->second % 2 != 0) {
            cout << "No" << endl;
            return 0;
        } 
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

class RollingHash():
    def __init__(self, s):
        self.length = len(s)
        self.base = 1009
        self.mod = (1 << 61) - 1
        self.hash = [0] * (self.length + 1)
        self.pow = [1] * (self.length + 1)

        for i in range(self.length):
            self.hash[i+1] = (self.hash[i] + s[i]) * self.base % self.mod
            self.pow[i+1] = self.pow[i] * self.base % self.mod

    def get(self, l, r):
        t = self.hash[r] - self.hash[l] * self.pow[r-l] % self.mod
        t = (t + self.mod) % self.mod
        return t

n = int(input())
a = [int(item) for item in input().split()]
b = [int(item) for item in input().split()]
a = a + a

diffa = []
diffb = []
for i in range(1, len(a)):
    diffa.append(a[i] ^ a[i-1])
for i in range(1, len(b)):
    diffb.append(b[i] ^ b[i-1])

RHa = RollingHash(diffa)
RHb = RollingHash(diffb)
query = RHb.get(0, n-1)
ans = []
for i in range(n):
    val = RHa.get(i, i+n-1)
    if val == query:
        ans.append((i, a[i] ^ b[0]))
ans.sort()
for k, x in ans:
    print(k, x)

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

int main(){
    int N, M, C;
    cin >> N >> M >> C;

    int a[M];
    int b[M];
    for(int i = 0; i < M; i++){
        cin >> b[i];
    }

    int ans = 0;
    int cou = 0;

    for(int i = 0; i < N; i++){
        ans = 0;
        for(int j = 0; j < M; j++){
            cin >> a[j];
        }

        for(int j = 0; j < M; j++){
            ans += a[j] * b[j];
        }

        ans += C;

        if(ans > 0){
            cou++;
        }
    }

    cout << cou << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w[ohara],x,y,sum,pos,W,v[ohara];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll w1[ohara],w2[ohara],w3[ohara],ww[ohara];
ll w1cou=0,w2cou=0,w3cou=0,wcou=0;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>W;
    rep(i,n)cin>>w[i]>>v[i];
    rep(i,n){
        if(w[i]==w[0])ww[wcou++]=v[i];
        else if(w[i]==w[0]+1)w1[w1cou++]=v[i];
        else if(w[i]==w[0]+2)w2[w2cou++]=v[i];
        else w3[w3cou++]=v[i];
    }
    sort(ww,ww+wcou);
    reverse(ww,ww+wcou);
    sort(w1,w1+w1cou);
    reverse(w1,w1+w1cou);
    sort(w2,w2+w2cou);
    reverse(w2,w2+w2cou);
    sort(w3,w3+w3cou);
    reverse(w3,w3+w3cou);
    ll v1=0,v2=0,v3=0,v=0;
    rep(i,wcou+1){
        //if(i!=0)v+=ww[i-1];
        rep(j,w1cou+1){
            //if(j!=0)v1+=w1[j];
            rep(k,w2cou+1){
                //v2+=w2[k];
                ll nokori;
                nokori=W-(i*w[0])-(j*(w[0]+1))-(k*(w[0]+2));
                if(nokori<0)continue;
                nokori=nokori/(w[0]+3);
                rep(z,nokori){
                    v3+=w3[z];
                }
                rep(z,i)v+=ww[z];
                rep(z,j)v1+=w1[z];
                rep(z,k)v2+=w2[z];
                ans=max(ans,v+v1+v2+v3);
                //if(v+v1+v2+v3==10)cout<<i<<" "<<j<<" "<<k<<" "<<nokori<<"\n";
                v=0;v1=0;v2=0;v3=0;
            }
        }
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 10496
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

ll A,B;

/* add your algorithm here */

int main() {
  cin >> A >> B;
  ll a = (A * B) - (A + B) + 1;

  cout << a << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


int n,a,b,c,x;

int next(int x){
	int res=(a*x+b)%c;
	return res;
}

int d[110];

int main(void){
	
	while(cin >> n,n){
		cin >> a >> b >> c >> x;

		for(int i=0;i<n;i++) cin >> d[i];
		
		int index=0;
		int ans=-1;

		for(int i=0;i<=10001;i++){
			if(index==n){
				ans=i-1;
				break;
			}
			if(x==d[index])
				index++;
			x=next(x);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	D := ReadInts(N)
	M := ReadInt()
	T := ReadInts(M)

	m := make(map[int]int)
	for _, d := range D {
		m[d]++
	}
	for _, t := range T {
		if m[t] == 0 {
			fmt.Println("NO")
			return
		}
		m[t]--
	}
	fmt.Println("YES")
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 16992
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

int main() {
	cin.sync_with_stdio(false); cin.tie(nullptr);
	string a, b; cin >> a >> b;
	int cnt = 0;
	for (int i = 0; i < a.size(); ++i)
		if (a[i] != b[i]) ++cnt;
	cout << cnt << endl;
	return 0;
}

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

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x) {
	if (x == 0) return 0;
	return counter(x >> 1) + (x & 1);
}

void solve() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		for (int j = 1; j <= A[i]; j++) {
			cin >> x[i][j] >> y[i][j];
		}
	}
	int ans = 0;
	for (int bits = 1; bits < (1 << N); bits++) {
		bool ok = true;
		for (int i = 1; i <= N; i++) {
			if (!(bits & (1 << (i - 1)))) continue;
			for (int j = 1; j <= A[i]; j++) {
				if (((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]) ok = false;
			}
		}
		if (ok) ans = max(ans, counter(bits));
	}
	cout << ans << endl;
	return;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define xx first
#define yy second
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int> 
#define lb(x) ((x)&(-(x)))
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 100010
using namespace std;
typedef long long ll;
int n,Q,tp;
ll mi,a[N],t[N],q[N];
int main(){
	scanf("%d%d",&n,&Q);
	q[tp=1]=mi=n;
	while(Q--){
		ll x;scanf("%lld",&x);
		while(tp&&q[tp]>=x)tp--;
		q[++tp]=x,mi=min(mi,x);
	}
	t[tp]=1;
	for(int i=tp;i;i--){
		ll k=q[i];
		int p=i;
		while(k>mi){
			int x=upper_bound(q,q+p,k)-q-1;
			t[x]+=t[i]*(k/q[x]),k%=q[x],p=x;
		}
		a[1]+=t[i],a[k+1]-=t[i];
	}
	for(int i=1;i<=n;i++)a[i]+=a[i-1],printf("%lld\n",a[i]);
	return 0;
}

Measured memory_bytes: 4096
$s = <STDIN>;
my @dat =  split(/ /,$s);
my $N =  $dat[0] ;
my $K =  $dat[1] ;

my $prenum;
$N = $N%$K;

while(){
  $prenum = $N;
  $N = abs($N-$K);
  if($prenum <$N){
      last;
  }
}
print "$prenum";


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;
 
template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}
 
ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}
 
ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    ll N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    B = abs(A - B);
    A = 0;
    N--;
    ll left = -N * D;
    ll right = -N * C;
    bool ret = false;
    for(int i = 0;i < N - 1;i++) {
        if(left <= B && B <= right) {
            ret = true;
        }
        left += C + D;
        right += C + D;
    }
    if(ret == true) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

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

int main() {
  int n;
  cin >> n;
  int count = 1;
  int arr[n];
  for (int i = 0; i < n; i++){
    cin >> arr[i];
  }
  int cur = arr[0];
  for(int i = 1; i < n; i++){
    if(cur > arr[i]){
      cur = arr[i];
      count++;
    }
  }
  cout << count;
}

Measured memory_bytes: 1024
from collections import *
n=int(input())
a=[]
for _ in range(n):
  a.append(input())
aset=set(a)
cnt=Counter(a)
cnt=dict(cnt)
maxi=0
for k in cnt.keys():
  maxi=max(maxi,cnt[k])

anss=[]
for s in aset:
  if cnt[s]==maxi:
    anss.append(s)
anss.sort()
for i in range(len(anss)):
  print(anss[i])


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

int main() {
	int n; cin >> n;
	vector<int> p(n*n);
	for (int i = 0; i < n*n; ++i) cin >> p[i];
	vector<vector<int> > d(n, vector<int>(n, -1));
	vector<vector<bool> > used(n, vector<bool>(n, false));

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			d[i][j] = min({i, j, n-1-i, n-1-j});
		}
	}

	vector<int> DI = {1, 0, -1, 0};
	vector<int> DJ = {0, 1, 0, -1};

	ll ans = 0;
	for (int x : p) {
		x--;
		int i = x/n; int j = x%n;
		ans += d[i][j];
		used[i][j] = true;
		deque<int> q;
		for (int k = 0; k < 4; ++k) {
			int di = DI[k]; int dj = DJ[k];
			if (0 > i+di or i+di >= n or 0 > j+dj or j+dj >= n) continue;
			if (d[i+di][j+dj] > d[i][j]) {
				d[i+di][j+dj] = d[i][j];
				q.push_back((i+di)*n + j+dj);
			}
		}
		while (!q.empty()) {
			int l = q.front();
			q.pop_front();
			int i = l/n; int j = l%n;
			for (int k = 0; k < 4; ++k) {
				int di = DI[k]; int dj = DJ[k];
				if (0 > i+di or i+di >= n or 0 > j+dj or j+dj >= n) continue;
				if (used[i][j]) {
					if (d[i+di][j+dj] > d[i][j]) {
						d[i+di][j+dj] = d[i][j];
						q.push_front((i+di)*n + j+dj);
					}				
				} else {
					if (d[i+di][j+dj] > d[i][j] + 1) {
						d[i+di][j+dj] = d[i][j] + 1;
						q.push_back((i+di)*n + j+dj);
					}				
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5848
import sys

s = "abcdefghijklmnopqrstuvwxyz"

for line in sys.stdin:
  while True:
    if ("the" in line) or ("this" in line) or ("that" in line):
      break
    else:
      l = [i for i in line]
      for i in range(len(l)):
        if l[i] in s:
          a = s.index(l[i])
          l[i] = l[i].replace(l[i],s[(a+1)%26])
      line = "".join(l)
  print(line.rstrip())

Measured memory_bytes: 7460
using System;
 
class program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int Senbei = int.Parse(input[0]);
    int Users = int.Parse(input[1]);
	if(Senbei % Users == 0){
    Console.WriteLine('0');
    }
    else{
      Console.WriteLine('1');
    }
  }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================

class UnionFind {
public:
	vector <ll> par; // 各元の親を表す配列
	vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}
};

int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================


	ll N, M, K;
	cin >> N >> M >> K;
	vll A(M), B(M), C(K), D(K);
	for (int i = 0; i < M; i++)
	{
		cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
	}
	for (int i = 0; i < K; i++)
	{
		cin >> C[i] >> D[i];
		C[i]--;
		D[i]--;
	}


	UnionFind know(N);
	for (int i = 0; i < M; i++)
	{
		know.merge(A[i], B[i]);
	}

	//for (int i = 0; i < N; i++)
	//{
	//	cout << know.root(i) << endl;
	//}

	vbool checked(N);
	for (int i = 0; i < N; i++)
	{
		checked[i] = false;
	}

	vll ans;
	for (int i = 0; i < N; i++)
	{
		ll s = know.size(i);

		ans.emplace_back(s-1);
	}



	for (int i = 0; i < K; i++)
	{
		if (know.root(C[i]) == know.root(D[i]))
		{
			ans[C[i]]--;
			ans[D[i]]--;
		}
	}

	for (int i = 0; i < M; i++)
	{
		ans[A[i]]--;
		ans[B[i]]--;
	}

	for (int i = 0; i < N; i++)
	{
		cout << ans[i] << " ";
	}

}





Measured memory_bytes: 6516
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(true)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int main()
{
	char a[3];
	while(scanf("%s",a)!=EOF)
	{
		puts((a[0]=='9' || a[1]=='9')?"Yes":"No");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string S;
	cin >> S;
	int ans = 0;
	for(int i = 0; i < S.length(); i++) ans += S[i] == '1' ? 1 : 0;
	cout << ans << endl;
	return 0;
}

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

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

ll mypow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = mypow(a, n/2);
    return res * res;
  }
  return a * mypow(a, n-1);
}


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

  ll n, p;
  cin >> n >> p;
  if(n == 1){
    cout << p << endl;
    return 0;
  }
  vl can;
  ll tmp = 2;
  ll cop = p;
  while(cop > 1 && tmp*tmp <= p){
    if(cop%tmp == 0) {
      can.push_back(tmp);
      cop /= tmp;
    }
    else tmp++;
  }

  ll ans = 1;
  ll cnt = 1;
  sort(all(can));
  can.push_back(-1);
  REP(i,sz(can)){
    if(can[i] != can[i-1]){
      ans *= mypow(can[i-1], cnt/n);
      cnt = 0;
    }
    cnt++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) scanf("%d",&a[i]);

  deque<int> b;
  rep(i,n) {
    if (i%2 == (n-1)%2) {
      b.push_front(a[i]);
    }
    else {
      b.push_back(a[i]);
    }
  }

  rep(i,n) printf("%d ",b[i]);
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#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 FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	double l;
	cin >> l;

	double ans = l*l*l/27.0;
	printf("%.10lf\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
typedef long long ll;
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    int A;
    int B;
    int C;
    
    cin >> A;
    cin >> B;
    cin >> C;

    cout << A+B+C-max(A,max(B,C)) << endl;

}

Measured memory_bytes: 256
import itertools
n,k = map(int, input().split())
d = list(map(int, input().split()))
safe = [i for i in range(10) if i not in d]

n_l = list(map(int, list(str(n))))
if len(set(safe)&set(n_l)) == len(set(n_l)):
    print(n)
    exit()

for v in itertools.product(safe, repeat=len(str(n))):
    if v[0] == 0: continue
    x = int("".join(list(map(str, v))))
    if int(x) >= n:
        print(x)
        exit()

for v in itertools.product(safe, repeat=len(str(n))+1):
    if v[0] == 0: continue
    x = int("".join(list(map(str, v))))
    if int(x) >= n:
        print(x)
        exit()

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  long long h[200009];
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  sort(h,h+n);
  reverse(h,h+n);
  long long ans=0;
  for(int i=k;i<n;i++){
    ans+=h[i];
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 1792
#pragma optimize("O3")
#pragma GCC target ("sse4")

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

typedef long long int ll;
typedef pair<ll, ll> pii;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define sz(a) ll(a.size())
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front 
#define MAXN 100010
#define N 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define nl '\n'
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);

template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
static_assert(D >= 1, "Vector dimension must be greater than zero!");
template<typename... Args>
	Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
	}
};
template<typename T>
struct Vec<1, T> : public vector<T> {
	Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
	}
};

ll modpower(ll x, ll y,ll p)
{
    ll res = 1;     // Initialize result
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; // y = y/2
        x = (x*x) % p;  // Change x to x^2
    }
    return res;
}
ll power(ll x, ll y)
{
    ll res = 1;     // Initialize result
    x = x ;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);
        y = y>>1; // y = y/2
        x = (x*x);  // Change x to x^2
    }
    return res;
}
// int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);}

ll modinv(ll a,ll p){return modpower(a,p-2,p);}

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

long long safe_sqrt(long long n) {
    long long res = sqrt((long double) n);
    if (res*res == n) return res;
    const long double eps = 1e-8;
    if ((long double)(res+1)*(res+1) < n + eps) return res+1;
    if ((long double)res*res + eps > n) return res-1;
    return res;
}   
// (a+b-1)/b for ceil
void solve(){
    ll l,r,d;
    cin>>l>>r>>d;
    cout<<r/d-(l-1)/d<<nl;
    return ;
}
int main()
{
    IO;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // #endif
    int T = 1;
    // cin >> T;
    f(c, 0, T){
        solve();
    }
    return 0;
}//multiset m make_pair make_tuple  tuple<int,int,int> continue resize insert count size else true isValid second first false erase double priority_queue 
//cout<<setprecision(12); push_back pop_back pop_front push_front  lower_bound upper_bound  reverse

Measured memory_bytes: 3540
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
    
int main()
{
    int N;
    cin >> N;
    int L;
    cin >> L;
    vector<string> x(N);
    for( int i = 0;i < N; ++i ){
        cin >> x[i]; 
    }
    sort(x.begin(),x.end());
    for( int i = 0;i < N; ++i ){
        cout << x[i];
    }
    cout << endl;
    return 0; 
}

Measured memory_bytes: 256
L,R = map(int,input().split())
ans = 10000000000
for i in range(L,R + 1):
	if ans == 0:
		break
		
	for j in range(i + 1,R + 1):
		if ans > i*j % 2019:
			ans = i*j % 2019
			if ans == 0:
				break
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
const ll INF=1001001001;
int j,n;
int main(){
  cin>>n;
  vector<ll> h(n);
  rep(i,n)cin>>h[i];
  vector<ll> dp(n,INF);
  dp[0]=0;
  for(ll i=1;i<n;i++){
    dp[i]=min(dp[i],dp[i-1]+abs(h[i-1]-h[i]));
    if(i>1)dp[i]=min(dp[i],dp[i-2]+abs(h[i-2]-h[i]));
  }
  cout<<dp[n-1];
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ori = a.size();
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());

    cout << (a.size() == ori ? "YES" : "NO") << endl;

    return 0;
}

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

#define ll long long

using namespace std;

int a[10001];
int M[101][101];

int main(){
 
 int h,w,n;
 cin>>h>>w>>n;

 for(int i=0;i<n;++i) cin>>a[i];
 
 int p=0,t=0;
 for(int i=0;i<h;++i){
     if(i%2){
         for(int j=w-1;j>=0;j--){
             M[i][j]=t+1;
             p++;
             if(p==a[t]) { t++; p=0; }
         }
     }else{
         for(int j=0;j<w;j++){
             M[i][j]=t+1;
             p++;
             if(p==a[t]) { t++; p=0; }
         }   
     }
 }

 for(int i=0;i<h;++i){
   for(int j=0;j<w;++j){
      cout<<M[i][j];
      if(j==w-1) cout<<endl;
      else cout<<" ";
   }
 }
   
 

 
 return 0;
}


Measured memory_bytes: 384
from itertools import permutations
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

res = 0
cnt = 0
gen = range(N)
for ls in permutations(gen):
    tmp = 0
    for i in range(N-1):
        tmp += ((xy[ls[i+1]][0]-xy[ls[i]][0])**2+(xy[ls[i+1]][1]-xy[ls[i]][1])**2)**0.5
    res += tmp
    cnt += 1
print(res/cnt)





Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(funcMain(Console.ReadLine()));
        }

        static private string funcMain(string arg)
        {
            string s1 = string.Empty;
            foreach (string buf in arg.Split(' '))
            {
                s1 += buf.ToUpper()[0];
            }

            return s1;
        }
    }
}


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

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,b,i,j;
    string ss="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string s,d;
    cin>>m>>s;
    for(auto c:s)
    {
       //cout<<c-65<<endl;
       d+=ss[(c-65+m)%26];
    }

    cout<<d<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
const int N=1e4+5;
typedef std::pair<int,int> P;
bool vis[10];int f[10]={0,2,5,5,4,5,6,3,7,6};
int n,m;
P dp[10004];bool used[10004];
int main() {
    scanf("%d%d",&n,&m);int x;
    while(m--) scanf("%d",&x),vis[x]=1;used[0]=1;
    for(int i=0;i<n;i++) for(int j=1;j<10;j++) if(used[i]&&vis[j]) {
        int t=i+f[j];
        if(t>n) continue;
        P c(dp[i].first+1,j);used[t]=1;
        dp[t]=std::max(dp[t],c);
    }
    while(n>0) {
        printf("%d",dp[n].second);
        n-=f[dp[n].second];
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
     if(a<b){
        for(int i=0;i<b;i++){
            cout<<a;
        }
        }
    else{
        for(int i=0;i<a;i++){
            cout<<b;
        }
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6, A = 26;

int to[N][A], td;
int code(char c){return c-'a';}

int cnt[N][A];
void add(vector<bool> &u, string &s, int i = 0, int v = 0){
	if(i == size(s)) return ;
	int c = code(s[i]);
	if(!to[v][c]) to[v][c] = ++td;
	
	add(u, s, i+1, to[v][c]);
	u[c] = 1;
	
	for(int x=0;x<A;++x) if(u[x]) cnt[v][x]++;
}

int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n;
	
	cin>>n;
	vector<string> s(n);
	for(auto &_ : s) cin>>_;
	
	sort(ALL(s),[](auto &x, auto& y){
		return size(x) > size(y);
	});
	
	ll ans = 0;
	for(string w : s){
		//cerr<<"?"<<w<<endl;
		
		reverse(ALL(w));
		
		int v = 0;
		for(int k=0;k+1<size(w);++k){
			int c = code(w[k]);
			if(!to[v][c]) {v = -1; break;}
			v = to[v][c];
		}
		
		//cerr<<"?"<<v<<endl;
		
		if(v!=-1){
			int cx = code(w.back());
			ans+=cnt[v][cx];
			//cerr<<":"<<ans<<endl;
		}
		
		
		vector<bool> u(A);
		add(u,w);
		
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 250504
use std::collections::VecDeque;

fn main() {
    proconio::input! {
        n: usize,
        m: usize,
        d: [(proconio::marker::Usize1, proconio::marker::Usize1, i64); m]
    };
    let mut g = vec![Vec::new(); n];
    for &p in &d {
        g[p.0].push((p.1, p.2));
        g[p.1].push((p.0, -p.2));
    }
    let mut visit = vec![0; n];
    let mut pos = vec![0; n];
    let mut valid = true;
    for i in 0..n {
        if visit[i] == 1 { continue }
        visit[i] = 1;
        let mut qu = VecDeque::new(); qu.push_back(i);
        while let Some(p) = qu.pop_front() {
            for &e in &g[p] {
                if visit[e.0] == 1 {
                    if pos[e.0] - pos[p] != e.1 {
                        valid = false;
                    }
                } else {
                    pos[e.0] = pos[p] + e.1;
                    visit[e.0] = 1;
                    qu.push_front(e.0);
                }
            }
        };
    }
    println!("{}", if valid { "Yes" } else { "No" });
}


Measured memory_bytes: 23844
A = list(map(int, input().split()))
A.sort()
Ans = 0
temp = (A[2] - A[0])//2
Ans += temp
A[0] += temp*2
temp = (A[2] - A[1])//2
Ans += temp
A[1] += temp*2
if A[0] == A[1] == A[2]:
    print(Ans)
elif A[0] == A[1]:
    print(Ans+1)
else:
    print(Ans+2)

Measured memory_bytes: 9200
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
const int MAX_N = 1e5 + 1;
int N, M;
int P[MAX_N];
int par[MAX_N];
int UFTrank[MAX_N];

void init(int n) {
   for (int i = 0; i < n; i++) {
      par[i] = i;
      UFTrank[i] = 0;
   }
}

int find(int x) {
   if (par[x] == x) {
      return x;
   } else {
      return par[x] = find(par[x]);
   }
}

void unite(int x, int y) {
   x = find(x);
   y = find(y);
   if (x == y) return;

   if (UFTrank[x] < UFTrank[y]) {
      par[x] = y;
   } else {
      par[y] = x;
      if (UFTrank[x] == UFTrank[y]) UFTrank[x]++;
   }
}

bool same(int x, int y) {
   return find(x) == find(y);
}       

int main() {
   cin >> N >> M;
   for (int i = 0; i < N; i++) {
      cin >> P[i];
      P[i]--;
   }
   int x, y;
   init(N);
   for (int i = 0; i < M; i++) {
      cin >> x >> y;
      x--;
      y--;
      unite(x, y);
   }

   int ans = 0;
   for (int i = 0; i < N; i++) {
      if (P[i] == i) ans++;
      else if (same(i, P[i])) ans++;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ctype.h>

#define INF 100000000

using namespace std;

int main()
{
    int n;
    cin >> n;
    int tmp, grid_max = -1, grid_min = 10000;
    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        grid_max = max(grid_max, tmp);
        grid_min = min(grid_min, tmp);
    }
    cout << grid_max - grid_min << endl;
    return 0;
}


Measured memory_bytes: 256
n,k = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp
cnt = 1
tar = s[0]
for i in 1..n do
    if tar != s[i-1]
        cnt += 1
        tar = s[i-1]
    end
end

max = n-cnt+2*k
if max >= n
    p n-1
else
    p max
end

Measured memory_bytes: 1916
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

const int MAX_P = 4010; //max
bool prime[MAX_P+1];

void Eratosthenes(void){
  for(int i=2;i<=MAX_P;i++)
    prime[i]=true;
  
  for(int i=2;i*i<=MAX_P;i++)
    if(prime[i])  
      for(int j=i;i*j<=MAX_P;j++)
        prime[i*j]=false;
}

int main(){
  int n;
  ll in;
  vector<ll> s;
  vector<ll> prime_v,prime_v3;
  map<ll,int> mm;
  map<ll,ll> sq;
  
  Eratosthenes();

  for(ll i=2;i<=100010;i++){
    sq[i*i] = i;
  }

  for(ll i=2;i<4010;i++){
    if(prime[i]) prime_v.push_back(i);
    if(prime[i]) prime_v3.push_back(i*i*i);
  }
  
  scanf("%d",&n);
  
  for(int i=0;i<n;i++){
    scanf("%lld",&in);
    s.push_back(in);
  }
  
  for(int i=0;i<n;i++){
    ll t = s[i];

    for(int j=0;j<prime_v3.size();j++){
      if(t < prime_v3[j]) break;
      
      while(t%prime_v3[j]==0){
        t /= prime_v3[j];
      }
    }

    s[i] = t;
  }

  for(int i=0;i<n;i++){
    mm[s[i]]++;
  }

  sort(s.begin(),s.end());
  s.erase(unique(s.begin(),s.end()),s.end());

  n = s.size();

  int ans = 0;
  
  for(int i=0;i<n;i++){
    int f[1000] = {};

    ll t = s[i];
    
    for(int j=0;j<prime_v.size();j++){
      if(t%(prime_v[j]*prime_v[j])==0){
        t/=(prime_v[j]*prime_v[j]);
        f[j] = 2;
      }else if(t%prime_v[j]==0){
        t /= prime_v[j];
        f[j] = 1;
      }else{
        f[j] = 0;
      }
    }

    ll q = 1;

    auto it = sq.find(t);
    
    if(it != sq.end()){
      q = it->second; 
    }else if(t > 1){
      q = t*t;

      if(q > 1e10){
        ans += mm[s[i]];
        continue;
      }
    }
    
    for(int j=0;j<prime_v.size();j++){
      if(f[j]==1)
        q *= (ll) prime_v[j] * prime_v[j];
      else if(f[j]==2)
        q *= prime_v[j];
    }
    
    if(mm[q]==0){
      ans += mm[s[i]];
    }else if(s[i] > q){
      ans += max(mm[s[i]],mm[q]);
    }
    
  }

  if(mm[1] > 0) ans ++;
  
  printf("%d\n",ans);
  
  return 0;
}


Measured memory_bytes: 17532
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,M;
    cin >> N >> M;
    M += N * 3;
    cout << M / 2 << endl;

}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
    char ch;
    cin>>ch;
    switch (ch)
    {
        case 'A':{
            cout<<"T";
            break;
        }
        case 'T' :{
            cout<<"A";
            break;
        }
        case 'C':{
            cout<<"G";
            break;
        }
        case 'G':{
            cout<<"C";
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
def prime_factorize(n):
    ans = []
    while n % 2 == 0:
        ans.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            ans.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        ans.append(n)
    return ans

a,b = map(int,input().split())
A = prime_factorize(a)
B = prime_factorize(b)
G = []
for i in set(A):
    if i in set(B):
        G.append(i)
print(len(set(G)) + 1)

Measured memory_bytes: 62240
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p);
p=(p*p);
k>>=1;
}
return a;
}
using namespace std;
  ll countDivisors(ll n) 
{ 
    ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                cnt++; 
  
            else 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
	ll n,k;
	cin>>n>>k;
	ll a[n+1];
	ll dp[k+1]={0};
	dp[0]=0;
	for(i=1;i<=n;i++)
	cin>>a[i];
	for(i=0;i<=k;i++)
	for(j=1;j<=n;j++)
	if(i>=a[j] && dp[i-a[j]]==0)
	dp[i]=1;
	//for(i=0;i<=k;i++)
	//cout<<dp[i];
	if(dp[k]==1)
	cout<<"First";
	else
	cout<<"Second";
	cout<<"\n"; 
 } 
}


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

vector<int> adj[100005];

bool vis[100005];
int par[100005];

int main(){
	int n,e,u,v;
	cin>>n>>e;
	for(int i=1;i<=e;i++){
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	queue<int> q;
	q.push(1);
	vis[1]=1;
	while(!q.empty()){
		int node = q.front();
		q.pop();
		for(auto x:adj[node]){
			if(!vis[x]){
				q.push(x);
				par[x] = node;
				vis[x]=1;
			}
		}
	}
	cout<<"Yes\n";
	for(int i=2;i<=n;i++){
		cout<<par[i]<<"\n";
	}
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, W; cin >> N >> W;
  vector<PII> xs;
  REP(i,N){
	int v, w, m;
	cin >> v >> w >> m;
	int p = 1;
	while(m>=p){
	  m -= p;
	  xs.EB(v*p, w*p);
	  p <<= 1;
	}
	if(m){
	  xs.EB(v*m, w*m);
	}
  }

  LL dp[2][10001];
  fill((LL*)dp, (LL*)dp+2*10001, 0);
  int crt = 0, nxt = 1;
  for(auto&& x: xs){
	REP(w,W+1)
	  dp[nxt][w] = dp[crt][w];
	FOR(w,x.SS,W+1)
	  maxi(dp[nxt][w], dp[crt][w-x.SS] + x.FF);
	swap(crt, nxt);
  }

  cout << *max_element(dp[crt], dp[crt]+W+1) << endl;

  return 0;
}

Measured memory_bytes: 3388
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		
		while(true) {
			int H = s.nextInt();
			int W = s.nextInt();
			if(H==0 && W==0) {
				break;
			}
			
			for(int i=1; i<=H; i++) {
				for(int j=1; j<=W; j++) {
					if(i==1 || i==H || j==1 || j==W) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
		s.close();
	}

}

Measured memory_bytes: 35008
N = int(input())
S = ''
if N == 0:
    print(0)
else:
    n = 1
    while N != 0:
        if N % (2 ** n) == 0:
            S += '0'
        else:
            S += '1'
            N -= (-1) ** (n - 1) * 2 ** (n - 1)
        n += 1

print(S[::-1])


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

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

    for (int ans = 8, temp = 599; ans >= 1; ans--, temp += 200)
        if (n <= temp)
        {
            cout << ans << endl;
            return 0;
        }
}


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


int main(){
	while (true)
	{
		double n;
		string ans;
		cin >> n;
		if (cin.eof() || n == 0) { break; }
		if (n <= 48.00) { ans = "light fly"; }
		else if (n <= 51.00) { ans = "fly"; }
		else if (n <= 54.00) { ans = "bantam"; }
		else if (n <= 57.00) { ans = "feather"; }
		else if (n <= 60.00) ans = "light";
		else if (n <= 64.00) ans = "light welter";
		else if (n <= 69.00) ans = "welter";
		else if (n <= 75.00) ans = "light middle";
		else if (n <= 81.00) ans = "middle";
		else if (n <= 91.00) ans = "light heavy";
		else ans = "heavy";
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(LL i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(LL i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const int mod = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAX = 100005;
vector<vector<int> > g(MAX);
int used[MAX];
vector<vector<int> > sons(MAX);
int depth[MAX];
void dfs(int u , int p = -1)
{
	used[u] = 1;
	
	for(auto v : g[u])
	{
		if(used[v])
		{
			if(v != p && depth[v] < depth[u])
				sons[u].PB(v);
			continue;
		}
		depth[v] = depth[u] + 1;
		dfs(v , u);
	}
	
	if(p != -1)
		sons[u].PB(p);
	for(int i = 0; i < SZ(sons[u]) - 1; i += 2)
	{
		cout << u << " " << sons[u][i] << endl;
		cout << u << " " << sons[u][i + 1] << endl;
	}
	if(SZ(sons[u]) % 2)
	{
		assert(p != -1);
		sons[p].PB(u);
	}
}
int main()
{
	ios_base::sync_with_stdio(0);
	int n , m;
	cin >> n >> m;
	if(m % 2)
	{
		cout << -1;
		return 0;
	}
	for(int i = 0; i < m; i++)
	{
		int u , v;
		cin >> u >> v;
		g[u].PB(v);
		g[v].PB(u);
	}
	dfs(1);
	
	//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


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

int main(){
    int N, ans=0;
    cin >> N;
    string s[N], X;
    int t[N];
    bool flag=false;
    for(int i=0; i<N; i++){
	cin >> s[i] >> t[i];
    }
    cin >> X;

    for(int i=0; i<N; i++){
	if(flag)
	    ans += t[i];
	if(X==s[i])
	    flag=true;
    }
    cout << ans << endl;
}


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

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

int main() {
  double x[3], y[3]; rep(i,3) cin >> x[i] >> y[i];
  double S = abs(((x[1]-x[0])*(y[2]-y[0])-(y[1]-y[0])*(x[2]-x[0]))/2);
  double d1 = sqrt(pow(x[1]-x[0],2)+pow(y[1]-y[0],2));
  double d2 = sqrt(pow(x[2]-x[1],2)+pow(y[2]-y[1],2));
  double d3 = sqrt(pow(x[0]-x[2],2)+pow(y[0]-y[2],2));
  double r = S/(d1+d2+d3)*2;
  double l = max(d1,max(d2,d3));
  double result = l*r/(2*r+l);
  cout << fixed << setprecision(10) << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define int long long

using namespace std;
int a[100001];
int b[100001];
int c[100001];
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;cin>>n;
    for (int i=1;i<n;i++) cin>>b[i];
    int sum=b[1]+b[n-1];
    for (int i=1;i<n-1;i++) sum+=min(b[i],b[i+1]);
        cout<<sum;
    return 0;
}


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

using namespace std;

int main() {
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  
  cout << s1[0] << s2[1] << s3[2] << endl;
}

Measured memory_bytes: 3548