akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include <iomanip>

using namespace std;

int main(void) {
  cout << setprecision(16);
  int n, k;
  cin >> n >> k;
  double p = 0;

  for (int i = 1; i <= n; i++) {
    if (i >= k) {
      p += (double)(n - k + 1) / n;
      break;
    }
    double cnt = ceil(log2((double)k / i));
    if (cnt < 0) {
      break;
    }
    p += (((double)1 / pow(2, cnt)) / n);
  }

  printf("%.15f\n", p);

  return 0;
}

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

using namespace std;


int main() {
    int N;
    cin >> N;
    vector<double> nn(N);
    for(int i=0; i<N; i++)cin >> nn.at(i);

    double sum = 0;

    for(int i=0; i<N; i++)sum += 1/nn.at(i);
    printf("%.6lf\n", 1/sum);

    return 0;
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 3e5 + 5;
int cntR[maxn], cntC[maxn];
int a[maxn],b[maxn];

bool cmp(ii a, ii b){
	if(a.first == b.first) {
		return a.second < b.second;
	}
	return a.first > b.first;
}

int main(){
	int r,c,m,i,j;
	scanf("%d %d %d",&r,&c,&m);

	set<ii> s;
	for(i=0;i<m;i++){
		scanf("%d %d",&a[i],&b[i]);
		a[i]--; b[i]--;
		s.insert(ii(a[i], b[i]));
		cntR[a[i]]++;
		cntC[b[i]]++;
	}
	vii listR, listC;
	for(i=0;i<r;i++){
		listR.pb(ii(cntR[i], i));
	}
	for(i=0;i<c;i++){
		listC.pb(ii(cntC[i],i));
	}
	sort(listR.begin(), listR.end(), cmp);
	sort(listC.begin(), listC.end(), cmp);

	int ans = listR[0].first + listC[0].first;
	vi maxR, maxC;
	for(i=0;i<r;i++){
		if(listR[0].first == listR[i].first){
			maxR.pb(listR[i].second);
		}
	}
	for(i=0;i<c;i++){
		if(listC[i].first == listC[0].first){
			maxC.pb(listC[i].second);
		}
	}

	ll totPos = (ll)maxR.size() * (ll)maxC.size();
	if(totPos > m){
		printf("%d\n",ans);
	}else{
		int ukuranR = maxR.size(), ukuranC = maxC.size();
		for(i=0;i<ukuranR;i++){
			for(j=0;j<ukuranC;j++){
				ii pas = ii(maxR[i], maxC[j]);
				if(s.find(pas) == s.end()){
					printf("%d\n",ans);
					return 0;
				}
			}
		}
		printf("%d\n",ans-1);
	}
	
	return 0;
};

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

int main() {
  int n;
  string str;
  cin >> n;
  int res[4];
  for(int i = 0; i < 4; i++) {
    res[i] = 0;
  }
  for(int i = 0; i < n; i++) {
    cin >> str;
    if(str == "AC") res[0]++;
    else if(str == "WA") res[1]++;
    else if(str == "TLE") res[2]++;
    else res[3]++;
   }
  cout << "AC x " << res[0] << endl;
  cout << "WA x " << res[1] << endl;
  cout << "TLE x " << res[2] << endl;
  cout << "RE x " << res[3] << endl;

  return 0;
}


Measured memory_bytes: 3608
#template
def inputlist(): return [int(j) for j in input().split()]
#template
N,M,K = inputlist()
A = inputlist()
B = inputlist()
a = [0]*(N+1)
b = [0]*(M+1)
for i in range(N):
    a[i+1] = a[i] + A[i]
for i in range(M):
    b[i+1] = b[i] + B[i]
ans,j = 0,M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K-a[i]:
        j -=1
    ans = max(ans,i+j)
print(ans)

Measured memory_bytes: 47652
#include <cstdio>

int main()
{
  int t;
  scanf("%d",&t);
  while(t--){
    int n,d;
    scanf("%d%d",&n,&d);
    printf("%d\n",(n-1)*127+(n%2==0?127-d:d));
  }
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

const int MAXN = 100005;

int N;
vector <int> E[MAXN];
int dp[MAXN][2];

void load() {
	scanf("%d", &N);
	for (int i = 1; i < N; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		E[a].push_back(b);
		E[b].push_back(a);
	}
}

int dfs(int x, int p) {
	int sum = 0, cnt = 0, mx = -1;
	for (auto it : E[x]) 
		if (it != p) {
			sum += dfs(it, x);
			mx = max(mx, dp[it][1] - dp[it][0]);
			cnt++;
		}
	dp[x][0] = sum + mx == cnt;
	dp[x][1] = sum == cnt;
	return dp[x][0];
}

int main() {
	load();
	puts(dfs(1, 0) ? "Second" : "First");
	return 0;
}

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

int dp[185][185][185],nxt[185][185][185];
string s[185];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
		cin>>s[i];
	for(int i=0;i<n;i++)
		for(int k=0;k<m;k++)
			for(int l=k;l<m;l++){
				if(s[i][k]!=s[i][l])	break;
				dp[i][i][k]=l;
			}
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			for(int k=0;k<m;k++)
				if(s[i][k]!=s[j][k])
					dp[i][j][k]=-1;
				else
					dp[i][j][k]=min(dp[i][j-1][k],dp[j][j][k]);
	for(int v=0;;v++){
		if(dp[0][n-1][0]==m-1)
			return cout<<v<<endl,0;
		for(int i=0;i<n;i++)
			for(int j=i;j<n;j++)
				for(int k=0;k<m;k++){
					int &ans = nxt[i][j][k];
					ans=-1;
					int pre=dp[i][j][k];
					if(pre!=-1&&pre!=m-1)	pre=dp[i][j][pre+1];
					ans=pre;
					int l=i,r=j;
					while(l<r){
						int mid = (l+r)>>1;
						int lv = dp[i][mid][k],rv=dp[mid+1][j][k];
						ans=max(ans,min(lv,rv));
						if(lv>rv)	l=mid+1;
						else r=mid;
					}
				}
		swap(nxt,dp);
	}
}


Measured memory_bytes: 49792
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
*/

ll n,k,a[100010],dp[42][2];

int main(void){
	cin>>n>>k;
	rep(i,n)cin>>a[i];
	//
	rep(i,42){
		dp[i][0]=0;//制約あり
		dp[i][1]=-1;//無制約
	}
	//
	irep(i,41){
		ll sum0=0,sum1;//0を選んだときの利益
		rep(j,n)if(a[j]>>i & 1)sum0++;
		// cout<<i<<":"<<sum0<<endl;
		sum0*=((ll)1<<i);
		sum1=n*((ll)1<<i)-sum0;
		if(k>>i & 1){
			dp[i][0]=dp[i+1][0]+sum1;//1にすると次も制約
			dp[i][1]=dp[i+1][0]+sum0;//ここを0にすることで次から自由になれる
			if(dp[i+1][1]>=0)dp[i][1]=max(dp[i][1],dp[i+1][1]+max(sum0,sum1));
		}else{
			dp[i][0]=dp[i+1][0]+sum0;
			if(dp[i+1][1]>=0)dp[i][1]=max(dp[i][1],dp[i+1][1]+max(sum0,sum1));
		}
		// cout<<i<<":"<<dp[i][0]<<","<<dp[i][1]<<endl;
	}
	cout<<max(dp[0][0],dp[0][1])<<endl;
	return 0;
}

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

int main()
{
	int n, br=0;
	string s;
	cin >> n >> s;
	for(int i=2; i<n; i++){
		if(s[i] == 'C' && s[i-1] == 'B' && s[i-2] == 'A') br++;
	}
	cout << br;
    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();
        for (int i=0;i<=n;i++) {
            for (int j=0;j<=n-i;j++) {
                int k = n-i-j;
                int total = i*10000+j*5000+k*1000;
                if (total == y) {
                    System.out.println(i + " " + j + " " + k);
                    return;
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}

Measured memory_bytes: 21844
// C - Candles
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N,K; cin>>N>>K;
	vi X(N); rp(i,0,N) cin>>X[i];

	vector<pair<int,int>> LR; //<left,right>
	rp(r,K-1,N){
		int l = r - (K-1);
		LR.emplace_back(X[l], X[r]);
	}

	int ans = INT_MAX;

	for(auto lr:LR){
		int l,r; tie(l,r) = lr;
		if(0 < l) ans = min(ans, abs(r));
		else if(r < 0) ans = min(ans, abs(l));
		else if(l == 0 && 0 < r) ans = min(ans, abs(r));
		else if(r == 0 && l < 0) ans = min(ans, abs(l));
		else{ // l < 0 && 0 < r
			if(abs(l) < abs(r)){
				ans = min(ans, abs(l)*2 + abs(r));
			}
			else{ // abs(l) >= abs(r)
				ans = min(ans, abs(r)*2 + abs(l));
			}
		}
	}

	cout<< ans <<endl;
}

Measured memory_bytes: 1276
n = gets.to_i

hash = {}
['S','H','C','D'].each do |suit|
    for rank in 1..13
        key = suit + " " + rank.to_s
        hash[key] = false
    end
end

n.times do
    card = gets.chomp
    hash[card] = true
end

hash.select{|key,val|
    puts key if !val
}

Measured memory_bytes: 6100
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, T = MAP()
ct = [LIST() for _ in range(N)]

c = 1001

for i in range(N):
	if ct[i][1] <= T:
		c = min(c, ct[i][0])

print("TLE" if c == 1001 else c)

Measured memory_bytes: 5200
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,q=mii()
s=list(ss())

dp=[0]*n

for i in range(n-1):
    if s[i]=="A" and s[i+1]=="C":
        dp[i+1]=dp[i]+1
    else:
        dp[i+1]=dp[i]

for i in range(q):
    x,y=mii()
    print(dp[y-1]-dp[x-1])

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

int main() {
  int n; cin >> n;
  double sum = 0;
  
  vector<double> cash(n);
  vector<string> currency(n);
  for (int i = 0; i < n; i++) cin >> cash[i] >> currency[i];
  
  for (int i = 0; i < n; i++) {
    if (currency[i] == "JPY") {
      sum += cash[i];
    } else if (currency[i] == "BTC") {
      double money = (380000.0 * cash[i]);
      sum += money;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define Rep(i,N) for(i=0;i<N;i++);
#define mod 1000000007

long mmax(long a,long b,long c){return a<b?max(b,c):max(a,c);}

long mmin(long a,long b,long c){return a<b?min(a,c):min(b,c);}

int mid(int a,int b,int c){
if((a<b&&b<c)||(a>b&&b>c))return 0;
return 1;
}
long long modinv(long long a) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}

long long moddevide(long long a,long long b){return (a*modinv(b))%mod;}

long long modncr(long long n,long long r){
  long long i,plus=1;
  for(i=0;i<r;i++){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

long long euclidean_gcd(long long a, long long b) {
  if(a < b) return euclidean_gcd(b, a);
  long long r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
  int i,N,K,cnt=0;
  char ss[5];
  cin>>N;
  vector<int> a(N);
  for(i=0;i<N;i++){
  cin>>a[i];
  }
  sort(a.begin(),a.end());
  K=N/2;
  cout <<a[K]-a[K-1];
  return 0;
}

Measured memory_bytes: 768
#include <cstdio>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    bool a[n+1]={false};
    a[0]=true;
    for (int i=1;i<=n;i++){
        if(i>=4 && a[i-4]==true){
            a[i]=true;
        }
        else if(i>=7 && a[i-7]==true){
            a[i]=true;
        }
    }
    if(a[n]){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        System.out.println(z + " " + x + " " + y);
    }

}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long int a,b,c,x,y,d=0,s=0,t;
	cin>>a>>b>>c>>x>>y;
	if(x>y)
	{
		d=x-y;
		t=d*a;
		x=x-d;
		
	}
	else
	{
		d=y-x;
		t=d*b;
		y=y-d;
		
	}
	int u,v;
	u=(x*2)*c;
	v=(x*a)+(x*b);
	if(u>v)
	{
		s=s+v;
	}
	else
	{
		s=s+u;
	}
	u=(d*c)*2;
	if(u>t)
	{
		s=s+t;
	}
	else
	{
		s=s+u;
	}
	cout<<s<<endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            while (scanner.hasNextDouble()) {
                double a = scanner.nextDouble();
                double b = scanner.nextDouble();
                double c = scanner.nextDouble();
                double d = scanner.nextDouble();
                double e = scanner.nextDouble();
                double f = scanner.nextDouble();
                double y = (a * f - d * c) / (a * e - b * d);
                double x = (c - b * y) / a;
                System.out.printf("%.3f %.3f\n", x, y);
            }
        }
    }
}

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

using namespace std;

string s;
long long ans, d, f[200005], l;

int main() {

    cin >> s;
    for(int i = 0; i < s.size(); ++i){
        f[i] = f[i - 1];
        if(s[i] == 'B') f[i]++;
    }
    for(int i = 0; i < s.size(); ++i){
        if(s[i] == 'W') ans += f[i];
    }
    cout << ans;

    return 0;

}


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

int main() {
    int N;
    cin >> N;
    vector<int>vec(N);
    int64_t min_ = 99999999;
    int64_t max_ = 0;
    for (int i=0; i < N; i++) {
        cin >> vec.at(i);
        if (min_ > vec[i]) {
            min_ = vec[i];
        }

        if (vec[i] > max_) {
            max_ = vec[i];
        }
    }

    int64_t min_kyori = INT64_MAX;
    for (int i=min_; i <= max_; i++) {
        int64_t kyori = 0;
        for (int j=0; j < N; j++) {
            kyori += int(pow(vec[j] - i, 2.0));
        }

        if (min_kyori > kyori) {
            min_kyori = kyori;
        }
    }

    cout << min_kyori << endl;
    return 0;
}

Measured memory_bytes: 256
/*input
3 7
1 6 3
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main()
{
	int a,b,c;
	scanf("%d/%d/%d",&a,&b,&c);
	if(b<=4) cout<<"Heisei";
	else cout<<"TBD";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <utility>
using namespace std;
typedef long long int ll;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct X_magic_ { X_magic_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } X_magic__;
constexpr ll INF = ((1LL << 61) + (1 << 29));

/*int main() {
	ll N;
	cin >> N;
	vector<ll> A(N);
	loop(i, N) cin >> A[i];
	vector<map<ll, ll>> dp(N+2);
	loop(i, N) {
		for (auto kv : dp[i]) {
			ll stock = kv.first;
			ll money = kv.second;
			
		}
	}
}*/

int main() {
	ll N;
	cin >> N;
	vector<ll> A(N);
	loop(i, N) cin >> A[i];
	// stock, money
	pair<ll, ll> m = { 0, 1000 }, s = { 0, 1000 };
	auto eval = [&A](ll i, pair<ll, ll> a) -> ll {
		return a.first * A[i] + a.second;
	};
	loop(i, N) {
		pair<ll, ll> new_m[2], new_s[2];
		{
			// sの判定
			new_s[0].first = m.first + m.second / A[i];
			new_s[0].second = m.second % A[i];

			new_s[1].first = s.first + s.second / A[i];
			new_s[1].second = s.second % A[i];
		}
		{
			// mの判定
			new_m[0].first = 0;
			new_m[0].second = m.first * A[i] + m.second;

			new_m[1].first = 0;
			new_m[1].second = s.first * A[i] + s.second;
		}
		m = (eval(i, new_m[0]) > eval(i, new_m[1]) ? new_m[0] : new_m[1]);
		s = (eval(i, new_s[0]) > eval(i, new_s[1]) ? new_s[0] : new_s[1]);
	}
	std::cout << m.second << std::endl;
}

Measured memory_bytes: 3196
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_10_C: Longest Common Subsequence

#include <algorithm>
#include <cstdio>
#include <cstring>

static unsigned int lcs(const char* x, const char* y)
{
  auto m = static_cast<int>(std::strlen(x));
  auto n = static_cast<int>(std::strlen(y));
  unsigned int c[m+1][n+1]; // extend -1

  for (auto i = 0; i < m+1; ++i) c[i][0] = 0u;
  for (auto j = 1; j < n+1; ++j) c[0][j] = 0u;

  for (auto i = 0; i < m; ++i) {
    for (auto j = 0; j < n; ++j) {
      c[i+1][j+1] = (x[i] == y[j])
        ? c[i][j] + 1
        : std::max(c[i+1][j], c[i][j+1]);
    }
  }
  return c[m][n];
}

int main()
{
  unsigned int q;
  std::scanf("%u", &q);
  const unsigned int MAX_LEN = 1000;
  char x[MAX_LEN+1], y[MAX_LEN+1];
  for (auto i = 0u; i < q; ++i) {
    std::scanf("%1000s", x);
    std::scanf("%1000s", y);
    auto l = lcs(x, y);
    std::printf("%u\n", l);
  }
}

// eof

Measured memory_bytes: 6640
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

const string YES = "Yes";
const string NO = "No";



// ***************************************


int main(){
    int A, B, C;
    cin >> A >> B >> C;
    int K;
    cin >> K;

    int cnt = 0;
    while(A >= B){
        B *= 2;
        cnt++;
    }
    while(B >= C){
        C *= 2;
        cnt++;
    }
    if (cnt <= K){
        cout << YES <<endl;
    } else{
        cout << NO << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
sx, sy, tx, ty = gets.split.map(&:to_i)

dx = tx - sx
dy = ty - sy

U = ?U
D = ?D
L = ?L
R = ?R

print R*dx + U*dy + L*dx + D*dy

dx += 1
dy += 1

puts L + U*dy + R*dx  + D + R + D*dy + L*dx + U


Measured memory_bytes: 1788
#include<iostream>
#include<stdio.h>
using namespace std;

int main()
{
    char s[50];
    int k, n;
    cin >> n;
    cin >> k;
    cin >> s;
    switch(s[k - 1])
    {
        case 'A':
            s[k - 1] = 'a';
            break;
        case 'B':
            s[k - 1] = 'b';
            break;
        case 'C':
            s[k - 1] = 'c';
            break;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
/*
*/
#include<bits/stdc++.h> 
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
#define int long long 
#define LL long long 
#define rg register 
#define pt(x) printf("%d ", x);
#define Fin(x) {freopen(#x".in","r",stdin);}
#define Fout(x) {freopen(#x".out","w",stdout);}
using namespace std;
const int MAXN = 1e6 + 10, INF = 1e9 + 10, mod = 1e18 + 7;
const double eps = 1e-9;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int N, X, f[MAXN], g[MAXN];
int add(int x, int y) {
	return x + y;
}
main() {
	N = read(); X = read();
    f[0] = 1; g[0] = 1;
    for(int i = 1; i <= N; i++) f[i] = add(f[i - 1] * 2 % mod, 3), g[i] = add(g[i - 1] * 2, 1);// cout << g[i] << endl;
	int ans = 0; 
	for(int i = N; i >= 1; i--) {
		if(X <= f[i] && X >= (f[i - 1] + 2)) {
			if(X == f[i]) {
				cout << ans + g[i]; return 0;
			}
			if(X == f[i - 1] + 2) {
				cout << ans + g[i - 1] + 1; return 0;
			} else {
				ans += g[i - 1] + 1;
				X -= f[i - 1] + 2;
			}
		}
		else X--;
	}
	cout << ans + max((int)0, X > 0 ? (int)1 : (int)0); 
	return 0;
}
/*
2 3
*/

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

int main() {
	// your code goes here
	int n;
	int c[50], v[50];
	int diff[50];
	int diffSum = 0;
	
	cin >> n;
	
	
	for(int i = 0 ; i< n ; i++) {
		cin >> v[i];
	}
	
	for(int i = 0 ; i< n ; i++) {
		cin >> c[i];
		diff[i] = v[i]-c[i];
		if(v[i]>c[i]) {
			diffSum += v[i]-c[i];
		}
	}
	
	
	
	cout << diffSum << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <stack>
#include <queue>
typedef long long ll;
using namespace std;

int main(){
  ll i,j,k,n,m;
  cin >> k >> n >> m;
  ll ret;
  ret = k+m+n-max(k,max(m,n));
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
N,A,B = input().split()
S = 0
def dsum(n):
    s = str(n)
    array = list(map(int,list(s)))
    return sum(array)

for i in range(1,int(N)+1):
    s = dsum(i)
    if int(A) <= s and s <= int(B):
        S += i
    else:
        continue
print(S)

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, A, B;
  cin >> N >> A >> B;
  vector<ll> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }
  ll res = 0;
  for (int i = 0; i < N - 1; i++) {
    res += min(B, A * (X[i + 1] - X[i]));
  }
  cout << res << '\n';
  return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

int main(void)
{
    int N, K;
    cin >> N >> K;

    ll ans = K;
    REP(i,N-1){
        ans *=(K-1); 
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3592
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n,m,k;
ll memo[3005][3005][4];
ll val[3005][3005];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>m>>k;
	
	int a,b,c;
	rep(x,0,k){
		cin>>a>>b>>c;
		
		val[a][b]=c;
	}
	
	rep(x,1,n+1){
		rep(y,1,m+1){
			rep(z,0,4){
				memo[x][y][0]=max(memo[x][y][0],memo[x-1][y][z]);
				memo[x][y][z]=max(memo[x][y][z],memo[x][y-1][z]);
			}
			
			rep(z,4,1){
				memo[x][y][z]=max(memo[x][y][z],memo[x][y][z-1]+val[x][y]);
			}
		}
	}
	
	ll ans=0;
	rep(z,0,4) ans=max(ans,memo[n][m][z]);
	
	cout<<ans<<endl;
	
}


Measured memory_bytes: 355680
fn solve() -> String {
    let (n, m) = readln();
    let mut g = vec![Vec::new(); n];
    for _ in 0..m {
        let (a, b, c): (usize, usize, i64) = readln();
        g[a-1].push((b-1, -c));
    }
    let mut cost = vec![i64::max_value(); n];
    cost[0] = 0;
    for i in 0..n {
        for u in 0..n {
            if cost[u] == i64::max_value() {
                continue;
            }
            for &(v, c) in &g[u] {
                if cost[v] > cost[u] + c {
                    cost[v] = cost[u] + c;
                    if i == n-1 && v == n-1 {
                        return "inf".to_string();
                    }
                }
            }
        }
    }
    (-cost[n-1]).to_string()
}
fn main() {
    println!("{}", solve());
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashSet;

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n { vs.push(readln()); }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(String, bool, f32, f64, isize, i8, i16, i32, i64, usize, u8, u16, u32, u64);
impl<T> FromLn for Vec<T> where T: FromLn {
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);

Measured memory_bytes: 4352
# -*- coding: utf-8 -*-


n, k = map(int, input().split())


def main(n, k):
    if n == 1:
        return n * k
    else:
        i = 1
        for _ in range(n):
            if i == 1:
                i *= k
            else:
                i *= (k - 1)
        return i

print(main(n, k))
# print(main(10, 8))


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

using namespace std;

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

const int N = 55;

int n,a[N][26],t[26];
string s,ans;

void dfs(int cur,int lst) {
  if (lst == 0) {
    cout << ans << endl;
    exit(0);
  }
  if (cur == 26)
    return;
  for (int i = 0 ; i < min(lst,t[cur]) ; i++)
    ans.push_back((char)cur + 'a');
  dfs(cur + 1,max(0,lst - t[cur]));
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n;
  for (int i = 1 ; i <= n ; i++) {
    cin >> s;
    for (int j = 0 ; j < s.size() ; j++)
      a[i][s[j] - 'a']++;
  }
  for (int i = 0 ; i < 26 ; i++) {
    t[i] = a[1][i];
    for (int j = 2 ; j <= n ; j++)
      t[i] = min(t[i],a[j][i]);
    // cerr << t[i] << endl;
  }
  for (int i = 50 ; i >= 0 ; i--) {
    ans.clear();
    dfs(0,i);
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)

using namespace std;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> H(N, 0);
    REP(i,N){
        cin >> H[i];
    }
    vector<vector<int>> R(N, vector<int>(0));
    REP(i,M){
        int a,b;
        cin >> a >> b;
        R[a-1].insert(R[a-1].begin(), b-1);
        R[b-1].insert(R[b-1].begin(), a-1);
    }
    int ans = 0;
    REP(i, N){
        bool is_highest = true;
        REP(j, R[i].size()){
            int x = R[i][j];
            if (H[i] <= H[x])is_highest = false;
        }
        if(is_highest)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8804
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  int dp[n];
  dp[0]=0;
  dp[1]=abs(arr[0]-arr[1]);
  for(int i=2;i<n;i++)
  {
    dp[i]=min(dp[i-2]+abs(arr[i]-arr[i-2]),dp[i-1]+abs(arr[i]-arr[i-1]));
  }
  cout<<dp[n-1];
  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  rep(i, s.size()) {
    if (s.at(i) == '1') cout << 9;
    else cout << 1;
  }
  cout << endl;
}

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

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)


int main(){
    ll L, R, d;
    cin >> L >> R >> d;

    ll l = (L - 1) / d;
    ll r = R / d;
    cout << r - l << endl;

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
  ll H; cin>>H;
  ll times=0;
  while(H>1){
    H/=2;
    times++;
  }
  ll ans=pow(2,times+1)-1;
  cout<<ans<<endl;
}

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

using namespace std;


int main() {
	//code
	int t=1;
	// cin>>t;
	while(t--)
	{
	    int n,m,sum=0;
        cin>>n;
        vector<int > a(n+1);
        vector<int > freq(n+1,0);
        for(int i=1;i<=n;i++)
        {
            if(i!=1)
                cin>>a[i];
            if(a[i]<i)
                freq[a[i]]++;
        }
        
       // for(int i=1;i<n;i++)
       //     if(a[i]>i)
       //         freq[a[i]]++;
        for(int i=1;i<=n;i++)
            cout<<freq[i]<<endl;
	}
	return 0;
	
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    int h,w; cin >> h >> w;
    char a[h][w];
    rep(i,h) rep(j,w) cin >> a[i][j];
    vector<bool> flag_h(h);
    vector<bool> flag_w(w);
    rep(i,h){
        rep(j,w){
        if(a[i][j] == '#') flag_h[i] = true;
        }
    }
    rep(j,w){
        rep(i,h){
        if(a[i][j] == '#') flag_w[j] = true;
        }
    }
    rep(i,h){
        rep(j,w){
        if(flag_h[i] && flag_w[j])cout << a[i][j];
        }
        if(flag_h[i])cout << endl;
    }
    return 0;
}

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


struct Node
{
    struct Node * parent;
    struct Node * left_child;
    struct Node * right_sibling;
    int key;
    int depth;
    Node(int key_ = -1) : parent{nullptr}, left_child{nullptr}, right_sibling{nullptr}, key{key_}, depth{-1} {};
};

int find_root(vector<Node> const & nodes){
    for (auto const & node : nodes){
        if (node.parent == nullptr) return node.key;
    }
    return -1;
}

void set_depth(int root, vector<Node> & nodes){
    nodes[root].depth = 0;
    stack<Node *> stacks;
    stacks.push(nodes[root].left_child);
    while (! stacks.empty()){
        auto pNode = stacks.top();
        stacks.pop();
        if (pNode == nullptr) continue;
        pNode->depth = pNode->parent->depth + 1;
        stacks.push(pNode->right_sibling);
        stacks.push(pNode->left_child);
    }
}

void show_node_data(Node const & node){
    cout << "node " << node.key << ": ";
    cout << "parent = " << ((node.parent == nullptr) ? -1 : node.parent->key) << ", ";
    cout << "depth = " << node.depth << ", ";
    if (node.parent == nullptr){
        cout << "root, ";
    }else if (node.left_child == nullptr){
        cout << "leaf, ";
    }else{
        cout << "internal node, ";
    }
    cout << "[";
    auto pNode = node.left_child;
    if (pNode != nullptr){
        cout << pNode->key;
        while (pNode->right_sibling != nullptr){
            pNode = pNode->right_sibling;
            cout << ", " << pNode->key;
        }
    }
    cout << "]" << endl;
}

int main()
{
    int n = 0;
    cin >> n;
    vector<Node> nodes(n);
    for (int i = 0; i != n; ++i) nodes[i].key = i;
    for (int i = 0; i != n; ++i){
        int node_id, k;
        cin >> node_id;
        cin >> k;
        int c0 = -1;
        int c1 = -1;
        for (int j = 0; j != k; ++j){
            cin >> c1;
            if (c0 == -1){
                nodes[node_id].left_child = & nodes[c1];
            }else{
                nodes[c0].right_sibling = & nodes[c1];
            }
            nodes[c1].parent = & nodes[node_id];
            c0 = c1;
        }
    }
    auto root = find_root(nodes);
    set_depth(root, nodes);
    for (auto & node : nodes) show_node_data(node);
    return 0;
}

Measured memory_bytes: 5872
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args){
        D();
    }

    public static void A(){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(6 - (a + b));
    }

    public static void B(){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String[] s = sc.nextLine().split("\\s+");
    StringBuilder ans = new StringBuilder();
    for(int i = 0; i < n; i++){
        ans.append(s[0].charAt(i));
        ans.append(s[1].charAt(i));

    }

    System.out.print(ans.toString());

    }

    public static void D(){
        int a = sc.nextInt();
        int b = sc.nextInt();
        //prevent overflow
        long c = a;
        c*=b;
        
        int temp;

        while((temp = a%b) != 0){
            
            a = b;
            b = temp;
        }

        System.out.println(c/b);
    }

    public static void GCD(){
//        First, if we subtract the smaller number from the larger number, the GCD doesn't change – therefore, if we keep on subtracting the number we finally end up with their GCD
//        Second, when the smaller number exactly divides the larger number, the smaller number is the GCD of the two given numbers.
        int a = sc.nextInt();
        int b = sc.nextInt();
        int temp = 0;

        while(true){
            temp = a % b;
            if (temp == 0){
                //b is the answer
                break;
            }
            b = a;
            a = temp;
        }
        System.out.println(b);
    }
}


Measured memory_bytes: 23764
//om namah shivaaay//
#include <bits/stdc++.h>
#define Om_namah_Shivaay ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
 #define ll long long
 using namespace std;
 int main()
 {
    Om_namah_Shivaay;
char i[4];
   cin>>i;
   if(i[0]=='7'||i[1]=='7'||i[2]=='7') cout<<"Yes";
   else cout<<"No";
 }


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

using ll=long long; 

ll sqpow(ll a, ll b){
	if(b==1)return a;
	if(b==0)return 1;
	if(b%2==0)return sqpow(a*a,b/2);
	else return a*sqpow(a*a,b/2);
}

void solve(){
	int n,k;
	cin>>n>>k;
	cout<<k*sqpow(k-1, n-1)<<endl;	
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
fn read_multi<T: std::str::FromStr>() -> Vec<T> {
    let mut s = std::string::String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_column<T: std::str::FromStr>(n: i32) -> Vec<T> {
    let mut v = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        v.push(s.trim().parse().ok().unwrap());
    }
    v
}

fn add_frame(vvc: Vec<Vec<char>>, cr: char) -> Vec<Vec<char>> {
    let mut ret: Vec<Vec<char>> = std::vec::Vec::<std::vec::Vec::<char>>::new();

    let cnum: usize = vvc[0].len();
    let mut vul: Vec<char> = std::vec::Vec::<char>::new();
    for _ in 0..cnum + 2 {
        vul.push(cr);
    }
    ret.push(vul);

    for i in 0..vvc.len() {
        let mut vi: Vec<char> = std::vec::Vec::<char>::new();
        vi.push(cr);
        for j in 0..cnum {
            vi.push(vvc[i][j]);
        }
        vi.push(cr);
        ret.push(vi);
    }

    let mut vll: Vec<char> = std::vec::Vec::<char>::new();
    for _ in 0..cnum + 2 {
        vll.push(cr);
    }
    ret.push(vll);

    ret
}


fn main() {
    let vn: Vec<i32> = read_multi(); //i32
    // println!("{:?}", vn);

    let vs: Vec<String> = read_column(vn[0]);
    let mut vvc: Vec<Vec<char>> = std::vec::Vec::<std::vec::Vec::<char>>::new();
    for i in 0..vs.len() {
        let vc: Vec<char> = vs[i].chars().collect();
        vvc.push(vc);
    }
    // println!("{:?}", vvc);

    let framed: Vec<Vec<char>> = add_frame(vvc, '.');
    // println!("{:?}", framed);


    for i in 1..(vn[0] + 1) as usize {
        let mut res: String = std::string::String::new();
        for j in 1..(vn[1] + 1) as usize {
            if framed[i][j] == '#' {
                res.push('#');
            } else {
                let mut n: i32 = 0;
                if framed[i - 1][j - 1] == '#' {    n += 1;    }
                if framed[i - 1][j    ] == '#' {    n += 1;    }
                if framed[i - 1][j + 1] == '#' {    n += 1;    }
                if framed[i    ][j - 1] == '#' {    n += 1;    }
                if framed[i    ][j + 1] == '#' {    n += 1;    }
                if framed[i + 1][j - 1] == '#' {    n += 1;    }
                if framed[i + 1][j    ] == '#' {    n += 1;    }
                if framed[i + 1][j + 1] == '#' {    n += 1;    }
                res.push(std::char::from_digit(n as u32, 10).unwrap());
            }
        }
        println!("{}", res);
    }
}


Measured memory_bytes: 2160
implicit none
integer:: n,y,i,j
 
read(*,*) n,y
 
do i=0,n
do j=0,n-i
if(10000*i+5000*j+1000*(n-i-j)==y)then
write(*,*) i,j,n-i-j
goto 100
endif
end do
end do
 
write(*,*) -1,-1,-1
 
100 end

Measured memory_bytes: 2780
#include<stdio.h>

main(){
  int a,b,tmp,c;

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

  if(b >a){
    tmp=b;
    b=a;
    a=tmp;
  }

  while(b!=0){
    c = a%b;
    a=b;
    b=c;
  }
  printf("%d\n",a);
return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<pii, ll> ppiil;
typedef pair<pii, int> ppiii;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
#define rep(i, a, b) for (ll i=(a); i<(b); i++)
#define rrep(i, a, b) for (ll i=(a); i>(b); i--)
#define btoe(obj) (obj).begin(), (obj).end()
#define pb push_back
#define str to_string
#define mkp make_pair
const ll INF = 1e19;
const ll MOD = 1e9 + 7;
void chmax(ll &a, ll b) { a = max(a, b); }
void chmin(ll &a, ll b) { a = min(a, b); }

template<typename T>
void print(T out) {
    cout << out << '\n';
}

template<typename T1, typename T2>
void print(pair<T1, T2> out) {
    cout << out.first << ' ' << out.second << '\n';
}

template<typename T>
void print(vector<T> A) {
    rep(i, 0, A.size()) {
        cout << A[i];
        cout << (i == A.size()-1 ? '\n' : ' ');
    }
}

template<typename T>
void print(set<T> S) {
    vector<T> A(btoe(S));
    print(A);
}

ll sum(vector<ll> A) {
    ll res = 0;
    for (ll a: A) res += a;
    return res;
}

ll max(vector<ll> A) {
    ll res = -INF;
    for (ll a: A) chmax(res, a);
    return res;
}

ll min(vector<ll> A) {
    ll res = INF;
    for (ll a: A) chmin(res, a);
    return res;
}

ll sum(ll A[], int len) {
    ll res = 0;
    rep(i, 0, len) res += A[i];
    return res;
}

ll max(ll A[], int len) {
    ll res = -INF;
    rep(i, 0, len) chmax(res, A[i]);
    return res;
}

ll min(ll A[], int len) {
    ll res = INF;
    rep(i, 0, len) chmin(res, A[i]);
    return res;
}

ll toint(string s) {
    ll res = 0;
    for (char c : s) {
        res *= 10;
        res += (c - '0');
    }
    return res;
}

int toint(char c) {
    return c - '0';
}

ll N, K;
vector<pll> XY;

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

    cin >> N >> K;
    XY.resize(N);
    rep(i, 0, N) cin >> XY[i].first >> XY[i].second; 

    ll ans = INF;
    rep(i, 0, N) {
        ll x1 = XY[i].first;
        ll y1 = XY[i].second;
        rep(j, i, N) {
            ll x2 = XY[j].first;
            ll y2 = XY[j].second;
            rep(k, j, N) {
                ll x3 = XY[k].first;
                ll y3 = XY[k].second;
                rep(l, k, N) {
                    ll x4 = XY[l].first;
                    ll y4 = XY[l].second;
                    ll xl = min({x1, x2, x3, x4});
                    ll xr = max({x1, x2, x3, x4});
                    ll yl = min({y1, y2, y3, y4});
                    ll yr = max({y1, y2, y3, y4});
                    ll cnt = 0;
                    for (pll xy : XY) {
                        ll x5 = xy.first;
                        ll y5 = xy.second;
                        if (xl <= x5 && x5 <= xr && yl <= y5 && y5 <= yr) {
                            cnt++;
                        }
                    }
                    if (cnt >= K) {
                        chmin(ans, (xr-xl) * (yr-yl));
                    }
                }
            }
        }
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 256
def prime_factorize(n):
    a = {1}
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.add(n)
    return a

a, b = map(int, input().split(" "))

while b:
    a, b = b, a%b
ar = prime_factorize(a)
print(len(ar))

Measured memory_bytes: 3188
#include<stdio.h>
int main()
{
    int n,x,a=0,size;
    scanf("%d",&n);
    x=n%10;
    n=n/10;
    size=2;
    while(n/10!=0)
    {
        if(x==n%10)
        {
            a=1;
            break;
        }
        else
        {
            x=n%10;
            n=n/10;
        }
        size++;
    }
    if(size==2)
        printf("Bad");
    else
    {
        if(x==n)
        {
            a=1;
        }
        if(a==0)
            printf("Good");
        else
            printf("Bad");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
int n , k , x , y ,m , s , f ;;
cin>>n>>k>>x>>y;
m = n-k ;
  s= k*x ; f = m*y;
if(n>k){
  cout<<s+f<<endl;
  }
else cout<<n*x<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

signed main(){
    ll N, ans = LONG_LONG_MAX;
    cin >> N;
    for(ll A = 1; A * A <= N; A++){
        if(N % A != 0) continue;
        ll B = N / A;
        ans = min(ans, max((ll)log10(A) + 1, (ll)log10(B) + 1));
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3900
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ldb long double
#define mt meke_tuple
template<typename T> bool ckmn(T &a, T b){ T c=a;a=min(a,b);return a!=c;}
template<typename T> bool ckmx(T &a, T b){ T c=a;a=max(a,b);return a!=c;}
const int N=200050;
vector<int> E[N];
int in[N],par[N];
int main()
{
	int n,u,v,i,m;
	scanf("%i %i",&n,&m);
	for(i=1;i<=n-1+m;i++) scanf("%i %i",&u,&v),E[u].pb(v),in[v]++;
	queue<int> q;
	for(i=1;i<=n;i++) if(in[i]==0) q.push(i);
	while(q.size())
	{
		u=q.front();
		q.pop();
		for(int v:E[u])
		{
			in[v]--;
			if(!in[v])
			{
				par[v]=u;
				q.push(v);
			}
		}
	}
	for(i=1;i<=n;i++) printf("%i\n",par[i]);
	return 0;
}

Measured memory_bytes: 9472
N = input()
S = list(input())
max_ = 0
alphabets = [chr(i) for i in range(97, 97+26)]
for i in range(1, len(S)-1):
    x = S[:i]
    y = S[i:]
    match = 0
    for a in alphabets:
        if a in x and a in y:
            match += 1
    if match > max_:
        max_ = match
print(max_)



Measured memory_bytes: 3060
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define N 805
#define INF 0x3f3f3f3f
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int n,m,k,sx,sy,top,stx[N*N],sty[N*N];
char s[N][N];
int dis[N][N],dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
bool inside(int x,int y)
{
	return x>=1 && x<=n && y>=1 && y<=m;
}
int main()
{
	re(n),re(m),re(k);
	for(int i=1;i<=n;++i)
	{
		scanf("%s",s[i]+1);
		for(int j=1;j<=m;++j)
			if(s[i][j]=='S')
				sx=i,sy=j;
	}
	memset(dis,-1,sizeof dis);
	dis[sx][sy]=0;
	top=1;stx[1]=sx;sty[1]=sy;
	for(int i=1;i<=top;++i)
	{
		int nx=stx[i],ny=sty[i];
		for(int j=0;j<4;++j)
		{
			int ex=nx+dx[j],ey=ny+dy[j];
			if(inside(ex,ey) && s[ex][ey]=='.' && !~dis[ex][ey])
			{
				dis[ex][ey]=dis[nx][ny]+1;
				++top;stx[top]=ex;sty[top]=ey;
			}
		}
	}
	int ans=INF;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			if(~dis[i][j] && dis[i][j]<=k)
				ans=min(ans,min(min(i-1,n-i),min(j-1,m-j)));
	printf("%d\n",1+(ans+k-1)/k);
}


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

int main() {
int n;
cin >> n;
int a[n];
for(int i=0;i<n;i++){
    cin >> a[i];
}
for(int i=0;i<n;i++){
    if(a[i]%2==0){
        if(a[i]%3==0||a[i]%5==0){continue;}
        else {cout << "DENIED";
        return 0;}
    }
}
cout << "APPROVED";
}


Measured memory_bytes: 256