akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"errors"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)

	if !sc.Scan() {
		panic(errors.New("cannot read stdin"))
	}
	s := strings.Split(sc.Text(), " ")

	var a, b, k int
	var err error
	if a, err = strconv.Atoi(s[0]); err != nil {
		panic(err)
	}
	if b, err = strconv.Atoi(s[1]); err != nil {
		panic(err)
	}
	if k, err = strconv.Atoi(s[2]); err != nil {
		panic(err)
	}

	min := int(math.Min(float64(a), float64(b)))
	numFound := 0
	found := -1
	// 公約数のうちk番目に大きいものを探して返す
	for i := min; i > 0; i-- {
		if a%i == 0 && b%i == 0 {
			numFound++
			if numFound == k {
				found = i
				break
			}
		}
	}

	fmt.Println(found)
}

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

int main() {
  int n;
  cin >> n;
  int a[n];

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

  int max_a=0;
  for (int i=0; i<n; i++) {
    max_a = max(max_a, a[i]);
  }

  int ans=100000000;
  for (int i=-100; i<=max_a; i++) {
    int temp=0;
    for (int j=0; j<n; j++) {
      temp += (a[j]-i)*(a[j]-i);
    }
    ans = min(ans, temp);
  }

  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

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

    int N, M, K;

    cin >> N >> M >> K;

    vector<vector<int> > C(N + 1);
    vector<vector<int> > B(N + 1);

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

        C[a].push_back(b);
        C[b].push_back(a);
    }

    for(int i = 0; i < K; i++) {
        int c, d;
        cin >> c >> d;

        B[c].push_back(d);
        B[d].push_back(c);
    }

    vector<int> R(N + 1);
    
    stack<int> s;

    vector<int> count(100005);

    int g = 1;

    for(int i = 1; i <= N; i++) {
        if(R[i] == 0) {
            s.push(i);
            while(!s.empty()) {
                int x = s.top();
                R[x] = g;
                s.pop();
                count[g]++;
                for(int j = 0; j < C[x].size(); j++) {
                    if(R[C[x][j]] == 0) {
                        R[C[x][j]] = -1;
                        s.push(C[x][j]);
                    }
                }
            }
            g++;
        }
    }

    for(int i = 1; i <= N; i++) {
        int c = count[R[i]] - C[i].size() - 1;
        for(int j = 0; j < B[i].size(); j++) {
            if(R[B[i][j]] == R[i]) c--;
        }
        cout << c << " ";
    }
}


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

