akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <atcoder/all>
#include <iostream>
using namespace std;
using namespace atcoder;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 998244353;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

struct Segtree {
    vector<int> data;
    int sz;
    
    Segtree(vector<int>& a) {
        int n = a.size();
        sz = 1;
        while (sz < n) {
            sz *= 2;
        }
        sz *= 2;
        data.resize(sz, 0);
        REP(i, n) {
            update(i, a[i]);
        }
    }

    int getval(int left, int right) {
        return getval_dfs(left, right, 0, sz/2, 0);
    }

    void update(int n, int val) {
        n += sz/2 - 1;
        while (true) {
            data[n] = max(data[n], val);
            if (n == 0) break;
            n = paridx(n);
        }
    }

    private:
    int paridx(int n) {
        return (n - 1) / 2;
    }
    int leftidx(int n) {
        return n*2 + 1;
    }
    int rightidx(int n) {
        return n*2 + 2;
    }
    int getval_dfs(int left, int right, int lbd, int rbd, int nownode) {
        if (right <= lbd) return 0;
        if (rbd <= left) return 0;
        if (left <= lbd && rbd <= right) {
            return data[nownode];
        } else {
            int vl = getval_dfs(left, right, lbd, (lbd + rbd) / 2, leftidx(nownode));
            int vr = getval_dfs(left, right, (lbd + rbd) / 2, rbd, rightidx(nownode));
            return max(vl, vr);
        }
    }

};

void solve() {
    int n,k;
    cin >> n >> k;
    vint a(n);
    cin >> a;
    vint tmp(300001,0);
    Segtree st(tmp);
    /* map<int, int> ma; */
    /* vint memo(n,1); */
    /* ma[a[0]] = 0; */
    int ans = 1;
    REP(i,n) {
        int nowval= a[i];
        int maxv = st.getval(nowval - k, nowval + k + 1);
        ans = max(ans, maxv + 1);
        st.update(a[i], maxv + 1);
    }
    cout << ans << endl;
}


int main() {
    solve();
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}



Measured memory_bytes: 9596
import copy
import heapq
import math
import fractions

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printmultiplerow(a):
    for i in a:
        print(i)
def printrow(a):
    for i in range(len(a)-1):
        print(a[i],end = " ")
    print(a[-1])



n = ip()
a = iprow()
for i in range(n):
    a[i]//=400
any = 0
for i in range(n):
    if a[i] >=8:
        a[i]=-1
        any+=1
for i in range(n-1,-1,-1):
    if a[i]==-1:
        a.pop(i)
l = len(set(a))
print(max(1,l),l+any)


Measured memory_bytes: 5344
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  vector<string> s(3);
  rep(i,3) cin >> s[i];
  rep(i,3) cout << s[i][i]; cout << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] tn = in.nextIntArray(n);
			int[] vn = in.nextIntArray(n);
			int T = 0;
			for (int i = 0;i < n; i++) T += tn[i];

			int m = 2 * T + 1;

			double[] maxV = new double[m];
			Arrays.fill(maxV, Double.MAX_VALUE);
			int prt = 0;
			for (int i = 0; i < n; i++) {
				for (int k = 0 ; k <= 2 * tn[i]; k++, prt++) {
					maxV[prt] = Math.min(vn[i], maxV[prt]);
				}
				prt--;
			}

			maxV[0] = 0;
			for (int i = 0; i < m - 1; i++) {
				maxV[i+1] = Math.min(maxV[i] + 0.5, maxV[i+1]);
			}

			maxV[m - 1] = 0;
			for (int i = m - 1; i > 0; i--) {
				maxV[i-1] = Math.min(maxV[i] + 0.5, maxV[i-1]);
			}

			double sum = 0;
			for (int i = 0; i < m - 1; i++) {
				sum += (maxV[i+1] + maxV[i]) * 0.5 / 2;
			}
			out.println(String.format("%.12f", sum));

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21844
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
#define intmax 2147483647
#define intmin -2147483647
#define llmax 9223372036854775807
using namespace std;

int n, mx, a[2][100];

