akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

long long f(long long b,long long n)
{
    if(n==0) return 0;
    else if(n<b) return n;
    return f(b,n/b) + (n%b);
}
int main()
{
    long long m,s;
    cin >> m >> s;
    long long k=m-s;
    long long ans=1e12+7;
    if(k<0)
    {
        cout << "-1" << "\n";
        return 0;
    }
    else if(k==0)
    {
        cout << m+1 << "\n";
        return 0;
    }
    else
    {
        long long t=sqrt(k);
        for(long long i=1;i<=t;i++)
        {
            if(k%i==0)
            {
                if(f(i+1,m) == s) ans=min(ans,i+1);
                if(f((k/i)+1,m) == s) ans=min(ans,(k/i)+1);
            }
        }
    }
    if(ans==1e12+7)
        cout << "-1" << "\n";
    else
        cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int N, a[10010]= {}, count = 0;
  cin >> N;
  for (int x = 1; x*x <= N; x++){
    for  (int y = 1; y*y<= N; y++){
      for (int z = 1; z*z <= N; z++){
        int num = x*x + y*y + z*z + x*y + y*z + z*x;
        if (num > N) break;
        a[num]++;
      }
    }
  }
  for(int i = 1; i<=N; i++){
    cout << a[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3668
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        hoge();
        //System.Console.ReadLine();
    }

    public static void hoge()
    {
        var kane = System.Console.ReadLine().Split(' ').Select(long.Parse).ToArray()[0];

        long big = kane / 500;
        kane = kane % 500;
        long small = kane / 5;
        System.Console.WriteLine(big * 1000 + small * 5);

    }
}

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

using namespace std;


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

    vector<int> v(N+1), w(N+1);

    vector<int> tmp(3, 0);

    // ナップサック問題の同じ種類の品物をいくつでも選んでよいときの容量W以内でk個までの価値の最大和dp[k][W]
    vector<vector<int> > dp(N+1, vector<int>(W+1, 0));

    for(int i = 0; i < N; i++) {
        cin >> v[i+1] >> w[i+1];
    }

    // 初期条件
    for(int j = 0; j <= W; j++) {
        dp[0][j] = 0;
    }

    // dp開始
    for(int i = 1; i <= N; i++) {
        for(int j = 0; j <= W; j++) {
            if(j - w[i] >= 0) {
                tmp = {};
                tmp.push_back(dp[i-1][j - w[i]] + v[i]);
                tmp.push_back(dp[i-1][j]);
                tmp.push_back(dp[i][j - w[i]] + v[i]);
                sort(tmp.begin(), tmp.end());
                dp[i][j] = tmp.back();
                // dp[i][j] = max({dp[i-1][j - w[i]] + v[i], dp[i-1][j], dp[i][j - w[i]] + v[i]});
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    cout << dp[N][W] << endl;
	return 0;
}


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

int main() {
  int s, w;
  cin >> s >> w;
  if (w >= s) {
      cout << "unsafe" << endl;
  }else {
      cout << "safe" << endl;
  }

  return 0;
}

Measured memory_bytes: 3600
#include<iostream>

using namespace std;

int bubbleSort(int A[], int N) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = N - 1; j >= i + 1; j--) {
			if (A[j] < A[j - 1]) {
				swap(A[j], A[j - 1]);
				flag = 1;
				sw++;
			}
		}
	}
	return sw;
}

int main(){
	int N, sw;
	int A[100];

	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];

	sw = bubbleSort(A, N);

	for (int i = 0; i < N; i++) {
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;

	return 0;
}


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

template <typename T> struct fenwick {
	int n;
	vector<T> a;

	fenwick(int _n) : n(_n), a(n + 1) { }

	void update(int i, T v) { // update i, 0 <= i < n
		assert(0 <= i && i < n);
		for (i++; i <= n; i += (i & -i)) {
			a[i] += v;
		}
	}

	T query(int i) { // sum [0, i), 0 <= i <= n
		assert(0 <= i && i <= n);
		T res{};
		for (; i; i -= (i & -i)) {
			res += a[i];
		}
		return res;
	}
};

const int MAXM = 1.1e5;
int N;
int M;

vector<int> evts[MAXM];
vector<int> divisors[MAXM];

int ans[MAXM];

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

	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		int l, r; cin >> l >> r; r++;
		evts[l].push_back(r);
	}

	for (int x = 1; x <= M; x++) {
		for (int y = x; y <= M; y += x) {
			divisors[y].push_back(x);
		}
	}

	fenwick<int> sum(M+2);
	for (int x = 1; x <= M; x++) {
		for (int r : evts[x]) {
			sum.update(x, 1);
			sum.update(r, -1);
		}

		for (int d : divisors[x]) {
			ans[d] += sum.query(x + 1);
			if (x + d <= M) {
				ans[d] -= sum.query(x + d + 1);
			}
		}
	}

	for (int x = 1; x <= M; x++) {
		cout << ans[x] << '\n';
	}

	return 0;
}

Measured memory_bytes: 17536
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない




