akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int q;
  cin >> q;
  vector<p> rpc(q);
  rep(i, q) cin >> rpc[i].first >> rpc[i].second;

  vector<int> num(100000);
  rep(i, n) num[a[i]]++;
    
  ll s = 0;
  rep(i, n) s += a[i];
  rep(i, q) {
    s += (rpc[i].second - rpc[i].first) * num[rpc[i].first];
    cout << s << endl;
    num[rpc[i].second] += num[rpc[i].first];
    num[rpc[i].first] = 0;
  }
  
  return 0;
}


Measured memory_bytes: 4792
#include<iostream>
#include<algorithm>
using namespace std;
int ans[100][100];
int main(){
	int n,k;
	while(true){
	cin>>n>>k;
	if(n==0&&k==0)break;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i==j)ans[i][j]=0;
			else ans[i][j]=1000869121;
		}
	}
	bool news;
	int a,b,c,d,e;
	for(int u=0;u<k;u++){
		cin>>news;
		if(news){
			cin>>c>>d>>e;
			c--,d--;
			ans[c][d]=min(ans[c][d],e);
			ans[d][c]=min(ans[d][c],e);
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					ans[i][j]=min(ans[i][c]+ans[d][j]+e,ans[i][j]);
					ans[i][j]=min(ans[i][d]+ans[c][j]+e,ans[i][j]);
				}
			}
		}
		else{
			cin>>a>>b;
			a--,b--;
			if(ans[a][b]==1000869121)cout<<"-1"<<endl;
			else cout<<ans[a][b]<<endl;
		}
	}
	}
	return 0;
}

Measured memory_bytes: 1204
import numpy as np

N = input()
N = int(N)
p = input().split()
p_l = [int(s) for s in p]

maxp = 0
flag = "Yes"
for i in range(0,N-1):
    if p_l[i]>maxp:
        maxp = p_l[i]
    if maxp > p_l[i+1]+1:
        flag = "No"
        break
print(flag)


Measured memory_bytes: 23132
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define MAXLEVEL 12
#define MAXW 100010

int n, q;
vector<int> ans, qv, ql, v, w, d;
vector<vector<int>> dp;
vector<vector<int>> qlist;

void dfs(int id, int level) {
	if (id > n) return;
	d[level] = id;

	int i, j, k;

	if (level < MAXLEVEL) {
		for (i = 0; i < MAXW; i++) {
			dp[level][i] = dp[level - 1][i];
			if (i - w[id] >= 0) dp[level][i] = max(dp[level][i], dp[level - 1][i - w[id]] + v[id]);
		}
	}

	for (auto qid : qlist[id]) {
		if (level < MAXLEVEL) ans[qid] = dp[level][ql[qid]];
		else {
			int m = level + 1 - MAXLEVEL, mm = 1 << m, sv, sw;
			ans[qid] = 0;
			for (i = 0; i < mm; i++) {
				sv = 0; sw = 0;
				for (j = 0; j < m; j++) {
					if ((1 << j) & i) {
						sv += v[d[level - j]];
						sw += w[d[level - j]];
					}
				}
				if (ql[qid] - sw >= 0) ans[qid] = max(ans[qid], sv + dp[MAXLEVEL - 1][ql[qid] - sw]);
			}
		}
	}

	dfs(id * 2, level + 1);
	dfs(id * 2 + 1, level + 1);
}

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

	int i, j, k;

	cin >> n;
	v.resize(n + 1);
	w.resize(n + 1);
	for (i = 1; i <= n; i++) cin >> v[i] >> w[i];
	
	cin >> q;
	ans.resize(q);
	qv.resize(q);
	ql.resize(q);
	qlist.resize(n + 1);
	for (i = 0; i < q; i++) {
		cin >> qv[i] >> ql[i];
		qlist[qv[i]].push_back(i);
	}

	dp.assign(MAXLEVEL, vector<int>(MAXW, 0));

	d.resize(n + 100);
	dfs(1, 1);

	for (i = 0; i < q; i++) cout << ans[i] << "\n";

	return 0;
}


Measured memory_bytes: 20884
# include<stdio.h>
int main()
{
	int n,/*max,*/s,t=1;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
//		if(i==0)
//		max=a[0];
//		else
//		if(max,a[i])
//		max=a[i];
	}
//	maxer=a[0];
	for(int i=0;i<n;i++)
	{
//		if(maxer!=max&&maxer<a[i])
        for(int j=i+1;j<n;j++)
        {
        	if(a[i]<a[j])
            {
  		       s=a[j];
        	   a[j]=a[i];
        	   a[i]=s;
			}
//			else
//			{
//				if(a[i]==a[j])
//				{
//					
//				}
//			}
		}
	}
	for(int i=0;i<n;i++)
	{
		if(i!=0)
		{
			if(a[i]<a[i-1])
			t+=1;
//			else
//			{
//				if(a[i]==a[i-1])
//				for(int k=i;k<)
//			}
		}
	 } 
	 printf("%d",t);
	 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 1e9
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

