akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    input! {x:isize,t:isize}
    println!("{}", max(0, x - t));
}


Measured memory_bytes: 4352
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=list(input())

for j in range(N-K):
    if T[K+j] == T[j]:
        T[K+j] = 0
print(sum([T.count("r")*P, T.count("s")*R, T.count("p")*S]))


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

const int MOD=1000000000+7;

int main(){
  ll n,k;
  cin >> n >> k;
  int ans=0;
  vector<ll> s(n+1);
  s[0]=0;
  for(int i=0;i<n;++i){
    s[i+1]=s[i]+(i+1);
  }
  while(k<n+1){
    ll ma=s[n]-s[n-k];
    ll mi=s[k-1];
    ans+=(ma-mi+1)%MOD;
    ans=ans%MOD;
    k++;
  }
  ans=(ans+1)%MOD;

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 4848
#include <stdio.h>

int main(void){
	int n,s,count=1;
	scanf("%d",&n);
	s=n;
  	if(n==1){ printf("%d",4);return 0;}
    if(n==2) {printf("%d",4);return 0;}
    if(n==4) {printf("%d",4);return 0;}
	while(1){
		if(s==1) s=n;
		else if(s%2==0) s=s/2;
		else s=3*s+1;
		if (s==4){
			printf("%d\n",count+4 );
			return 0;
		}
		count++;
	}
	return 0;
}

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

ll xorprod(ll x){
    if(x==-1)return 0;
    ll even = (x+1)%2;
    ll ones = (x/2)%2;
    ll ans=1;
    if(even)ans=x;
    if(ones)ans^=1;
    return ans;
}

int main(){
    ll a,b;
    cin>>a>>b;
    if(a==0)cout<<xorprod(b);
    else cout<<(xorprod(a-1)^xorprod(b));
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AizuOnlineJudgement.ITP1_2_A
{
	public static class Program
	{
		public static void Main (string[] args)
		{
			var ab = Console.ReadLine ().Split (' ').Select (s => int.Parse (s)).ToArray ();
			Console.WriteLine (ab[0] < ab[1] ? "a < b" : ab[0] > ab[1] ? "a > b" : "a == b");
		}
	}
}



Measured memory_bytes: 9248
K = [None]*30
A = [None]*30
Ms = [0]*31
def main():
    N, M = map(int, input().split())
    for i in range(N):
        K[i], *A[i], = map(int, input().split())
    for i in A:
        if i == None:
            break
        for j in i:
            Ms[j] += 1
    print(Ms.count(N))

main()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
// #include <bits/stdc++.h>

using namespace std;
typedef long long li;
typedef long double lf;

li n;
lf dp[305][305][305];

lf calc(int x, int y, int z) {
    int sum = x + y + z;
    lf &ans = dp[x][y][z];

    if (ans >= 0) {
        return ans;
    }

    if (sum == 0) {
        ans = 0;
    } else {
        ans = n / (lf) sum;
        if (x > 0) {
            lf xprob = x / (lf) sum;
            ans += xprob * calc(x - 1, y, z);
        }

        if (y > 0) {
            lf prob = y / (lf) sum;
            ans += prob * calc(x + 1, y - 1, z);
        }

        if (z > 0) {
            lf prob = z / (lf) sum;
            ans += prob * calc(x, y + 1, z - 1);
        }
    }

    return ans;
}

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

    cin >> n;

    int counts[3] = {};
    for (int i = 0; i < n; ++i) {
        li c;
        cin >> c;
        counts[c-1]++;
    }

    for (int i = 0; i < 305; ++i) {
        for (int j = 0; j < 305; ++j) {
            for (int k = 0; k < 305; ++k) {
                dp[i][j][k] = -1;
            }
        }
    }
    cout.precision(12);
    cout << calc(counts[0], counts[1], counts[2]) << endl;
    return 0;
}


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

typedef long long ll;

int main(){
  ll a,b,c;
  ll sum = 0;
  ll k,t;

  scanf("%lld %lld %lld %lld", &a, &b, &c, &k);

  if(a >= k){
    printf("%lld\n", k);
  }

  else{
    k = k - a;

    if(b >= k){
      printf("%lld\n", a);
    }

    else{
      k = k - b;

      printf("%lld\n", a - k);
    }
  }

  return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>
long long red[100000];
long long green[100000];
long long less[100000];
void qsred(int l,int r){
	int i,j;
	long long mid,temp;
	i=l;j=r;mid=red[(l+r)/2];
	while (i<=j){
		while (red[i]>mid) i++;
		while (red[j]<mid) j--;
		if (i<=j){
			temp=red[i];
			red[i]=red[j];
			red[j]=temp;
			i++;j--;
		}  
	}
	if (j>l) qsred(l,j);
	if (i<r) qsred(i,r);
}
void qsgreen(int l,int r){
	int i,j;
	long long mid,temp;
	i=l;j=r;mid=green[(l+r)/2];
	while (i<=j){
		while (green[i]>mid) i++;
		while (green[j]<mid) j--;
		if (i<=j){
			temp=green[i];
			green[i]=green[j];
			green[j]=temp;
			i++;j--;
		}  
	}
	if (j>l) qsgreen(l,j);
	if (i<r) qsgreen(i,r);
}
void qsless(int l,int r){
	int i,j;
	long long mid,temp;
	i=l;j=r;mid=less[(l+r)/2];
	while (i<=j){
		while (less[i]>mid) i++;
		while (less[j]<mid) j--;
		if (i<=j){
			temp=less[i];
			less[i]=less[j];
			less[j]=temp;
			i++;j--;
		}  
	}
	if (j>l) qsless(l,j);
	if (i<r) qsless(i,r);
}
int main(){
	int x,y,a,b,c,i,la,lb,ll,mark;
	long long ans=0,min;
	scanf("%d %d %d %d %d",&x,&y,&a,&b,&c);
	for (i=1;i<=a;i++)
	  scanf("%lld",&red[i]);
	for (i=1;i<=b;i++)
	  scanf("%lld",&green[i]);
	for (i=1;i<=c;i++)
	  scanf("%lld",&less[i]);
	qsred(1,a);
	qsgreen(1,b);
	qsless(1,c);
	la=x;lb=y;ll=1;
	red[0]=2147483647;
	green[0]=2147483647;
	while (1==1){
		min=red[la];
		mark=1;
		if (green[lb]<min)
		{	min=green[lb];
		    mark=2;}
		if (less[ll]<min) break;
		if (mark==1)
		  {ll++;la--;
		  }else{
		  	ll++;lb--;
		  }
		
	}
	for (i=1;i<=la;i++)
	  ans=ans+red[i];
	for (i=1;i<=lb;i++)
	  ans=ans+green[i];
	for (i=1;i<=ll-1;i++)
	  ans=ans+less[i];
  printf("%lld",ans);
}

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

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

signed main(){
  int n,k;
  cin>>n>>k;
  int ans=0;
  while(n>0){
    n/=k;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 256
from heapq import heappush, heappop
import sys
input = sys.stdin.buffer.readline

n, m = map(int, input().split())

neighbor = [[] for _ in range(n+1)]

for i in range(m):
    A, B = map(int, input().split())
    neighbor[A].append(B)
    neighbor[B].append(A)

h = []

heappush(h, (0, 1, 0))

ans = [0] * (n+1)
while h:
    step, cur, prev = heappop(h)

    for i in neighbor[cur]:
        if ans[i] == 0:
            ans[i] = cur
            heappush(h, (step+1, i, cur))

print('Yes')
for i in range(2, n+1):
    print(ans[i])


Measured memory_bytes: 103312
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<string> S(N);

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

    char base = S[0][S[0].length() - 1];

    for(int i = 1; i < N; i++) {
        for(int j = 0; j < i; j++) {
            if(S[i] == S[j]) {
                cout << "No" << endl;
                return 0;
            }
        }
        if(base != S[i][0]) {
            cout << "No" << endl;
            return 0;
        }
        base = S[i][S[i].length() - 1];
    }

    cout << "Yes" << endl;
}

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

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.math.BigInteger; 
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigInteger a = new BigInteger(sc.next());
        BigInteger b = new BigInteger(sc.next());
        if(a.equals(b)){
            System.out.println("EQUAL");

        }
        else if(a.compareTo(b) < 0){
            System.out.println("LESS");
        }
        else{
            System.out.println("GREATER");
        }

	}
}


Measured memory_bytes: 22996
import numpy as np
def resolve_b():
    card = [list(map(int, input().split())) for i in range(3)]
    l = [[0,0,0],[0,0,0],[0,0,0]]
    n = int(input())

    for i in range(n):
        num = int(input())
        for j in range(3):
            for k in range(3):
                if card[j][k] == num:
                    l[j][k] = 1
    nl = np.array(l)

    if sum(l[0]) == 3 or sum(l[1]) == 3 or sum(l[2]) == 3 or sum(l[:][0]) == 3 or sum(nl[:,0]) ==3 or sum(nl[:,1]) ==3 or sum(nl[:,2])==3:
        print("Yes")
    elif (l[0][0] + l[1][1] + l[2][2]) == 3 or (l[0][2] + l[1][1] + l[2][0])==3:
        print("Yes")
    else:
        print("No")
        
resolve_b()

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

using namespace std;


int main()
{
    int a, b, c, d, e, k;

    cin >> a >> b >> c >> d >> e >> k;
    
    if (abs(a-b) > k || abs(a-c) > k || abs(a-d)>k ||
            abs(a-e)>k || abs(b-c)>k || abs(b-d)>k ||
            abs(b-e)>k || c-d > k || c-e > k || d-e>k) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }

    return 0;   
}

Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
cnt = 0
c = 0
for i in range(N):
    s = 0
    A = list(map(int, input().split()))
    for j in range(M):
        s += A[j] * B[j]
    s += C
    if s > 0:
        c += 1