int main() {

	int a, b,c;
	cin >> a >> b>>c;
	cout << min(c, b / a) << endl;

	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left
from collections import defaultdict
N=int(input())
D=[[] for i in range(2*10**5+1)]
U=[[] for i in range(2*10**5+1)]
L=[[] for i in range(2*10**5+1)]
R=[[] for i in range(2*10**5+1)]
arr=[]


T=[[[] for i in range(2*10**5+1)] for i in range(4)]
li=['U','L','D','R']
for i in range(N):
    X,Y,v=input().split()
    X,Y=int(X),int(Y)
    arr.append((X,Y,v))
    if v=='U':
        U[X].append(Y)
    if v=='D':
        D[X].append(Y)
    if v=='L':
        L[Y].append(X)
    if v=='R':
        R[Y].append(X)
ans=float('inf')
for i in range(2*10**5+1):
    D[i].sort()
    for u in U[i]:
        b=bisect_left(D[i],u)
        if b==len(D[i]):
            continue
        ans=min(ans,5*(D[i][b]-u))
    L[i].sort()
    for r in R[i]:
        b=bisect_left(L[i],r)
        if b==len(L[i]):
            continue
        ans=min(ans,5*(L[i][b]-r))
        
def check(R,U):
    res=float('inf')
    for A,B in U.items():
        B.sort()
    for xr,yr in R:
        b=bisect_left(U[xr+yr],xr)
        if b==len(U[xr+yr]):
            continue
        res=min(res,10*(U[xr+yr][b]-xr))
    return res

def f1(x,y):return x,y
def f2(x,y):return -y,x
def f3(x,y):return -x,-y
def f4(x,y):return y,-x
fanc=[f1,f2,f3,f4]
for t in range(4):
    arr2=[]
    for x,y,v in arr:
        a,b=fanc[t](x,y)
        c=li[(li.index(v)+t)%4]
        arr2.append((a,b,c))
    r2,u2=[],defaultdict(list)
    for x,y,v in arr2:
        if v=='R':
            r2.append((x,y))
        if v=='U':
            u2[x+y].append(x)
    ans=min(ans,check(r2,u2))
print(ans if ans!=float('inf') else 'SAFE')

Measured memory_bytes: 337556
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}



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

  if(k>(n-1)*(n-2)/2){
    cout << -1 << endl;
    return 0;
  }
  int a=((n-1)*(n-2)/2)-k;

  vector<int> g[110];
  for(int i=2;i<=n;i++){
    g[i].push_back(1);
    g[1].push_back(i);
  }
  int cnt=0;
  for(int i=2;i<=n;i++){
    for(int j=2;j<=n;j++){
      if(i>=j)continue;
      if(a==cnt)break;
      g[i].push_back(j);
      g[j].push_back(i);
      cnt++;
    }
  }
  int ans=n-1;
  ans+=a;
  cout << ans << endl;
  for(int i=1;i<=n;i++){
    FOR(j,g[i].size()){
      if(i<g[i][j]){
        cout << i << " " << g[i][j] << endl;
      }
    }
  }
  
  
}


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

int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    int len[3];  
    for(int j = 0; j < 3; j++) {
      cin >> len[j];
    }    
    sort(len, len+3);
  
    if(len[2]*len[2] == len[0]*len[0] + len[1]*len[1]) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

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

using namespace std;
using ll=long long ;

void solve() {
    ll k; cin >> k;
    ll x = k/50;
    int j = k%50;

    vector<ll> a(50, 50+x);
    j = (50-j);
    for (int i = 0; i < j; i++) {
        a[i] += -50+j-1;
    }
    for (int i = j; i < 50; i++) {
        a[i] += j;
    }

    cout << "50\n";
    for (auto& x: a) {
        cout << x << ' ';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
def ketashirabe(atai)
  kaisu=0
  k=atai
  loop{
    if(k/10!=0)
      k=k/10
    kaisu+=1
    else 
      return kaisu+1
    end 
  }
end

m=gets.to_i
result=[]
dasu=[]
ha=Array.new
for a in 1..m**(1/2.0)
  if(m%a==0&&a<=m/a)
  ha<<a
  ha<<m/a
  result.push(ha)
  ha=[]
  end
end

for sa in 0..result.length-1
  if(ketashirabe(result[sa][0])>=ketashirabe(result[sa][1]))
  dasu.push(ketashirabe(result[sa][0]))
  else
    dasu.push(ketashirabe(result[sa][1]))
  end
end

puts dasu.min


Measured memory_bytes: 14824
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();
		if (a<b) System.out.println("a < b");
		else if (a>b) System.out.println("a > b");
		else System.out.println("a == b");
	}
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  int i;
  int count = 0;
  vector<bool> check(n, false);
  for(i = 0; i < n; i++)
  {
    cin >> a.at(i);
  }
  for(i = 0; i < n; i++)
  {
    if(i == a.at(a.at(i)-1)-1 && check.at(a.at(i)-1) == false)
    {
      count++;
      check.at(a.at(i)-1) = true;
    }
    check.at(i) = true;
  }
  cout << count << endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String data = sc.nextLine();
        
        String[] array = data.split(" ");
        
        long n = Long.parseLong(array[0]);
        long k = Long.parseLong(array[1]);
        
        long min = n % k;
        long buf = 0;
        while(true)
        {
            buf = Math.abs(min - k);
            
            if(min < buf)
            {
                break;
            }
            else
            {
                min = buf;
            }
        }
        
        System.out.println(min);
    }
}


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

