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

public class Main {

    public static void main(String args[]) throws IOException {
        FastReader in = new FastReader();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        Task.solve(in, out);
        out.close();
    }

    static class Task {

        public static void solve(FastReader in, PrintWriter out) {
            double t = in.nextDouble(), x = in.nextDouble();
            System.out.println(t/x);
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        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;
        }
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 300010
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int top;
struct node
{	int l,r,sum; node *lc,*rc;
	node(int _l=0,int _r=0):l(_l),r(_r){sum=0;lc=rc=NULL;}
}*rt[N],pool[7000000],*null;
inline node *newnode(int l,int r)
{	node *x=pool+ ++top;
	x->l=l; x->r=r; x->sum=0; x->lc=x->rc=null;
	return x;
}
node *build(int l,int r)
{	node *x=newnode(l,r);
	if(l==r) return x;
	int mid=(l+r)>>1;
	x->lc=build(l,mid); x->rc=build(mid+1,r);
	return x;
}
struct Q{int l,r;}q[N];
node *ins(node *la,int pos)
{	node *x=newnode(la->l,la->r); x->lc=la->lc; x->rc=la->rc; x->sum=la->sum+1;
	if(x->l==x->r) return x;
	int mid=(x->l+x->r)>>1;
	if(pos<=mid) x->lc=ins(la->lc,pos);
	else x->rc=ins(la->rc,pos);
	return x;
}
int query(node *x,node *y,int l,int r)
{	if(x->l==l&&x->r==r) return x->sum-y->sum;
	int mid=(x->l+x->r)>>1;
	if(r<=mid) return query(x->lc,y->lc,l,r);
	else if(l>mid) return query(x->rc,y->rc,l,r);
	else return query(x->lc,y->lc,l,mid)+query(x->rc,y->rc,mid+1,r);
}
inline bool cmp(Q x,Q y){return x.l<y.l;}
int main()
{	int n,m; cin>>n>>m; rt[0]=build(1,m);
	null=pool; null->lc=null->rc=null; null->l=null->r=null->sum=0;
	for(rint i=1;i<=n;i++) scanf("%d%d",&q[i].l,&q[i].r);
	sort(q+1,q+n+1,cmp);
	for(rint i=1,j=1;i<=m;i++)
	{	rt[i]=rt[i-1];
		for(;j<=n&&q[j].l==i;j++) rt[i]=ins(rt[i],q[j].r);
	}
	printf("%d\n",n);
	for(rint i=2;i<=m;i++)
	{	int sum=n;
		for(rint j=0;j<m;j+=i) sum-=query(rt[min(m,j+i-1)],rt[j],j+1,min(m,j+i-1));
		printf("%d\n",sum);
	}
	return 0;
}


Measured memory_bytes: 224128
import java.io.*;
import java.util.*;
class Main{

	public static void main(String[] args) {
        FastScanner in = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        long cnt = 0;
        for(int i=1;i<n;i++) {
        	for(int j=1;j<n;j++) {
        		if(i*j>=n) break;
        		else cnt++;
        	}
        }
        out.println(cnt);
        out.flush();
	}
	
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		
		String next() {
			while(!st.hasMoreTokens())
				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());
		}
		
		int[] readArray(int n) {
			int a[] = new int[n];
			for(int i=0;i<n;i++) a[i] = nextInt();
			return a;
		}
		
		Integer[] readArray(long n) {
		    Integer a[] = new Integer[(int)n];
			for(int i=0;i<n;i++) a[i] = nextInt();
			return a;
		}
		
		long[] readArray(int n,long x) {
			long a[] = new long[n];
			for(int i=0;i<n;i++) a[i] = nextLong();
			return a;
		}
		
	}
	
	static class Pair implements Comparable<Pair> {
		int x, y;
		Pair(int a, int b){ x = a; y = b; }
		int getKey() { return x; }
		int getVal() { return y; }
		@Override
		public int compareTo(Pair o) {
			if(o.getVal() - this.getVal()>0)
				return -1;
			else if(o.getVal() - this.getVal()<0)
				return 1;
			else 
				return 0;
		}
		
	}
	
	static boolean arrayEquals(char a[], char b[]) {
		int n = a.length;
		boolean verdict = true;
		for(int i=0;i<n;i++) {
			if(a[i]!=b[i]) {
				verdict = false;break;
			}
		}
		return verdict;
	}
	
	static long lcm(long a, long b) {
		return (a*b)/gcd(a,b);
	}
	
	static long gcd(long a, long b) {
		if(b==0) return a;
		else return gcd(b,a%b);
	}
	
	static long hashInt(int x,int y) {
		return x*(1_000_000_000L)+y;
	}
}


Measured memory_bytes: 33520
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int N, Q, K[75];
ll D[75], M[75], DM[75], ans[75];
string S;

