akhauriyash/Code-Regression huggingface dataset:
import java.io.*

val pw = PrintWriter(System.out)
const val MOD = 1000000007L
const val INF = 2147483647
const val LINF = 9223372036854775807L

fun main(args: Array<String>) {
    solve()
    pw.flush()
}

fun solve() {
    val k = nextInt()
    for (i in 0..9){
        val new = i.toString()
        list.add(new)
        make(new, i, 1)
    }
    val list2: MutableList<Long> = mutableListOf()
    for (i in list){
        if(i.first() == '0') continue
        list2.add(i.toLong())
    }
    list2.sort()
    println(list2[k - 1])

}

val list: MutableList<String> = mutableListOf()
fun make(str: String, last: Int,  level: Int) {
    if(level == 11) return
    for(i in last-1..last+1){
        if(i < 0 || i > 9) continue
        val new = str + i.toString()
        list.add(new)
        make(new, i, level + 1)
    }

}


fun println(v: String) {
    pw.println(v)
}

fun print(v: String) {
    pw.print(v)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ").toMutableList()
fun nextIntList(index: Int = 0) = next().split(" ").map { it.toInt() + index }.toMutableList()
fun nextLongList(index: Long = 0L) = next().split(" ").map { it.toLong() + index }.toMutableList()
fun nextDoubleList() = next().split(" ").map { it.toDouble() }.toMutableList()

fun ary(n: Int, init: String = "") = Array(n) { init }
fun intAry(n: Int, init: Int = 0) = IntArray(n) { init }
fun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }
fun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }
fun ary2(n: Int, m: Int, init: String = "") = Array(n) { Array(m) { init } }
fun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }
fun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }
fun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }
fun ary3(n: Int, m: Int, k: Int, init: String = "") = Array(n) { Array(m) { Array(k) { init } } }
fun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }
fun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }
fun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }

fun abs(n: Int): Int = Math.abs(n)
fun abs(n: Long): Long = Math.abs(n)
fun abs(n: Double): Double = Math.abs(n)
fun max(vararg values: Int) = if (values.isEmpty()) -INF else values.max()!!
fun max(vararg values: Long) = if (values.isEmpty()) -LINF else values.max()!!
fun min(vararg values: Int) = if (values.isEmpty()) INF else values.min()!!
fun min(vararg values: Long) = if (values.isEmpty()) LINF else values.min()!!

Measured memory_bytes: 141036
#include <stdio.h>

int main(void)
{
    while(true) {
        int n,res=0;
        bool l=false,r=false,last=false;

        scanf("%d", &n);
        if(!n) break;

        for(int i=0; i < n; i++) {
            char s[3];
            scanf("%s", s);
            if(s[0] == 'l')
                l = !l;
            else
                r = !r;

            if( (l == r) && (l != last) ) {
                last = !last;
                res += 1;
            }
        }
        printf("%d\n", res);
    }
    return 0;
}

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

using namespace std;

using ll = long long;