print(c)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main() {
    FAST
    ll n,m,x;
    cin>>n>>m>>x;
    ll inc[n][m],cost[n];
    for(int i=0;i<n;i++){
        cin>>cost[i];
        for(int j=0;j<m;j++) cin>>inc[i][j];
    }
    ll u[m]={0};
    ll ans=LLONG_MAX;
    int range=1<<n;
    for(int i=1;i<range;i++){
        ll u[m]={0};
        ll minCost=0;
        for(int j=0;j<n;j++){
            if((i>>j)&1){
                minCost+=cost[j];
                for(int k=0;k<m;k++){
                    u[k]+=inc[j][k];
                }
            }
        }
        int cnt=0;
        for(int p=0;p<m;p++){
            if(u[p]>=x) cnt++;
        }
        if(cnt==m) ans=min(ans,minCost); 
    }
    if(ans==LLONG_MAX) cout<<-1<<endl;
    else cout<<ans<<endl;
}

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

int main(){
    int  a = 0;
    cin >> a;
    long long  b = 2,c = 1,e = 0;
    long long  d=0;
    if ( a == 0 ){
        cout << b << endl;
    }  else if ( a == 1 ){
        cout << c << endl;
    } else {
        for (int i = 2;i <= a  ; i++){
            d = b + c;
            b = c;
            c = d;
        }
        cout << d << endl;
    }

}

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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    u64 X;
    cin >> X;
    u64 y = 100;
    u32 i = 0;
    for (i = 0; y < X; i++) {
        y = floor(y * 1.01);
    }
    cout << i << endl;
}


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