#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
using ll = long long;

ll lcm(ll a,ll b){
	
	return (a*b)/(__gcd(a,b));
}

void solve() 
{ 
int a,b;
cin>>a>>b;
cout<<6-a-b;

}
 

int main(){


		solve();
		cout<<endl;
	
	

					
}
		

	

		

 



Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, w;
	cin >> n >> w;
	vector<int>weight(n), value(n);
	for (int i = 0; i < n; i++) {
		cin >> weight[i] >> value[i];
	}
	ll dp[n + 1][w + 1];
	for (int i = 0; i <= n; i++)dp[i][0] = 0;
	for (int i = 0; i <= w; i++)dp[0][i] = 0;
	for (int i = 1; i <= n; i++) {
		for (int k = 1; k <= w; k++) {
			if (i == 0 || k == 0)
				dp[i][k] = 0;
			else if (weight[i - 1] <= k) {
				dp[i][k] = max(value[i - 1] + dp[i - 1][k - weight[i - 1]], dp[i - 1][k]);
			}
			else
				dp[i][k] = dp[i - 1][k];
		}
	}
	cout << dp[n ][w] << endl;
}


Measured memory_bytes: 79232
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;


ll modpow(ll a,ll n,ll m=MOD){
    ll p=1;
    for(;n;n>>=1,a=a*a%m)
        if(n&1)
            p=p*a%m;
    return p;
}

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