int d[30][30], c[505][505];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, C;
    cin >> n >> C;
    for (int i = 0; i < C; i++) {
        for (int j = 0; j < C; j++) {
            cin >> d[i][j];
        }
    }

    vector< vector<int> > cnt(3, vector<int>(C, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> c[i][j];
            cnt[(i + j) % 3][c[i][j] - 1]++;
        }
    }

    int ans = 1145141919;
    for (int i = 0; i < C; i++) {
        int tmp1 = 0;
        for (int j = 0; j < C; j++) {
            tmp1 += cnt[0][j] * d[j][i];
        }
        for (int j = 0; j < C; j++) {
            if (j == i) continue;
            int tmp2 = 0;
            for (int k = 0; k < C; k++) {
                tmp2 += cnt[1][k] * d[k][j];
            }
            for (int k = 0; k < C; k++) {
                if (k == i || k == j) continue;
                int tmp3 = 0;
                for (int l = 0; l < C; l++) {
                    tmp3 += cnt[2][l] * d[l][k];
                }
                ans = min(ans, tmp1 + tmp2 + tmp3);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))


    SINT32 T[100001] = {0};
    SINT32 A[100001] = {0};

    SINT64 SUM[100001] = {0};


void quick_sort (SINT64 array[], int left, int right);
void swap_int (int *x,  int *y);
void swap_d (SINT64 *x,  SINT64 *y);
int partition (SINT64 array[], int left, int right);


void swap_int (int *x,  int *y) {
    int temp;
    temp = *x;
    *x = *y;
    *y = temp;
}

void swap_d (SINT64 *x,  SINT64 *y) {
    SINT64 temp;
    temp = *x;
    *x = *y;
    *y = temp;
}
 
int partition (SINT64 array[], int left, int right) {
    int i, j, pivot;
    i = left;
    j = right + 1;
    pivot = left;   // 先頭要素をpivotとする
 
    do {
        do { i++; } while (array[i] < array[pivot]);
        do { j--; } while (array[pivot] < array[j]);
        // pivotより小さいものを左へ、大きいものを右へ
        if (i < j) {
            swap_d(&array[i], &array[j]);
            swap_int(&T[i], &T[j]);
            swap_int(&A[i], &A[j]);
        }
    } while (i < j);
 
    swap_d(&array[pivot], &array[j]);   //pivotを更新
    swap_int(&T[pivot], &T[j]);   //pivotを更新
    swap_int(&A[pivot], &A[j]);   //pivotを更新
    return j;
}
 

void quick_sort (SINT64 array[], int left, int right) {
    int pivot;
    if (left < right) {
        pivot = partition(array, left, right);
        // pivotを境に再帰的にクイックソート
        quick_sort(array, left, pivot-1);
        quick_sort(array, pivot+1, right);
    }
}





SINT32 main() {
    SINT32 a;
    scanf("%d",&a);

    SINT64 ans = 0;


    
    for (SINT32 i = 0; i < a; i++) {
        scanf("%d%d", &T[i],&A[i]);

        SUM[i] = T[i] + A[i];
    }

    quick_sort(SUM, 0, a-1);

    for (SINT32 i = a; i >= 0; i--) {
        if (a % 2 == 0) {
        if ( i % 2 == 1 ) {
            ans = ans + T[i];
        } else {
            ans = ans - A[i];
        }
        } else {
        if ( i % 2 == 0 ) {
            ans = ans + T[i];
        } else {
            ans = ans - A[i];
        }
        }
    }


    printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1664
import sys
class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x


N, M = map(int, input().split())
info = [tuple(map(int, s.split())) for s in sys.stdin.readlines()]
#print(info)

uf = UnionFind(N)

for a, b in info:
    a -= 1; b -= 1
    uf.union(a, b)

ans = min(uf.parents)

print(-ans)

Measured memory_bytes: 50232
N = int(input())
A = [int(i) for i in input().split()]
B = [0]+A[:]+[0]
s = 0
for i in range(N+1):
    s += abs(B[i]-B[i+1])

for i in range(N):
    t = abs(B[i+1]-B[i])+abs(B[i+2]-B[i+1])-abs(B[i+2]-B[i])
    print(s-t)

Measured memory_bytes: 14048
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 5e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	int n, x;
	cin >> n >> x;
	int cur = 0, ans = 1;
	for(int i = 0; i < n; i++)
	{
		int a; cin >> a;
		cur += a;
		if(cur <= x)
			++ans;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    ll n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n), f(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<ll>());
    ll l = -1, r = 1e12;
    while(l + 1 < r) {
        ll mid = (l + r) / 2;
        bool ok = [&](){
            ll s = 0;
            rep(i, n) {
                s += max(0ll, a[i] - mid / f[i]);
            }
            return s <= k;
        }();
        if (ok) r = mid; else l = mid;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3456
#include <cstdio>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int q;
	scanf("%d",&q);
	rep(tt,q){
		int n,cnt=0;
		scanf("%d",&n);
		while(true){
			int d[7]={},tmp=n,i,mx=-1;
			for(i=0;tmp>0;i++){
				d[i]=tmp%10;
				tmp/=10;
			}
			if(i<=1) break;
			for(int j=1;j<i;j++){
				int l=0,r=0;
				rep(k,j) l=10*l+d[j-1-k];
				rep(k,i-j) r=10*r+d[i-1-k];
				mx=max(mx,l*r);
			}
			n=mx;
			cnt++;
		}
		printf("%d\n",cnt);
	}
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
#include <boost/range/adaptor/indexed.hpp>
using namespace std;

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

template <typename T>
std::ostream &operator<<(std::ostream &ostr, const std::vector<T> &v) {
  for (const auto &i : v | boost::adaptors::indexed())
    ostr << (i.index() > 0 ? " " : "") << i.value();
  return ostr;
}

using P = pair<int, int>;
const int INF = 1e9;
const int NX[4] = {-1, 1, 0, 0};
const int NY[4] = {0, 0, -1, 1};

inline void Main() {
  // code
  int n, res = 1;
  int d[100];

  cin >> n;
  rep(i, n) cin >> d[i];
  sort(d, d+n);

  rep(i, n-1) {
    if(d[i] < d[i+1]) {
      res++;
    }
  }

  cout << res << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc092/tasks/abc092_a
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
set<string> S;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	string s;
	for(int i = 1; i <= n; i++){
		cin >> s;
		S.insert(s);
	}
	cout <<(int)S.size() << endl;
	
	return 0;
}

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

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int k = ni();
		int[] h = na(n);
		int result = 0;
		for(int hi : h) {
			if(hi >= k)result++;
		}
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		} 
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main() {

    double d,t,s;
    cin >> d>>t>>s;

    if (d / s <= t) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }


    return 0;
}

Measured memory_bytes: 3692
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
using namespace std;
typedef long long ll;
const long long llnrm=LLONG_MAX;
const int nrm=INT_MAX;
const int nrn=INT_MIN;
const int nmax=1e5+5;
const int mod=1e9+7;
const int lim=1e8;
int main(){
	long long n, a, b, sum=0,sumd=0,d;
	cin>>n>>a>>b;
	for (int k=1; k<=n; k++){
		d=k;
		while (d>0){
			sumd+=d%10;
			d=d/10;
		}
		if (sumd>=a and sumd<=b){
			sum+=k;
		}
		sumd=0;
	}
	cout<<sum;
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

int main()
{
	cout << setprecision(10);
	int a , b; 
	cin >> a >> b;
	//MAX a;
	int cover = b * 2;
	int left = a - cover ;
	cout << max(0,left)<<endl;


}


Measured memory_bytes: 256
n,a,b = map(int,input().split())
passed=0
out = 0
for i in input():
    if i == "a":
        if passed < a+b:
            passed += 1
            print("Yes")
        else:
            print("No")
    elif i == "b":
        if passed < a+b and out < b:
            passed += 1
            out += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")

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

void solve() 
{
    int n,k,q;cin>>n>>k>>q;
    map<int,int>a;
    REP(i,q){int x;cin>>x;a[x]++;}
    REP(i,n){
        if(a[i+1]>q-k)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

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

Measured memory_bytes: 5376
#include <stdio.h>
#include <math.h>

int main() {
	int week;
	double husai = 100;
	double rishi;
	
	scanf("%d",&week);
	
	for(int i=0;i<week;i++){
		rishi = ceil((husai * 5)/100);
		husai = husai + rishi;
	}
	
	husai = husai * 1000;
	printf("%.f\n",husai);
	
	return 0;
}


Measured memory_bytes: 2552
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  if (n % 10 == 7 || (n / 10) % 10 == 7 || n / 100 == 7) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }

  return 0;
}


Measured memory_bytes: 3100
import java.io.BufferedReader
import java.util.*

fun main() = abc175b()

@OptIn(ExperimentalStdlibApi::class)
fun abc175b() = SimpleFastIOWithToken_abc175b().exec {
    val n = readInt()
    val lList = LongArray(n) { readLong() }.sortedArray()

    var answer = 0L

    for (i in 0 until n) for (j in i + 1 until n) for (k in j + 1 until n) {
        val a = lList[i]
        val b = lList[j]
        val c = lList[k]
        if (a + b > c && a < b && b < c) answer++
    }

    println(answer)
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_abc175b(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readLong(): Long = java.lang.Long.valueOf(readString())

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }

    fun exec(action: SimpleFastIOWithToken_abc175b.() -> Unit) {
        var t: Throwable? = null
        Thread(null, { action() }, "solve", 128 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, t1 -> t = t1 } }
            .apply { start() }.join()
        t?.let { throw it }
        kotlin.io.print(sb)
    }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)


Measured memory_bytes: 38724
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
c = floyd_warshall(csgraph_from_dense(c))

result = 0
for _ in range(H):
    for i in map(int, input().split()):
        if i == -1:
            continue
        result += c[i][1]
print(int(result))


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

int abs(int a){
    if (a > 0)
        return a;
    else
        return -a;
}


int main() {
    int N; cin >> N;
    int x[N];
    int y[N];
    int h[N];
    int answerh,answercx,answercy;
    for (int i=0; i<N; i++) cin >> x[i] >> y[i] >> h[i];
    
    for (int i=0; i<=100; i++){
        for (int j=0; j<=100; j++){
            int H;
            for (int k=0; k<N; k++){
                if (h[k] != 0) {
                    H = h[k]+abs(x[k]-i)+abs(y[k]-j);
                    break;
                }
            }
            for (int l = 0; l<N; l++){
                if (H < 1) break;
                if (h[l] != 0){
                    if (h[l]+abs(x[l]-i)+abs(y[l]-j) != H) break;
                }
                else{
                    if ((H-abs(x[l]-i)-abs(y[l]-j))>0) break;
                }
                if (l == N-1){
                    answerh = H;
                    answercx = i;
                    answercy = j;
                }
            }
        }
    }
    cout << answercx << " " << answercy <<" " << answerh;

    
    return 0;
}


Measured memory_bytes: 256
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools


a = [int(s) for s in stdin.readline().rstrip().split()]
K = a[0]
N = a[1]
A = [int(s) for s in stdin.readline().rstrip().split()]

diff = []
for el in range(len(A)):
    if el == len(A) - 1:
        diff.append(K-A[el]+A[0])
        break
    diff.append(A[el+1]-A[el])

print(K-max(diff))


Measured memory_bytes: 80356
#include <iostream>
using namespace std;
#define REP(i,n) for(int i=0;i<int(n);i++)

int main()
{
  int n;
  while(1){
    cin >> n;
    int w[n];
    if(n == 0) break;
    REP(i,n){
      string s;
      cin >> s;
      w[i]= s.size();
    }
    int c, x;
    REP(i,n){
      x = 0;
      for(int j = i; j < n && x < 5; j++){
        x += w[j];
        c = j+1;
      }
      if(x != 5) continue;
      for(int j = c; j < n && x < 12; j++){
        x += w[j];
        c = j+1;
      }
      if(x != 12) continue;
      for(int j = c; j < n && x < 17; j++){
        x += w[j];
        c = j+1;
      }
      if(x != 17) continue;
      for(int j = c; j < n && x < 24; j++){
        x += w[j];
        c = j+1;
      }
      if(x != 24) continue;
      for(int j = c; j < n && x < 31; j++){
        x += w[j];
        c = j+1;
      }
      if(x != 31) continue;
      cout << i+1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 3156
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int a,b;
	cin>>a>>b;
	if(a<=8&&b<=8)puts("Yay!");
	else puts(":(");
}


Measured memory_bytes: 256
array = gets.chomp.split(" ").map { |e|e.to_i }
if array[0] <= array[2]  then
  x = 0
else x = 1
end
if array[2] <= array[1]  then
 y = 0
else y = 1
end

if x +y == 0 then
  puts("Yes")

else puts("No")

end


Measured memory_bytes: 1788
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <queue>
#include <thread>
#include<bits/extc++.h>
 
using namespace __gnu_pbds;
#pragma GCC optimize("Ofast")
 
#define ll long long
 
#define gc (c = getchar())
#define gi(x) scanf("%d", &x)
#define gid(x, y) scanf("%d%d", &x, &y)
#define gll(x) scanf("%lld", &x)
#define glld(x, y) scanf("%lld%lld", &x, &y)
#define gllt(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define git(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define pi(x) printf("%d\n", x)
#define pr(x) return !(printf("%lld\n", (long long)(x)))
#define pcs(ch, cs, x) printf("Case %c%d: %d\n", ch, cs, x)
#define pllcs(ch, cs, x) printf("Case %c%d: %lld\n", ch, cs, x)
#define pcsyn(ch, cs, st) printf("Case %c%d: %s\n", ch, cs, (st) ? "Yes" : "No")
#define pyn(st) printf("%s\n", (st) ? "yes" : "no")
#define pryn(st) return !(printf("%s\n", (st) ? "YES" : "NO"))
#define pll(x) printf("%lld\n", x)
#define plld(x, y) printf("%lld %lld\n", x, y)
 
#define mp(x, y) std::make_pair(x, y)
#define fcs(x) while (x--)
#define dbg(x) std::cerr << #x << " " << x << std::endl
#define fi freopen("in.txt", "r", stdin)
#define fo freopen("out.txt", "w", stdout)
#define siz(x) (int)x.size()
#define pb(x) push_back(x)
 
inline long long max(long long x, long long y) { return x > y ? x : y; }
 
inline long long min(long long x, long long y) { return x > y ? y : x; }
 
long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }
 
int main(){
	ll n, x, t;
    gllt(n, x, t);
    long long ret = n % x ? (n / x + 1) * t : (n / x) * t;
    pll(ret);
}

Measured memory_bytes: 3856
from itertools import accumulate

N,Q=map(int,input().split())
S=input()
res=[0 for i in range(N)]
for i in range(1,N):
    if S[i] == "C" and S[i-1] == "A":
        res[i]=1
res=list(accumulate(res))

for i in range(Q):
    l,r=map(int,input().split())
    print(res[r-1]-res[l-1])


Measured memory_bytes: 7960
#include <stdio.h>

void print(char s[], int x, int y)
{
    int i;
    for (i = x; i <= y; i++)
        putchar(s[i]);
    putchar('\n');
}

void reverse(char s[], int x, int y)
{
    int i;
    for (i = 0; i <= (y - x) / 2; i++) {
        char c;
        c = s[x + i];
        s[x + i] = s[y - i];
        s[y - i] = c;
    }
}

void replace(char s1[], int x, int y, char s2[])
{
    int i;
    for (i = x; i <= y; i++) {
        s1[i] = s2[i - x];
    }
}


int main(void)
{
    char str[1001];
    scanf("%s", str);

    int q;
    scanf("%d", &q);

    int i;
    for (i = 0; i < q; i++) {
        char command[8];
        scanf("%s", command);

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

        if (command[0] == 'p')
            print(str, a, b);
        else if (command[2] == 'v')
            reverse(str, a, b);
        else if (command[2] == 'p') {
                char p[1000];
                scanf("%s", p);
                replace(str, a, b, p);
        }
    }
        return 0;
}

Measured memory_bytes: 572
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

int a, b, c;
void in(){
    cin >> a >> b >> c;
}

void solve(){

    if(a + b >= c){
        print("Yes");
    }else{
        print("No");
    }


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,a,odd=0;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> a;
        if(a%2) odd++;
    }
    if(odd%2) cout << "NO" << endl;
    else cout << "YES" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
char s[200];
int i,a[200];
int main()
{
    scanf("%s",s);
    a['a']=0;
    a['b']=0;
    a['c']=0;
    for (i=0;i<=2;i++)
        a[s[i]]+=1;
    if (a['a']==1&&a['b']==1&&a['c']==1) printf("Yes"); else printf("No");
    return(0);
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
string N;
cin >> N;
int i = 0;
for(char t : N)
  i+= t-'0';
int j = N[0] -'0' - 1 + 9 * int(N.size()-1);
cout << max(i,j) << endl;
}

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


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

string s;
ll a[27], cnt;
int main() {
	cin >> s;
	REP(i, 4) {
		a[s[i] - 'A']++;
		//cout << s[i] - 'A' << endl;
	}
	REP(i, 27) {
		if (a[i] != 2 and a[i] != 0) {
			cout << "No" << endl;
			return 0;
		}
		else if (a[i] == 2)cnt++;
	}
	//cout << cnt << endl;
	if (cnt == 2)cout << "Yes" << endl;
	else cout << "No" << endl;
	
}


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

int func(int x)
{
    long a = 7;
    int ans = 1;
    for (int i = 0; i < x; i++)
    {
        if (a % x != 0)
        {
            a = (a * 10 + 7) % x;
            ans++;
        }
        else
        {
            return ans;
        }
    }
    return -1;
}


int main() {
    long K;
    cin >> K;
    cout << func(K);
}

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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

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

   int n,a,cnt=0;
   cin>>n;
   map<int,int> mp;

   rep(i,0,n){
      cin>>a;
      mp[a]++;
   }

   for(auto it:mp){
      if(it.first <= it.second) cnt += (it.second - it.first);
      else cnt += it.second;
   }

   cout<<cnt<<'\n';
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
#define N 200050
#define M 200
#define int long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
#define ll long long
#define SIZE N

using namespace std;
int ar[N],tot;

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin>>n;
	for(int i=0;i<n;i++){
	    cin>>ar[i];
	    tot^=ar[i];
	}
	for(int i=0;i<n;i++){
	    int a = tot^ar[i];
	    cout<<a<<" ";
	}
}


Measured memory_bytes: 5128
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int r,g;
    cin>>r>>g;
    if((r+g)%2==0){
        cout<<(r+g)/2<<endl;
    }else{
        cout<<(r+g)/2 + 1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  ABC121
//
//  Created by NanamiYamamoto on 2019/03/09.
//  Copyright © 2019年 NanamiYamamoto. All rights reserved.
//

#include <iostream>
#include <string>
#include <vector>
#include <cstdio>

using namespace std;


int main(int argc, const char * argv[]) {
	int numofCols, numofRows;
	int h, w;

	scanf("%d %d", &numofRows, &numofCols);
	scanf("%d %d", &h, &w);

	cout << numofRows*numofCols - numofRows*w - numofCols*h + h*w; 
}




Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <stdlib.h>
#include <deque>
#include <cstdint>
using namespace std;

int main () {
  int n;
  cin >> n ;
  int a[n];
  int b[n];
  for (int i = 0; i < n; i++){
    int t;
    cin >> t;
    a[i] = t;
    b[t-1] = i+1;
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++){
    cout << b[i] << " ";
  }
  return 0;
}

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

void solve() {
    ll n, h;
    cin >> n >> h;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    ll maxa = -1;
    rep(i, n) maxa = max(maxa, a[i]);
    sort(b.rbegin(), b.rend());
    vector<ll> strong;
    rep(i, n) {
        if (b[i] > maxa) {
            strong.push_back(b[i]);
        } else {
            break;
        }
    }

    ll tot = 0;
    rep(i, strong.size()) {
        tot += strong[i];
        if (tot >= h) {
            cout << i + 1 << endl;
            return;
        }
    }

    cout << (h - tot + maxa - 1) / maxa + strong.size() << endl;

}

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


Measured memory_bytes: 5872
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int W[N];
  for (int i = 0; i < N; ++i) {
    scanf("%d", &W[i]);
  }

  int ans = 10000000;
  int leftS,rightS;
  int hold;

  for (int i = 0; i < N-1; ++i){
    leftS=0;
    rightS=0;
    for(int j=0;j<i+1;j++){
      leftS += W[j];
    }
    for(int j=i+1;j<N;j++){
      rightS += W[j];
    }
    hold = abs(leftS-rightS);
    if(hold<ans) ans = hold;
  }

  cout << ans << endl;

}
 



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

int main()
{
    int n;
    cin >> n;
    int a[103];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 1; i < n - 1; i++){
        if(a[i] == a[i - 1]){
            ans++;
            a[i] = a[i + 1] + 1;
        }
    }
    if(a[n - 2] == a[n - 1]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def main():
    S = input()
    for i in range(2**3):
        tmp = ""
        for n in range(len(S)-1):
            tmp += S[n]
            if (i >> n) & 1:
                tmp += "+"
            else:
                tmp += "-"
        tmp += S[-1]
        if eval(tmp) == 7:
            tmp += "=7"
            print(tmp)
            return

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <stdio.h>
#include <ctype.h>


int main(void)
{
    char s[5000];
    int n,k;

    scanf("%d %d", &n,&k);
    scanf("%s",s);

    s[k-1] = tolower(s[k-1]);

    //printf("%d--%d\n", n,k);
    printf("%s\n",s);


    return 0;
}

Measured memory_bytes: 128
#include <set>
#include <map>
#include <unordered_map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <tuple>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-9;
const double INF = 2147483647;
#define rep(i, n) rep3(i, 0, n)
#define rep2(i, n) rep3(i, 1, n+1)
#define rep3(i, x, n) for(ll i = x; i < (ll)(n); i++)

template<class T>
void printv(vector<T> v) {
    for(auto it = v.begin(); it != v.end(); it++){
        cout << *it << ",";
    }
    cout << endl;
}
template<class T>
void printp(vector<pair<T,T>> v) {
    for(auto it = v.begin(); it != v.end(); it++){
        cout << (*it).first << "," << (*it).second << endl;
    }
    cout << endl;
}
template<class T>
void printp(map<T,T> v) {
    for(auto it = v.begin(); it != v.end(); it++){
        cout << (*it).first << "," << (*it).second << endl;
    }
    cout << endl;
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数
 
        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
 
        // その結果を push
        res.push_back({a, ex});
    }
 
    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(void){
    ll N,K;
    cin>>N>>K;
    vector<ll> p(N);
    rep(i,N) cin>>p[i];
    sort(p.begin(), p.end(), [](auto const& lhs, auto const& rhs) {
        return lhs < rhs;
    });
    ll ans = 0;
    rep(i,K) ans += p[i];
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 3624
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
      int[] a = new int[N];
      int[] sum = new int[N];
      Arrays.fill(sum, 0);
      int i=0;
      int j=0;
      for(i=0;i<N;i++){
        a[i] = sc.nextInt();
      }
      ArrayList<Integer> intList = new ArrayList<Integer>();
      int ssum=0;
      for(i=N-1;i>=0;i--){
        ssum=0;
        for(j=1;j*(i+1)<=N;j++){
          ssum=ssum+sum[j*(i+1)-1];
        }
        if(a[i]==1&&ssum%2==0){
          intList.add(i+1);
          sum[i]=1;
        }else if(a[i]==0&&ssum%2==1){
          intList.add(i+1);
          sum[i]=1;
        }
      }
      System.out.println(intList.size());
      for(int k:intList){
        System.out.print(k+" ");
      }
    }
}

Measured memory_bytes: 92592
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <cstdint>
#include <mutex>
#include <thread>
#include <bitset>

#define FOR(x,y)	for(int i=x;i<y;i++)
#define FOR2(x,y)	for(int j=x;j<y;j++)

#define LL			unsigned long long int

using namespace std;

int main(void)
{
	char c;

	cin >> c;
	if ('A' <= c && c <= 'Z')
		cout << "A";
	else
		cout << "a";

	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>

char H[1046527][13];

int getChar(char ch) {
  if (ch == 'A')
    return 1;
  else if (ch== 'C')
    return 2;
  else if (ch == 'G')
    return 3;
  else if (ch== 'T')
    return 4;
  else
    return 0;
}

long long getkey(char str[]) {
  long long sum = 0, p = 1, i;
  for (i = 0; i < strlen(str); i++) {
    sum += p * getChar(str[i]);
    p *= 5;
  }
  return sum;
}

int h1(int key) {return key % 1046527;}
int h2(int key) {return 1 + key % (1046526);}

int find(char str[]) {
  long long key, i, h;
  key = getkey(str);
  for (i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % 1046527;
    if (strcmp(H[h], str) == 0) return 1;
    else if (strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]) {
  long long key, i, h;
  key = getkey(str);
  for (i = 0;;i++) {
    h = (h1(key) + i*h2(key)) % 1046527;
    if (strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main(void)
{
  int i, n, h;
  char str[13], com[9];
  for (i = 0; i < 1046527; i++) H[i][0] = '\0';
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s %s", com, str);
    if (com[0] == 'i') 
      insert(str);
    else {
      if (find(str)) {
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }
  return 0;
}



Measured memory_bytes: 15016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a, b;
    cin >> a >> b;
    int ans = 1;
    ll mv = gcd(a, b);
    ll tmp = mv;
    
    for (ll i = 2; i * i <= mv; i++) {
        bool f = false;
        
        while(tmp % i == 0) {
            f = true;
            tmp /= i;
        }
        
        if (f) {
            ans++;
        }
    }
    
    if (tmp != 1) {
        ans++;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
transfer = [tuple(map(int, input().split())) for _ in range(m)]

# [ball_num, oppotunity that the red ball in the box]
balls = [[0, 0]] + [[1, 1]] + [[1, 0] for _ in range(n - 1)]

for x, y in transfer:
    # from_box = balls[x]
    # to_box = balls[y]
    balls[x][0] -= 1
    balls[y][0] += 1
    if balls[x][1] == 1:
        balls[y][1] = 1
        if balls[x][0] == 0:
            balls[x][1] = 0

# print(balls)
print(len(list(filter(lambda x: x[1] == 1, balls))))

Measured memory_bytes: 28216
n=gets.to_i
a=gets.split.map(&:to_i)
x=0
y=0
1.upto(n-1) do |i|
  y+=a[i]
end
(n-1).times do |i|
  x+=(a[i]*y)%(10**9+7)
  y-=a[i+1]
end
puts x%(10**9+7)


Measured memory_bytes: 33812
// !=D
#include <bits/stdc++.h>

using namespace std;

vector<long long> p;
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, a, b;
	cin>> n >> a;
	long long sum = 0;
	while(--n)
	{
		cin>> b;
		sum += max(0, a - b);
		a = b + max(0, a - b);
	}
	cout<< sum << endl;
	
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, a;
  cin >> N >> M;
  priority_queue<int> q;
  for (int i = 0; i < N; i++){
    cin >> a;
    q.push(a);
  }
  
  for (int i = 0; i < M; i++){
    a = q.top(); q.pop();
    q.push(a/2);
  }
  long long ans = 0;
  for (int i = 0; i < N; i++){
    ans += q.top();
    q.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
    int n, t;
    cin >> n >> t;

    vector<int> h;
    inputVector(h, n);

    int sum = 0;
    int prev = INT_MAX;
    rep(i, n) {
	int offset, period;
	if (i > 0 && h[i] < h[i - 1]) {
	    offset = sum - (h[i - 1] - h[i]);
	    period = h[i - 1];
	} else {
	    offset = sum;
	    period = h[i];
	}
	int ret = ((t - offset + 1) + period - 1) / period;
	ret = min(ret, prev);
	ret = max(ret, 1LL);
	sum += h[i];
	h[i] = period;
	prev = ret;
	cout << ret << endl;
    }

    return 0;
}

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

int main() {
    vector<int> v;

    int t;
    cin >> t;
    v.push_back(t);
    cin >> t;
    v.push_back(t);
        cin >> t;
    v.push_back(t);

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

    cout << v[0] << " " << v[1] << " " << v[2] << endl;

    return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
 
using namespace std;
const int maxn = 1e5 + 10;
 
#define ll long long
#define LL long long
const ll MOD = 1e9 + 7;
ll v[maxn], a[maxn];
LL da[maxn];//G++ long long
ll inv[maxn],fac[maxn],finv[maxn];
void make()
{
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<maxn;i++)
	{
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		fac[i]=fac[i-1]*(ll) i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
ll C(int a,int b)
{
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
int main() {
    ios_base::sync_with_stdio(0);
    ll n;
    make();
    ll id1 = 0, id2 = 0;
    cin >> n;
    memset(a, 0, sizeof(a));
    memset(v, 0, sizeof(v));
    for(ll i = 1; i <= n + 1; ++i){
        cin >> a[i];
        v[a[i]]++;
    }
    for(ll i = 1; i <= n + 1; ++i){
        if(v[a[i]] == 2 && !id1){
            id1 = i;
        }
        else if(v[a[i]] == 2) {
            id2 = i;
        }
    }
    ll L = max(id1 - 1LL, 0LL), M = id2 - id1 - 1LL, R = max(n + 1LL - id2, 0LL);
    ll res = 0;
    for(ll i = 1; i <= n + 1; ++i){
        res = C(n + 1, i * 1LL);
        res -= C(L + R, (i - 1) * 1LL);
        if(res < 0)res += MOD;
        cout << res << '\n';
    }
    return 0;
}

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

h, w, m = map(int, input().split())
col = [0] * w
row = [0] * h
places = set()
for _ in range(m):
    h, w = map(int, input().split())
    h -= 1; w -= 1
    row[h] += 1
    col[w] += 1
    places.add((h, w))

col_wi = []
for i, item in enumerate(col):
    col_wi.append((item, i))
row_wi = []
for i, item in enumerate(row):
    row_wi.append((item, i))

col_wi.sort(reverse=True)
row_wi.sort(reverse=True)

col_max = col_wi[0][0]
row_max = row_wi[0][0]

ans = 0
has_blank_center = False
for cval, ci in col_wi:
    if cval != col_max:
        break
    for rval, ri in row_wi:
        if rval != row_max:
            break
        if (ri, ci) not in places:
            has_blank_center = True
            break
    if has_blank_center:
        break

if has_blank_center:
    print(col_max + row_max)
else:
    print(col_max + row_max - 1)


Measured memory_bytes: 165932