int main(){
	cin >> n;
	mx = 0;
	lp(n)
		cin >> a[0][i];
	lp(n)
		cin >> a[1][i];
	lp(n - 1)
		a[0][i + 1] += a[0][i];
	lp(n - 1)
		a[1][n - 2 - i] += a[1][n - 1 - i];
	lp(n)
		mx = max(mx, a[0][i] + a[1][i]);
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)

    val n, m = scanner.nextInt
    val a = Array.fill(n)(new Array[Int](m))
    val b = new Array[Int](m)

    for(i <- 0 until n) {
      for(j <- 0 until m) {
        a(i)(j) = scanner.nextInt
      }
    }
    for(i <- 0 until m) {
      b(i) = scanner.nextInt
    }

    for(i <- 0 until n) {
      println((a(i) zip b).foldLeft(0){ case (s, t) => s + t._1 * t._2 })
    }
  }
}


Measured memory_bytes: 59820
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N;

int digit(int n){
  int ans = 0;
  while(n > 0){
    ans += n % 10;
    n /= 10;
  }
  return ans;
}
int main(){
  cin >> N;
  if(N % digit(N) == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

using namespace std;

int n , m;
vector<int> point, points;

int main()
{
	int c;
	while(cin >> n >> m){
		if(n == 0, m == 0) break;
		point.push_back(0);

		for(int i = 0; i < n; i++)
		{
			cin >> c;
			point.push_back(c);
		}

		n++;

		for(int i = 0; i < n; i++)
		{
			for(int j = i; j < n; j++)
			{
				points.push_back(point[i]+point[j]);
			}
		}
		int ans = 0, left, right, mid;

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

		for(int i = 0; i < points.size(); i++)
		{
			left = 0;
			right = points.size();

			int temp = m - points[i];

			if(temp < 0) continue;

			while(right - left > 1)
			{
				mid = (right + left) / 2;
				if(temp < points[mid]) right = mid;
				else if(temp > points[mid]) left = mid;
				else if(temp == points[mid]) break;
			}
			ans = max(ans, points[i] + points[left]);
		}
		cout << ans << endl;
		point.clear();
		points.clear();
	}
}

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

int main(void)
{
    int n;
    int a[50], b[50], c[50];
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    for (int i = 0; i < n - 1; i++)
    {
        cin >> c[i];
    }
    int sum = 0;
    int pre = 0;
    for (int i = 0; i < n; i++)
    {
        if (pre+1 == a[i] && i != 0)
        {
            sum += c[pre - 1];
        }
        sum += b[a[i] - 1];
        pre = a[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		// スペース区切りの整数の入力
		for(int i=1;i<=a;i++){
			list.add(sc.nextInt());
		}

		Optional<Integer> min = list.stream()
		.min((c, b) -> c.compareTo(b));
		Optional<Integer> max = list.stream()
		.max((c, b) -> c.compareTo(b));

		System.out.println(max.get()-min.get());
	}
}

Measured memory_bytes: 27092
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        long min = Integer.MAX_VALUE;
        for (int i = 1 ; i < h ; i++) {
            long a = (long) i * w;
            if ((h - i) % 2 == 0) {
                long b = (long) (h - i) * w / 2;
                min = Math.min(min, Math.abs(a - b));
            } else {
                long b = (long) (h - i  - 1) * w / 2;
                long c = (long) ((h - i + 1) / 2 ) * w ;
                min = Math.min(min, Math.max(a, c) - Math.min(a, b));
            }
            if (w % 2 == 0) {
                long b = (long) (h - i) * w / 2;
                min = Math.min(min, Math.abs(a - b));
            } else {
                long b = (long) (h - i) * (w - 1) / 2;
                long c = (long) (w + 1)* (h - i) / 2;
                min = Math.min(min, Math.max(a, c) - Math.min(a, b));
            }
        }

        for (int i = 1 ; i < w ; i++) {
            long a = (long) i * h;
            if ((w- i) % 2 == 0) {
                long b = (long) (w - i) * h / 2;
                min = Math.min(min, Math.abs(a - b));
            } else {
                long b = (long) (w - i - 1) * h / 2;
                long c = (long) ((w - i + 1) / 2) * h;
                min = Math.min(min, Math.max(a, c) - Math.min(a, b));
            }
            if ( h % 2 == 0) {
                long b = (long) (w - i) * h / 2;
                min = Math.min(min, Math.abs(a - b));
            } else {
                long b = (long) (w - i) * (h - 1 ) / 2;
                long c = (long) (w - i) * (h+ 1) / 2;
                min = Math.min(min, Math.max(a, c) - Math.min(a, b));
            }
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 24020
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
using namespace std;

long long anss,anst;
string s;
int main()
{
    cin>>s;
    for (int i=0; i<s.size(); i++){
        if(s[i]=='S') anss++;
        else {
            anst++;
            if(anss) anss--,anst--;
        }
    }
    cout<<anss+anst<<endl;
    return 0;
}

Measured memory_bytes: 640
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
l = inp.shift().split(' ')
a = l[0] * 1
b = l[1] * 1 
sum = 1
d = b - a
for (i=2; i<=999; i++) {
    s = sum + i
    if (d == s - sum) {
        ans = sum - a
        break;
    }
    sum = s
}
console.log(ans)

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

class RMQ{
public:
  int n;
  P dat[555555];
  void init(int _n){
    n=1;
    while(n<_n)n*=2;
    rep(i,2*n) dat[i]=P(MAX,-1);
  }
  void update(int k,P a){
    k+=n-1;dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
  }
  P query(int a,int b){return query(a,b,0,0,n);}
  P query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return P(MAX,-1);
    if(a<=l&&r<=b) return dat[k];
    P vl=query(a,b,k*2+1,l,(l+r)/2);
    P vr=query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
};

RMQ r;
void Main() {
  ll n,m,k;
  cin >> n >> m >> k;
  ll a[n];
  rep(i,n) R a[i];
  set<int> s;
  rep(i,n) s.in(a[i]);
  s.in(0);
  int ans=MAX;
  tr(it,s) {
    r.init(n);
    int x=0;
    priority_queue<int,vector<int>,greater<int> > que[n];
    rep(i,n) {
      if(a[i]<=*it) x=i+1;
      else que[x].push(a[i]);
    }
    int cnt=0;
    rep(i,n) {
      if(que[i].size()>=m) {
        r.update(i,P(que[i].top(),i));
        cnt+=que[i].size()-m+1;
      }
    }
    if(cnt<k) break;
    int Mi=MAX,Ma=-MAX;
    rep(i,k) {
      P p=r.query(0,n);
      Mi=min(Mi,p.F);
      Ma=max(Ma,p.F);
      que[p.S].pop();
      if(que[p.S].size()>=m) r.update(p.S,P(que[p.S].top(),p.S));
      else r.update(p.S,P(MAX,-1));
    }
    ans=min(ans,Ma-Mi);
  }
  pr(ans);
}

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


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> p(5);
  vector<int> r(5);
  for (int i=0; i<5; i++){
    cin >> p[i];
    r[i] = p[i] % 10; //rに１０で割ったあまりを代入
    if (r[i]==0) {
      r[i]=10; //あまりが0なら１０に
      p[i] -= 10; //便宜上あまりが０なら10引いておく（後で足すことになるから）
    }
  }
  int count=0;
  for (int i=0; i<5; i++){
    count += (p[i] / 10)*10 + 10;
  }
  sort(r.begin(),r.end());
  count -= 10-r[0];
  cout << count << endl;
}


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

int main(){
  int n;
  cin >> n;
  map<string,int> mp;

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

  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
  
}

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

void Main()
{
	int N, Y; cin >> N >> Y;
	rep(x, 2001) {
		int tmp = Y / 1000 - N - 9 * x;
		if (tmp % 4 == 0) {
			int y = tmp / 4;
			int z = N - x - y;
			if (y >= 0 && z >= 0) {
				cout << x << " " << y << " " << z << endl;
				return;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
    LL ans = 0;
    vector<pair<LL, int>> memo;

    REP(i, N) memo.PB(MP(A[i], 1));

    REP(i, M) memo.PB(MP(C[i], B[i]));

    sort(ALL(memo), greater<pair<LL, int>>());
    REP(i, memo.size()) {
        if(N < memo[i].second) {
            ans += memo[i].first * N;
            break;
        }

        ans += memo[i].first * memo[i].second;
        N -= memo[i].second;
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(M);
    std::vector<long long> C(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
    }
    solve(N, M, std::move(A), std::move(B), std::move(C));
    return 0;
}


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

public class Main{

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

	public static void solve(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0){
				break;
			}
			int[] a = new int[n];
			for(int i=0;i<n;i++){
				a[i] = sc.nextInt();
			}
			Arrays.sort(a);
			int ans = Integer.MAX_VALUE/2;
			for(int i=1;i<n;i++){
				ans = Math.min(ans,a[i]-a[i-1]);
			}
			System.out.println(ans);
		}	
	}
}

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

int main() {
	ll n,k;
	cin>>n>>k;
	ll arr[n];
	for(ll i=0;i<n;i++){
		cin>>arr[i];
	}
	ll i=0;
	ll itr=n-k;
	while(itr-- ){
		if(arr[k+i]>arr[i]){
			cout<<"Yes"<<"\n";
		}
		else{
			cout<<"No"<<"\n";
		}
		i++;
		}
	return 0;
}

Measured memory_bytes: 5152
#include<stdio.h>
int main(){
    int i, j, l, d, N, k, count=0;
    int snuke[101], A[101];
    scanf("%d%d", &N, &k);
    j=k;
    for(i=1;i<=N;i++)
        snuke[i]=i;
    while(j>0){

        {
            scanf("%d", &d);
            for(i=1; i<=d; i++)
                scanf("%d", &A[i]);
            for(i=1; i<=d; i++){
                l=A[i];
                snuke[l]=0;
            }
        }
    j--;
    }
    for(i=1; i<=N; i++){
        if(snuke[i]!=0)
            count++;
    }
    printf("%d\n", count);
    //for(i=1; i<=N; i++)
    //    printf("%d ",snuke[i]);
    return 0;
}

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

ll gcd(ll a,ll b){
  if(b==0) return a;
  return gcd(b,a%b);
}

int main(){
  ll a,b; cin>>a>>b;
  ll ans=1,x= gcd(a,b),y=x;
  for(ll i=2;i*i<=x;i++){
    if(y%i==0){
      ans++;
      while(y%i==0){
        y/=i;
      }
    }
  }if(y>1) ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
using namespace std;
int main(){
    long long X,N,titen,count;
    long long A[1003];
    count=1;
    titen=0;
    cin >> N >>X;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int k=0;k<N;k++){
        titen=titen+A[k];
        
        if(titen>X){
            break;
        
        }
        count++;
    }
    cout << count <<endl;
}



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

import heapq

A = [] # heapの初期値はリストで持たせておく

while True:
    com = input()
    if com[:2] == 'en':
        break
    if com[0] == 'i':
        _, key = com.split()
        key = -int(key)  # min-ヒープになるので、-1をかけることで解決する。
        heapq.heappush(A, key)
    else:
        print(-heapq.heappop(A)) # 出力するときも-1かけるのを忘れずに


Measured memory_bytes: 45564
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>

//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)

LL h, w, n, m, k, t, s, p,q, last, cnt, sum, ans, dp[2000][2000], a[20000], b[20000];
string str, ss;
bool f[1100][1100];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
bitset<4400000>bi;
vector<Edge>vec;
vector<LL>v;
map<string, vector<LL>>ma;
multiset<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	bi[0] = 1;
	rep(i, n) {
		bi |= bi << (a[i]);
	}
	while(1) {
		if (bi[(sum + 1) / 2 + k]) {
			cout << (sum + 1) / 2 + k << endl;
			break;
		}
		k++;
	}
	return 0;
}


Measured memory_bytes: 3328
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AGC
{
    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 count(string s)
        {
            long cnt = 0;
            long num = 0;
            for (var i = 0; i < s.Length - 1; ++i)
            {
                if (s[i] == s[i + 1])
                { ++cnt; }
                else
                {
                    num += (cnt + 1) / 2;
                    cnt = 0;
                }
            }
            num += (cnt + 1) / 2;
            return num;

        }
        static void Main(string[] args)
        {
            var s = ReadLine();
            var k = Sarray()[0];
            if (s.First() != s.Last())
                WriteLine(k * count(s));
            else
            {
                if (s.Length == s.Count(c => c == s[0]))
                    WriteLine((k * (long)s.Length) / 2L);
                else
                {
                    var idx = 0;
                    for (var i = 0; i < s.Length; ++i)
                        if (s[0] != s[i])
                        {
                            idx = i;
                            break;
                        }
                    WriteLine(count(s.Substring(idx, s.Length - idx) + s.Substring(0, idx)) * (k - 1) + count(s));
                }
            }
        }
    }
}


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

using namespace std;
const int mod = 1e9 + 7;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for(long long i = 0;i < n;i++)
int main()
{
  long long N;
  int A[300000];
  long long  sum=0;
  long long  ans=0;
  cin>>N;
  REP(i,N){
    cin>>A[i];
    sum+=A[i];
  }
  //cout<<ans<<endl;
  for(int i = 0;i < N;i++){
    sum-=A[i];
    ans=(A[i]*(sum%mod)+ans)%mod;
  //cout<<ans<<endl;
  }
  cout<<ans;
  return 0;
}




Measured memory_bytes: 4364
import java.util.*;
import java.util.stream.*;

class Main {
	Scanner sc;
	int N, M, K;
	List<Integer>[] to;
	int[] group;
	int[] blocks;
	Map<Integer, Integer> groupNum;
	
	@SuppressWarnings("unchecked")
	void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		K = sc.nextInt();
		
		to = new List[N];
		for (int i = 0; i < N; i++) to[i] = new ArrayList<>();
		for (int i = 0; i < M; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			to[a].add(b);
			to[b].add(a);
		}
		groupNum = new HashMap<>();
		group = new int[N];
		for (int from = 0; from < N; from++) {
			if (group[from] > 0) continue;
			dfs(from, from+1);
		}
		blocks = new int[N];
		for (int i = 0; i < K; i++) {
			int c = sc.nextInt() - 1;
			int d = sc.nextInt() - 1;
			if (group[c] == group[d]) {
				blocks[c]++;
				blocks[d]++;
			}
		}
		String ans =
			IntStream.range(0, N)
				.map(i -> groupNum.get(group[i])-1-blocks[i]-to[i].size())
				.mapToObj(n -> String.valueOf(n))
				.collect(Collectors.joining(" "));
		
		System.out.println(ans);
	}
	
	private void dfs(int from, int g) {
		group[from] = g;
		for (int v : to[from]) {
			if (group[v] > 0) continue;
			dfs(v, g);
		}
		groupNum.put(g, groupNum.getOrDefault(g, 0) + 1);
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


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

int main() {
    char X, Y;
    cin >> X >> Y;
    if (X < Y) {
        cout << "<\n";
    }
    else if (X > Y) {
        cout << ">\n";
    }
    else{
        cout << "=\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }

void yes() { cout << "Yay!\n"; }
void no() { cout << ":(\n"; }

int main() {
    init();

    int n; cin >> n;
    eFOR(i, 1, n) {
        if (int(i * double(1.08)) == n) {
            cout << i << "\n";
            return 0;
        }
    }
    no();
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
sum = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if L[i] != L[j] and L[i] != L[k] and L[j] != L[k] and L[i]+L[j] > L[k] and L[i]+L[k] > L[j] and L[k]+L[j] > L[i]:
                sum += 1
print(sum)

Measured memory_bytes: 9200
#include<cstdio>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	double sum=0;
	for(int i=0;i<n;i++)
	{
		double num;
		scanf("%lf",&num);
		num=1/num;
		//printf("%lf\n",num);
		sum+=num;
	}
	printf("%lf",1/sum);
}

Measured memory_bytes: 256
s = str(input())
w="SUN"
x="MON"
c="TUE"
v="WED"
b="THU"
n="FRI"
if w == s:
    ans = 7
elif x == s:
    ans = 6
elif c == s:
    ans = 5
elif v == s:
    ans = 4
elif b == s:
    ans = 3
elif n ==s:
    ans = 2
else:
    ans = 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <limits.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
#define INF LLONG_MAX/3
#define inf INT_MAX/3
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
bool prime(int p) {
	for (int i = 2;i <= sqrt(p);i++) {
		if (p%i == 0)return false;
	}
	return true;
}
int modpow(int a, int b) {
	if (b == 0)return 1;
	if (b == 1)return a % MOD;
	if (b % 2)return modpow(a, b - 1)*a%MOD;
	else return modpow(a, b / 2)*modpow(a, b / 2) % MOD;
}
int comb(int a, int b) {
	if (b == 0 || a == b)return 1;
	if (b == 1)return a % MOD;
	return (comb(a - 1, b - 1) + comb(a - 1, b)) % MOD;
}
// Library End !
int n;
P p[100000];
int main() {
	cin >> n;
	rep(i, n)cin >> p[i].first >> p[i].second;
	sort(p, p + n);
	cout << p[n-1].first + p[n - 1].second << endl;
	return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    lint N, M, X;
    cin >> N >> M >> X;
    vector<vector<lint>> G(N, vector<lint>(M + 1, 0));
    rep(i, N) rep(j, M + 1) { cin >> G[i][j]; }
    // ddump(G);
    lint mi = 1e14;
    bool c  = false;
    for (int bits = 0; bits < (1 << N); bits++) {
        vector<lint> A(M, 0);
        lint sum = 0;
        for (int i = 0; i < N; i++) {
            if (bits & (1 << i)) {
                sum += G[i][0];
                for (int j = 0; j < M; j++) {
                    A[j] += G[i][j + 1];
                }
            }
        }
        bool ok = true;
        for (int j = 0; j < M; j++) {
            if (A[j] < X) { ok = false; }
        }
        if (ok) {
            mi = min(mi, sum);
            c  = true;
        }
    }
    if (!c) {
        cout << -1 << endl;
    } else {
        cout << mi << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
S=gets.chomp
Sd="keyence"
pointer1=0
for i in 0...S.size do
    if Sd[pointer1]==S[i] then 
        pointer1+=1
        if pointer1==7 then break end
    else break end
end
pointer2=S.size-1
c=0
(S.size-1).downto(0) do |i|
    if Sd[6-c]==S[i] then 
        c+=1
        if c==7 then break end
    else break end
end 
if pointer1+c>=7 then puts "YES" else puts "NO" end


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
// #define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int n; cin >> n;
    int res = 0;
    rep1(i, n){
        string s; s = to_string(i);
        int cnt = s.size();
        if(cnt%2) res++;
    }
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7816
//Optimise
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// #define MULTI_TEST
#ifdef LOCAL
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
    out << '[' << p.first << ", " << p.second << ']';
    return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
    while (*name == ',' || *name == ' ')
        name++;
    std::cerr << name << " { ";
    for (const auto &v : arg)
        cerr << v << ' ';
    cerr << " }\n";
}
template <typename Arg1, typename... Args>
void PC(const char *names, Arg1 &&arg1, Args &&... args)
{
    while (*names == ',' || *names == ' ')
        names++;
    const char *comma = strchr(names, ',');
    std::cerr.write(names, comma - names) << " { ";
    for (const auto &v : arg1)
        cerr << v << ' ';
    cerr << " }\n";
    PC(comma, args...);
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
    std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    std::cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define f first
#define s second
#define pb push_back
auto TimeStart = chrono::steady_clock::now();

const int NAX = 2e5 + 10, MOD = 1000000007;

void solveCase(int caseNo)
{
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    switch (m1)
    {
    case 1:
        cout << (d1 == 31) << '\n';
        break;
    case 2:
        cout << (d1 == 28) << '\n';
        break;
    case 3:
        cout << (d1 == 31) << '\n';
        break;
    case 4:
        cout << (d1 == 30) << '\n';
        break;
    case 5:
        cout << (d1 == 31) << '\n';
        break;
    case 6:
        cout << (d1 == 30) << '\n';
        break;
    case 7:
        cout << (d1 == 31) << '\n';
        break;
    case 8:
        cout << (d1 == 31) << '\n';
        break;
    case 9:
        cout << (d1 == 30) << '\n';
        break;
    case 10:
        cout << (d1 == 31) << '\n';
        break;
    case 11:
        cout << (d1 == 30) << '\n';
        break;
    case 12:
        cout << (d1 == 31
        ) << '\n';
        break;
    default:
        break;
    }
}

int main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
#ifdef MULTI_TEST
    cin >> t;
#endif
    for (int i = 1; i <= t; ++i)
    {
        solveCase(i);
#ifdef TIME
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}

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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int N, min_mod;
  cin >> N >> min_mod;
  int ans = 0;
  if(min_mod == 0) {
    cout << N*N << endl;
    return 0;
  }
  REPS(i,min_mod+1,N+1) {
    ans += (N/i) * (i-min_mod);
    ans += max(0LL, (N % i) - min_mod + 1);
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
import Control.Applicative
import Data.Char
 
main :: IO ()
main = do
    [_, b] <- map read . words <$> getLine
    xs <- getLine
    putStrLn $ solve xs b
    
solve :: String -> Int -> String
solve xs n = (take (n-1) xs) ++ ((toLower (xs !! (n-1))) : (drop n xs) )

Measured memory_bytes: 508
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  int n,k;
  cin>>n>>k;
  ll ans=k;
  rep(i,0,n-1){
    ans*=k-1;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char s[3];
	int i;
	int cnt = 0;

	scanf("%s", s);

	for (i = 0; i < 3; i++) {
		if (s[i] == 'A') cnt++;
	}

	if (cnt == 0 || cnt == 3) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}

	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int x, y;

	while (1)
	{
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0) break;
		else if (x < y)
		{
			printf("%d %d\n", x, y);
		}
		else
		{
			printf("%d %d\n", y, x);
		}

	}
	return 0;

}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    string s;
    cin>>s;
    if(s.size()<26){
        bool used[26]={};
        REP(i,s.size()) used[s[i]-'a']=true;
        REP(i,26) if(!used[i]){
            s.push_back(char(i+'a'));
            break;
        }
        cout<<s<<endl;
        return 0;
    }
    string t=s;
    if(!next_permutation(All(t))) cout<<-1<<endl;
    else{
        int i=0;
        while(i<s.size()&&s[i]==t[i]){
            ++i;
        }
        REP(k,25-i) t.pop_back();
        cout<<t<<endl;
    }
}


Measured memory_bytes: 256
import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
cnt=0
for i in range(n-2):
  a=l[i]
  for j in range(i+1,n-1):
    b=l[j]
    k=bisect.bisect_left(l,a+b)
    cnt+=(k-j-1)
print(cnt)
    


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    ll A, B, ans = 0;
    cin >> A >> B;
    ll n = __gcd(A, B);
    ll s = floor(sqrt(n));
    for (int i = 2; i <= s; i++)
    {
        if (n % i == 0)
        {
            while (n % i == 0)
            {
                n /= i;
            }
            ans++;
        }
    }
    if (n > s)
    {
        ans++;
    }
    cout << ans + 1;
    return 0;
}

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

using namespace std;

const int maxn=1e5+5;

int h,s[maxn];

int parent(int i)
{
    return i/2;
}

int left(int i)
{
    return i*2;
}

int right(int i)
{
    return i*2+1;
}

int main()
{
    scanf("%d",&h);
    for(int i=1;i<=h;i++){
        scanf("%d",&s[i]);
    }
    for(int i=1;i<=h;i++){
        cout<<"node "<<i<<": key = "<<s[i]<<", ";
        if(parent(i)>=1){
            cout<<"parent key = "<<s[parent(i)]<<", ";
        }
        if(left(i)<=h){
            cout<<"left key = "<<s[left(i)]<<", ";
        }
        if(right(i)<=h){
            cout<<"right key = "<<s[right(i)]<<", ";
        }
        cout<<endl;
    }
    return 0;
}
/*
5
7 8 1 2 3
*/



Measured memory_bytes: 3136
N = int(input())
ans = len(str(N))
for i in range(1,int(N**0.5)+1):
    if N % i == 0:
        #print(i)
        #print("leng",len(str(N/i)))
        #print(ans,len(str(i)),len(str(N//i)),len(str(int(N/i))))
        ans = min(ans,max(len(str(i)),len(str(N//i))))
print(ans)


Measured memory_bytes: 9244
//#include<bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <list>
#include <climits>
#include <bitset>

/*
Not easy to be successful,Dont give up
*/

using namespace std;
#define all(v)          ((v).begin()), ((v).end())
#define pb push_back
#define Compiler_Beso ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define clr(v,d)        memset(v, d, sizeof(v))
#define endl '\n'
const double EPS = 1e-12;
typedef long long ll;
const double PI = 3.14159265359;
enum dir       { DOWN = 0, UP, RIGHT, LEFT, DOWN_RIGHT, DOWN_LEFT, UP_RIGHT, UP_LEFT };
int  dir_r[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int  dir_c[] = { 0, 0, 1, -1, 1, -1, 1, -1 };

int main()
{
	Compiler_Beso

		int n;
	cin >> n;
	vector<int>x(n+1), y(n+1);
	for (int i = 0; i < n; i++){
		cin >> x[i] >> y[i];
	}
	sort(all(y));
	sort(x.rbegin(), x.rend());
	ll ans = 0;
	for (int i = 0; i < n; i++)
	if (x[i]>y[i])
		ans += 2 * (x[i] - y[i]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
string s,c,ch;
int x,y;
int main(){
    cin>>s>>c;
    in(x);in(y);
    cin>>ch;
    if(ch==s)x--;
    else y--;
    cout<<x<<" "<<y<<endl;
    return 0;
}


Measured memory_bytes: 256