ll combination(ll n,ll a){
    ll x = 1,y = 1;
    REP(i,a){
        x = x*(n-i)%MOD;
        y = y*(i+1)%MOD;
    }
    return x*modinv(y,MOD)%MOD;
}

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll answer = 1;
    ll num = n;
    answer = modpow(2,n);
    answer--;
    answer -= combination(n,a);
    if(answer < 0)answer+= MOD;
    answer -= combination(n,b);
    if(answer < 0)answer+= MOD;
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  int A[N][M];
  REP(i,N)REP(j,M){
    cin>>A[i][j];
    A[i][j]--;
  }
  int ans=N;
  int S[M];
  REP(i,M)S[i]=1;
  REP(m,M){
    int T[M];
    REP(i,M)T[i]=0;
    REP(i,N){
      REP(j,M)if(S[A[i][j]]){
        T[A[i][j]]++;
        break;
      }
    }
    int argmax_t=distance(T,max_element(T,T+M));
    ans=min(ans,T[argmax_t]);
    S[argmax_t]=0;
    // REP(i,M)cerr<<T[i];
    // cerr<<endl;
    // cerr<<argmax_t<<endl;
    // REP(i,M)cerr<<S[i];
    // cerr<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
n = int(input())
s = [int(input()) for _ in range(n)]
s = sorted(s)
i = s[0]
cnt = 1
num = 0
for j in s[1:]:
    if i == j:
        cnt += 1
    else:
        if cnt % 2 != 0:
            num += 1
        cnt = 1
    i = j
if cnt % 2 != 0:
    num += 1
print(num)





Measured memory_bytes: 8280
#include <iostream>
using namespace std;
int main()
{
	int n, m, a[25], i;
	while (cin >> m && m)
	{
		for (i = 0; i < m; i++)
			cin >> a[i];
		n = 32;
		i = 0;
		while (n > 0)
		{
			n -= (n-1)%5;
			cout << n << endl;
			if (n <= 0) break;
			n -= ((a[i]>=n)?n:a[i]);
			cout << n << endl;
			i++;
			if (i >= m) i = 0;
		}
	}
}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();

        int[] a = new int[n];
        int[] b = new int[n-1];
        for (int i = 0; i < n-1; i++) {
            b[i] = sc.nextInt();
            a[i] = -1;
        }

        int ans = 0;
        for (int i = 0; i < n-1; i++) {
            if (a[i] == -1) {
                a[i] = b[i];
            }
            if (i < n-2 && b[i] < b[i+1]) {
                a[i + 1] = b[i];
            }
            ans += a[i];
        }
        ans += b[n-2];

        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 21204
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct T{
  int key;
  struct T *right;
  struct T *left;
  struct T *parent;
};
typedef struct T *Tree;

void insert(int);
void Mprint(Tree);
void Fprint(Tree);

Tree root;

int main(){
  int x,m,i;
  char s[10];
  
  scanf("%d",&m);

  for(i=0 ; i<m ; i++){
    scanf("%s",s);
    if(0==strcmp(s,"insert")){
      scanf("%d",&x);
      insert(x);
    }

      if(0==strcmp(s,"print")){
      Mprint(root);
      printf("\n");
      Fprint(root);
      printf("\n");
    }
  }

  return 0;
}

void insert(int k){
  Tree y = NULL;
  Tree x = root;
  Tree z;

  z=malloc(sizeof(struct T));
  z->key = k;
  z->right = NULL;
  z->left = NULL;

  while(x!=NULL){
    y=x;
    if(z->key < x->key) x=x->left;
    else x=x->right; 
  }

  z->parent=y;

  if(y==NULL)root=z;
  else if(z->key < y->key) y->left=z;
  else y->right=z;
}

void Mprint(Tree A){
  if(A!=NULL){
    Mprint(A->left);
    printf(" %d",A->key);
    Mprint(A->right);
  }
}

void Fprint(Tree A){
 if(A!=NULL){
   printf(" %d",A->key);
   Fprint(A->left);
   Fprint(A->right);
 }
}

Measured memory_bytes: 24040
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>

using namespace std;


long long RepeatSquare(long long n, long long p, long long m){
    if(p == 0) return 1;
    if(p%2 == 0){
        long long t = RepeatSquare(n, p/2, m);
        return t * t %m;
    }
    return n * RepeatSquare(n, p-1, m) %m;
}

long long choose(long long a, long long b, long long m)
{
    long long up = 1, lo = 1;
    for (int i = 0; i < b; i++)
    {
        up = up * ((a - i) % m) %m;
        lo = lo * ((b - i) % m) %m;
    }
    
    long long tmp = RepeatSquare(lo, m-2, m);
    //cout << "tmp" << tmp << endl;
    return up * tmp %m;
    //return up / lo %m;
}

int main(int argc, char const *argv[])
{
    long long n, a, b;
    long long mod = 1000000007;
    cin >> n >> a >> b;
    long long sum = (RepeatSquare(2, n, mod) -1) % mod;

    if(b > a){
        swap(a,b);
    }
    long long num = 0;
    long long a1 = choose(n, a, mod);
    long long b1 = choose(n, b, mod);
    //cout << "a1: " << a1 << " b1: " << b1 << endl;
    num = ((sum - a1) % mod - b1) %mod;
    long long ans = 0;
    if(num < 0)
        ans = num + mod;
    else{
        ans = num;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>



int main(){
	int a,b,c,tmp;
	
	scanf("%d%d%d",&a,&b,&c);
	tmp=a;
	a=b;
	b=tmp;
	tmp=a;
	a=c;
	c=tmp;
	printf("%d %d %d",a,b,c);
	return 0;
}




Measured memory_bytes: 1724
def aaa(n,m):
    count1 = 1
    count2 = 1
    if n % 2 == 1:
        count1 = count1 + n//2
        count2 = count2 + n//2 + 1
    else:
        count1 = count1 + n//2
        count2 = count2 + n//2
    if m % 2 == 1:
        count1 = count1 + m//2 + 1
        count2 = count2 + m//2
    else:
        count1 = count1 + m//2
        count2 = count2 + m//2
    l3 = [count1,count2]
    return l3
s = list(input())
n = len(s)
j = 0
a = 0
b = 0
l = [0]*n
for i in range(len(s)):
    if s[i] == "R" and j == 0:
        a = a + 1
    elif s[i] == "R" and j == 1:
        l[c-1] = aaa(a-1,b)[0]
        l[c] = aaa(a-1,b)[1]
        a = 1
        b = 0
        j = 0
    elif s[i] == "L" and j == 0:
        j = 1
        c = i
    elif s[i] == "L" and j == 1:
        b = b + 1
l[c-1] = aaa(a-1,b)[0]
l[c] = aaa(a-1,b)[1]
for x in l:
    print(x,end=" ")

Measured memory_bytes: 56824
n = int(input())

for _ in range(n):
    xa, ya, ra, xb, yb, rb = map(float, input().split())
    dist = ((xa - xb)**2 + (ya - yb)**2)**.5
    if ra + rb < dist:
        print('0')
    elif abs(ra - rb) <= dist:
        print('1')
    elif (rb < ra):
        print('2')
    elif (ra < rb):
        print('-2')

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

int main() {
        char a, b;
        scanf("%c %c", &a, &b);
        if ((a=='H' && b=='H') || (a=='D' && b=='D')) {
                printf("H\n");
        } else {
                printf("D\n");
        }
        return 0;
}


Measured memory_bytes: 256
import math
A, B = map(int, input().split())

xa_min = math.ceil((A * 100) / 8)
xa_max = math.floor(((A + 1) * 100) / 8)

xb_min = math.ceil((B * 100) / 10)
xb_max = math.floor(((B + 1) * 100) / 10)

low_price = max(xa_min, xb_min)

if xb_max <= xa_min or xa_max <= xb_min:
    print(-1)
else :
    print(low_price)

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


bool cmp(pair<long long,long long>p1, pair<long long,long long>p2)
{
    if(p1.first==p2.first)return p1.second>p2.second;
    return p1.first < p2.first;
}
void show(vector<ll>&vc)
{
    for(auto it:vc)
    {
        cout<<it<<" ";
    }
    cout<<endl;
    return;

}


void solve()
{

    ll n;
    vector<ll>vc;
    cin>>n;

    for(int i=0;i<n;i++)
    {
        ll temp;
        cin>>temp;
        vc.push_back(temp);

    }

    ll dp[100007];
    memset(dp,0,sizeof dp);

    dp[0] = 0;
    dp[1] = abs(vc[1]-vc[0]);

    for(int i=2;i<n;i++)
    {

        dp[i] = min( dp[i-1] + abs(vc[i]-vc[i-1]) , dp[i-2] + abs(vc[i]-vc[i-2]));
    }

    cout<<dp[n-1]<<endl;


}

int main()
{


    ll t=1;
    //cin>>t;
    //t=1;

    while(t--)
    {
        solve();
    }
}


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

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

   int K,Q; cin>>K>>Q;
   vector<int> d(K);
   for(int i=0;i<K;i++) cin>>d[i];

   while(Q--){
      int N,X,M; cin>>N>>X>>M;
      vector<int> D=d;
      for(int i=0;i<K;i++) D[i]=(D[i]%M==0? M:D[i]%M);
      lint fst=X,lst=X;
      lst+=accumulate(D.begin(),D.begin()+(N-1)%K,0LL);
      lst+=accumulate(D.begin(),D.end(),0LL)*((N-1)/K);
      cout<<(N-1)-(lst/M-fst/M)<<endl;
   }
   return 0;
}


Measured memory_bytes: 384
import math
n = int(input())
a_tmp = input().split()
a_tmp1 = []
for i in range(n):
    a_tmp1.append(int(a_tmp[i])-i-1)
a = sorted(a_tmp1)
if n % 2 == 0:
    x = a[n//2]
else:
    x = a[n//2]
ans = 0
for _ in a:
    ans += math.fabs(_ - x)
print(int(ans))


Measured memory_bytes: 28400
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	a--;

	int l=c/gcd(c,d)*d;
	cout<<b-b/c-b/d+b/l-(a-a/c-a/d+a/l)<<endl;	

	return 0;


}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    string S;
    string T;
    cin >> n;
    cin >> S;
    cin >> T;
   
    for(int i = 0; i < n; i++){
        cout << S[i];
        cout << T[i];
    }
}


Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
#define ll  long long 
  vector<ll>to[1000005];
int main(){
  string a;cin>>a;
  ll b=0;
  rep(i,a.size()-1){
    if(a[i+1]!=a[i])b++;
  }
  cout<<b;
}


Measured memory_bytes: 23936
use proconio::input;
use std::collections::HashSet;
 
fn main() {
  input! {
    n: usize,
    w: usize,
    mut vals: [(usize, usize);n]
  }
  
  let mut dp: Vec<Vec<usize>> = vec![vec![0;w+1];n+1];
  for i in 0..n {
    for ii in 0..=w {
      let (weight, value) = vals[i];
      if weight <= ii {
        dp[i+1][ii] = std::cmp::max(dp[i+1][ii], dp[i][ii-weight] + value);
      }
      
      dp[i+1][ii] = std::cmp::max(dp[i+1][ii], dp[i][ii]);
    }
  }
  
  println!("{}", dp[n][w]);
}

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

using namespace std;

template<typename T>void read(T&x){x=0;int fl=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')
fl=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}x*=fl;}
template<typename T,typename...Args>inline void read(T&t,Args&...args){read(t);read(args...);}

typedef long long LL;

const int N = 200005;

int n, k, c;
char s[N];
bool ff[N], gg[N];
int f[N], g[N];

int main(){
	read(n, k, c);
	scanf("%s", s+1);
	for(int i = 1; i <= n; i++){
		if(s[i] == 'o'){
			f[i] = ff[i] = 1;
			i += c;
		}
	}
	for(int i = 1; i <= n; i++)
		f[i] += f[i-1];
	for(int i = n; i >= 1; i--){
		if(s[i] == 'o'){
			g[i] = gg[i] = 1;
			i -= c;
		}
	}
	for(int i = n; i >= 1; i--)
		g[i] += g[i+1];
	for(int i = 1; i <= n; i++)
		if(ff[i] && gg[i] && f[i-1] + g[i+1] < k)
			printf("%d\n", i);
	return 0;
}

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

using namespace std;

//#define int long long
#define PB push_back
#define PPB pop_back
typedef pair<int, int> pii;
//static const int INF = 1LL<<61;
static const int INF = 1<<30;

bool visit[5005];
vector<int> tree, G[5005];

void dfs(int a) {
  if (visit[a]) return;
  visit[a] = true;
  for (int i = 0; i < G[a].size(); ++i) {
    dfs(G[a][i]);
  }
  tree.PB(a);
}

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

  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    G[a].PB(b);
  }

  for (int i = 1; i <= n; ++i) {
    sort(G[i].begin(), G[i].end());
    dfs(i);
  }

  bool other = true;
  for (int i = 0; i < tree.size() - 1; ++i) {
    int a = tree[i];
    other = binary_search(G[tree[i + 1]].begin(), G[tree[i + 1]].end(), a);
    if (!other) break;
  }

  for (int i = tree.size() - 1; 0 <= i; --i) {
    cout << tree[i] << endl;
  }
  cout << !other << endl;

  return 0;
}