int main(){
    int n, k; cin >> n >> k;
    ll ans = k;

    for(int i = 1; i < n; i++){
        ans *= (k-1); 
    }

    put(ans);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using int64=long long;
constexpr int N=10001,mod=998244353;
char a[N],b[N];
int fact[N],factinv[N],f[N][N];
void exgcd(const int &a,const int &b,int &x,int &y) {
	if(!b) {
		x=1,y=0;
		return;
	}
	exgcd(b,a%b,y,x);
	y-=a/b*x;
}
inline int inv(const int &x) {
	int ret,tmp;
	exgcd(x,mod,ret,tmp);
	return (ret%mod+mod)%mod;
}
inline int C(const int &n,const int &m) {
	if(n<m||n<0||m<0) return 0;
	return (int64)fact[n]*factinv[m]%mod*factinv[n-m]%mod;
}
int main() {
	scanf("%s%s",a,b);
	const int n=strlen(a);
	for(register int i=fact[0]=1;i<=n;i++) {
		fact[i]=(int64)fact[i-1]*i%mod;
	}
	factinv[n]=inv(fact[n]);
	for(register int i=n;i;i--) {
		factinv[i-1]=(int64)factinv[i]*i%mod;
	}
	int s1=0,s2=0;
	for(register int i=0;i<n;i++) {
		if(a[i]=='1'&&b[i]=='1') s1++;
		if(a[i]=='1'&&b[i]=='0') s2++;
	}
	for(register int i=0;i<=s2;i++) {
		f[0][i]=(int64)fact[i]*fact[i]%mod;
	}
	for(register int i=1;i<=s1;i++) {
		for(register int j=1;j<=s2;j++) {
			f[i][j]=((int64)f[i-1][j]*i%mod*j%mod+(int64)f[i][j-1]*j%mod*j%mod)%mod;
		}
	}
	int ans=0;
	for(register int i=0;i<=s1;i++) {
		(ans+=(int64)f[s1-i][s2]*fact[i]%mod*fact[i]%mod*C(s1,i)%mod*C(s1+s2,i)%mod)%=mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 387712
#include<iostream>
#include<algorithm>
using namespace std;
int N;
long M,V,P;
long A[1<<17];
long po[1<<17];
main()
{
	cin>>N>>M>>V>>P;
	for(int i=0;i<N;i++)cin>>A[i];
	sort(A,A+N);
	int Li=-1,Ri=N-1;
	long okv=A[N-P];
	while(Ri>=0&&A[Ri]>=okv)Ri--;
	Ri++;
	while(Ri-Li>1)
	{
		int Mi=(Li+Ri)/2;
		long dist=A[Mi]+M;
		long ret=M*(V-1);
		int okid=Mi;
		for(int i=0;i<N;i++)
		{
			if(i==Mi)po[i]=-1;
			else
			{
				if(A[i]<=dist)
				{
					po[i]=min(dist-A[i],M);
					okid=i;
				}
				else po[i]=0;
				ret-=po[i];
			}
		}
		if(N-okid-1>=P)
		{
			Li=Mi;
			continue;
		}
		if(ret<=0)
		{
			Ri=Mi;
			continue;
		}
		int id=N-1;
		for(int i=0;i<P-1;i++)
		{
			if(id==Mi)id--;
			if(id<0)break;
			ret-=M-po[id];
			id--;
		}
		if(ret<=0)
		{
			Ri=Mi;
		}
		else Li=Mi;
	}
	cout<<N-Ri<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll cnt[30];
int main(){
  IOS();
  string s;
  cin >> s;
  ll n = SZ(s);

  ll ans = 1 + n*(n-1)/2;
  REP (i,n) cnt[s[i]-'a']++;
  REP (i,26) if (cnt[i]) ans -= cnt[i] * (cnt[i]-1) / 2;
  cout << ans << endl;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

string encrypt(int n){
	int m=n/1000,c=n%1000/100,x=n%100/10,i=n%10;
	string res;
	if(m>0){
		if(m!=1)res+=to_string(m);
		res+="m";
	}
	if(c>0){
		if(c!=1)res+=to_string(c);
		res+="c";
	}
	if(x>0){
		if(x!=1)res+=to_string(x);
		res+="x";
	}
	if(i>0){
		if(i!=1)res+=to_string(i);
		res+="i";
	}
	return res;
}

int decrypt(string s){
	int l=0,len=0;
	int res=0;
	rep(i,s.length()){
		if(s[i]=='m'){
			if(len==0)res+=1000;
			else res+=1000*stoi(s.substr(l,len));
			l=i+1;
			len=0;
		}else if(s[i]=='c'){
			if(len==0)res+=100;
			else res+=100*stoi(s.substr(l,len));
			l=i+1;
			len=0;
		}else if(s[i]=='x'){
			if(len==0)res+=10;
			else res+=10*stoi(s.substr(l,len));
			l=i+1;
			len=0;
		}else if(s[i]=='i'){
			if(len==0)res+=1;
			else res+=1*stoi(s.substr(l,len));
			l=i+1;
			len=0;
		}else len++;
	}
	return res;
}

int main(){
	cin.sync_with_stdio(false);
	int n;
	cin>>n;
	rep(i,n){
		string s1,s2;
		cin>>s1>>s2;
		cout<<encrypt(decrypt(s1)+decrypt(s2))<<endl;
	}
	return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> vec(M);
  vector<int> num(M);
  for(int i=0; i<M; i++){
    cin >> num.at(i);
    for(int j=0; j<num.at(i); j++){
      int x;
      cin >> x;
      vec.at(i).push_back(x);
    }
  }
  vector<int> lamp(M);
  for(int i=0; i<M; i++){
    cin >> lamp.at(i);
  }
  
  int ans = 0;
  
  for(int bit = 0; bit < (1 << N); bit++){
    map<int,bool> mp;
    for(int i=0; i<N; i++){
      if(bit & (1 << i)){
        mp[i+1] = true;
      }
    }
    bool on = true;
    for(int i=0; i<M; i++){
      int sw = 0;
      for(int j=0; j<num.at(i); j++){
        if(mp.count(vec.at(i).at(j))){
          sw++;
        }
      }
      if(sw %2 != lamp.at(i)){
        on = false;
      }
    }
    if(on){
      ans++;
    }
  }
  cout << ans << endl;  
}

Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            String filename = "";
            if (filename.isEmpty()) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new BufferedReader(new FileReader(filename + ".in"));
                out = new PrintWriter(filename + ".out");
            }
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine(), " :");
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    int[] readIntArray(int size) throws IOException {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    <T> List<T>[] createGraphList(int size) {
        List<T>[] list = new List[size];
        for (int i = 0; i < size; i++) {
            list[i] = new ArrayList<>();
        }
        return list;
    }

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 1l * 200 * 1024 * 1024).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    void solve() throws IOException {
        int a = readInt();
        int b = readInt();
        int sum = a + b;
        if (sum >= 10) {
            out.println("error");
        } else {
            out.println(sum);
        }

    }


}

Measured memory_bytes: 23508
N, K = gets.split.map(&:to_i)
XYs = readlines.map{|l| l.split.map(&:to_i)}

xs, ys = XYs.transpose.map(&:sort)
c = Array.new(N + 1){Array.new(N + 1, 0)}
XYs.each{|x, y| c[xs.index(x) + 1][ys.index(y) + 1] = 1}
[*0 .. N].product([*0 ... N]).each{|i, j| c[i][j + 1] += c[i][j]}
[*0 ... N].product([*0 .. N]).each{|i, j| c[i + 1][j] += c[i][j]}
ans = 1e20.to_i
[*[*0 ... N].combination(2)].repeated_permutation(2) do |(i1, i2), (j1, j2)|
  next unless c[i2 + 1][j2 + 1] - c[i2 + 1][j1] - c[i1][j2 + 1] + c[i1][j1] >= K
  s = (xs[i2] - xs[i1]) * (ys[j2] - ys[j1])
  ans = s if s < ans
end
puts ans

Measured memory_bytes: 2172
s = list(input())
count = 0
flag = 1
if s[0] == "A":
    s[0] = s[0].lower()
    for i in range(len(s)):
        if (i >= 2 and i <= len(s)-2) and s[i] == "C":
            s[i] = s[i].lower()
            count += 1
    for i in s:
        if str(i).isupper():
            flag = 0
            break
    if count != 1:
        flag = 0
else:
    flag = 0
if flag == 1: print("AC")
else: print("WA")

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n, k;
vector<int> a;
bool dp[5010][5010];
bool check(int in)
{
    int copy = a[in];
    a[in] = 0;
    for(int i = 0; i < k; i++){
        if(i == a[0]){
            dp[0][i] = true;
        } else {
            dp[0][i] = false;
        }
    }
    for(int i = 1; i < a.size(); i++){
        for(int j = 0; j < k; j++){
            if(a[i] > j){
                dp[i][j] = dp[i - 1][j];
            } else {
                dp[i][j] = (dp[i - 1][j] || dp[i - 1][j - a[i]]);
            }
        }
    }
    a[in] = copy;
    for(int i = k - copy; i < k; i++){
        if(dp[a.size() - 1][i] == true){
            return true;
        }
    }
    return false;
}

int main()
{
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        int in;
        cin >> in;
        if(in < k){
            a.push_back(in);
        }
    }
    sort(a.begin(), a.end());
    int sum = 0;
    /*for(int i = a.size() - 1; i >= 0; i++){
        sum += a[i];
        if(sum > k){
            while(a.size() == max(2, i)){
                a.pop_back();
            }
            sum = 0;
        }
    }*/
    int ok = a.size();
    int ng = -1;
    while(ok - ng > 1){
        int mid = (ok + ng) / 2;
        if(check(mid) == true){
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << endl;
    return 0;
}

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

int main(){
    int n,flag=0;
    cin >>n;
    for(int i=1; i<=9; i++){
        for(int j=1; j<=9; j++){
           if(n==i*j){
               flag=1;
           }
        }
    }
    if(flag==1)
    cout <<"Yes" <<endl;
    else
      cout <<"No" <<endl;
return 0;
}

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

int main(){
    int n, x;
    std::cin >> n >> x;
    std::vector<int> a(n);
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
    }
    
    std::sort(a.begin(), a.end());
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(i < n - 1 && a[i] + a[i + 1] <= x){
            ans++;
            x -= a[i];
        }else if(i < n - 1 && a[i] <= x){
            ans++;
            x -= a[i];
        }else if(a[i] == x){
            ans++;
            x -= a[i];
        }
    }
    
    std::cout << ans << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
import math, itertools
N, D = map(int, input().split())
num = [list(map(int, input().split())) for _ in range(N)]
l = list(range(N))

count = 0
for i, j in itertools.combinations(l, 2):
    distance = 0
    for n in range(D):
        distance += (num[i][n] - num[j][n])**2
    if math.sqrt(distance).is_integer():
        count += 1

print(count)


Measured memory_bytes: 3060
import java.util.*;
import java.lang.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int min=100000;
		if(min>a+b)min=a+b;
		if(min>a+c)min=a+c;
		if(min>c+b)min=c+b;
		System.out.println(min);
	}
}

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