ll a, b, c, x, y;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> a >> b >> c >> x >> y;
    ll ans = INF;
    erep(i, 0, 1000000) {
        ll p, q, r;
        r = i;
        p = x - r/2;
        q = y - r/2;
        if (p < 0) p = 0;
        if (q < 0) q = 0;
        ans = min(ans, p * a + q * b + c * r);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "atcoder/all"
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
const ll mod = 1e9 + 7;
int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());

  cout << (s < t ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3620
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print('-1')
else:
    cnt = 1
    cur = 7
    while True:
        if cur % K == 0:
            print(cnt)
            break
        if cnt > K:
            print('-1')
            break
        cur = (cur * 10 + 7) % K
        cnt += 1

Measured memory_bytes: 9136
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
signed main() {
	int n; string s; cin >> n >> s;
	bool b = 0;
	for0(i, n) { s[i]--; if (s[i] == '1')b = 1; }
	if (b) {
		int k = 1, ans = 0;
		for0(i, n) {
			if (k % 2) {
				ans += (s[i] - '0'); ans %= 2;
			}
			int p = n - i - 1;
			while (p && p % 2 == 0) { p /= 2; k *= 2; }
			p = i + 1;
			while (p && p % 2 == 0) { p /= 2; k /= 2; }
		}cout << ans << endl;
	}
	else {
		int k = 1, ans = 0;
		for0(i, n) {
			if (k % 2 && s[i] == '2')ans++;
			int p = n - i - 1;
			while (p && p % 2 == 0) { p /= 2; k *= 2; }
			p = i + 1;
			while (p && p % 2 == 0) { p /= 2; k /= 2; }
		}
		ans %= 2;
		cout << ans * 2 << endl;
	}
}

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

def get_input() -> int:
    """
    標準入力を取得する.

    Returns:\n
        int: 標準入力
    """
    K = int(input())

    return K


def main(K: int) -> None:
    """
    メイン処理.

    Args:\n
        K (int): 整数（1 <= K <= 10^6）
    """
    # 求解処理
    ans = -1
    remainder = 7 % K
    for i in range(1, 9000000):
        if remainder == 0:
            ans = i
            break
        remainder = (10 * remainder + 7) % K

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    K = get_input()

    # メイン処理
    main(K)


Measured memory_bytes: 9176
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <vector>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i_, __start, __end) for(ll i_=(ll)__start; i_<(ll)__end; i_++)
#define print(_a) cout << _a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");


int main(){
    string s1, s2;
    cin >> s1 >> s2;
    if(s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0]){
      print("YES");
    }else{
      print("NO");
    }
   
  return 0;
}

Measured memory_bytes: 256
/*
キュー
*/
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
	"strings"
)

// Item i
type Item interface {
	String() string
}

// Queue キュー
type Queue struct {
	data []Item
	head int
	tail int
}

// NewQueue キュー作成
func NewQueue(maxLength int) *Queue {
	return &Queue{make([]Item, maxLength+1), 0, 0}
}
func progCur(idx, maxLen int) int {
	return (idx + 1) % maxLen
}
func (q *Queue) isFull() bool {
	// tail と headには一つ間をおく.
	return progCur(q.tail, len(q.data)) == q.head
}
func (q *Queue) isEmpty() bool {
	return q.head == q.tail
}
func (q *Queue) enqueue(e Item) {
	if q.isFull() {
		panic("queue is full.")
	}
	q.data[q.tail] = e
	q.tail = progCur(q.tail, len(q.data))
}
func (q *Queue) dequeue() Item {
	if q.isEmpty() {
		panic("queue is empty.")
	}
	e := q.data[q.head]
	q.head = progCur(q.head, len(q.data))
	return e
}
func (q *Queue) String() string {
	var buf bytes.Buffer
	sep := ""
	for i := q.head; i != q.tail; i = progCur(i, len(q.data)) {
		buf.WriteString(fmt.Sprintf("%s%s", sep, q.data[i]))
		sep = " "
	}
	return fmt.Sprintf("head[%d] tail[%d] elem[%s]", q.head, q.tail, buf.String())
}

// Process プロセス
type Process struct {
	Name string
	Time int
}

func (p Process) String() string {
	return fmt.Sprintf("{%s %d}", p.Name, p.Time)
}