Measured memory_bytes: 2060
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 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)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var HWD = Sarray();
            var H = HWD[0];
            var W = HWD[1];
            var D = HWD[2];
            var dct = new Dictionary<long, Tuple<int, int>>();
            for (var i = 0; i < H; ++i)
            {
                var a = Sarray();
                for (var j = 0; j < W; ++j)
                    dct[a[j] - 1] = Tuple.Create(i, j);
            }
            var rui = new long[H * W];
            for (var i = D; i < H * W; ++i)
            {
                var dst = Abs(dct[i - D].Item1 - dct[i].Item1) + Abs(dct[i - D].Item2 - dct[i].Item2);
                rui[(int)i] = rui[(int)i - D] + dst;
            }
            var Q = Sarray()[0];
            for (var i = 0; i < Q; ++i)
            {
                var lr = Sarray();
                var l = lr[0] - 1;
                var r = lr[1] - 1;
                var ans = rui[r] - rui[l];
                WriteLine(ans);
            }
            Out.Flush();
        }
    }
}

Measured memory_bytes: 27948
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  string S;
  cin >> S;
  if (S.at(0)==S.at(1)||S.at(1)==S.at(2)||S.at(2)==S.at(3)) {
    cout << "Bad" << endl;
  }
  else {
    cout << "Good" << endl;
  }
}

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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;

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

   ll N,H;
   cin>>N>>H;
   vector<ll>a(N),b(N);
   for(ll i=0;i<N;i++)cin>>a[i]>>b[i];
   ll max_a = *max_element(a.begin(),a.end());
   ll ans = 0;
   sort(b.begin(),b.end());
   bool flg=true;
   for(ll i=N-1;i>=0;i--){
      if(b[i]<max_a)break;
      H-=b[i];
      ans++;
      if(H<=0){
         flg = false;
         break;
      }
   }
   if(flg)ans += H/max_a + (H%max_a!=0);
   cout<<ans;
   return 0; 
}


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