int main() {
    int N;
    while (cin >> N, N) {
        vector<pair<int,int> > v;
        for (int i = 0; i < N; i++) {
            int id, am, as, bm, bs, cm, cs, dm, ds;
            cin >> id >> am >> as >> bm >> bs >> cm >> cs >> dm >> ds;
            int sum = (am + bm + cm + dm) * 60 + as + bs + cs + ds;
            v.push_back(pair<int,int>(sum, id));
        }

        sort(v.begin(), v.end());

        cout << v[0].second << endl;
        cout << v[1].second << endl;
        cout << v[N-2].second << endl;
    }

    return 0;
}

Measured memory_bytes: 3192
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

//ユークリッドの互除法　a,bは最大公約数を求めたい２つの数
class Euclid_Gojyohou{
    public:
    long long int gcd(long long int a, long long int b) {
        long long int tmp;
        long long int r = 1;
        if (b > a) {
            tmp = a;
            a = b;
            b = tmp;
        }
        r = a % b;
        while (r != 0) {


            a = b;
            b = r;
            r = a % b;

        }
        return b;
    }
};

int main() {
	cout << fixed << setprecision(18);
	long long int b,x=1,y,p,q,tmp;
	cin>>p>>q;
	Euclid_Gojyohou euc;
	q=q/euc.gcd(p,q);
	tmp=q;
	for(int i=2;i*i<=q;i++){
		if(tmp%i==0){x*=i;}
		while(tmp%i==0){
			tmp/=i;
		}
	}
	cout<<x*tmp<<endl;
} 



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