func schedule(quant int, queue *Queue) string {
	var output bytes.Buffer
	total := 0
	for !queue.isEmpty() {
		p := queue.dequeue()
		q, ok := p.(*Process)
		if !ok {
			panic("")
		}
		if q.Time <= quant {
			// プロセス終了
			output.WriteString(fmt.Sprintf("%s %d\n", q.Name, total+q.Time))
			total += q.Time
		} else {
			q.Time -= quant
			queue.enqueue(q)
			total += quant
		}
	}
	return output.String()
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	nq := eGetInts(reader)
	n, q := nq[0], nq[1]
	queue := NewQueue(n)
	for i := 0; i < n; i++ {
		pInfo := eGetFields(reader)
		queue.enqueue(&Process{pInfo[0], eAtoi(pInfo[1])})
	}
	fmt.Print(schedule(q, queue))
}
func eGetLine(r *bufio.Reader) string {
	s, err := r.ReadString(byte('\n'))
	if err != nil {
		if err != io.EOF {
			log.Fatal(err.Error())
		}
		return s
	}
	return strings.TrimRight(s, "\r\n")
}
func eGetInt(r *bufio.Reader) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetFields(r *bufio.Reader) []string {
	line := eGetLine(r)
	fields := strings.Split(line, " ")
	return fields
}
func eGetInts(r *bufio.Reader) []int {
	line := eGetLine(r)
	fields := strings.Split(line, " ")
	var ints []int
	for _, f := range fields {
		ints = append(ints, eAtoi(f))
	}
	return ints
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

type ints []int

func (s ints) String() string {
	var buf bytes.Buffer
	sep := ""
	for _, v := range s {
		buf.WriteString(fmt.Sprintf("%s%d", sep, v))
		sep = " "
	}
	return buf.String()
}

func reverse(a ints) ints {
	r := make(ints, len(a))
	for i := 0; i < len(a); i++ {
		r[i] = a[len(a)-1-i]
	}
	return r
}



Measured memory_bytes: 9836
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int A[210000], B[210000], C[210000];

int main(){
	long long int N, K;
	cin >> N >> K;
	for(int i = 1; i <= N; i++){
		cin >> A[i];
		B[i] = A[i];
		C[i] = -A[i];
	}
	B[0] = C[0] = -1e9 - 10;
	sort(B, B + N + 1);
	sort(C, C + N + 1);
	long long int L1 = -INF, R1 = INF;
	while(R1 - L1 > 1){
		long long int mid1 = (L1 + R1) / 2;
		long long int S = 0;
		for(int i = 1; i <= N; i++){
			long long int L = 0, R = N + 1;
			while(R - L > 1){
				long long int mid = (L + R) / 2;
				if(A[i] > 0){
					if(A[i] * B[mid] <= mid1){
						L = mid;
					}else{
						R = mid;
					}
				}else{
					if(-A[i] * C[mid] <= mid1){
						L = mid;
					}else{
						R = mid;
					}
				}
			}
			if(A[i] > 0 && B[L] >= A[i]){
				L -= 1;
			}
			if(A[i] <= 0 && C[L] >= -A[i]){
				L -= 1;
			}
			// cout << "de " << A[i] << " " << L << endl;
			S += L;
		}
		S /= 2;
		// cout << mid1 << " " << S << endl;
		if(S >= K){
			R1 = mid1;
		}else{
			L1 = mid1;
		}
	}
	cout << R1 << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, K;
string s;
int ans1, ans2;

signed main(){
    cin >> N;
    int mx = 0;
    for(int i = 0; i < N; i++){
        int h;
        cin >> h;
        if(mx <= h)ans1++;
        mx = max(mx, h);
    }
    cout << ans1 << endl;


    return 0;
}

/*

*/

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<int>t(n),x(n),y(n);
rep(i,n){
    cin>>t[i]>>x[i]>>y[i];
}
int _t=0,_x=0,_y=0;
bool ok=true;
rep(i,n){
    int dt=t[i]-_t;
    int dist=abs(x[i]-_x)+abs(y[i]-_y);
    if(dt%2==dist%2&&dist<=dt){
        _t=t[i],_x=x[i],_y=y[i];
        continue;
    }
    ok=false;
    break;    
}
if(ok){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
return 0;
}

Measured memory_bytes: 1408
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define vec vector<long long int>
#define fi first
#define se second
#define pb push_back
int main()
{
    int n;
    cin >> n;
    int count = 0;
    int flag = 0;

    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        if (a == b)
        {
            count++;
        }
        else
        {
            if (count > 2)
            {
                flag = 1;
            }
            count = 0;
        }
    }
    if (count > 2)
    {
        flag = 1;
    }
    if (flag == 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define fi first
#define se second 

int main(){
    vpll A(5);
    rep(i,5){
        int tmp,tmp2; 
        cin>>tmp;
        tmp2=(10-tmp%10)%10;
        A[i].fi=tmp2;
        A[i].se=tmp;
    }
    sort(all(A));
    //rep(i,5)cout<<A[i].fi<<A[i].se<<endl;
    int ans=0;
    rep(i,4)ans+=A[i].fi+A[i].se;
    ans+=A[4].se;
    cout<<ans<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String[][] key = new String[10][5];
		key[1] = new String[] {".",",","!","?"," "};
		key[2] = new String[] {"a","b","c"};
		key[3] = new String[] {"d","e","f"};
		key[4] = new String[] {"g","h","i"};
		key[5] = new String[] {"j","k","l"};
		key[6] = new String[] {"m","n","o"};
		key[7] = new String[] {"p","q","r","s"};
		key[8] = new String[] {"t","u","v"};
		key[9] = new String[] {"w","x","y","z"};
		int n = stdIn.nextInt();
		for(int i = 0; i < n; i++) {
			String tmp = stdIn.next();
			for(int j = 0; j < tmp.length(); j++) {
				char c = tmp.charAt(j++);
				int ks = 0;
				if(c == '0') {
					j--;
					continue;
				}
				while(true) {
					char p = tmp.charAt(j++);
					if(p == '0') {
						j--;
						break;
					}
					ks++;
				}
				int ss = Integer.parseInt(String.valueOf(c));
				System.out.print(key[ss][ks%key[ss].length]);
			}
			System.out.println();
		}
		
	}
	
}

Measured memory_bytes: 21716
import java.util.*;

public class Main {

	static int mod = 998244353;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

		long[][] dp = new long[C+1][D+1];
		dp[A][B] = 1L;
		for (int j=B;j<D;j++) {
			dp[A][j+1] = dp[A][j]*A%mod;
		}
		for (int i=A;i<C;i++) {
			dp[i+1][B] = dp[i][B]*B%mod;
		}
		for (int i=A;i<C;i++) {
			for (int j=B;j<D;j++) {
				dp[i+1][j+1] = (dp[i+1][j]*(i+1)%mod+dp[i][j+1]*(j+1)%mod-dp[i][j]*(long)i%mod*j%mod+mod)%mod;
			}
		}
		System.out.println(dp[C][D]);
	}
}

Measured memory_bytes: 107304
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    ll ans;
    ll t,a;
    ll maxt=1;
    ll maxa=1;
    rep(i,n){
        cin>>t>>a;
        maxt=max((maxt+t-1)/t,(maxa+a-1)/a)*t;
        maxa=max((maxt+t-1)/t,(maxa+a-1)/a)*a;
    }
    cout<<maxt+maxa<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define P(x) {if (debug) cout << x << endl;}
#define H(x) P(#x << ": " << (x))
#define FR(i,a,b) for (int i=(a); i<(b); i++)
#define F(i,n) FR(i,0,n)
#define DR(i,a,b) for (int i=(b); i-->(a);)
#define D(i,n) DR(i,0,n)
#define S(s) (int)(s).size()
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,v)
#define MA(a,v) a = max(a,v)
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
template<class T> ostream &operator<<(ostream &os, V<T> v) {
    F(i,S(v)) os<<(i?" ":"")<<v[i];
    return os;
}
const bool debug = 0;