void solve() {
    cin >> N >> S >> Q;
    rep(i, Q)cin >> K[i];

    rep(i, N) {
        char c;
        rep(j, Q) {
            if (i >= K[j]) {
                c = S[i - K[j]];
                if (c == 'D') {
                    D[j]--;
                    DM[j] -= M[j];
                } else if (c == 'M') {
                    M[j]--;
                }
            }
        }

        c = S[i];
        rep(j, Q) {
            if (c == 'D') {
                D[j]++;
            } else if (c == 'M') {
                M[j]++;
                DM[j] += D[j];
            } else if (c == 'C') {
                ans[j] += DM[j];
            }
        }
    }

    rep(j, Q)cout << ans[j] << endl;
}

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

Measured memory_bytes: 1948
var
    n,i,j: Integer;
    a:array[1..2,1..100] of Integer;
function get_max(s,t:Integer): Integer;
begin
    if s>t then 
    begin
        exit(s);
    end
    else 
    begin
        exit(t);
    end;
end;

function solution(position_i,position_j:Integer):Integer;
var
    x,i: Integer;
begin
    x:=0;
    if position_i=2 then
    begin
        for i := position_j to n do
        begin
            inc(x,a[2][i]);
        end;
        exit(x);
    end;
    if position_j<n then 
    begin
        x:=a[position_i][position_j];
        exit(x+get_max(solution(1,position_j+1),solution(2,position_j)));
    end
    else 
    begin
        x:=a[1][n]+a[2][n];
        exit(x);
    end;
end;

begin
    readln(n);
    for i := 1 to 2 do
    begin
        for j := 1 to n do
        begin
            read(a[i][j]);
        end;
        readln;
    end;
    writeln(solution(1,1));
end.

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int targetTime = scan.nextInt();
		
		int ans = Integer.MAX_VALUE;
		int[][] costTime = new int[n][2];
		for (int i = 0; i < costTime.length; i++) {
			for (int j = 0; j < 2; j++) {
				costTime[i][j] = scan.nextInt();
			}
		}
		
		for (int i = 0; i < costTime.length; i++) {
			if (!(costTime[i][1] <= targetTime)) {
				continue;
			}
			
			if(ans > costTime[i][0]) {
				ans = costTime[i][0];
			}
		}
		
		if (ans == Integer.MAX_VALUE) {
			System.out.println("TLE");
		} else {
			
			System.out.println(ans);
		}
		
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
int n,k,array1[1005],sum=0,i;
scanf("%d %d",&n,&k);
for(i=0;i<n;++i){
    scanf("%d",&array1[i]);
}
sort(array1,array1+n);
i=0;
while(k--){
    sum+=array1[i++];
}
printf("%d\n",sum);

    return 0;
}


Measured memory_bytes: 3804
//intのオーバーフローに気をつけろ,AGCはだいたいlongにしておけ
//nextLineよりnextだ
//読み込みは先に全部やっておけ
//for文を回す回数を気をつけろ

import java.util.Scanner;

public class Main {

	public static void main(String args[]) throws InterruptedException {
		    Scanner sc = new Scanner(System.in);

		    String s = sc.next();
		    String t = sc.next();
		    int count = 0;
		    int counter = 0;
		    
		    for(int i = 0; i <= s.length()-t.length(); i++) {
		    	
		    	for(int j = 0; j < t.length(); j++) {
		    		if(s.substring(s.length()-t.length()+j-i, s.length()-t.length()+j-i+1)
		    				.equals(t.substring(j, j+1)) ||
		    				s.substring(s.length()-t.length()+j-i, s.length()-t.length()+j-i+1).equals("?")) {
		    			count++;
		    		}
		    	}
		    	
		    	if(count == t.length()) {
		    		s = s.substring(0,s.length()-t.length()-i) + t + s.substring(s.length()-i);
		    		counter++;
		    		break;
		    	}else {
		    		count = 0;
		    		continue;
		    	}
		    }
		    if(counter == 0) {
		    	System.out.println("UNRESTORABLE");
		    }else {
		    	s = s.replace("?", "a");
		    	System.out.println(s);
		    }
		    
		    
		    
		    sc.close(); }