#define null               ""
#define endl               '\n'
#define all(dat)           dat.begin(), dat.end()
#define over(msg)          cout << msg << endl, exit(0);
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

int n, res, a[100005];

int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    cont (i, n) {
        cin >> a[i];
        res = gcd(res, a[i]);
    }
    if (res >= a[n]) {
        cout << a[n] << endl;
    } else {
        cout << res << endl;
    }
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


ll black[200005];
ll white[200005];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N ;
    cin >> N;
    string S;
    cin >> S;
    
    ll now = 0 ;
    for(int i = 0 ; i < N; i++){
        white[i] = now;
        if(S[i] == '#') now ++;
    }
    
    now = 0;
    for(int i = N-1; i>=0;i--){
        black[i] = now;
        if(S[i] == '.') now ++;
    }
    
    ll ans = N;
    rep(i, N){
        ans = min(ans, black[i] + white[i]);
    }
    cout << ans << endl;
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 3732
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#include <random>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;\
                    c>0?i<b:\
                    i>b;\
                    i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

string reverse_str(string s) {
	reverse(all(s));
	return s;
}

char a, b;

void solve() {
	cin >> a >> b;
	char res = b;
	if (a == 'D') {
		if (b == 'H') res = 'D';
		else res = 'H';
	}
	cout << res << endl;
}

signed main() {
	srand(time(NULL));
	int T = (int)1e15;
	cout << fixed << setprecision(15);
	rep(i, T) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}

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

int main()
{
    // string S;
    // cin >> S;
    // int i;
    // for(i=0; i < S.length(); i++){
    //   cout << "x";
    // }
    int N;
    int i;
    string ans = "YES";
    cin >> N;
    vector<int> A(N);
    for(i = 0; i < N;i++){
      cin >> A.at(i);
    }
    sort(A.begin(),A.end());
    for(i = 0; i < N-1;i++){
      if(A.at(i) == A.at(i+1)){
        ans = "NO";
        break;
      }
    }
    cout << ans;
}


Measured memory_bytes: 1024
// 高速化.
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back

int main(){
    
    // 1. 入力情報.
    char o[101010];
    int Q;
    scanf("%s %d", o, &Q);
    
    // 2. 文字列を, Q回操作.
    int t, f;
    string p = "", s = ""; // prefix, suffix
    char c[11];
    bool flip = false;
    rep(i, Q){
        scanf("%d", &t);
        // 2-1. 文字列 S の前後を反転.
        if(t == 1) flip = !flip;
        
        // 2-2. 文字列 S の先頭, 末尾を操作.
        if(t == 2){
            scanf("%d %s", &f, c);
            
            // 2-3. 文字列 S の先頭に C を追加.
            if(f == 1){
                if(flip) s.pb(c[0]);
                else     p.pb(c[0]);
            }
            
            // 2-4. 文字列 S の末尾に C を追加.
            if(f == 2){
                if(flip) p.pb(c[0]);
                else     s.pb(c[0]);
            }
        }
    }
    
    // 3. 出力.
    int ol = strlen(o);
    int pl = p.size();
    int sl = s.size();
    if(flip){
        repr(i, sl - 1, 0) printf("%c", s[i]);
        repr(i, ol - 1, 0) printf("%c", o[i]);
        rep(i, pl)         printf("%c", p[i]);
    }else{
        repr(i, pl - 1, 0) printf("%c", p[i]);
        rep(i, ol)         printf("%c", o[i]);
        rep(i, sl)         printf("%c", s[i]);
    }
    return 0;
    
}

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