int safeMod(int a, int m) {
    return (a%m+m)%m;
}

void test(int k, V<V<int>> res) {
    int n = S(res);
    assert(n <= 500);
    map<int,multiset<int>> m;
    F(i,n) F(j,n) {
        assert(1 <= res[i][j] && res[i][j] <= k);
        multiset<int> ms;
        ms.insert(res[safeMod(i-1,n)][j]);
        ms.insert(res[safeMod(i+1,n)][j]);
        ms.insert(res[i][safeMod(j-1,n)]);
        ms.insert(res[i][safeMod(j+1,n)]);
        if (m.count(res[i][j])) {
            assert(ms == m[res[i][j]]);
        } else {
            m[res[i][j]] = ms;
        }
    }
    assert(S(m) == k);
}

V<V<int>> build(int k) {
    if (k == 1) return V<V<int>>{{1}};
    int exc = safeMod(-k, 4);
    int n = (k+exc)/2;
    H(exc)
    H(n)
    V<int> digsA(n), digsB(n);
    iota(ALL(digsA), 1);
    iota(ALL(digsB), k-n+1);
    F(i,exc) digsB[i] = digsA[i];
    H(digsA)
    H(digsB)
    V<V<int>> a(n, V<int>(n));
    F(i,n) F(j,n) {
        a[i][j] = (i%2 == 0 ? digsA : digsB)[(n-i+j)%n];
    }
    return a;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    /*FR(k,995,1001) {
        test(k, build(k));
    }*/
    int k; cin>>k;
    V<V<int>> res = build(k);
    int n = S(res);
    test(k, res);
    cout<<n<<"\n";
    F(i,n) cout<<res[i]<<"\n";
}

Measured memory_bytes: 4480
/* Header {{{ */
#include <bits/stdc++.h>
using namespace std;

typedef long long readtype;
typedef long long var;
typedef long double let;

readtype read() {
  readtype a = 0, c = getchar(), s = 0;
  while (!isdigit(c)) s |= c == '-', c = getchar();
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
  return s ? -a : a;
}

#ifdef LOCAL_LOGGER
#define logger(...) fprintf(stderr, __VA_ARGS__)
#define abortif(v, ...) if (v) {logger("Error in Line %d, Function '%s()'.\nInfo: ", __LINE__, __FUNCTION__); logger(__VA_ARGS__); exit(0);}
#else
#define logger(...);
#define abortif(v, ...);
#endif
/* }}} */

const let EPS = 1e-8;

int sign(let x) { return (x < -EPS) ? -1 : (x > EPS ? 1 : 0); }

struct Point {
  let x, y;

  friend Point operator - (Point a, Point b) {
    return (Point) {a.x - b.x, a.y - b.y};
  }

  friend let Times(Point a, Point b) {
    return a.x * b.y - a.y * b.x;
  }

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

  Point Rotate(Point k) {
    let z = k.dist();
    return Rotate(k.y / z, k.x / z);
  }

  Point Rotate(let sink, let cosk) {
    return (Point) {
      x * cosk - y * sink, x * sink + y * cosk
    };
  }

  friend let Dist(Point a, Point b) { return (a - b).dist(); }
};

typedef Point Vec;

struct Line {
  Point p;
  Vec v;
  Line(Point a, Point b) { p = a, v = b - a; }

  friend let Dist(Line l, Point p) {
    return (p - l.p).Rotate(l.v).y;
  }
};

struct Polygon {
  vector<Point> p;

  Point &operator [] (int k) { return p[k]; } 
  int size() { return p.size(); }
  void push(Point t) { p.push_back(t); }

  friend let ConvexDiameter(Polygon poly) {

    int p = 0;
    let res = 0;
    for (int i = 0; i < poly.size(); ++i) {
      let tdist = Dist(poly[i], poly[p]);
      while (true) {
        res = max(res, tdist);
        int np = (p + 1 == poly.size()) ? 0 : p + 1;
        let nxdist = Dist(poly[i], poly[np]);
        if (sign(nxdist - tdist) < 0) break;
        p = np, tdist = nxdist;
      }
    }

    // for (int i = 0; i < poly.size(); ++i) {
    //   for (int j = 0; j < poly.size(); ++j) {
    //     if (sign(Dist(poly[i], poly[j]) - res) > 0) {
    //       printf("%d %d\n", i, j);
    //     }
    //   }
    // }

    return res;
  }
};