const int INF = 1000000000;

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

		if(n==0)
			break;

		int T[10][10];
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				if(i==j){
					T[i][j] = 0;
				}
				else{
					T[i][j] = INF;
				}
			}
		}

		int m = 0; //町の数

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

			T[a][b] = T[b][a] = c;

			if(a+1>m){
				m = a+1;
			}
			if(b+1>m){
				m = b+1;
			}
		}

		for(int k=0;k<m;k++){
      for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
          if(T[i][j]>T[i][k]+T[k][j]){
            T[i][j] = T[i][k]+T[k][j];
          }
        }
      }
    }

    int ans=0;
    int anstime=INF;
    int timee;

    for(int i=0;i<m;i++){
      timee=0;
      for(int j=0;j<m;j++){
        timee+=T[i][j];
      }
      if(anstime>timee){
        anstime=timee;
        ans=i;
      }
    }

    cout << ans << " " << anstime << endl;

  }
  return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF = 2e9
#define LINF = 1e18
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << = << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO")
#define Yes(n) cout << ((n) ? "Yes" : "No")

void input(vector<int> x, auto n){
   rep(i,n)cin >> x[i];
}

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

    int mi = 1000000, ma = -1000000; 
    ll sum = 0;

    rep(i,n){
        int a;
        cin >> a;
        mi = min(mi,a);
        ma = max(ma,a);
        sum += a;
    }

    cout << mi << " " << ma << " " << sum << endl;
}


Measured memory_bytes: 3040
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int X =sc.nextInt();
        if(K*500>=X){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 25172
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	m := nextInt()
	c := nextInt()
	blist := make([]int, m)
	for i := 0; i < m; i++ {
		blist[i] = nextInt()
	}
	amat := nextIntMat(n, m)

	cnt := 0
	for i := 0; i < n; i++ {
		sum := c
		for j := 0; j < m; j++ {
			sum += amat[i][j] * blist[j]
		}
		if sum > 0 {
			cnt++
		}
	}

	fmt.Println(cnt)

}