const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
typedef pair<ll,pair<int,int>> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

bool f[110];

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

    int n;
    cin >> n;
    int a[n];
    REP(i,n) {
        cin >> a[i];
        f[i] = 1;
    }
    vector<int> ans;
    for (int i = n; i >= 1; i--) {
        int cnt = i;
        for (int j = n-1; j >= 0; j--) {
            if (!f[j]) continue;
            if (cnt == a[j]) {
                f[j] = 0;
                ans.pb(a[j]);
                break;
            } else {
                cnt--;
            }
        }
    }

    if (ans.size()==n)
    for (int i = n-1; i>=0; i--) {
        cout << ans[i] << endl;
    }
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
/*
   * * * * *       *        * * * * * * * * * * * * * * * * * * * * * * * *     * * * * * * *               * *               * * * * * * * * * *
   * * * * *      * *       * * * * * * * * * * * * * * * * * * * * * *    *    * * * * * * *              * * *             * ** * * * * * * * * *
   * *           * * *            * *     * *     * *      * *          * * *   * * *       *             * * * *           * * * *       * *    * *
   * * * * *    * * * *           * *     * *     * *       * * * * * * *  * *  * * * * * * *            * * * * *         * *  * *       * * * * *
   * * * * *   * * * * *          * *     * *     * *        * * * * ** *   * * * * * * * * *           * * * * * *       * *   * * * *   * * * *
         * *  * * * * * *   * *   * *     * *     * *       * * * * * * *    * ** *     * * *          * * * * * * *     * *    * * * *   * *  * *
         * * * *       * *  * *   * *     * *     * *      * *          *     * * *     * * *         * *       * * *   * *     * *       * *   * *
   * * * * ** *         * * * * * * * * * * * * * * * * * * * * * * * * *      *  * * * * * * * * * ** *         * * * * *      * * * * * * *    * *
   * * * * * *           * ** * * * * * * * * * * * * * * * * * * * * * *       * * * * * * * * * * * *           * * * *       * * * * * * *     * *
*/

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <set>
#define ll long long
#define rep(i, a, b) for (int i = int(a); i <= int(b); i++)
#define sz(a) int((a).size())
#define shit while(t--)
#define fr for(int i=0;i<n;i++)
#define pi acos(-1)
using namespace std;
int arr[95];
ll dp[20001];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n; cin >> n;
    if(n==1)
    {
        cout<<"ACL"<<endl;
    }
    else if(n==2)
    {
        cout<<"ACLACL"<<endl;
    }
    else if(n==3)
    {
        cout<<"ACLACLACL"<<endl;
    }
    else if(n==4)
    {
        cout<<"ACLACLACLACL"<<endl;
    }
    else if(n==5)
    {
        cout<<"ACLACLACLACLACL"<<endl;
    }


    return 0;
}