	public static  int gcd(int a, int b) {
	    if (a < b) {
	        int tmp = a;
	        a = b;
	        b = tmp;
	    }

	    int r = -1;
	    while (r != 0) {
	        r = a % b;
	        a = b;
	        b = r;
	    }

	    return a;
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

const int  MAXN = 200001;

int A[MAXN];
int ans[MAXN] = {0};
int main(){
    int N;cin >> N;
    rep(i,N-1){
        cin >> A[i];
        ans[A[i]]++;
    }


    Rep(i,N)cout << ans[i] << endl;

    return 0;

}

Measured memory_bytes: 5080
while(True):
    m,d = map(int,input().split())
    if m==0 and d==0:
        break
    dn = sum([[31,29,31,30,31,30,31,31,30,31,30,31][a] for a in range(m-1)]) + d-1
    print(["Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"][dn%7])


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;

int n;
string s;

int main()
{
	cin>>s;
	REP(i,s.length()-8) cout<<s[i];
	puts("");
	return  0;
}












Measured memory_bytes: 768
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
a.sort()
b.sort() 
c.sort()
ans=0 
from bisect import bisect_left as bl,bisect_right as br 
for i in b: 
    left=bl(a,i)
    right=n-br(c,i)
    ans+=left*right 
print(ans)

Measured memory_bytes: 104932
import math
n,d = map(int,input().split())
xy = [list(map(int,input().split())) for i in range(n)]

ans = 0
for i in range(n):
    x = xy[i][0] ** 2
    y = xy[i][1] ** 2
    sub = math.sqrt(x+y)
    if sub <= d:
        ans += 1
        
print(ans)        

Measured memory_bytes: 45384
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<int> xx={0,1,0,-1},yy={1,0,-1,0};
signed main(){
  int H,W;
  cin>>H>>W;
  vector<string> A(H);
  for(string &S:A)
    cin>>S;
  int k=0;
  for(string &S:A)
    for(char &c:S)
      if(c=='.')
        k++;
  vector<vector<int>> B(H,vector<int>(W,0));
  B[0][0]=1;
  queue<pair<int,int>> C;
  C.push(make_pair(0,0));
  while(!C.empty()){
    int x=C.front().first,y=C.front().second;
    C.pop();
    if(x==H-1 && y==W-1){
      cout<<k-B[x][y]<<endl;
      return 0;
    }
    for(int i=0;i<4;i++){
      int xxx=x+xx[i],yyy=y+yy[i];
      if(0<=xxx && xxx<H && 0<=yyy && yyy<W && B[xxx][yyy]==0 && A[xxx][yyy]=='.'){
        B[xxx][yyy]=B[x][y]+1;
        C.push(make_pair(xxx,yyy));
      }
    }
  }
  cout<<-1<<endl;
}

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

#define REP(i, s, n) for(int i = (s); i < int(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(co) co.begin(), co.end()

int dp[101][3][2];
int sche[101];
const int MOD = 10000;

int main()
{
	int n, k; cin >> n >> k;
	n--;
	memset(sche, -1, sizeof(sche));
	rep(i, k)
	{
		int a, b; cin >> a >> b;
		a--; b--;
		sche[a] = b;
	}

	if (sche[0] != -1) dp[0][sche[0]][0] = 1;
	else rep(i, 3) dp[0][i][0] = 1;

	rep(i, n)
	{
		if (sche[i + 1] != -1) rep(j, 3)
		{
			if (j == sche[i + 1]) dp[i + 1][sche[i + 1]][1] += dp[i][sche[i + 1]][0] % MOD;
			else dp[i + 1][sche[i + 1]][0] += (dp[i][j][0] + dp[i][j][1]) % MOD;
		}
		else rep(j, 3) rep(k, 3)
		{
			if (j == k) dp[i + 1][j][1] += dp[i][k][0] % MOD;
			else dp[i + 1][j][0] += (dp[i][k][0] + dp[i][k][1]) % MOD;
		}
	}

	int ans = 0;
	rep(i, 3) (ans += (dp[n][i][0] + dp[n][i][1])) %= MOD;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3092
package main

import (
	"fmt"
	"unicode"
)

func main() {
	var a string
	fmt.Scan(&a)

	if IsFirstUpper(a) {
		fmt.Println("A")
	} else {
		fmt.Println("a")
	}

}

func IsFirstUpper(v string) bool {
	if v == "" {
		return false
	}
	r := rune(v[0])
	return unicode.IsUpper(r)
}


Measured memory_bytes: 1772
def main():
    lis = list(map(int, input().split()))
    ans = lis[0] * lis[2]
    a, b = lis[0:2], lis[2:4]
    for i in a:
        for j in b:
            if i * j > ans:
                ans = i * j
                
    print(ans)
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9064
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
  string S;
  cin >> S;
  int len = S.length();
  int count_0 = 0;
  int count_1 = 0;
  bool odd = false;
  for (int i=0;i<len;i++) {
    if (S[i] == '0') {
      if (odd) count_0++;
      else count_1++;
    } else {
      if (odd) count_1++;
      else count_0++;
    }
    odd = !odd;
  }
  cout << min(count_0, count_1) << endl;
  return 0;
}


Measured memory_bytes: 512
K = int(input())
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(arr[K-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
static const int MAX_N = 100000;
static const int MAX_Q = 100000;
static const int NIL = -1;

int N;
int a[MAX_N], b[MAX_N], c[MAX_N];
int Q, K;
int x[MAX_Q], y[MAX_Q];

struct edge{int to, cost;};
vector<edge> G[MAX_N];
ll d[MAX_N];

void bfs(int s){
	for(int i = 0; i < N; i++) d[i] = NIL;
	d[s] = 0;
	queue<int> q;
	q.push(s);
	int u;
	while(!q.empty()){
		u = q.front(); q.pop();
		for(int i = 0; i < G[u].size(); i++){
			edge e = G[u][i];
			if(d[e.to] == NIL){
				d[e.to] = d[u] + e.cost;
				q.push(e.to);
			}
		}
	}
}

void solve(){
	for(int i = 0; i < N - 1; i++){
		G[a[i] - 1].push_back((edge){b[i] - 1, c[i]});
		G[b[i] - 1].push_back((edge){a[i] - 1, c[i]});
	}
	bfs(K - 1);
	for(int i = 0; i < Q; i++) cout << d[x[i] - 1] + d[y[i] - 1] << endl;
}

int main(){
	cin >> N;
	for(int i = 0; i < N - 1; i++) cin >> a[i] >> b[i] >> c[i];
	cin >> Q >> K;
	for(int i = 0; i < Q; i++) cin >> x[i] >> y[i];
	solve();
	return 0;
}


Measured memory_bytes: 10740
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<vector>
#define R register
#define next kkksc03
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
inline ll read();
inline void write(ll x);
inline void writesp(ll x);
inline void writeln(ll x);
char s1[1000000],s2[1000000];
ll n,m;
int main(){	
	n=read();m=read();
	writeln(n*m/__gcd(n,m));
}
inline ll read(){
	ll x=0,t=1;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') t=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*t;
}
inline void write(ll x){
	if(x<0){putchar('-');x=-x;}
	if(x<=9){putchar(x+'0');return;}
	write(x/10);putchar(x%10+'0');
}
inline void writesp(ll x){
	write(x);putchar(' ');
}
inline void writeln(ll x){
	write(x);putchar('\n');
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 16

int main(int argc, char *argv[]) {

	char input[N];
	fgets(input, N, stdin);
	char num_array[3][4];
	int i = 0, j = 0, k = 0;
	while (i < N && j < 3) {
		if (input[i] == ' ' || input[i] == '\0') {
			while( input[++i] == ' ' || input[i] == '\0'){}
			j++;
			num_array[j][k] = '\0'; 
			k = 0;
			continue;
		}
		num_array[j][k++] = input[i++];
	}
		
	
	int A = atoi(num_array[0]);
	int B = atoi(num_array[1]);
	int T = atoi(num_array[2]);
	
	int generate_num = T / A;
	int total_biskets = B * generate_num;
	
	printf("%d", total_biskets);
	
}

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

#define f(i,a,b) for( ll  i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter   ios::sync_with_stdio(false);cin.tie(0)

// policy-based



using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;



 
const ll MAX = 3e5+100;
const ll inf = 1e9;
const ll mod = 1e9+7;

ll a[MAX],b[MAX],c[MAX];
int main(){
	fastio;
	ll n;
	cin >> n;
	f(i,0,n) cin >> a[i],c[a[i]]++;
	f(i,0,n) cin >> b[i],c[b[i]]++;
	f(i,1,n+1){
		if(c[i]>n){
			cout <<"No\n";
			return 0;
		}
	}
	reverse(b,b+n);
	ll ini = 0, fin = n-1,num;
	while(ini<n && a[ini]!=b[ini]) ini++;
	while(fin>=0 && a[fin]!=b[fin]) fin--;

	ll x =0,y = n-1;
	
	if(ini <=fin){
		f(i,ini,fin+1){
			if(a[x] != a[ini] && b[x] != a[ini]) swap(b[x],b[i]),x++;
			else swap(b[y],b[i]), y--;
		}
	}
	cout << "Yes\n";
	f(i,0,n) cout << b[i] <<" ";
	cout << endl;
	return 0;
}

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

def factorization(num):
    import math
    # 因数分解した結果をタプルのリストで返す
    # [(prime, count), ...]
    MAX_PRIME = int(math.sqrt(num)) + 1
    primes = []
    is_prime = [True] * (MAX_PRIME+1)
    for i in range(2, MAX_PRIME+1):
        if is_prime[i]:
            primes.append(i)
            for j in range(2*i, MAX_PRIME+1, i):
                is_prime[j] = False
    insu = []
    tmp = num
    max_count = 0
    for i in range(len(primes)):
        count = 0
        while tmp%primes[i] == 0:
            tmp //= primes[i]
            count += 1
        if count > 0:
            insu.append((primes[i], count))
            max_count = max(max_count, count)
        if tmp == 1:
            break
    if tmp != 1:
        insu.append((tmp, 1))
    return insu

def main():
    N = int(input())
    insu = factorization(N)
    ans = 0
    for p, c in insu:
        ans += int((-1 + pow(1 + 8 * c, 0.5)) / 2)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 20048
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if (a==b&&b!=c||a==c&&b!=c||c==b&&a!=c) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#-*-coding:utf-8-*-

def main():
    N,M,L=map(int,input().split())
    A=[]
    B=[]
    ans_matrix=[]
    A=[list(map(int,input().split())) for _ in range(N)]
    B=[list(map(int,input().split())) for _ in range(M)]

    ans_matrix=[[0]*L for _ in range(N)]
    for n in range(N):
        for l in range(L):
            tmp=0
            for m in range(M):
                tmp+=A[n][m]*B[m][l]
            ans_matrix[n][l]=tmp
    for ans in ans_matrix:
        print(*ans)

if __name__=="__main__":
    main()


Measured memory_bytes: 7056
#include<cstdio>
 
int a, b, c, aNew, bNew, cNew;
 
int main()
{
    scanf("%d%d%d", &a, &b, &c);
    int n = 0;
    while(!(a&1) && !(b&1) && !(c&1))
    {
        n++;
        aNew = (b + c) >> 1; bNew = (a + c) >> 1;  cNew = (a + b) >> 1; 
        if(a == aNew && b == bNew && c == cNew)
        {
            printf("%d\n", -1);
            return 0;
        }
        a = aNew; b = bNew; c = cNew;
    }
    printf("%d\n", n);
    return 0;
}

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

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

   cout << a * b << endl;
}

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

ll n,e;
ll inf=1e15;
vector<vector<ll>> E(15,vector<ll>(15,inf));
vector<vector<ll>> dp(1<<15+1,vector<ll>(15,-1));

ll rec(ll s,ll bit, ll v) {
  if(dp[bit][v]!=-1) return dp[bit][v];
  if(bit==(1<<v)) return dp[bit][v]=E[s][v];
  ll res=inf;
  ll prev_bit=bit-(1<<v);
  for(ll i=0;i<n;i++) {
    if(prev_bit&(1<<i)) {
      res=min(res,rec(s,prev_bit,i)+E[i][v]);
    }
  }
  return dp[bit][v]=res;
}

int main() {
  cin >> n >> e;
  for(ll i=0;i<e;i++) {
    ll f,t,w;
    cin >> f >> t >> w;
    E[f][t]=w;
  }
  ll ans=inf;
  for(ll i=0;i<n;i++) {
    ans=min(ans,rec(i,(1<<n)-1,i));
    for(ll j=0;j<n;j++) {
      for(ll k=0;k<(1<<n);k++) {
        dp[k][j]=-1;
      }
    }
  }
  if(ans==inf) {
    ans=-1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 12504
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            char c;
            int[] n = io.r<int>(' ');
            int b = n[0] + n[1];
            if (n[0] == -1 && n[1] == -1 && n[2] == -1) { break; }
            if (n[0] == -1 || n[1] == -1) { c = 'F'; }
            else if (b >= 80) { c = 'A'; }
            else if (b >= 65) { c = 'B'; }
            else if (b >= 50) { c = 'C'; }
            else if (b >= 30) { if (n[2] >= 50) { c = 'C'; } else { c = 'D'; } }
            else { c = 'F'; }
            io.w(c);
        }
        io.wflush();
    }
}

namespace LIB
{
    public class io
    {
        private const int WMAX = 1000;
        private static StringBuilder S = new StringBuilder();
        public static T r<T>() { return util.parse<T>(r()); }
        public static T[] r<T>(char s = ' ') { return r().Split(s).Select(util.parse<T>).ToArray(); }
        public static T[] r<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = r<T>(); } return r; }
        public static T[][] r<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = r<T>(s); } return r; }
        private static string r() { return Console.ReadLine(); }
        public static void w(object v, bool lf = true) { S.Append(util.parse<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { wflush(); } }
        public static void wflush() { Console.Write(S.ToString()); S.Length = 0; }
    }
    public class util
    {
        public static T parse<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
    }
    public class memo<Key, Result>
    {
        private Dictionary<Key, Result> R;
        public memo() { R = new Dictionary<Key, Result>(); }
        public Result exec(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
    }
}

Measured memory_bytes: 10340
#include <bits/stdc++.h>
using namespace std;
int main(void){
   int N,M,l,r,ans;
   cin>>N>>M;
   vector<int>L(M);
   vector<int>R(M);
   cin>>L[0]>>R[0];
   l=L[0];
   r=R[0];
   for(int i=1;i<M;i++){
        cin>>L[i]>>R[i];
       l=max(l,L[i]);
       r=min(r,R[i]);
   }
   ans=r-l+1;
   if(0>ans){
       ans=0;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define INF 1e9
#define All(x) (x).begin(),(x).end()
#define Cout(x) cout << (x) << endl
typedef long long ll;
using namespace std;

int main(){
    ll N,A,B,X,Y;
    string s,t;
    cin>>A>>B;
    if(A*500>=B)Cout("Yes");
    else Cout("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < N; X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair


using namespace std;

int main(){

    //各aiとそれの+-1となる値をカウントアップするようにする
    //そうしてカウントした中で一番大きい数が答えとなる
    //mapを用いてO(n log n)

    int n;
    cin >> n;

    map<int, int> m;
    int ans = 0;

    rep(i,n){
        int tmp;
        cin >> tmp;

        m[tmp]++;
        m[tmp - 1]++;
        m[tmp + 1]++;
    }

    for(auto i = m.begin(); i != m.end(); i++){
        ans = max(ans, i->second);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4736
def change(t) :
    if t == 1 :
        return 6000
    elif t == 2 :
        return 4000
    elif t == 3 :
        return 3000
    elif t == 4 :
        return 2000


t1, n1 = map(int, input().split())
t2, n2 = map(int, input().split())
t3, n3 = map(int, input().split())
t4, n4 = map(int, input().split())

print(change(t1) * n1)
print(change(t2) * n2)
print(change(t3) * n3)
print(change(t4) * n4)


Measured memory_bytes: 5600
#include <stdio.h>


int combination(int n, int x)
{
	int count = 0;
	int a, b, c;

	for(a=1;a<=n;a++){
		for(b=a+1;b<=n;b++){
			for(c=b+1;c<=n;c++){
				if(a+b+c==x && a!=b && b!=c && c!=a)
					count++;
			}
		}
	}
	return count;
}

int main(void)
{
	int n, x;
	int i;


	while(scanf("%d %d", &n, &x)!=EOF && !(n==0 && x==0)){
		printf("%d\n", combination(n, x));
	}

	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNextInt()){
				double[] a=new double[6];
				for(int i=0;i<6;i++)a[i]=Double.parseDouble(sc.next());
				double x = (a[2]*a[4]-a[1]*a[5])/(a[0]*a[4]-a[1]*a[3]);
				double y = (a[0]*a[5]-a[2]*a[3])/(a[0]*a[4]-a[1]*a[3]);
				
				System.out.println(String.format("%.3f %.3f",x+0.0,y+0.0));
				
			}
		}
	}
}

Measured memory_bytes: 26460
#include<stdio.h>
#define N 100

typedef struct{
  int m[6];
} DICE;

void diceroll(DICE *,char);
int judge(DICE *,DICE *);
int judge2(DICE *,DICE *,char,char);

int main(){
  DICE dice[N];
  int i, j, cnt, judge=0;

  //input cnt
  scanf("%d",&cnt);
  
  //input dice
  for(j=0;j<cnt;j++){
    for(i=0;i<6;i++) scanf("%d",&dice[j].m[i]);
  }
  
  //judge
  for(i=0;i<cnt;i++){
    for(j=i+1;j<cnt;j++){
      if(judge2(&dice[i],&dice[j],'S','E')==0 ||judge2(&dice[i],&dice[j],'E','S')==0 ||judge2(&dice[i],&dice[j],'W','N')==0 ||judge2(&dice[i],&dice[j],'N','W')==0) judge++;
    }
  }

  //result
  if(judge>0) printf("No\n");
  else printf("Yes\n");
  
  return 0;
}



void diceroll(DICE *dice,char c){
  int tmp;
  tmp=dice->m[0];
  
  if(c=='N'){
    dice->m[0]=dice->m[1];
    dice->m[1]=dice->m[5];
    dice->m[5]=dice->m[4];
    dice->m[4]=tmp;
  }
  
  else if(c=='S'){
    dice->m[0]=dice->m[4];
    dice->m[4]=dice->m[5];
    dice->m[5]=dice->m[1];
    dice->m[1]=tmp;
  }
  
  else if(c=='E'){
    dice->m[0]=dice->m[3];
    dice->m[3]=dice->m[5];
    dice->m[5]=dice->m[2];
    dice->m[2]=tmp;
  }
  
  else if(c=='W'){
    dice->m[0]=dice->m[2];
    dice->m[2]=dice->m[5];
    dice->m[5]=dice->m[3];
    dice->m[3]=tmp;
  }

  else return;
}

int judge(DICE *d1, DICE *d2){
  int i;

  for(i=0;i<6;i++){
    if(d1->m[i]!=d2->m[i]) return 1;
  }
  
  return 0;
}

int judge2(DICE *d1,DICE *d2,char a, char b){
  int i, j;
  
  for(i=0;i<4;i++){
    diceroll(d1,a);
    
    for(j=0;j<5;j++){
      diceroll(d1,b);
      
      if(judge(d1,d2)==0) return 0;
    }
    
  }
  
  return 1;
}



Measured memory_bytes: 2108
A_0 = [int(i) for i in input().split()]
A_1 = [int(i) for i in input().split()]
A_2 = [int(i) for i in input().split()]
A = [A_0,A_1,A_2]
N = int(input())
B = set()
for i in range(N):
    B.add(int(input()))
for i in range(3):
    C = {A[k][i] for k in range(3)}
    D = {A[i][k] for k in range(3)}
    if C <= B or D <= B:
            print("Yes")
            break
else:
    if {A[0][0],A[1][1],A[2][2]} <= B or {A[0][2],A[1][1],A[2][0]} <= B:
        print("Yes")
    else :
        print("No")

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

using namespace std;
typedef long long ll;
const int MAXN = 6100;

int N, T;
ll M;
ll dp[MAXN][MAXN];

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N >> M;
    T = 3 * N;

    dp[0][0] = 1;

    for (int i = 0; i <= T; i++)
    {
        for (int j = 0; j <= T; j++)
        {
            dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % M;
            dp[i+2][j+1] = (dp[i+2][j+1] + dp[i][j] * (i + 1)) % M;
            dp[i+3][j+1] = (dp[i+3][j+1] + dp[i][j] * (i + 1) * (i + 2)) % M;
        }
    }

    ll res = 0;
    for (int i = 0; i <= N; i++)
        res = (res + dp[T][i]) % M;
    cout << res << "\n";
}

Measured memory_bytes: 286976
#include<iostream>

using namespace std;
int main() {
	int N;
	cin >> N;
	if (N == 1) {
		cout << "Hello World" << endl;
	}
	else if (N == 2) {
		int A, B;
		cin >> A >> B;
		int sum = 0;
		sum = A + B;
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int k, a, b; cin >> k >> a >> b;
  bool c = 0;
  for(int i = a; i <= b; ++i){
    if(i % k == 0) c = 1;
  }
  if(c) cout << "OK\n";
  else cout << "NG\n";
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<pair<int,int>> range(N);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    range[i].first = a+b;
    range[i].second = a-b;
  }
  
  sort(range.begin(), range.end());
  int l = range[0].first;
  int ans = 1;
  for (int i = 1; i < N; i++) {
    if (l <= range[i].second) {
      ans += 1;
      l = range[i].first;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define T true
#define F false
#define endl "\n"
typedef char ch;
typedef bool boll;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef set < string > sst;
typedef set < long long > sl;
typedef queue < long long > que;
typedef vector < long long > vec;
typedef map < long long, long long > mll;
typedef pair < long long, long long > pll;
typedef vector < pair < long long, long long > > vpl;
typedef pair < long long, unsigned long long > pul;

int main(){
    int n,m,ans=0;
    cin >> n >> m;
    int h[n];
    bool onroad[n]={false},good[n]={true};
    for(int i=0;i<n;i++) {
        good[i] = true;
        cin >> h[i];
    }
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;

        /*onroad[a-1]=true;
        onroad[b-1]=true;*/

        if(h[a-1]>h[b-1]){
            good[a-1] = good[a-1]&&true;
            good[b-1] = false;
        }
        else if(h[a-1]<h[b-1]){
            good[b-1] = good[b-1]&&true;
            good[a-1] = false;
        }
        else{
            good[a-1] = false;
            good[b-1] = false;
        }
    }
    for(int i=0;i<n;i++){
        //cout << good[i]<<endl;
        if(good[i]) ans++;
    }
    cout << ans;
}


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

int main() {
	int x;
	int c5 = 0;
	int c7 = 0;
	
	for (int i=0; i<3; i++) {
		cin >> x;
		if ( x == 5 ) c5++;
		if ( x == 7 ) c7++;
	}
	if ( c5 ==2 && c7 == 1) {
		cout << "YES";
	} else {
		cout << "NO";
	}
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

          
		var inputArray = retreiveStringArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var S = inputArray[0];

			var N = S.Length;

			var count = 0;

			for (int i = 0; i < N/2; i++) {
				if(S[i] != S[N - i - 1]) {
					count++;
				}
			}

			//答えの出力
			var ans = count;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    int a=1,b;
    if(y==2*x)
        cout<<"Yes"<<endl;
    else if(y==4*x)
        cout<<"Yes"<<endl;
    else{
            bool f=0;
    while(1)
    {
        b=x-a;
        if(b>0)
        {
           long long q=a*2+b*4;
            if(q==y)
            {
                f=1;break;
            }
            a++;
        }
    else
        break;
    }
    if(f==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  int n;
  cin >> n;
  int num;
  int ans = 0;
  rep(i,n){
    cin >> num;
    if(num == 2) ++ans;
    else if(num % 2 == 0 || num == 1) continue;
    else{
      int m = sqrt(num);
      int o = 0;
      for(int j = 3; j <= m; j++){
        if(num % j == 0 ){
          o++;
          break;
        }
      }
      if( o == 0) ans++;
    }
  } 
  cout << ans << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include<string>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn=1e5+4;
inline ll pow(ll t){
	return t*t*t;
}
int main(){
    ll n,k;
    while(cin>>n>>k){
    	ll ans=0;
    	if(k&1){
    		ans=pow(n/k);
		}
		else{
			ll t=n/k;
			ans=pow(t);
			if(n%k>=k/2)
				t++;
			ans+=pow(t);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#AOJ A
while 1:
    n,p = map(int,input().split())
    if n == 0 and p == 0:
        break
    s = [0]*n
    w = p
    while 1:
        for i in range(n):
            flg = False
            if w > 0:#碗が空でない
                w -= 1
                s[i] += 1
            else:#碗が空
                if s[i - 1] == p:
                    flg = True
                    if i > 0:
                        ans = i-1
                    else:
                        ans = n-i-1
                    break
                w += s[i]
                s[i] = 0
        if flg:
            print(ans)
            break


Measured memory_bytes: 5600
#include <iostream>

typedef long long ll;

#define FOR(i,a,b) for(ll i = (a);i < (b);++i)
#define REP(i,n) FOR(i,0,n)

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){

  int a,b,c;
  cin >> a >> b >> c;

  int ans = (a^b)^c;

  cout << ans << endl;
    
  return 0;
}


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

int main() {
	int N, M;
	cin >> N >> M;
	int ans[M]={0};
	for (int i=0; i<N; i++){
	    int K;
	    cin >> K;
	    for (int i=0; i<K; i++){
	        int A;
	        cin >> A;
	        ans[A-1]++;
	    }
	}
	int count=0;
	for (int i=0; i<M; i++){
	    if (ans[i]==N) count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,T;
	cin >> n >> T;
	int ans = 0 , pre = -T;
	for(int i=1,t;i<=n;i++) {
		cin >> t;
		int add = min(T,t + T - (pre + T));
		ans += add;
		pre = t;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

#define N 100

int check(int id, int distance, int a[N + 1][N], int count[N], int d[N]){
    if(d[id] != -1 && distance >= d[id]) return d[id];
    d[id] = distance;
    for(int i = 0; i < count[id]; ++i){
        check(a[id][i], distance + 1, a, count, d);
    }
    return d[id];
}

int main(){
    int n;
    std::scanf("%d", &n);

    int a[N + 1][N];
    int d[N + 1];
    int count[N + 1];
    for(int i = 1; i <= n; ++i){
        int id;
        std::scanf("%d", &id);
        std::scanf("%d", &count[id]);
        for(int j = 0; j < count[id]; ++j){
            std::scanf("%d", &a[id][j]);
        }
        d[id] = -1;
    }

    check(1, 0, a, count, d);

    for(int i = 1; i <= n; ++i){
        std::printf("%d %d\n", i, d[i]);
    }

    return 0;
}



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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 305;

int n, cnt[5];
db dp[N][N][N];
bool u[N][N][N];

db calc(int a, int b, int c) {
	if (u[a][b][c]) return dp[a][b][c];
	u[a][b][c] = 1;
	if (!a && !b && !c) return dp[a][b][c] = 0.0;
	int zeroes = n - a - b - c;
	db C = (c ? calc(a, b + 1, c - 1) : 0.0);
	db B = (b ? calc(a + 1, b - 1, c) : 0.0);
	db A = (a ? calc(a - 1, b, c) : 0);
	return dp[a][b][c] = (a * A + b * B + c * C + n + 0.0) / (n - zeroes);
}

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	cout << setprecision(10) << fixed;
	
	cin >> n;

	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		cnt[x]++;
	}

	cout << calc(cnt[1], cnt[2], cnt[3]);
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


Measured memory_bytes: 246016
#include <iostream>
#include <string>
 
int CountIsland(std::string* map);
void DeleteIsland(int x,int y,std::string* map);
 
int main()
{
    std::string map[12]={};
    do{
        for(int i=0;i<12;i++){
            if(!(std::cin>>map[i])){
                return 0;
            }
        }
        std::cout<<CountIsland(map)<<std::endl;
    }while(std::cin);
}
int CountIsland(std::string* map)
{
    int island=0;
    for(int i=0;i<12;i++){
        for(int j=0;j<12;j++){
            if(map[i][j]=='1'){
                island++;
                DeleteIsland(i,j,map);
            }
        }
    }
    return island;
}
void DeleteIsland(int x,int y,std::string* map)
{
    map[x][y]='2';
    if(x>0&&map[x-1][y]=='1'){
        DeleteIsland(x-1,y,map);
    }
    if(x<11&&map[x+1][y]=='1'){
        DeleteIsland(x+1,y,map);
    }
    if(y>0&&map[x][y-1]=='1'){
        DeleteIsland(x,y-1,map);
    }
    if(y<11&&map[x][y+1]=='1'){
        DeleteIsland(x,y+1,map);
    }
}
 

Measured memory_bytes: 1196
#pragma region
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
#pragma endregion

void solve() {
  int now = 1;
  int a, b;
  cin >> a >> b;
  int ans = 0;
  while (now < b) {
    now += a - 1;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
abc = [list(map(int,input().split())) for _ in range(N)]
dp = [[0]*3 for _ in range(N)]
dp[0][0],dp[0][1],dp[0][2] = abc[0][0],abc[0][1],abc[0][2]

for i in range(1,N):
  for j in range(3):
    for k in range(3):
      if j != k:
        dp[i][k] = max(dp[i][k], dp[i-1][j] + abc[i][k])

ans = max(dp[N-1])
print(ans)

Measured memory_bytes: 74140
#include "bits/stdc++.h"
#include <chrono>
#include <random>
#include <cstdio>
#define ll long long int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define mod 1000000007LL
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define pll pair<ll, ll>
#define pint pair<int, int>
#define S second
#define F first
#define all(c) (c).begin(),(c).end()
using namespace std;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
const int N=500001;
// vector<pair<ll, ll> > adj[N];
// bool vis[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
#define pi 3.14159265358979323846264338
using namespace std; 
ll max(ll a, ll b){ if(a>b)return a;return b;}
ll min(ll a, ll b){ if(a < b) return a;return b;}
ll inf = 100000000000000000;
vector <pint> adj[N];

ll n, a, b;
vl h(N);

bool check(ll x)
{
    ll tot = 0;

    rep(i, n)
    {

        if(h[i] > b*x)
        {
            tot += ((h[i] - b*x)/(a-b));
            if((h[i] - b*x) % (a - b) != 0) tot++;
        }

        else continue;
    }

    if(tot > x) return false;
    return true;
}

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

    ll l = 0, r = 1e10;
    ll ans = LLONG_MAX;

    while(l <= r)
    {
        ll mid = (l+r)/2;
        // cout<<l<<" "<<r<<endl;
        if(check(mid))
        {
            r = mid - 1;           
            ans = min(ans, mid);
        }
        else
        {
            l = mid + 1;
        }
    }

    if(check(l))
    {
        ans = min(ans, l);
    }

    // cout<<check(31250000000000000)<<endl;

    // cout<<check(3)<<endl;

    cout<<ans<<endl;

}

int main()
{

    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)

    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }


    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 18624