Point ReadPoint() {
  Point p;
  scanf("%Lf%Lf", &p.x, &p.y);
  return p;
}

Polygon ReadPolygon() {
  Polygon poly;
  int g = read();
  for (int i = 1; i <= g; ++i) 
    poly.push(ReadPoint());
  return poly;
}

int main() {
// #ifndef ONLINE_JUDGE
//   freopen("CGL_4_B.in", "r", stdin);
//   freopen("CGL_4_B.out", "w", stdout);
// #endif
// #ifdef LOCAL_LOGGER
//   freopen("CGL_4_B.log", "w", stderr);
// #endif
  Polygon poly = ReadPolygon();
  printf("%.8Lf\n", ConvexDiameter(poly));
  return 0;
}

/* ==== Makefile ==== {{{
CompileAndRun:
	make Compile
	make Run

Compile:
	g++ -o CGL_4_B CGL_4_B.cpp -g -Wall -DLOCAL_LOGGER

CompileUF:
	g++ -o CGL_4_B CGL_4_B.cpp -g -Wall -DLOCAL_LOGGER -fsanitize=undefined

Run:
	./CGL_4_B < CGL_4_B.in > CGL_4_B.out
==================
}}} */



Measured memory_bytes: 8144
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4 6");
            WillReturn.Add("2 1");
            WillReturn.Add("3 4");
            WillReturn.Add("4 10");
            WillReturn.Add("3 4");
            //11
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4 6");
            WillReturn.Add("2 1");
            WillReturn.Add("3 7");
            WillReturn.Add("4 10");
            WillReturn.Add("3 6");
            //13
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("4 10");
            WillReturn.Add("1 100");
            WillReturn.Add("1 100");
            WillReturn.Add("1 100");
            WillReturn.Add("1 100");
            //400
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("4 1");
            WillReturn.Add("10 100");
            WillReturn.Add("10 100");
            WillReturn.Add("10 100");
            WillReturn.Add("10 100");
            //0
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    struct NimotuDef
    {
        internal int W;
        internal int V;
    }

    static void Main()
    {
        checked {
            List<string> InputList = GetInputList();

            int[] wkArr = { };
            Action<string> SplitAct = pStr =>
                wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();

            SplitAct(InputList[0]);
            int W = wkArr[1];

            var NimotuList = new List<NimotuDef>();
            foreach (string EachStr in InputList.Skip(1)) {
                SplitAct(EachStr);
                NimotuList.Add(new NimotuDef() { W = wkArr[0], V = wkArr[1] });
            }

            //最大の価値[重さ合計]なDP表
            var DPDict = new Dictionary<long, int>();
            DPDict[0] = 0;

            foreach (NimotuDef EachNimotu in NimotuList) {
                foreach (int EachKey in DPDict.Keys.OrderByDescending(A => A).ToArray()) {
                    long NewKey = EachKey + EachNimotu.W;
                    if (NewKey > W) continue;

                    int NewVal = DPDict[EachKey] + EachNimotu.V;

                    if (DPDict.ContainsKey(NewKey)) {
                        if (DPDict[NewKey] < NewVal) {
                            DPDict[NewKey] = NewVal;
                        }
                    }
                    else DPDict[NewKey] = NewVal;
                }
            }
            Console.WriteLine(DPDict.Values.Max());
        }
    }
}


Measured memory_bytes: 16352
def naka(a,b,A,B):
    if a == 0 or a == A-1 or b == 0 or b == B-1:
        return '#'
    return '.'

while True:
    H,W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for h in range(H):
        for w in range(W):
            print(naka(h,w,H,W), end='')
        print()
    print()


Measured memory_bytes: 7008
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)  for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i > (b); --i)
#define rep(i, n)	  for(int i = 0; i < (n); ++i)
#define all(c)		  begin(c), end(c)
#define rall(c)		  rbegin(c), rend(c)
#define SZ(a)		  ((ll) a.size())

typedef long long		   ll;
typedef unsigned long long ull;