Measured memory_bytes: 3020
#include<bits/stdc++.h>
using namespace std;
bool check(long i,long a,long b)
{
    if(i>=a && i<=b)
        return 1;
    return 0;
}
int main()
{
    //ifstream cin("input.in");
    //ofstream cout("output.out");
    ios::sync_with_stdio(0);cin.tie(0);
    long a,b,c,d,s=0;
    cin>>a>>b>>c>>d;
    for(long i=0;i<=100;i++)
        if(check(i,a,b) && check(i,c,d))
            s++;
    cout<<max(s-1,0l);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
//const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

double fillsunuke(ll v){
    double c(v);
    double temp = 0;
    while(v!=0){
        temp += v%10;
        v/=10;
    }
    return c/temp;
}


ll next(ll N){
    
    vector<ll> cand;
    vector<double> sunuke;
    cand.push_back(N);
    sunuke.push_back(fillsunuke(N));
    

    rep(d,log10(N)+1){
        
        ll y = pow(10,d+1)*(N/pow(10,d+1)+1) -1;
        cand.push_back(y);
        sunuke.push_back(fillsunuke(y));
        
    }
    
    ll ans = N;
    double s = sunuke[0];
    
    rep(i,cand.size()){
        
        if(sunuke[i]<s){
            s =sunuke[i];
            ans = cand[i];
        }
        
    }

    return ans;
}


int main() {
    
    ll k;cin>>k;
    
    ll first = 1;
    cout<<1<<endl;
    rep(j,k-1){
        first = next(first+1);
        cout<<first<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(){
  int i,mini,k,N,A[100],c=0;
  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&A[i]);

  for(i=0;i<N;i++){
    mini = i;
    for(k=i;k<N;k++){
      if(A[k]<A[mini]){
	mini=k;
      }
    }
    k=A[i];
    A[i]=A[mini];
    A[mini]=k;
    if(i!=mini)c++;
  }
  for(k=0;k<N;k++)if(k!=N-1)printf("%d ",A[k]);else printf("%d\n",A[k]);
  printf("%d\n",c);
  return 0;
}



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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.141592653589793238462643383279;
const int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

string s, t, S;
bool match[550000];
int mod = 1e9 + 7;
void rolliha(int hash) {
    int hpow = 1;
    for (int i = 0; i < t.length(); i++) { hpow = hpow * hash % mod; }
    int th = 0, Sh = 0;
    for (int i = 0; i < t.length(); i++) {
        th = (th * hash + t[i]) % mod;
        Sh = (Sh * hash + S[i]) % mod;
    }
    for (int i = 0; i < s.length(); i++) {
        if (th != Sh) { match[i] = false; }
        Sh = (Sh * hash + S[i + t.length()] - S[i] * hpow % mod + mod) % mod;
    }
}
int dp[550000];
int dfs(int idx, int depth = 0) {
    if (depth > 550000) {
        cout << -1 << endl;
        exit(0);
    }
    if (!match[idx]) { return 0; }
    if (dp[idx] != 0) { return dp[idx]; }
    return dp[idx] = dfs((idx + t.length()) % s.length(), depth + 1) + 1;
}
signed main() {
    cin >> s >> t;
    while (S.length() < s.length() + t.length() - 1) { S += s; }
    fill(match, match + s.length(), true);
    rolliha(114514), rolliha(1919), rolliha(810);
    int ans = 0;
    for (int i = 0; i < s.length(); i++) { chmax(ans, dfs(i)); }
    cout << ans << endl;
}


Measured memory_bytes: 13572
n,m,x = map(int,input().split())
data = []
a = [0]*n
ans = float('inf')

for i in range(n):
    d = list(map(int,input().split()))
    data.append(d)

def bfs(arrs):
    if len(arrs) == n:
        global ans
        a = [0]*m
        c = 0
        for i in range(n):
            if arrs[i]==1:  
                C = data[i][0]
                A = data[i][1:]
                c += C
                for j in range(m):
                    a[j] += A[j]
        for i in a:
            if i<x:return
        ans = min(ans,c)
    else:
        bfs(arrs + [0])
        bfs(arrs + [1])

bfs([])
if ans == float('inf'):ans=-1
print(ans)


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


int main(){
     int t,n;
     while(cin>>n,n){
	  vector<int> r,l;
	  for(int i=0;i<n;i++){
	       cin>>t;
	       r.push_back(t);
	  }
	  for(int i=0;i<n;i++){
	       cin>>t;
	       l.push_back(t);
	  }
	  sort(r.begin(),r.end(),greater<int>());
	  sort(l.begin(),l.end(),greater<int>());

	  bool flag = true;
	  for(int i=0;i<n;i++){
	       for(int j=0;j<n;j++){
		    if(r[j] > 0){ 
			 r[j]--;
			 l[i]--;
		    }
	       }
	       if(l[i] != 0){
		    flag = false;
		    break;
	       }
	  }

	  cout<<(flag ? "Yes" : "No")<<endl;
     }

     return 0;
}

Measured memory_bytes: 0
# 52 D - Megalomania
N = int(input())
work = []
for _ in range(N):
    a,b = map(int,input().split())
    work.append((a,b))

# 締め切りが早い順にソート
work = sorted(work,key = lambda x:x[1],reverse = False)

result = 'Yes'
t = 0
for i,j in work:
    t += i
    if t>j:
        result = 'No'
        break
print(result)

Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll A,B,C;
    cin>>A>>B>>C;
    
    if(A==B&&B==C){
        if(A%2==0) cout<<-1<<endl;
        else cout<<0<<endl;
        return 0;
    }
    
    if(A%2==1||B%2==1||C%2==1){
        cout<<0<<endl;
        return 0;
    }
    
    ll count=0;
    ll odd=0;
    while(odd==3||odd==0){
        count++;
        odd=0;
        
        A/=2;
        B/=2;
        C/=2;
        
        if(A%2==1)odd++;
        if(B%2==1)odd++;
        if(C%2==1)odd++;
    }
    
    cout<<count<<endl;
}


Measured memory_bytes: 256
using System;
//using System.Text;
namespace AIZU_Cs_
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, y,z;
            string[] s = Console.ReadLine().Split(' ');
            x = int.Parse(s[0]);
            y = int.Parse(s[1]);
            z = int.Parse(s[2]);
            if (x < y && y < z) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 8848
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << "\n"
struct UnionFind {
private:
    ll N;
    vector<ll> parent;
    vector<ll> num;
    vector<ll> diff_weight;

public:
    UnionFind(ll n){
        N = n;
        rep(i,0,N) parent.push_back(i);
        rep(i,0,N) num.push_back(1);
        rep(i,0,N) diff_weight.push_back(0);
    }

    ll root(ll x){
        if(x == parent[x]){
            return x;
        }else{
            ll r = root(parent[x]);
            diff_weight[x] += diff_weight[parent[x]];
            return parent[x] = r;
        }
    }

    void unite(ll a, ll b, ll w = 0){
        w += weight(a); w -= weight(b);
        a = root(a); b = root(b);
        if(a == b) return;
        parent[b] = a;
        ll sum = num[a] + num[b];
        num[a] = sum;
        num[b] = sum;
        diff_weight[b] = w;
    }

    bool same(ll a, ll b){ return root(a) == root(b);}
    
    ll sz(ll x){ return num[root(x)];}

    ll weight(ll x){
        root(x);
        return diff_weight[x];
    }

    ll diff(ll a, ll b){
        return weight(b) - weight(a);
    }
};

void solve(){
    ll N,M;
    cin >> N >> M;
    ll A[100010], B[100010];
    UnionFind uf(100010);
    ll ans = N-1;
    rep(i,0,M){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        if(not uf.same(A[i], B[i])){
            ans--;
            uf.unite(A[i], B[i]);
        }
    }
    print(ans);

    

}

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

Measured memory_bytes: 7172
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ティツ?ェテ・ツ仰陛ァツ板淌ヲツ按静」ツ?陛」ツつ古」ツ?淌」ツδ。テ」ツつステ」ツδε」ツδ嘉」ツδサテ」ツつケテ」ツつソテ」ツδ?
		Scanner scan = new Scanner(System.in);
		while(scan.hasNextInt()){
			int n = scan.nextInt();
			int count=0;
			for(int a=0;a<=9;a++){
				for(int b=0;b<=9;b++){
					for(int c=0;c<=9;c++){
						for(int d=0;d<=9;d++){
							if(a+b+c+d==n){
								count++;
							}
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 18828
#include <bits/stdc++.h>
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define rep(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;
const ll mod=1e9+7;

ll n,k,a,b;
vector<ll> e[100009];
bool visited[100009];

ll dfs(ll x){
    visited[x]=1;
    ll re=1;
    if(x==1){
        re=k;
        rep(i,e[x].size()){
            (re*=k-1-i)%=mod;
            (re*=dfs(e[x][i]))%=mod;
        }
        return re;
    }
    rep(i,e[x].size()){
        if(i)(re*=k-1-i)%=mod;
        if(!visited[e[x][i]])(re*=dfs(e[x][i]))%=mod;
    }
    return re;
}

int main(){
    cin>>n>>k;
    rep(i,n-1){
        cin>>a>>b;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    cout<<dfs(1)<<endl;
}

Measured memory_bytes: 9344
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring> 
using namespace std;
 
long long dp[1005][1005],h,w;
char s[1005][1005];
int main(){
	scanf("%d%d\n",&h,&w);
	for (int i=1;i<=h;i++){
		for (int j=1;j<=w;j++){
			scanf("%c",&s[i][j]);
		}
		if (i < h)
		scanf("\n");
	}
	dp[1][1]=1;
	for (int i=1;i<=h;i++){
		for (int j=1;j<=w;j++){
			if (s[i][j] == '.' && (i!= 1 || j != 1))
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%(1000000007);
		}
	}
	printf("%lld\n",dp[h][w]%(1000000007));
	return 0;
} 

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

class Road{
public:
	int d, p;
	Road() {}
	Road(int d = 0, int p = 0): d(d), p(p) {}
	bool operator < (const Road r)const {
		return p < r.p;
	}
};

int main() {
	int n, m;
	while (1) {
		cin >> n >> m;
		if (n == 0 && m == 0)break;
		vector<Road> r;
		int d, p;
		for (int i = 0; i < n; i++) {
			cin >> d >> p;
			Road tmp(d, p);
			r.push_back(tmp);
		}

		sort(r.begin(), r.end());
		int i = n - 1;
		for(int j = 0; j < m; j++) {
			r[i].d--;
			if (r[i].d == 0) {
				if (i > 0)i--;
				else break;
			}
			
		}
		int sum = 0;
		for(int j = 0; j < n; j++){
			sum += r[j].d * r[j].p;
		}
		cout << sum << endl;
	}




	return 0;
}

Measured memory_bytes: 3196
import math

def gcd(x, y):
    if y == 0: return x
    return gcd(y, x%y)

def factorize(n):
    res = []
    for i in range(2, int(math.sqrt(n))+1):
        if n%i: continue
        res.append([i,0])
        while n%i == 0:
            n /= i
            res[-1][1] += 1
    if n != 1: res.append([n,1])
    return res

a, b = map(int, input().split())
g = gcd(a,b)
f = factorize(g)
ans = len(f) + 1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL ans = 1ll<<60;
int n,x[105];
inline LL calc(int w){
	LL tot = 0;
	for (int i = 1; i <= n; ++i) tot += (x[i]-w)*(x[i]-w);
	return tot;
}
int main(){
	int i;
	cin >> n;
	for (i = 1; i <= n; ++i) cin >> x[i];
	for (i = -100; i <= 200; ++i) ans = min(ans,calc(i));
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// const ll INF = 1e18;
//const ll MOD = 1e9+7;
//const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()

double A;
double B;
ll N;

int Main() {
    cin >> A >> B >> N;
    ll ans = 0;

    if (B-1 < N) {
        ans = floor(A*(B-1)/B) - A*floor((B-1)/B);
    } else {
        ans = floor(A*N/B) - A*floor(N/B);
    }
    
    cout << ans << endl;
    
    return 0;
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int l, r;
  cin >> l >> r;
  vector<int> a;
  for(int i = l; i < r + 1; i++)
  {
    a.push_back(i % 2019);
    if(a.size() == 2019)
    {
      break;
    }
  }
  int mini = 2019;
  for(int i = 0; i < a.size(); i++)
  {
    for(int j = i + 1; j < a.size(); j++)
    {
      mini = min(mini, a[i] * a[j] % 2019);
    }
  }
  cout << mini;

  return 0;
}

Measured memory_bytes: 256
use v5.18;
use warnings;
use List::Util qw( min );
sub read_line { chomp(my $s = <>); $s }
sub splited_read_line { split / /, read_line }

my $s = read_line;
my @ideals = (
  join( '', map { $_ % 2 == 0 ? '1' : '0' } 1 .. length $s ),
  join( '', map { $_ % 2 == 1 ? '1' : '0' } 1 .. length $s ),
);
my @str = split //, $s;
say min map {
  my $diff_num = 0;
  my @binaries = split //, $_;
  for my $i (0 .. length($s) - 1 ) {
    $diff_num++ if $binaries[$i] != $str[$i];
  }
  $diff_num;
} @ideals;



Measured memory_bytes: 32128
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static StreamReader sr;

        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)998244353;
        static List<long>[] G;
        static long[] nums;//子の数
        static List<long> path;//0→N-1までのPath
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var Sij = new string[N];
            for (var i = 0; i < N; ++i)
                Sij[i] = ReadLine();
            var cnt = 0L;
            for (var r = 0; r < N; ++r)
            {
                var flg = true;
                for (var h = 0; h < N; ++h)
                {
                    for (var w = h + 1; w < N; ++w)
                    {
                        if (Sij[h][(int)((w + r) % N)] != Sij[w][(int)((h + r) % N)])
                            flg = false;
                        if (!flg) break;
                    }
                    if (!flg) break;
                }
                if (flg) ++cnt;
            }
            WriteLine(cnt * N);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (int)(n); ++i)
#define repk(i,k, n) for (ll i = k; i < (int)(n); ++i)
#define MAX 5000010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll sum,cnt;
ll N;


int main() {
	string input;
	cin >> input;
	vector<string> s = { " ","SAT","FRI","THU","WED","TUE","MON","SUN" };

	rep(i, s.size()) {
		if (input == s[i]) {
			cout << i << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	double a,b;
	cin>>a>>b;
	cout<<a/b<<endl;
}

Measured memory_bytes: 256
a=list(map(int,input().split()))
takahashi=0
takahashicount=0
aoki=0
aokicount=0

for i in range(a[2]):
    aoki+=a[1]
    if (a[2]-aoki)>0:
        aokicount+=1
    elif (a[2]-aoki)==0:
        break
    else:
        break
        
for i in range(a[0]):
    takahashi+=a[3]
    if (a[0]-takahashi)>0:
        takahashicount+=1
    elif (a[0]-takahashi)==0:
        break
    else:
        break
if takahashicount==aokicount:
    print("Yes")
elif takahashicount>aokicount:
    print("Yes")
elif takahashicount<aokicount:
    print("No")

Measured memory_bytes: 61860
#include<stdio.h>
int main(void){
  int N;
  scanf("%d",&N);
  int H[N],i,max,sum=1;
  for(i=0;i<N;i++) scanf("%d",&H[i]);
  max=H[0];
  for(i=1;i<N;i++){
    if(H[i]>=max){
      max=H[i];
      sum++;
    }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128