akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int[] abc=cin.ArrayInt(3,0);
      Array.Sort(abc);
      Console.WriteLine(abc[0]+abc[1]);
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}

Measured memory_bytes: 11348
# coding: utf-8

S = list(input())
N = len(S)
A = S[:(N-1)//2]
B = S[(N-1)//2+1:]

def kaibun(l):
    n = len(l)
    for i in range(max(n//2-1,1)):
        if l[i] != l[n-1-i]:
            return False
    return True
if kaibun(S) and kaibun(A) and kaibun(B):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define abs(a)((a)>=(0) ? (a):(-(a)))
long long int A[110];
int main(void){
    long long int N, i, j, MAX=0;
    scanf("%lld", &N);
    for(i=0; i<N; i++) scanf("%lld", A+i);
    for(i=0; i<N-1; i++){
        for(j=i+1; j<N; j++){
            if(MAX<abs(A[i]-A[j])){
                MAX = abs(A[i]-A[j]);
            }
        }
    }
    printf("%lld\n", MAX);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <algorithm>
using namespace std;
#include <cmath>
#include <string>
#define elif else if
int main(void) {
  int N;
  cin>> N;
  long long names[5]={0};
  string march = "MARCH";
  rep(i,N){
    string str;
    cin>>str;
    rep(j,5){
      if(str[0]==march[j] )
        names[j]++;
    }
  }

  long long comb =0;

  rep(i,5){
    for(int j =i+1;j<5;j++ ){
      for(int k =j+1;k<5;k++ ){
        comb += names[i]*names[j]*names[k];
      }
    }
  }

  cout<<comb<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main() {

  int n, a[100], i;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);

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

  return 0;
}


Measured memory_bytes: 2048
def resolve():
    N = int(input())
    AB = [list(map(int, input().split())) for _ in range(N)]

    # コストを予め計算しておく
    cost = [0] * (1 << N)
    for bit in range(1 << N):
        for i in range(N):
            for j in range(i + 1, N):
                if bit >> i & 1 and bit >> j & 1:
                    cost[bit] += AB[i][j]

    dp = [0] * (1 << N)
    for s in range(1, 1 << N):
        t = s
        while t > 0:
            dp[s] = max(dp[s], dp[s - t] + cost[t])
            t = s & (t - 1)
            
    print(dp[-1])


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 74992
a=int(input())
b=int(input())
c=int(input())
d=int(input())
if a<=b and c<=d:
  print(a+c)
elif a<=b and d<=c:
  print(a+d)
elif b<=a and c<=d:
  print(b+c)
else:
  print(b+d)
     


Measured memory_bytes: 2940
import math

N = int(input())

def digit(n):
    d = 0
    while n > 0:
        d += 1
        n //= 10

    return d

F = digit(N)

for n in range(1, int(math.sqrt(N)) + 1):
    if N % n != 0:
        continue
    else: # N % n == 0
        F = min(F, max(digit(n), digit(N // n)))

print(F)

Measured memory_bytes: 9060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll n;cin>>n;
    vector<string> a(n);
    vector<ll> b(n);
    For(i,0,n) cin>>a[i]>>b[i];
    string s;cin>>s;
    bool flag=false;
    For(i,0,n){
        if(flag)ans+=b[i];
        if(a[i]==s) flag=true;
    }
    cout<<ans<<endl;
    
}
int main(){
    Main();
    return 0;
}

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

using namespace std;

int main(){

	int n;
	int t;
	int a;
	double min=100000000.0;
	double cal;
	int mini;
	vector<int> h;

	cin>> n >> t >> a;

	h.resize(n);

	for(int i=0;i<n;i++){
		cin>> h[i];
		cal=abs(t-h[i]*0.006-a);
		if(cal<min){
			min=cal;
			mini=i+1;
		}
	}

	cout<< mini << "\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

ll N, K;
ll ans;

int main()
{
  scanf( "%lld%lld", &N, &K );

  repi( b, K+1, N+1 )
    ans += (N/b)*(b-K)+std::max<ll>(0, N-(N/b)*b+(K==0?0:1)-K);
  
  printf( "%lld\n", ans );

  return 0;
}

Measured memory_bytes: 128
import collections

N = int(input())
count = 0

for k in range(1,N+1):
    # 初期化
    num = []
    n = k
    if(n % 2 == 0):
        continue

    for i in range(2,k+1):
        if n % i == 0:
            n = int(n // i)
            num.append(i)


    num_counter = collections.Counter(num)
    ans = 1
    for value in num_counter.values():
        ans *= value+1

    if(ans == 8):
        count += 1



print(count)

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

using namespace std;

#define ll long long

void solve() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a*c, max(a*d, max(b*c, b*d)));
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,x,ans=0,s,m;cin>>n>>x;
  lvector A(n);rep(i,n) cin>>A[i];
  for(ll pos=1;pos<n;++pos) {
    s=A[pos-1]+A[pos];
    if(s<=x) continue;
    m=min(s-x,A[pos]);
    A[pos]-=m,ans+=m;
    s=A[pos-1]+A[pos];
    if(s>x) A[pos-1]-=s-x,ans+=s-x;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<long long int>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vb vector<bool>
#define vvl vector<vector<ll> >
#define vvi vector<vector<int> >
#define pl pair<ll,ll>
#define pb push_back
#define PI 3.14159265
#define mod 998244353
#define pb push_back
#define mp make_pair
#define fri(s,n) for(int i=s;i<n;i++)
#define frj(s,n) for(int j=s;j<n;j++)
#define T(i) int i=1;cin>>i;while(i--)
#define vsi vector<set<int> >
#define pii pair<int,int>
#define inf 1e9
#define vpii vector<pair<int,int> >


ll power(ll a,ll b){
    if(b==0)
        return 1;
    if(b&1)
        return a*power(a,b-1);
    ll temp=power(a,b/2);
    return temp*temp;
    }
ll mycompare(ll a,ll b){
    return a>b;
    }

ll mincost(int level,vi &height,vi &dp,int k){
    if(level==0)
        return 0;
    if(level==1)
        return abs(height[0]-height[1]);
    if(dp[level]!=-1)
        return dp[level];
    ll cost=INT_MAX;
    for(int l=level-k;l<level;l++){
        if(l>=0)
            cost=min(cost,abs(height[level]-height[l])+mincost(l,height,dp,k));
    }
    return dp[level]=cost;
    }
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    fast;
        int n,k;
        cin>>n>>k;
        vi height(n);
        fri(0,n)
            cin>>height[i];
        vi dp(n,-1);
        cout<<mincost(n-1,height,dp,k);
    }


Measured memory_bytes: 13480
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}

int main(){
    string s; cin>>s;
    ll ans=0;
    for(ll bit=0;bit<(1<<(s.size()-1));bit++){
        string tmp=to_string(s[0]-'0');
        for(ll i=0;i<s.size()-1;i++){
            if(bit&(1<<i)){
                ans+=stol(tmp);
                tmp=to_string(s[i+1]-'0');
            }
            else{
                tmp+=to_string(s[i+1]-'0');
            }
        }
        ans+=stol(tmp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
l = [[0,0,0]]
for i in range(n):
  t,x,y = map(int, input().split())
  l.append([t,x,y])

enable = True
for i in range(1, len(l)):
  d = abs(l[i][1]-l[i-1][1]) + abs(l[i][2]-l[i-1][2])
  delta = l[i][0]-l[i-1][0]
  if delta < d or (delta - d) % 2 != 0:
    enable = False
    break
    
if enable:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 19532
import heapq
import sys

sys.setrecursionlimit(1000)

BLACK = '#'
WHITE = '.'


def m():
    H, W = [int(x) for x in input().split(' ')]
    board = [[c for c in list(input())] for _ in range(H)]

    # x, y, score
    q = [(0, 0, 0)]
    is_reachable = False
    while len(q) > 0:
        p, x, y = heapq.heappop(q)
        if x == H - 1 and y == W - 1:
            is_reachable = True

        nexts = [(x+1, y), (x, y+1), (x-1, y), (x, y-1)]
        for i, j in nexts:
            if 0 <= i and i < H and 0 <= j and j < W:
                if board[i][j] == BLACK:
                    continue

                if board[i][j] == WHITE:
                    board[i][j] = p+1
                    heapq.heappush(q, (p+1, i, j))
                    continue

                if board[i][j] > p+1:
                    board[i][j] = p+1
                    heapq.heappush(q, (p+1, i, j))
                    continue

    if is_reachable:
        blacks = 0
        for i in range(H):
            for j in range(W):
                if board[i][j] == BLACK:
                    blacks += 1
        ans = H*W - blacks - board[H-1][W-1] - 1
        print(ans)
    else:
        print(-1)


m()


Measured memory_bytes: 45272
/*Enter your code here. Read input from STDIN. Print your output to STDOUT*/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n";
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define maxN 1000000

int32_t main()
{
    fastio;
    
    int n; cin >> n;
    double p[n];
    for(int i=0; i<n; i++) cin >> p[i];

    double dp[n+1]; memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    for(int i=0; i<n; i++){
        for(int j=i+1; j>=0; j--){
            dp[j] = (j==0?0:dp[j-1]*p[i]) + dp[j]*(1-p[i]);
        }
    }

    double ans = 0;
    for(int i=n/2 + 1; i<=n; i++) ans += dp[i];
    cout << fixed << setprecision(10) << ans << endl;
    return 0;   
}
    

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

int a, b;
ll ans = 0;

int main() {
  cin >> a >> b;
  ans = ll(a) * b / __gcd(a, b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string O,E;cin>>O>>E;
  int M=O.size(),N=E.size();
  for(int i=0;i<N;i++)cout<<O.at(i)<<E.at(i);
  if(M>N)cout<<O.at(M-1);
  cout<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (Math.abs(a - b) - w > 0)
            System.out.println(Math.abs(a - b) - w);
        else
            System.out.println(0);
    }
}


Measured memory_bytes: 23252
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end
x = gets_i
max = 0

1.upto(32) do |b|
  2.upto(10) do |pp|
    a = b**pp
    max = a if x >= a && a >= max
  end
end

puts max

Measured memory_bytes: 14568
#include <iostream>
#include <iomanip>
using std::cin;
using std::cout;
using std::endl;

#define N 3

int main()
{
    int A[N] = {};

    for (int i = 0; i < N; i++)
        cin >> A[i];
    if (A[0] + A[1] + A[2] > 21)
    {
        cout << "bust" << endl;
    }
    else
    {
        cout << "win" << endl;
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int M,D;
    
    scanf("%d", &M);
    // スペース区切りの整数の入力
    scanf("%d",&D);
    
  	double a,b;
  int count = 0;
  int i = 0;
  int t = 0;
  for(t=1;t<M+1;t++){
  for(i=1;i<D+1;i++){
  a = i %10;
  b = (i/10)%10;
	if(a >= 2 && b >= 2){
      if(a*b == t){
        count++;
      }
    }
        }
  }
  
  printf("%d",count);
    return 0;
}


Measured memory_bytes: 128
from functools import reduce
from itertools import combinations
from operator import mul


def solve(string):
    n, *s = string.split()
    # num = [len([True for _s in s if _s[0] == _i]) for _i in "M A R C H".split()]
    initial = "MARCH"
    num = [0 for _ in range(6)]
    for _s in s:
        i = initial.find(_s[0])
        num[i] += 1
    return str(sum([reduce(mul, n) for n in combinations(num[:5], 3)]))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 12468
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forna(i,a,n) for(int i =a; i < n; i++)
#define fornd(i,a) for (int i = (a)-1; i >= 0; i--)
#define endl '\n'
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);
#define all(x) x.begin(), x.end()
typedef long long int unsigned lliu;
typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
#define MAXN 100005

int n;
int hap[MAXN][3];
int mem[MAXN][3];
int inf = 1e9;

int dp(int i, int caso){
	if(i>=n)
		return 0;
	if(mem[i][caso]!=-1)
		return mem[i][caso];
	int &res = mem[i][caso]; 
	switch (caso){
	case 0:
		res = max(hap[i][1]+dp(i+1, 1), hap[i][2]+dp(i+1, 2));
		break;
	case 1:
		res = max(hap[i][0]+dp(i+1, 0), hap[i][2]+dp(i+1, 2));
		break;
	case 2:
		res = max(hap[i][1]+dp(i+1, 1), hap[i][0]+dp(i+1, 0));
		break;
	default:
		break;
	}
	return res;
	
}

int main(){
	fastIO
	cin>>n;
	forn(i, n)
		forn(j, 3)
			cin>>hap[i][j];
	memset(mem, -1, sizeof(mem));
	int res = max(dp(0, 0), max(dp(0, 1), dp(0, 2)));
	cout<<res<<endl;

	return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s;
    cin >> s;
    ll k;
    cin >> k;
    int ans = 1;
    rep(i, k) {
        if (i==s.size()) break;
        if (s[i]!='1') {
            ans = s[i]-'0';
            break;
        }
    }
    
    cout << ans << endl;
    return 0;
}


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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int res = 1;
  int d[n - 1];
  for (int i = 0; i < n - 1; i++) d[i] = a[i + 1] - a[i];
  int sg = 0;
  for (int i = 0; i < n - 1; i++) {
    if (d[i] > 0) {
      if (sg == -1) {
        res++;
        sg = 0;
      } else sg = 1;
    } else if (d[i] < 0) {
      if (sg == 1) {
        res++;
        sg = 0;
      } else sg = -1;
    }
  }
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    int n, a[100015], dp[100015];
    cin >> n;
    for (int i = 0; i <= 100010; i++) {
        if (i < n) cin >> a[i];
        dp[i] = 1e9;
    }
    
    dp[0] = -1e9;
    dp[1] = a[0];
    
    for (int i = 1; i < n; i++) {
        int l = 0, r = 100010;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (dp[mid] <= a[i]) l = mid;
            else r = mid;
        }
        //cout << l << endl;
        
        if (dp[l] != a[i]) dp[l + 1] = a[i];
    }
    
    for (int i = n; i >= 0; i--) {
        if (dp[i] != 1e9) {
            cout << i << endl;
            return 0;
        }
    }
}



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

int main()
{
    int n, c=0;
    cin >> n;
    int a1[n], a2[n];

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

    sort(a1, a1+n);

    for(int i=0; i<n; i++){
        if(a1[i] == a2[i]) c++;
    }

    if(c == n || c == n-2) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 3580
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    REP(i, n){
        cin >> a[i] >> b[i];
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end(), greater<ll>());
    ll lb, ub, ans;
    if(n % 2 == 0){
        lb = a[n/2-1]+a[n/2];
        ub = b[n/2-1]+b[n/2];
        ans = ub - lb + 1;
    }
    else{
        lb = a[n/2];
        ub = b[n/2];
        ans = ub - lb + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6056
import sys
import math
import collections
import bisect
import copy
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    p = [ni() - 1 for _ in range(n)]

    table = [0] * n

    maxnum = 0
    for i in range(n):
        idx = p[i]
        if idx == 0:
            table[idx] = 1
        else:
            table[idx] = table[idx - 1] + 1
        maxnum = max(maxnum, table[idx])

    print(n - maxnum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 83240
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;

bool check(ll n,ll i){
	while(n%i==0)n/=i;
	return n%i==1;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll n; cin >> n;
	ll res=0;
	vector<ll> p;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			if(check(n,i))p.push_back(i);
			if(check(n,n/i))p.push_back(n/i);
		}
	}
	for(ll i=2;i*i<=(n-1);i++){
		if((n-1)%i==0){
			p.push_back(i);
			p.push_back((n-1)/i);
		}
	}
	p.push_back(n);
	if(n-1>2)p.push_back(n-1);
	sort(p.begin(),p.end());
	p.erase(unique(p.begin(),p.end()),p.end());
	/*for(int i=0;i<p.size();i++){
		cout << p[i] << endl;
	}*/
	cout << p.size() << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int f(lli b){
	int d = 0;
	while(b!=0){
		b/=10;
		d++;
	}
	return d;
}

int main(void){
	lli n; cin >> n;
	vector<pair<int, mp>> a;
	
	for(lli i = 1; i <= 100000; i++) if(n%i==0) a.push_back(pair<int, mp>(f(max(i, n/i)), mp(i, n/i)));
	
	sort(a.begin(), a.end());
	
	cout << a[0].fir << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define re register int
#define F(x,y,z) for(re x=y;x<=z;x++)
#define FOR(x,y,z) for(re x=y;x>=z;x--)
typedef long long ll;
#define I inline void
#define IN inline int
#define C(x,y) memset(x,y,sizeof(x))
#define STS system("pause")
template<class D>I read(D &res){
	res=0;register D g=1;register char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')g=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		res=(res<<3)+(res<<1)+(ch^48);
		ch=getchar();
	}
	res*=g;
}
const int Mod=1e9+7;
vector<int>e[5050];
int n,m,ans,X,Y,f[5050][5050],s[5050],siz[5050];
I add(int &x,int y){(x+=y)>=Mod?x-=Mod:0;}
I D_1(int x,int fa){
	f[x][1]=1;siz[x]=1;
	for(auto d:e[x]){
		if(d==fa)continue;
		D_1(d,x);static int g[5050];
		F(i,0,siz[x]+siz[d])g[i]=0;
		F(i,1,siz[x])F(j,1,siz[d]){
			add(g[i],Mod-(ll)f[x][i]*f[d][j]%Mod*s[j]%Mod);
			add(g[i+j],(ll)f[x][i]*f[d][j]%Mod);
		}
		siz[x]+=siz[d];F(i,0,siz[x])f[x][i]=g[i];
	}
}
int main(){
	read(n);
	F(i,1,n-1){
		read(X);read(Y);e[X].emplace_back(Y);e[Y].emplace_back(X);
	}
	s[0]=1;for(re i=2;i<=n;i+=2)s[i]=(ll)s[i-2]*(i-1)%Mod;
	D_1(1,0);
	for(re i=2;i<=n;i+=2)add(ans,(ll)f[1][i]*s[i]%Mod);
	printf("%d",ans);
	return 0;
}



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

using namespace std;
#define ll long long

const int MOD = 1e9+7;


string s; 
ll d, n;
ll dp[10005][101][2];  // k = 0, cannot cross limit, k = 1 can

ll solve(ll i, ll sum, ll k){
    if(i == n) return sum == 0;
    if(dp[i][sum][k] == -1) {
    ll dig = s[i] - '0';
    if(k) dig = 9;
    
ll res = 0;
    for(int j = 0; j <= dig; j++){
    res += solve(i+1, (sum + j)%d, (k == 1 ||  (k == 0 && j < dig ) ? 1 : 0)  );
    res %= MOD;
}
dp[i][sum][k] = res;
}
return dp[i][sum][k];
}
 
int main(){
    cin >> s >> d;
    n = s.size();
    
    memset(dp, -1, sizeof(dp));

    cout << (solve(0, 0, 0) - 1 + MOD)%MOD;
    
}




Measured memory_bytes: 20204
n = int(input())
a = [list(map(int,input().split()))for i in range(n)]
ans = 0
for i in range(n):
    for j in range(n):
        ans += ((a[i][0]-a[j][0])**2 + (a[i][1]-a[j][1])**2)**0.5
print(ans/n)

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

using namespace std;

int main(){

	int i,j,copy;
	int n[10];

	for (i = 0; i < 10; i++) 
		cin >> n[i];
	
	

	for (i = 0; i < 10; i++) {
		for (j = i + 1; j < 10; j++) {
			if (n[i] < n[j]) {
				copy = n[i];
				n[i] = n[j];
				n[j] = copy;
			}
		}
	}

	for (i = 0; i < 3; i++) 
		cout << n[i] << endl;
	
	return 0;
}

Measured memory_bytes: 1160
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

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

fun main() {
    val (a, b, x) = nextLongList()
    val ans = b / x + 1 - if (a > 0) (a - 1) / x + 1 else 0
    println(ans)
}

Measured memory_bytes: 37872
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int func(int n){
    if(n%2==0){
        return n/2;
    }else{
        return 3*n+1;
    }
}

int a[1000005] = {};

int main()
{
    int s,cnt=0,index=0;
    cin>>s;
    while(cnt!=1000000){
        cnt++;
        a[s]++;
        // cout<<"s: "<<s<<endl;
        // cout<<"a[s]: "<<a[s]<<endl;
        if(a[s]==2){
            cout<<cnt<<endl;
            break;
        }
        s = func(s);
    }
}

Measured memory_bytes: 256
#https://qiita.com/k-tokitoh/items/8fc1a2de8b110a043ea2
#模写、ｄｐ
N = int(input())
dp = [110000]*(N+1)
dp[0] = 0
for i in range(1, N + 1):
    dp[i] = dp[i-1]+1
    p6 = 1
    p9 = 1
    while i >= 6 ** p6:
        dp[i] = min(1 + dp[i - 6 ** p6],dp[i])
        p6 += 1
    while i >= 9 ** p9:
        dp[i] = min(1 + dp[i - 9 ** p9],dp[i])
        p9 += 1


print(dp[N])

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n;
	cin >> n;
	int ans = 0;
	set<int>s;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		s.insert(x);
		if( x == *s.begin()) ans++;
	}
	cout << ans;
}

Measured memory_bytes: 13028
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
int flag[100];
char st[100];
int n,a[100000],b[100000],c[100000];
void init()
{
    for (int i=0;i<=9;++i) flag[i]=0;
    return;
}
int main()
{
    //freopen("e.in","r",stdin);
    //freopen("e.out","w",stdout);
    scanf("%s",st);
    n=strlen(st);
    for (int i=1;i<=n;++i) a[i]=(int)(st[i-1])-48;
    if (a[1]<5) a[1]+=5;else a[1]-=5;
    for (int i=1;i<=n;++i) ++flag[a[i]];
    bool FLAG=1;
    for (int i=0;i<=9;++i) if (flag[i]>1) {FLAG=0;break;}
    if (FLAG) {for (int i=1;i<=n;++i) printf("%d",a[i]);cout<<endl;return 0;}
    for (int i=1;i<=n;++i) b[i]=c[i]=a[i];
    bool flag1=0,flag2=0;
    while (1)
    {
        bool ttt=0;
        if (b[0]==0 && flag1==0)
        {
            bool Flag=1;
            init();
            for (int i=1;i<=n;++i)
            {
                if (flag[b[i]]) {Flag=0;++b[i];int t=i;while (b[t]>9) b[t]=0,++b[t-1],--t;for (int j=i+1;j<=n;++j) b[j]=0;break;}
                flag[b[i]]=1;
            }
            if (Flag) flag1=1;
            ttt=1;
        }
        if (c[0]==0 && flag2==0)
        {
            bool Flag=1;
            init();
            for (int i=1;i<=n;++i)
            {
                if (flag[c[i]]) {Flag=0;--c[i];int t=i;while (c[t]<0) c[t]=9,--c[t-1],--t;for (int j=i+1;j<=n;++j) c[j]=9;break;}
                flag[c[i]]=1;
            }
            if (Flag) flag2=1;
            ttt=1;
        }
        if (!ttt) break;
    }
    long long A=0LL,B=0LL,C=0LL;
    for (int i=1;i<=n;++i) B=B*10+b[i];
    for (int i=1;i<=n;++i) C=C*10+c[i];
    for (int i=1;i<=n;++i) A=A*10+a[i];
    //cout<<A<<endl<<B<<endl<<C<<endl<<endl;
    if (B-A>=A-C || b[0]!=0) {for (int i=1;i<=n;++i) printf("%d",c[i]);cout<<endl;}else {for (int i=1;i<=n;++i) printf("%d",b[i]);cout<<endl;}
    return 0;
}

Measured memory_bytes: 3256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18

priority_queue<llint,vector<llint>,greater<llint>> que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint r,g,b;

void solve(){
	cin >> r >>g >> b;
	llint a=r*100+g*10+b;
	if(a%4==0)cout << "YES" << endl;
	else cout << "NO" << endl;

}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#define	MOD  1000000007;
using namespace std;

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

	int aP = 0;
	int bP = 0;
	int cP = 0;

	char card = A[0];
	aP++;
	bool end = false;
	while (true)
	{
		switch (card)
		{
		case 'a':
			if (aP == A.size()) {
				cout << "A" << endl;
				end = true;
				break;
			}
			card = A[aP];
			aP++;
			break;
		case 'b':
			if (bP == B.size()) {
				cout << "B" << endl;
				end = true;
				break;
			}
			card = B[bP];
			bP++;
			break;
		case 'c':
			if (cP == C.size()) {
				cout << "C" << endl;
				end = true;
				break;
			}
			card = C[cP];
			cP++;
			break;
		}
		if (end)
		{
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N;
vector <int > C,S,F;
vector <int > x;





int main()
{

	cin >> N;

	C.resize(N);
	S.resize(N);
	F.resize(N);
	x.resize(N);
	REP(i,N-1){
		cin >> C[i] >> S[i] >> F[i];
	}

	REP(i,N-1){
		x[i] = S[i];
		x[i] += C[i];
		FOR(j,i+1,N-1){
			if(x[i]%F[j]==0)
				x[i] = max(S[j],x[i]);
			else
				x[i] = max(S[j],x[i]+(F[j] - x[i]%F[j]));

			x[i] += C[j];

		}
	}

	REP(i,N-1){
		cout << x[i] << endl;
	}
	cout << 0;
}





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

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

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

    private static void solve() {
        char[] s = in.next().toCharArray();
        char[] t = in.next().toCharArray();

        int ans = 0;
        for (int i=0; i < s.length; i++) {
            if (s[i] == t[i])
                ans++;
        }

        out.println(ans);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

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

}


Measured memory_bytes: 21076
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        k: usize,
    }
    let n = 50;
    let mut a = (0..n).collect::<Vec<usize>>();
    for i in 0..n {
        a[i] += k / n;
    }
    for i in 0..k % n {
        for j in 0..n {
            if i == j {
                a[j] += n;
            } else {
                a[j] -= 1;
            }
        }
    }
    println!("{}", n);
    println!(
        "{}",
        a.iter()
            .map(|&ai| format!("{}", ai))
            .collect::<Vec<_>>()
            .join(" ")
    );
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  int sum=0;
  for(int i=0;i<n;i++) cin>>a.at(i);
  
  while(true){
    bool ok=false;
    for(int i=0;i<n;i++){
      if(a.at(i)%2!=0) ok=true;
    }
    if(ok) break;
    for(int i=0;i<n;i++) a.at(i)/=2;
    sum++;
  }
  cout<<sum<<endl;

}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
int n,m;
int a[500010];
int b[500010];

bool check(int x)
{
	int front1=(x<a[m]);
	int front2=front1;
	int now1,now2;
	int asd=-1;//优先最近 
	rep(i,1,m)
	{
//		if(x>a[i])
//		{
//			now=1;
//		}
//		else
//		now=0;
		now1=(x<a[m+i]);
		if(now1==front1)
		{
//			asd=i;
			asd=1;
			break;
//			if(asd==-1)
//			{
//				asd=i;
//			}
//			else
//			{
//				
//			}
		}
		else
		front1=now1;
		
		now2=(x<a[m-i]);
		if(now2==front2)
		{
			asd=2;
			break;
		}
		else
		front2=now2;
	}
	if(asd==-1)
	{
		return a[1]<=x;
	}
	else
	if(asd==1)
	return now1^1;
	else
	return now2^1;
}
int main()
{
	cin>>n;
	m=n;
	n=2*n-1;
	rep(i,1,n+1)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	int l=1,r=n,mid;
	while(l<r)
	{
		mid=(l+r)>>1;
		if(check(b[mid]))//成立 
		{
			r=mid;
		}
		else
		{
			l=mid+1;
		}
	}
	cout<<b[l]<<"\n";
	return 0;
}


Measured memory_bytes: 5140
#include <bits/stdc++.h>
using namespace std;
#define s size
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define MOD 100000007
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0)
#define ll long long
typedef vector<ll> vl;
typedef map<ll,ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
bool D(int n, unordered_map<int, int> &P)
{
    if (P[n] > 1)
        return false;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            if (i != 1)
            {
                if (P.find(i) != P.end() || P.find(n / i) != P.end())
                    return false;
            }
            else if (P.find(i) != P.end())
                return false;
        }
    }

    return true;
}
int main()
{IOS;
int t;
t=1;
while(t--)
{ll n,i,c,p;
 cin >> n;

    set<ll> v;
    unordered_map<int, int> P;
    c = 0;
    for (i = 0; i < n; i++)
    {
        cin >> p;
        if (p == 1)
            c++;
        else
            v.insert(p), P[p]++;
    }
    if (c == 1)
        cout << 1;
    else if (c > 1)
        cout << 0;
    else
    {
        vector<ll> V;

        for (auto h : v)
        {
            if (D(h, P))
                V.pb(i + 1);
        }
        cout << V.size();
    }}
    return 0;
}


Measured memory_bytes: 23840
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>

using namespace std;

int main(){
  string S,sum,plus;
  cin >> S;
  for(int i=2; i<S.size(); i+=2){
    int j=(S.size()-i)/2;
    sum=S.substr(0,j);
    plus=S.substr(j,j);
    if(sum==plus){
      cout << j*2 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 384
s = input()
for _ in range(int(input())):
  c = input().split()
  a = int(c[1])
  b = int(c[2])
  if c[0] == "replace":
    s = s[:a] + c[3] + s[b+1:]
  elif c[0] == "reverse":
    s = s[:a] + s[a:b+1][::-1] + s[b+1:]
  else:
    print(s[a:b+1])


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



int main()
{
  ll A, B, K;
  cin >> A >> B >> K;
  ll cnt = 0;
  ll ans = min(A, B) + 1;
  while (cnt < K)
  {
    ans -= 1;
    if (A % ans == 0 && B % ans == 0)
    {
      cnt += 1;
    }
  }
  cout << ans << endl;
}


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

int main() {
    int a, b;
    char op;
    cin >> a >> op >> b;
    while (op!='?') {
        if (op == '+') {
            cout << a+b <<endl;
        } else if (op == '-') {
            cout << a-b <<endl;
        } else if (op == '*') {
            cout << a*b <<endl;
        } else if (op == '/') {
            cout << a/b <<endl;
        }
        cin >> a >> op >> b;
    }
    return 0;
}


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

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  if (n%2 != 0){
    cout << "No" << endl;
    return 0;
  }
  for (int i=0;i < n/2;i++){
    if (s[i] != s[n/2+i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
/*
Author : farhan132
*/
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
typedef pair < ll , pair < ll , ll > > cm;

#define ff first
#define ss second
#define pb push_back
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<=(b);i++)
#define f22(a,b) for(int j=(a);j<=(b);j++)
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld", &a , &b)
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n", a , b)
#define PI 3.14159265359
#define bug printf("**!\n")
#define mem(a , b) memset(a, b ,sizeof(a))
#define front_zero(n) __builtin_clzll(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcountll(n)
#define clean cout.flush()

const ll mod = (ll)1e9+7;
const ll maxn = (ll)1e5+10;
const int nnn = 664579+500;
const int inf = numeric_limits<int>::max()-1;
//const ll INF = numeric_limits<ll>::max()-1;
const ll INF = 1e18;

ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
ll dxx[]={0,1,0,-1,1,1,-1,-1};
ll dyy[]={1,0,-1,0,1,-1,1,-1};

//ofstream wr ("txt.txt");
//ifstream rr ("input.txt");

bool comp(dd a,dd b){
	if((abs(a-b)) <= 0.0000000001) return 1;
	return 0;
}

dd dist(dd x , dd y){
	
	return sqrt( (x*x) + (y*y) );
}

void solve(){
	
	ll n;
	dd d;
	cin >> n >> d;
	ll ans = 0;
	while(n--){
		dd x,y;
		cin >> x >> y;
		dd dis = dist(x,y);
		if(dis <= d || comp(d,dis)) ans++;
	}
	cout<<ans;
 	return;
}

int main() {
   
   ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
   //freopen("input.txt", "r", stdin);
   //freopen("output.txt", "w", stdout);
    ll T;
    T=1;
    //cin >> T;
    //scanf("%lld",&T);
    ll CT = 0;
    
    //work();
    while(T--){
    	//cout << "Case #" << ++CT <<": " ;
    	//printf("Case %lld: ",++CT);
		solve();
	}
	
    return 0;
}
/*


*/

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

int main(){
    string A, B, C; cin >> A >> B >> C;
    int a=0, b=0, c=0;
    char temp='a';
    //while((!(temp='a' && a==A.size())) && (!(temp='b' && b==B.size())) && (!(temp='c' && c==C.size()))){
    while(1){
        //cout << "temp is " << temp << endl;
        if (temp=='a'){
            if (a==A.size()) break;
            temp=A.at(a);
            a++;
        } else if (temp=='b'){
            if (b==B.size()) break;
            temp=B.at(b);
            b++;
        } else if (temp=='c'){
            if (c==C.size()) break;
            temp=C.at(c);
            c++;
        }
    }
    cout << (char)(temp-'a'+'A') << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;
use std::cmp::Ordering;

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let N = buf_it.next().unwrap().parse::<usize>().unwrap();
    let mut A = (0..2*N).map(|_| buf_it.next().unwrap().parse::<isize>().unwrap()).collect::<Vec<_>>();
    A.sort();
    println!("{}",(0..N).map(|i| A[i*2]).sum::<isize>());
}

Measured memory_bytes: 4352
def main():
  n,y=map(int,input().split())
  for i in range(n+1):
    for j in range(n+1):
      k=n-i-j
      if k<0:continue
      if y==10000*i+5000*j+1000*k:exit(print(i,j,k))
  print(-1,-1,-1)
main()

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  string s;
  int a=0;
  cin >> s;
  rep(i,0,3){
    if(s[i]=='a') a++;
    else if(s[i]=='b') a+=2;
    else a+=3;
  }
  
  if(a==6) co("Yes");
  else co("No");
  
  return 0;
}


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

def main():
    def count1(d, i):
        i2 = 2 ** i
        ret = (d // i2) * (i2 // 2)
        d -= 2 * ret
        if d >= i2 // 2:
            ret += d - (i2 // 2) + 1
        return ret

    A, B = [int(x) for x in input().strip().split()]
    ans = 0
    for i in range(40):
        ans += ((count1(B, i+1) - count1(A-1, i+1)) % 2) * 2 ** i
    
    print(ans)

if __name__ == '__main__':
    main()

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

int main(int argc, char **argv) {
  int i;
  int N, K;
  cin >> N >> K;
  vector<bool> A(N, false);
  for (int i = 0; i < K; ++i) {
    int d;
    cin >> d;
    for (int j = 0; j < d; ++j) {
      int k;
      cin >> k;
      --k;
      A[k] = true;
    }
  }
  int cnt = 0;
  for (int i = 0; i < N; ++i)
    if (!A[i])
      cnt++;
  cout << cnt << endl;
  return 0;
}


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

int main()
{
    int a[5], c=0, res=0;
    for(int i=0; i<5; i++) cin>>a[i];
    for(int i=0; i<5; i++)
    {
        if(a[i]%10==0) res+=a[i];
        else
        {
            res+=(((a[i]/10)+1)*10);
            c=max(c, (10-(a[i]%10)));
        }
    }
    cout<<(res-c)<<endl;

    return 0;
}


Measured memory_bytes: 256