int main() {
	ll R;
	ll G;
	scanf("%lld", &R);
	scanf("%lld", &G);
	printf("%lld", 2 * G - R);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=(1LL<<63) - 600;
const ll mod=1e9+7 ;

int main(){
  int N, K; cin >> N >> K; ll x[N], y[N];
  rep(i, N){
    cin >> x[i] >> y[i];
  }
  ll ans = longinf;
  if(K==2){
    rep(i, N){
      rep(j, N){
        if(i==j) continue;
        ans = min(abs(x[i]-x[j])*abs(y[i]-y[j]), ans);
      }
    }
    cout << ans << endl; return 0;
  }
  if(K==3){
    rep(i, N){
    rep(j, N){
      if(i==j) continue;
      rep(k, N){
        if(i==k || j==k) continue;
        ll R = max({x[i], x[j], x[k]});
        ll L = min({x[i], x[j], x[k]});
        ll U = max({y[i], y[j], y[k]});
        ll D = min({y[i], y[j], y[k]});
        ans = min(ans, (R-L)*(U-D));
      }
    }
    }
    cout << ans << endl; return 0;
  }
  rep(i, N){
    rep(j, N){
      if(i==j) continue;
      rep(k, N){
        if(i==k || j==k) continue;
        rep(l, N){
          if(i==l || j==l || k==l) continue;
          ll R = max({x[i], x[j], x[k], x[l]});
          ll L = min({x[i], x[j], x[k], x[l]});
          ll U = max({y[i], y[j], y[k], y[l]});
          ll D = min({y[i], y[j], y[k], y[l]});
          int cnt = 0;
          rep(m, N){
            if(x[m]>=L&&x[m]<=R&&y[m]<=U&&y[m]>=D)
              cnt++;
          }
          if(cnt>=K) ans = min(ans, (R-L)*(U-D));
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n,i,a;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        a=i;
        if((a%3)==0){
            printf(" %d",i);
        }else{
            for(;a;){
                if((a%10)==3){
                    printf(" %d",i);
                    a=0;
                }
                a=a/10;
            }
        }
    }
    putchar('\n');
    return 0;
}



Measured memory_bytes: 2144
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 4004;
typedef long long ll;
const int mod = 1e9 + 7;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
inline void reduce(int & x){ x += x >> 31 & mod; }
int n, m, k;
int g0[maxn][2], pl[maxn << 1], *g1 = pl + maxn;
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m >> k;
	int ans = 0;
	std::fill(g1, g1 + maxn, 1);
	rep(i, 1, n + m) {
		rep(j, 0, n) {
			reduce(g0[j][0] = g1[j] - g1[j - 1]);
			reduce(g0[j][1] = g1[j - 1] - g1[j - k]);
		}
		rep(j, 0, n) {
			g1[j] = ((unsigned) g1[j - 1] + g0[j][0] + g0[j][1]) % mod;
			if((n - j) % (k - 1) == 0 && i * (k - 1) - j + 1 <= m)
				ans = (ans + g0[j][1]) % mod;
		}
	}
	cout << ans << '\n';
}


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

bool isodd(int A, int B, int C){
	if(A % 2 ==0 && B % 2 ==0 && C % 2 ==0){
      return true;
    }else{
      return false;
    }
}
 
int main() {
 
  int A,B,C;
  cin >> A >> B >> C;
  
  int count = 0;
  bool ff = false;
  
  while( isodd(A,B,C) ){
    
    if(A == B && B == C){
     ff = true;
     break;
    }
    
    int h_A,h_B,h_C;
    h_A = A/2;
    h_B = B/2;
    h_C = C/2;
    A = h_B + h_C;
    B = h_A + h_C;
    C = h_A + h_B;
    
    count++;
  }
  
  if(ff == false){
      cout << count << endl;
  }else{
      cout << "-1" << endl;
  }
 
}

Measured memory_bytes: 3564
#define _For(idx, from, to, inc, cmp) \
	for(auto idx=(from) ; idx cmp (to) ; inc idx)
#define ForLE(idx, from, to) \
	_For(idx, from, to, ++, <=)
#define ForGE(idx, from, to) \
	_For(idx, from, to, --, >=)
#define ForLT(idx, from, to) \
	_For(idx, from, to, ++, <)
#define ForGT(idx, from, to) \
	_For(idx, from, to, --, >)
#define For(idx, from, to) \
	_For(idx, from, to, ++, <)
#include <iostream>
#include <string>

void DisableIOSync() {
	std::cin.tie(0);
	std::cout.tie(0);
	std::ios::sync_with_stdio(false);
}
constexpr int NChar = 'z'-'a'+1;
int Count[NChar];
int main() {
	DisableIOSync();
	std::string str;
	std::getline(std::cin, str);

	for(auto c : str) {
		++Count[int(c - 'a')];
	}
	For(i, 0, NChar) {
		if(Count[i] == 0) {
			std::cout << char(i+'a') << std::endl;
			return 0;
		}
	}
	std::cout << "None" << std::endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VVI mnc;
const in inf=1e18;
const in mx=42*12;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,ga,gb;
  cin>>n>>ga>>gb;
  mnc.resize(mx,VI(mx,inf));
  mnc[0][0]=0;
  in a,b,c;
  forn(z,n){
    cin>>a>>b>>c;
    for(in i=mx-a-1;i>=0;--i){
      for(in j=mx-b-1;j>=0;--j){
	mnc[i+a][j+b]=min(mnc[i+a][j+b],mnc[i][j]+c);
      }
    }
  }
  in tm=inf;
  for(in x=1;x*max(ga,gb)<mx;++x){
    tm=min(tm,mnc[x*ga][x*gb]);
  }
  if(tm==inf)
    cout<<-1<<endl;
  else
    cout<<tm<<endl;
  return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define maxn 200009
#define LL long long
#define mod 1000000007
using namespace std;
int a[maxn],b[maxn],c[maxn],t[maxn],R[maxn],n;
inline int qpow(LL x,int y){
  LL ans=1;
  while(y){
    if(y&1) ans=ans*x%mod;
    x=x*x%mod;y>>=1;
  } return ans;
}
inline void add(int p,int w){
  for(int i=p;i<=n;i+=(i&-i)) t[i]=(t[i]+w)%mod;
}
inline int query(int p){
  int ret=0;
  for(int i=p;i;i-=(i&-i)) ret=(ret+t[i])%mod;
  return ret;
}
int main(){
  int S=1,ans=0;scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",a+i),c[a[i]]++;
  for(int i=n-1;i>0;i--) c[i]+=c[i+1]-1;
  b[0]=1;
  for(int i=1;i<=n;i++){
    if(c[i]<=0) puts("0"),exit(0);
    S=(LL)S*c[i]%mod;
    b[i]=(LL)b[i-1]*(c[i]>1?c[i]-1:1)%mod*qpow(c[i],mod-2)%mod;
  }
  R[n]=n;
  for(int i=n-1;i>0;i--) R[i]=c[i+1]>1?R[i+1]:i;
  for(int i=n;i>=1;i--){
    LL tmp=(query(R[a[i]])-query(a[i]-1)+mod)%mod;
    ans=(tmp*qpow(b[a[i]],mod-2)+ans)%mod;
    add(a[i],b[a[i]]);
  }
  R[1]=1;
  for(int i=2;i<=n;i++) R[i]=c[i]>1?R[i-1]:i;
  memset(t,0,sizeof(t));
  for(int i=n;i>=1;i--){
    LL tmp=(query(a[i]-1)-query(R[a[i]]-1)+mod)%mod;
    ans=(mod-tmp*b[a[i]]%mod+ans)%mod;
    add(a[i],qpow(b[a[i]],mod-2));
  }
  ans=(LL)ans*(mod/2+1)%mod;
  memset(t,0,sizeof(t));
  for(int i=1;i<=n;i++)
    ans=(ans+i)%mod,ans=(ans-query(a[i])-1+mod)%mod,add(a[i],1);
  ans=(LL)ans*S%mod;
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 4096
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var scanner *bufio.Scanner

func printIt() {
	sentence := nextString()
	pattern := nextString()
	sentence += sentence
	if strings.Count(sentence, pattern) != 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanLines)
	printIt()
}



Measured memory_bytes: 1096
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using V = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(n);
    vector<ll> a(n);
    map<ll, ll> m;
    rep(i, n)
    {
        cin >> a[i];
        m[-a[i]+i] ++;
    }
    ll s = 0;
    rep(i, n)
    {
        m[-a[i]+i] --;
        s += m[a[i]+i];
    }
    cout << s << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

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

char s1[2000];
char s2[2000];

int LCS(int,int);

int main(){
  int sumstring;
  int i,j,k;
  scanf("%d",&sumstring);

  for(i = 0; i < sumstring; i++){
    scanf("%s",s1);
    scanf("%s",s2);
    printf("%d\n",LCS(strlen(s1),strlen(s2)));
  }

  return 0;
}

int LCS(int length1, int length2){

  int i,j,x;
  int answer[1001][1001];

  x = 0;

  for(i = 0; i < length1; i++){
    answer[i][0] = 0;
  }

  for(i = 0; i < length2; i++){
    answer[0][i] = 0;
  }
  for(i = 0; i < length1; i++){
    for(j = 0; j < length2; j++){
      if(s1[i]==s2[j] && s1[i]!=' ' && s2[i] != ' '){
        if(i == 0 || j == 0){
          answer[i][j] = 1;
        }
        else{
          answer[i][j] = answer[i-1][j-1]+1  ;
        }
      }

      else{
        if(i == 0 && j != 0){
          answer[i][j] = answer[0][j-1];
        }
        else if(i !=0 && j == 0){
          answer[i][j] = answer[i-1][0];
        }
        else if(i == 0 && j == 0){
          answer[0][0] = 0;
        }
        else if(i != 0 && answer[i-1][j] > answer[i][j-1]){
          answer[i][j] = answer[i-1][j];
        }
        else if(answer[i-1][j] <= answer[i][j-1]){
          answer[i][j] = answer[i][j-1];
        }
      }
    }
  }
  return answer[length1-1][length2-1];
}



Measured memory_bytes: 5616
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int solve(string& s, int& i)
{
    int a = 0;
    int b = 0;
    char prev = '+';
    for(;;){
        int x = 0;
        if(s[i] == '('){
            ++ i;
            x += solve(s, i);
            ++ i;
        }else{
            while('0' <= s[i] && s[i] <= '9'){
                x *= 10;
                x += s[i] - '0';
                ++ i;
            }
        }

        if(prev == '+'){
            a += b;
            b = x;
        }else if(prev == '-'){
            a += b;
            b = -x;
        }else if(prev == '*'){
            b *= x;
        }else{
            b /= x;
        }

        if(s[i] == ')' || s[i] == '=')
            break;

        prev = s[i];
        ++ i;
    }

    return a + b;
}

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

    while(--n >= 0){
        string s;
        cin >> s;
        int i = 0;
        cout << solve(s, i) << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int a, b;
    cin >> a >> b;
    int ret = 0;
    while (1 + ret * (a - 1) < b) {
        ret++;
    }
    cout << ret << "\n";
    return 0;
}

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 complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
const int K = 9;
set<pi> ops[1 << (K+1)];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    int V[N+1], W[N+1]; F0R(i, N) cin >> V[i+1] >> W[i+1];


    FOR(r, 1, min(N+1, (1 << (K+1)))) {
        vpi vals;
        int cur = r;
        while (cur > 0) {
            pi X = {W[cur], V[cur]} ;
            vals.pb(X);
            cur /= 2;
        }
        F0R(m, (1 << sz(vals))) {
            int v = 0, w = 0;
            F0R(i, sz(vals)) {
                if (m & (1 << i)) {
                    w += vals[i].f; v += vals[i].s;
                }
            }
//            cout << r << " " << m << " " << v << " " << w << nl;
            auto it = ops[r].ub({w, -1});
            if (it != ops[r].begin()) {
                it--;
                if (it->s >= v) {
                    continue;
                }
            }
            it = ops[r].ub({w, -1});
            while (it != ops[r].end() && it->s <= v) {
                ops[r].erase(it);
                it = ops[r].ub({w, -1});
            }
            ops[r].ins({w, v});
        }

    }


    int Q; cin >> Q;

    F0R(q, Q) {
        int ve, L; cin >> ve >> L;
        vpi vals;
        int cur = ve;
        while (cur >= (1 << (K+1))) {
            pi X = {W[cur], V[cur]};
            vals.pb(X);
            cur /= 2;
        }
        int ans = 0;
        F0R(m, 1 << sz(vals)) {
            int v = 0, w = 0;
            F0R(i, sz(vals)) {
                if (m & (1 << i)) {
                    w += vals[i].f; v += vals[i].s;
                }
            }
            auto it = ops[cur].ub({L-w+1, -1});
            if (it == ops[cur].begin()) continue;
            it--;
            ans = max(ans, v + it->s);
        }
        cout << ans << nl;
    }
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 36944
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

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

    long long sum = 0;
    for (int i=1; i<=n; i++) {
        if ( (i%3)*(i%5) ) sum += i;
    }

    cout << sum << endl;

    return 0;
}

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


#define WHITE 0
#define RED 1
#define BLUE 2

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

#define DEBUG

struct Apple{
    int val;
    int color;
};


void solve(long long X, long long Y, long long A, long long B, long long C, std::vector<long long> p, std::vector<long long> q, std::vector<long long> r){
    vector<Apple> apples;
    for(auto iter: p){
        apples.push_back(Apple{iter, RED});
    }
    for(auto iter: q){
        apples.push_back(Apple{iter,BLUE});
    }
    for(auto iter: r){
        apples.push_back(Apple{iter,WHITE});
    }

    sort(apples.begin(), apples.end(), [](Apple a, Apple b){
        if(a.val > b.val){
            return true;
        }else if(a.val < b.val){
            return false;
        }else{
            return a.color < b.color;
        }
    });  // aがbより先頭にくるときtrueになるように。

    ll tookRed = 0;
    ll tookBlue = 0;
    ll tookWhite = 0;
    ll res = 0;
    for(auto iter: apples){
        if(iter.color == RED){
            if(tookRed == X){
                // redはとりきった
                continue;
            }
            tookRed++;
            res += iter.val;
        }else if(iter.color == BLUE){
            if(tookBlue == Y){
                continue;
            }
            tookBlue++;
            res += iter.val;
        }else if(iter.color == WHITE){
            tookWhite++;
            res += iter.val;
        }else{
            assert(0);
        }
        if(tookRed + tookBlue + tookWhite == X + Y){
            break;
        }
    }

    cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> p(A);
    for(int i = 0 ; i < A ; i++){
        scanf("%lld",&p[i]);
    }
    std::vector<long long> q(B);
    for(int i = 0 ; i < B ; i++){
        scanf("%lld",&q[i]);
    }
    std::vector<long long> r(C);
    for(int i = 0 ; i < C ; i++){
        scanf("%lld",&r[i]);
    }
    solve(X, Y, A, B, C, std::move(p), std::move(q), std::move(r));
    return 0;
}


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

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


    int c;
    if( 99 <  b ) c = a*1000 + b;
    else if( 9 < b ) c = a*100 + b;
    else c = a*10 + b;

    for( int i = 4; i < 400; ++i ){
        if( c == i*i ){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m,z;
char a[105][105];
int main()
{
	cin>>n>>m;
	for (int i=1;i<=n;i++)
	  for (int j=1;j<=m;j++)
	    cin>>a[i][j];
	for (int i=1;i<=n;i++)
	  {
	    for (int j=1;j<=m;j++)
	      if (a[i][j]=='#') cout<<a[i][j];else
	        {
	        	if (a[i+1][j]=='#') z++;
	        	if (a[i-1][j]=='#') z++;
	        	if (a[i][j-1]=='#') z++;
	        	if (a[i][j+1]=='#') z++;
	        	if (a[i-1][j-1]=='#') z++;
	        	if (a[i-1][j+1]=='#') z++;
	        	if (a[i+1][j-1]=='#') z++;
	        	if (a[i+1][j+1]=='#') z++;
	        	cout<<z;
	        	z=0;
	        }
	    cout<<endl;
	  }
	return 0;
}

Measured memory_bytes: 256
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1e9+7;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //
    ll N, M;
    cin >> N >> M;
    vector<ll> dp(N + 2, 0);
    dp[0] = 1;
    dp[1] = 1;
    rep(i, M)
    {
        ll a;
        cin >> a;
        dp[a] = -1;
    }
    rep(i, N)
    {
        if (dp[i + 2] < 0)
        {
            continue;
        }
        ll d0 = max(dp[i + 0], 0LL);
        ll d1 = max(dp[i + 1], 0LL);
        dp[i+2] = (d0 + d1) % BIGP;
    }
    cout << dp[N];
    //
    return 0;
}

Measured memory_bytes: 3548