int main() {
  ll n; cin >> n;
  ll ans=0;
  rep(i,n){
    ans += i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


char A[200], B[200], C[200];
int inA = 0;
int inB = 0;
int inC = 0;

int main() {

	scanf("%s%s%s", A, B, C);

	char next = 'a';
	inA = 1;

 	while (true) {
		if (next == 'a') {
			if (inA == strlen(A)) {
				printf("A");
				return 0;
			}
			next = A[inA];
			inA++;
		}
		else if (next == 'b') {
			if (inB == strlen(B)) {
				printf("B");
				return 0;
			}
			next = B[inB];
			inB++;
		}
		else if (next == 'c') {
			if (inC == strlen(C)) {
				printf("C");
				return 0;
			}
			next = C[inC];
			inC++;
		}





	}




}



Measured memory_bytes: 128
<?php
    
    list($N,$M,$X) = array_map('intval',explode(" ",trim(fgets(STDIN))));
    
    for($i=0;$i<$N;$i++){
        $array[$i] = array_map('intval',explode(" ",trim(fgets(STDIN))));
        $book_fee[$i] =  array_shift($array[$i]);
    }
    // var_dump($book_fee);
    // var_dump($array);
    
    $min_sum=INF;
    //全ての本について買う場合買わない場合があるので2のN乗ループで間に合う
    //全ビット探査する
    for($bit=0;$bit<(1<<$N);$bit++){
        //理解度達成フラグ
        $flg=0;
        $fee_sum = 0;
        $unst_sum = array_fill(0,$M,0);
        for($k=0;$k<$N;$k++){
            //あるビットパターンについてビットが立っているとき
            if($bit & (1<<$k)){
                $fee_sum += $book_fee[$k];
                for($n=0;$n<$M;$n++){
                    $unst_sum[$n] += $array[$k][$n];
                }
                
            }
        }
        //調査が終わった時点で理解度の合計がすべて達成しているか
        foreach($unst_sum as $value){
            if($value < $X){
                //理解度が足りてないときに立つフラグ
                $flg = 1;
            }
        }
        //理解度達成していれば金額を比較して小さいものを残していく
        if($flg==0){
            if($min_sum > $fee_sum){
                $min_sum = $fee_sum;
                // $comb    = $bit;
            }
        }
    }
    if($min_sum == INF){
        echo "-1\n";
    }else{
        echo $min_sum."\n";
    }

?>

Measured memory_bytes: 16152
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N, M;

int main() {

	cin >> N >> M;

	if (N % 2) {
		rep(i, M) {
			cout << i + 1 << " " << M * 2 - i << endl;
		}
	}
	else {
		for (int m = M / 2, i = 0; m > 0; m--, ++i) {
			cout << i + 1 << " " << i + m * 2 + 1 << endl;
		}
		for (int m = (M + 1) / 2, i = M / 2 * 2 + 1; m > 0; m--, ++i) {
			cout << i + 1 << " " << i + m * 2 << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3576
from sys import stdin
from itertools import combinations
from math import factorial
import numpy as np
import math

n = int(stdin.readline().rstrip())

t = [0]*n
x = [0]*n
y = [0]*n
for i in range(n):
    t[i],x[i],y[i] = [int(x) for x in stdin.readline().rstrip().split()]

t = [0] + t
x = [0] + x
y = [0] + y

if n == 1:
    if x[1]+y[1] > t[1]:
        print("No")
        exit()
    elif t[1]%2 != (x[1]+y[1])%2:
        print("No")
        exit()
    else:
        print("Yes")
        exit()

for i in range(1,n):
    if abs(x[i]-x[i-1])+abs(y[i]-y[i-1]) > t[i]-t[i-1]:
        print("No")
        exit()
    elif (t[i]-t[i-1])%2 != (abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2:
        print("No")
        exit()

print("Yes")



Measured memory_bytes: 21512
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------

signed main() {
	int x, y = 1;
	while (cin >> x && x) {
		cout << "Case " << y++ << ": " << x << endl;
	}
}


Measured memory_bytes: 3028
fun main(){
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val aList = mutableListOf<List<Int>>()
    for (i in 0 until k){
        val d = readLine()!!.toInt()
        val a = readLine()!!.split(" ").map { it.toInt() }
        aList.add(a.toList())
    }

    val f = Array(n){true}
    aList.forEach { a ->
        a.forEach { f[it - 1] = false }
    }
    println(f.filter { it }.size)
}

Measured memory_bytes: 39248
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const int Mod= 1000000007;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

#define dbg(x1) cout<<#x1<<" = "<<(x1)<<endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<(x1)<<" "<<#x2<<" = "<<(x2)<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<(x1)<<" "<<#x2<<" = "<<(x2)<<" "<<#x3<<" = "<<(x3)<<endl
int n;
int a[maxn];
int pos[maxn];
ll Fac[maxn],Inv[maxn],inv[maxn];
void init()
{
    Fac[0]=Inv[0]=Fac[1]=Inv[1]=inv[1]=1;
    for(int i=2;i<maxn;i++)
    {
        Fac[i]=Fac[i-1]*i%Mod;
        inv[i]=inv[Mod%i]*(Mod-Mod/i)%Mod;
        Inv[i]=Inv[i-1]*inv[i]%Mod;
    }
}
ll c(ll n,ll m)
{
    if(n<m||m<0) return 0;
    return Fac[n]*Inv[m]%Mod*Inv[n-m]%Mod;
}
int main() {
    //freopen(".in", "r", stdin);
    init();
    scanf("%d",&n);
    n++;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int flag1=0,flag2=0;;
    for(int i=1;i<=n;i++)
    {
        if(pos[a[i]]!=0)
        {
            flag1=pos[a[i]];
            flag2=i;
        }
        pos[a[i]]=i;
    }
    for(int i=1;i<=n;i++)
    {
        ll ans = (c(n,i) - c(flag1-1+n-flag2,i-1) +Mod)%Mod;
        printf("%lld\n",ans);
    }
    return 0;
}



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

int main() {
	int N;
	long ans;

	ans = 0;

	cin >> N;
	vector<int> value(N);

	for(int num = 0; num < N; num++){
		cin >> value[num];
	}
	sort(value.begin(), value.end(), greater<int>());

	ans +=1;	// num = 0

	for(int num = 1; num < N; num++){
		if(value[num] < value[num-1])
			ans += 1;
	}
 	 cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, k;
	cin >> n >> k;
	vector<ll> a(n + 1);
	repn(i, 1, n + 1) cin >> a[i];
	vector<ll> sum(n + 1);
	sum[0] = 0LL;
	repn(i, 1, n + 1) sum[i] = sum[i - 1] + a[i];
	vector<ll> pos;
	repn(i, 1, n + 1) repn(j, i, n + 1) pos.pb(sum[j] - sum[i - 1]);
	for(ll i = 55; i >= 0; i--){
		//if we have more than k of that bit, only pass down the
		//ones that have it on
		//otherwise, no change
		vector<ll> pos1;
		int cnt = 0;
		rep(j, pos.size()) if(pos[j] & (1LL << i)){
			cnt++;
			pos1.pb(pos[j]);
		}
		if(cnt >= k){
			//we can have this this bit set
			pos = pos1;
		}
	}
	ll ans = pos[0];
	repn(i, 1, k) ans &= pos[i];
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  ll ans = n;
  ll cnt = 0;
  REP(i, n - 1) {
    if (s[i] != s[i + 1]) {
      ++cnt;
      ll l = max((ll)i + 1, n - 1 - i);
      ans = min(ans, l);
    }
  }
  if (cnt == 0) ans = n;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
// AOJ Vol-3 0312: Net Cafe
// 2017.9.30

#include <stdio.h>

#define MAX 200005
#define N 16

int m;
int w[MAX], t[MAX];;
int sw[MAX], st[MAX];
int c[N], b[N];
int dp[N][32770];		// 32768 = 2^15

int bsch(int *a, int x)
{
	int h, l = 1, r = m;

    while (l < r) {
        h = (l + r) >> 1;
		if (a[h] == x) return h;
        if (a[h] < x) l = h + 1; else r = h;
    }
	return l-1;
}

int main()
{
	int n, i, j, k, x, y, lim, ans;

	scanf("%d%d", &m, &n); m++;
	for (sw[0] = st[0] = 0, i = 1; i < m; i++) {
		scanf("%d%d", w+i, t+i);
		sw[i] = sw[i-1] + w[i], st[i] = st[i-1] + t[i];
	}
	for (i = 0; i < n; i++) scanf("%d%d", c+i, b+i);

//	memset(dp, 0, sizeof(dp));
	for (i = 0; i < n; i++)	{
		x = bsch(sw, c[i]);
		y = bsch(st, b[i]);
		if (x > y) x = y;
		if (x == m-1) { ans = m-1; goto Done; }
		dp[0][1<<i] = x;
	}

	lim = 1 << n;
	for (k = 1; k < lim; k++) {
		for (i = 0; i < n; i++)	{			// this book shelf
			for (j = 0; j < n; j++) {		// last book shelf
				if (dp[j][k] && !(k & (1<<i))) {
					int ii = k | (1 << i);
					x = bsch(sw, sw[dp[j][k]] + c[i]);
					y = bsch(st, st[dp[j][k]] + b[i]);
					if (x > y) x = y;
					if (x > dp[i][ii]) dp[i][ii] = x;
				}
			}
		}
	}
	for (ans = 0, i = 0; i < n; i++) if (dp[i][lim-1] > ans) ans = dp[i][lim-1];
Done:
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 6608
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
//#include <unordered_map>
//#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

vector <int> Vp;

bool pchk[400050];
int main() {
	int i, j, k, l;
	for (i = 2; i <= 400000; i++) {
		if (pchk[i]) continue;
		Vp.push_back(i);
		for (j = 2 * i; j <= 400000; j += i) pchk[j] = true;
	}

	srand(time(0));
	vector <int> Va;
	for (auto it : Vp) {
		if (it % 5 == 1) Va.push_back(it);
		if (Va.size() == 55) break;
	}

	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) printf("%d ", Va[i]);
	return !printf("\n");
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <math.h>
int minimum(int a, int b) { return a < b ? a : b; }
int maximum(int a, int b) { return a > b ? a : b; }
const long long mod = 1000000007;
//const long long mod = 998244353;


int main() {
	int A[9];
	for (int i = 0; i < 9; i++) {
		scanf("%d", A + i);
	}
	int N;
	scanf("%d", &N);
	auto b = new int[N];
	for (int i = 0; i < N; i++) {
		scanf("%d", b + i);
	}
	int bp[][3] = {
		{0,1,2},
		{3,4,5},
		{6,7,8},
		{0,3,6},
		{1,4,7},
		{2,5,8},
		{0,4,8},
		{2,4,6}
	};
	for (int i = 0; i < N; i++)for (int j = 0; j < 9; j++) {
		if (A[j] == b[i])A[j] = 0;
	}
	bool bingo = false;
	for (int i = 0; i < 8; i++) {
		if (A[bp[i][0]] == 0 && A[bp[i][1]] == 0 && A[bp[i][2]] == 0) {
			bingo = true;
		}
	}
	printf(bingo ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
while True:
    try:
        n, k = map(int, input().split())
        if n <= 2:
            print(n-1)
            continue
        lst = []
        ans = 0
        string = input()
        temp = string[0]
        count = 1
        for c in string[1:]:
            if c == temp:
                count += 1
            else:
                temp = c
                lst.append(count)
                ans += count-1
                count = 1
        lst.append(count)
        ans += count-1
        ans += min(k*2, len(lst)-1)
        print(ans)
    except:
        break

Measured memory_bytes: 4060
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
#define erase(i) erase(i, 1)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
template<typename T> void remove(std::vector<T>& vector, unsigned int index){vector.erase(vector.begin() + index);}
//priority_queue<int, vi, greater<int> > que;//昇順
//priority_queue<int> que; // 降順

using namespace std;

const int mod=1e9+7;

signed main()
{
    SPEED;
    int n,m;
    cin >> n >> m;
    if(n == m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        {
            cout << "No" << endl;
        }
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main() {
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if (a*b >= c * d)cout << a * b << endl;
	else cout << c * d << endl;






	return 0;
}

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

int main(){
    long L;
    cin >> L;
    vector<long> A(L), C({0}), B(L + 1), D(L + 1);
    for(auto& i : A){
        cin >> i;
        C.push_back(1 ^ (i & 1));
    }
    partial_sum(C.begin(), C.end(), C.begin());

    long s(0);
    auto c = [](long a){return a == 0 ? 2 : a & 1;};
    for(int i = 1; i <= L; ++i){
        s += A[i - 1];
        B[i] = min(s, B[i - 1] + c(A[i - 1]));
    }
    s = 0;
    for(int i = L - 1; i >= 0; --i){
        s += A[i];
        D[i] = min(s, D[i + 1] + c(A[i]));
    }

    long mindex(0), ans(numeric_limits<long>::max() / 3);
    for(int i = 0; i <= L; ++i){
        if(B[mindex] - C[mindex] > B[i] - C[i])mindex = i;
        ans = min(ans, B[mindex] - C[mindex] + C[i] + D[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7156
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 1e9+7;
 
int parent[N];
 
int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 
 
ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}
 
int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}
 
void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}
 
ll nCr(ll n, ll r) {
    ll res = 1;
    for(ll i=1;i<=r;i++) {
        res = res * (n - r + i) / i;
        // is different from
        // res *= (n -r + i) / i;
    }
    return res;
}
 
int ask(int i, int j) {
    cout << "? " << i + 1 << ' ' << j + 1 << endl;
    int v;
    cin >> v;
    return v;
}

int sumDigits(string s) {
    int sum = 0;
    int n = s.length();
    while(n-- > 0) {
        sum += (s[n] - '0');
        s = s.substr(0, n);
    }
    return sum;
}

void solve() {
    string s;
    cin >> s;
    //cout << sumDigits(s) << endl;
    if(sumDigits(s) % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return;
} 
 
int main()
{
    IOS
    //int t;
    //cin >> t;
    //while(t--) 
    solve();
    return 0; 
}

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

using namespace std;

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

int main(int argc, char const *argv[]) {
	int a,b,c,d;
	std::cin >> a >> b >> c >> d;
	std::cout << min(a ,b) + min(c,d) << '\n';
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
dic = defaultdict(int)

for i in range(1,n+1):
    s = str(i)
    dic[int(s[0]),int(s[-1])] += 1

point = 0

for i in range(1,10):
    for j in range(1,10):
        point += dic[i,j]*dic[j,i]

print(point)

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

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

    int ans=0;
    while(h>0){
        h-=n;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);

		int A=sc.nextInt();
		int P=sc.nextInt();

		int x=A*3+P;

		System.out.println((int)Math.floor((double)(x/2)));

		sc.close();

	}

}


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

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

Measured memory_bytes: 256
M = 998244353
N, S = map(int, input().split())

ans = 0
prev = [0]*S
for i, a in enumerate(map(int, input().split()), 1):
  if a > S:
    continue
  prev[0] = i
  ans += prev[S-a]*(N-i+1)
  for j, s in enumerate(prev[:S-a], a):
    prev[j] += s
print(ans%M)


Measured memory_bytes: 3808
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			int[] p = new int[n];
			long[] c = new long[n];
			for (int i = 0; i < n; i++) {
				p[i] = sc.nextInt();
			}
			for (int i = 0; i < n; i++) {
				c[i] = sc.nextInt();
			}
			long ans = Long.MIN_VALUE;
			for (int i = 0; i < n; i++) {
				int next = i;
				long max = Long.MIN_VALUE;
				long score = 0;
				for (int j = 0; j < k; j++) {
					next = p[next] - 1;
					score += c[next];
					max = Math.max(max, score);
					if (next == i) {
						if (score > 0) {
							long tmpmax = Long.MIN_VALUE;
							long tmpscore = 0;
							int roopcnt = k / (j + 1) - 1;
							int amari = k % (j + 1) + (j + 1);
							next = i;
							for (int l = 0; l < amari; l++) {
								next = p[next] - 1;
								tmpscore += c[next];
								tmpmax = Math.max(tmpmax, tmpscore);
							}
							max = Math.max(tmpmax + roopcnt * score, max);
						}
						break;
					}
				}
				ans = Math.max(max, ans);
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 48300
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int N = cin.nextInt();
        int A = cin.nextInt();
        int B = cin.nextInt();

        int ans = 0;



        WriteLine((N*A < B)? N*A:B);
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 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;
    }
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 40;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  ll dp[n+1][2][5];
  rep(i, n+1) rep(j, 2) rep(t, 5) dp[i][j][t] = 0;
  dp[0][0][0] = 1;

  rep(i, n) {
    int x = s[i]-'0';
    rep(j, 2) {
      for(int t = 0; t <= k; ++t) {
        rep(c, (j?10:x+1)) dp[i+1][(j||c < x)][t+((c==0)?0:1)] += dp[i][j][t];
      }
    }
  }
  cout << dp[n][0][k] + dp[n][1][k] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c,d,e = 0;
	
	scanf("%d %d %d",&a,&b,&c);

	while(a <= b){
		
		d = c % a;
		
		if(d == 0){
			++e;
		}
		++a;
	}
	
	printf("%d\n",e);

	return 0;
}

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

const int vmax=1000010;
const int inf=1023456789;

int N,M;
struct node{int to,cost;};
vector<node> graph[vmax];

typedef tuple<int,int> state;
int dist[vmax];
bool used[vmax];

int prim(){
	rep(i,N)dist[i]=inf,used[i]=false;
	dist[0]=0;
	int res=0;
	priority_queue<state,vector<state>,greater<state>> q;
	q.push(state(0,0));
	while(!q.empty()){
		int c,v;tie(c,v)=q.top();q.pop();
		if(used[v]) continue;
		res+=dist[v];
		used[v]=true;
		for(auto &e:graph[v]){
			int nc=e.cost;
			int nv=e.to;
			if(used[nv]) continue;
			if(dist[nv]>nc){
				dist[nv]=nc;
				q.push(state(nc,nv));
			}
		}
	}
	return res;
}

int main(void){
	cin >> N >> M;
	rep(i,M){
		int a,b,c;
		cin >> a >> b >> c;
		graph[a].push_back({b,c});
		graph[b].push_back({a,c});
	}
	cout << prim() << endl;
	return 0;
}

Measured memory_bytes: 28496
m, d = map(int,input().split())
cnt = 0
for i in range(1, m + 1):
    for j in range(1, d + 1):
        if (j % 10) * (j // 10) == i and j % 10 >= 2 and j // 10 >= 2:
            cnt += 1
print(cnt)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    ll n;
    cin >> n;
    
    int m = 0;
    ll sum = 0;
    rep3(i, 1, 13) {
        sum += pow_(26LL, i);
        if (sum >= n) { // i 文字
            rep3(j, 1, i) n -= pow_(26LL, j);
            m = i;
            break;
        }
    }
    cerr << n << " " << m << endl;
    
    vector<int> v;
    n--;
    while (1) {
        v.eb(n % 26);
        n /= 26;
        if (n == 0) break;
    }
    cerr << v << endl;
    while (sz(v) < m) v.eb(0);
    reverse(all(v));
    rep(i, sz(v)) cout << (char)(v[i] + 'a');
    cout << endl;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
lli lcm(lli num1, lli num2){
    return num1 / gcd(num1, num2) * num2;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> N >> M >> S >> T;
  map<int,char> mp;
  mp[0]=S[0];
  K=lcm(N,M);
  rep(i,1,N)mp[K/N*i]=S[i];
  rep(i,1,M)mp[K/M*i]=T[i];
  string X="";
  rep(i,0,N)X.pb(mp[K/N*i]);
  if(S!=X)flag=true;
  X="";
  rep(i,0,M)X.pb(mp[K/M*i]);
  if(T!=X)flag=true;
  if(flag)Out(-1);
  else Out(K);
}
  

Measured memory_bytes: 8448
/* *
 *
 * Author: Hamkor
 *
 * */
 
#include <bits/stdc++.h>

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */
int gcd(int a, int b){return b == 0? a : gcd(b, a%b);}
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, x, m = 1e9; cin>>n>>x;
	vector<int> a(n), b;
	for(int i =0; i<n; ++i){
		cin>>a[i];
		if (i > 0) b.push_back(abs(a[i] - a[i-1]));
		m = min(m, abs(x - a[i]));
	}
	int s = 0;
	for (auto i : b) s = gcd(s, i);
	cout<<gcd(s, m);
	return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y,z,p,a,b,c,i,j,k,ans=0;
  cin >> x >> y >> z >> p;
  int m[x][y];
  memset(m,0,sizeof(m));
  for(i=0;i<p;i++){
    cin >> a >> b >> c;
    m[a][b]++;
  }
  for(i=0;i<y;i++){
    for(j=0;j<x;j++){
      cin >> k;
      ans+=k*m[j][i];
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3096