func nextIntMat(a int, b int) [][]int {
	mat := make([][]int, a)
	for i := 0; i < a; i++ {
		mat[i] = make([]int, b)
		for j := 0; j < b; j++ {
			mat[i][j] = nextInt()
		}
	}
	return mat
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1788
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <deque>
#define $ ios::sync_with_stdio(0);
using namespace std;
typedef long long ll;

struct sa
{
    char ch[100];
    int f;
    int x;
}p[200];
int cmp(sa a,sa b)
{
    if(strcmp(a.ch,b.ch)>0)
        return a.ch>b.ch;
    if(strcmp(a.ch,b.ch)<0)
        return a.ch<b.ch;
    if(strcmp(a.ch,b.ch)==0)
        return a.f>b.f;
}
int main()
{
    int n;
    $
    while(scanf("%d",&n)!=-1)
    {
        memset(p,0,sizeof(p));
        for(int i=1;i<=n;i++)
            scanf("%s %d",p[i].ch,&p[i].f),p[i].x=i;
        sort(p+1,p+n+1,cmp);
        for(int i=1;i<=n;i++)
            printf("%d\n",p[i].x);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <numeric>
using namespace std;
#define ll long long int
#define ld long double
#define vi vector<ll>
#define di deque<ll>
#define vvi vector<vi>
#define vs vector<string>
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define fs first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
#define mxn (ll)1e5
#define INF = 1e18L + 5;
int main(){
    ll n,m,x;
    cin>>n>>m>>x;
    bool f = false;
    vvi v(n,vi(m+1));

    for(ll i=0;i<n;i++){
        for(ll j=0;j<(m+1);j++){
            cin>>v[i][j];
        }
    }
    ll cost = 1e18;

    for(ll i=0;i<(pow(2,n));i++){

        ll t = i;
        vi p(m+1,0);
        //cout<<i<<" | ";
        for(ll j=0;j<n;j++){
            //cout<<(t%2)<<" ";
            if(t%2){

                for(ll k=0;k<(m+1);k++){
                    p[k] += v[j][k];
                }

            }
            t /= 2;
        }
//        cout<<endl;
//
//        for(ll j=0;j<(m+1);j++){
//            cout<<p[j]<<" ";
//        }
//        cout<<endl;

        bool c = true;

        for(ll j=1;j<(m+1);j++){
            if(p[j]<x){
                c = false;
            }
        }

        if(c){
            f = true;
            if(!f){
                cost = p[0];
            }
            else{
                if(p[0]<cost){
                    cost = p[0];
                }
            }
        }

    }

    if(f){
        cout<<cost<<endl;
    }
    else{
        cout<<"-1"<<endl;
    }

}

Measured memory_bytes: 3352
// Aizu Vol-2 0228: Seven Segments
// 2017.8.6

#include <stdio.h>

char p[10][7] = {
	{ 1,1,1,1,1,1,0 }, { 0,1,1,0,0,0,0 }, { 1,1,0,1,1,0,1 }, { 1,1,1,1,0,0,1 }, { 0,1,1,0,0,1,1 },
	{ 1,0,1,1,0,1,1 }, { 1,0,1,1,1,1,1 }, { 1,1,1,0,0,1,0 }, { 1,1,1,1,1,1,1 }, { 1,1,1,1,0,1,1 } };

int main()
{
	int n, d;
	int i, j, k;
	char a[7];

	while (1) {
		scanf("%d", &n); if (n < 0) break;
		for (j = 0; j < 7; j++) a[j] = 0;
		for (i = 0; i < n; i++) {
			scanf("%d", &d);
			for (j = 6; j >= 0; j--) {
				k = (a[j] ^ p[d][j]) & 1, putchar(k + '0');
				if (k) a[j] = !a[j];
			}
			putchar('\n');
		}
	}
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const double INF=(1e20);
const int maxn=(1e5)+10;
int n; char s[10];
int id[300],a[maxn];
int x[maxn],y[maxn];
double xmx,xmn,ymx,ymn;
int fx[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
double solve(double mid) {
	xmx=ymx=-INF; xmn=ymn=INF;
	double A,B;
	for (int i=1;i<=n;i++) {
		A=x[i],B=y[i];
		if (a[i]==0) A+=mid;
		else if (a[i]==1) A-=mid;
		else if (a[i]==2) B+=mid;
		else B-=mid;
		xmx=max(xmx,A);
		xmn=min(xmn,A);
		ymx=max(ymx,B);
		ymn=min(ymn,B);
	//	printf("%.2lf %.2lf\n",A,B);
	}
	return (xmx-xmn)*(ymx-ymn);
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	id['R']=0; id['L']=1;
	id['U']=2; id['D']=3;
	for (int i=1;i<=n;i++) {
		read(x[i]),read(y[i]);
		scanf("%s",s+1);
		a[i]=id[s[1]];
	}
	double l=0,r=(1e10),m1,m2,len;
	for (int i=1;i<=1000;i++) {
		len=(r-l)/3;
		m1=l+len; m2=l+2*len;
		if (solve(m1)<solve(m2)) r=m2;
		else l=m1;
	}
	printf("%f\n",solve(l));
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
int main (void){
	int n=0;
	scanf("%d",&n);
	int num[n];
	for(int i=0;i<n;i++){
		scanf("%d",&num[i]);
	}

	for(int i=n-1;i>0;i--){
		printf("%d ",num[i]);
	}
	printf("%d",num[0]);

	printf("\n");
}



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

#define for_(i,a,b) for(int i=a;i<b;++i)

int main() {
	int A = 0, B = 0, a;
	for_(i,0,4) scanf("%d", &a), A += a;
	for_(i,0,4) scanf("%d", &a), B += a;
	printf("%d\n",max(A,B));
	return 0;
}

Measured memory_bytes: 1184
def base_10_to_n(X, n):
    if (int(X/n)):
        return base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

li = list(map(int, input().split()))
ans = len(base_10_to_n(li[0], li[1]))
print(ans)

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define vi vector<int>

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N = 10;
int f[N];
int main(){
	int x, y, z, w;
	cin >> x>> y >> z >> w;
	f[x]++; f[y]++; f[z]++; f[w]++;
	if(f[1] != 1 || f[9] != 1 || f[7] != 1 || f[4] != 1){
		cout << "NO"<<endl;
	}
	else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

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

    ll A, B; cin >> A >> B;
    ll g = gcd(A, B);
    if (g == 1) {
        cout << 1 << '\n';
        return 0;
    }
    map<ll,ll> ps = prime_factor(g);
    cout << ps.size()+1 << '\n';
    // for (auto it = ps.begin(); it != ps.end(); ++it) { cout << it->first << ": " << it->second << endl; }

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>


//二次元の累積和で実装もしよう　以下
/*

500*500の二次元グリッド
列車をプロットしていく
終着点の座標を固定して累積和を取っていく
始点は動かさない
*/
int main(void){
    int N,M,Q,counter = 0;
    int i,j;
    scanf("%d %d %d",&N,&M,&Q);
    int L[M],R[M],p[Q],q[Q];
    int grid[N+1][N+1];
    for(i=0;i<=N;i++){
        for(j=0;j<=N;j++){
            grid[i][j] = 0;
        }
    }
    for(i=0;i<M;i++){
        scanf("%d %d",&L[i],&R[i]);
        grid[L[i]][R[i]]++;
    }
    for(i=1;i<=N;i++){
        for(j=1;j<=N;j++){
            grid[i][j] += grid[i][j-1];
        }
    }
    for(i=0;i<Q;i++){
        scanf("%d %d",&p[i],&q[i]);
    }
    for(i=0;i<Q;i++){
        for(j=p[i];j<=q[i];j++){
            counter += grid[j][q[i]]-grid[j][p[i]-1];
        }
        printf("%d\n",counter);
        counter = 0;
    }
    return 0;
}

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

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

const int mod = 1e9 + 7;
int dp[64][3];

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

  dp[0][0] = 1;
  rep(i, 63) rep(j, 3) rep(a, 2) rep1(b, a, 2) {
    (dp[i + 1][(1 + a + b + j - (n >> i & 1)) >> 1] += dp[i][j]) %= mod;
  }

  cout << dp[63][0] << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long const MOD = 1000000007LL;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int d = a - b;
    if (d < c) cout << c - d << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
  int n;
  string input;

  while (true) {
    cin >> n;
    if (n == 0) { break; }

    int count = 0, left = 0, right = 0, last = 0;

    for (int i = 0; i < n; i++) {
      cin >> input;
      if      (input == "lu" && left == 0)  { left = 1; }
      else if (input == "ru" && right == 0) { right = 1; }
      else if (input == "ld" && left == 1)  { left = 0; }
      else if (input == "rd" && right == 1) { right = 0; }

      if (last == 0 && left == 1 && right == 1) { last = 1; count++; }
      if (last == 1 && left == 0 && right == 0) { last = 0; count++; }
    }

    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<string> b;
    for(int i=0;i<n;i++){
    	string S;
    	cin >> S;
        b.push_back(S);
        //cin >> b.at(i);
    }
    int m;
    cin >> m;
    vector<string> r;
    for(int i=0;i<m;i++){
    	string S;
        cin >> S;
        r.push_back(S);
        //cin >> r.at(i);
    }
    int ans=0;

    for(int i=0;i<n;i++){
        int sum=0;

        for(int j=0;j<n;j++){
            if(b.at(i)==b.at(j)){
                ++sum;
            }
        }
        for(int j=0;j<m;j++){
            if(r.at(j)==b.at(i)) {
                --sum;
            }
        }
        if(ans<sum) 
            ans=sum;
    }
    
    cout << ans << endl;
    return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A[int(1e5 + 5)];

int main(){
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A, A + N);

  int M = 0, ans = 0;
  for (int i = 0; i < N - 1; i++){
    int now = min(abs(A[N-1] - A[i]), A[i]);
    if (M < now){
      ans = A[i]; M = now;
    }
  }
  cout << A[N-1] << " " << ans << endl;


  return 0;
}


Measured memory_bytes: 3968
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a=0,b=0,c=0,d,n=0,x=0;
    VI m(3);
    string s,s1,s2;
    cin >> a >> b >> c >> d;
    cout << a*b - c*b - d*a + c*d << endl;
    return 0;
} 

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

int main() {
    int A, B, K; cin >> A >> B >> K;
    for (int i = min(A, B); i >= 1; --i) {
        if (A % i == 0 && B % i == 0) {
            --K;
            if (K == 0) {
                cout << i << endl;
                return 0;
            }
        }
    }
    assert(false);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

struct s{
  int a;
  int b;
  double c;
};

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int a,b,c;
  cin >> a >> b >> c;
  if((a == b && a != c) || (a == c && a != b) || (b == c && b != a)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256