akhauriyash/Code-Regression huggingface dataset:
use std::io;
use std::str::FromStr;  

fn main() {
    let n: i32 = read();
    let xs: Vec<i32> = reads();

    let mut ord: Vec<(i32,usize)> =
        xs.into_iter().enumerate().map(|(i,x)| (x, i+1)).collect();
    ord.sort();

    let ans: Vec<usize> = ord.into_iter().map(|p| p.1).collect();

    printv(&ans);
}

#[allow(dead_code)]
fn getline() -> String {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().to_string()
}

#[allow(dead_code)]
fn read<T>() -> T where T : FromStr {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn reads<T>() -> Vec<T> where T : FromStr {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn printv<T>(xs: &[T]) where T : std::fmt::Display {
    xs.iter().fold("", |s, x| {
        print!("{}{}", s, x);
        " "
    });
    println!();
}


Measured memory_bytes: 8444
p = int(input())
dr = input().split(' ')
d, r = int(dr[0]), int(dr[1])


for i in range(p):
    nb = int(input())
    if nb == 1:
        r += d
    else:
        if d % nb == 0:
            r += d/nb
        else:
            r += (d//nb) +1

print(int(r))


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            if (map.containsKey(s)) {
                map.put(s, map.get(s) + 1);
            } else {
                map.put(s, 1);
            }
        }
        int max = 0;
        ArrayList<String> list = new ArrayList<>();
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            int x = entry.getValue();
            if (max < x) {
                list.clear();
                list.add(entry.getKey());
                max = x;
            } else if (max == x) {
                list.add(entry.getKey());
            }
        }
        Collections.sort(list);
        StringBuilder sb = new StringBuilder();
        for (String s : list) {
            sb.append(s).append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 82680
N=int(input())
S=input()

West=[0]
East=[0]
for i in range(1,N+1):
    if S[i-1]=="W":
        West.append(West[-1]+1)
        East.append(East[-1])
    else:
        West.append(West[-1])
        East.append(East[-1]+1)
ans=N
for j in range(N):
    p=West[j]+East[-1]-East[j+1]
    if ans>p:
        ans=p
print(ans)

Measured memory_bytes: 17644
#include <cstdio>
#include <vector>
#include <utility>
#define ll long long
#define isdigit(c) ('0' <= c && c <= '9')
#define rep(i,n) for (int i = 0; i < int(n); ++ i)
using namespace std;

namespace IO {
	const int BUF_SIZE = 1 << 15;
	char IBUF[BUF_SIZE], OBUF[BUF_SIZE];
	char *PIBUF = IBUF + BUF_SIZE - 1, *POBUF = OBUF;
	
	inline int getchar() {
		if (++ PIBUF == IBUF + BUF_SIZE)
			fread(PIBUF = IBUF, 1, BUF_SIZE, stdin);
		return *PIBUF;
	}
	
	inline void putchar(int x) {
		*POBUF = x;
		if (++ POBUF == OBUF + BUF_SIZE)
			fwrite(POBUF = OBUF, 1, BUF_SIZE, stdout);
	}
	
	inline void flush() {
		if (POBUF != OBUF)
			fwrite(OBUF, 1, POBUF - OBUF, stdout);
		fflush(stdout);
	}
}

#define getchar()  IO :: getchar()
#define putchar(x) IO :: putchar(x)

inline
int getint() {
	int a = 0, b = 1, c = getchar();
	for (;!isdigit(c); c = getchar()) if (c == '-') b = -b;
	for (; isdigit(c); c = getchar()) a = (a<<3) + (a<<1) + (c^48);
	return a * b;
}

template <typename T>
inline void putint(T x) {
	if (x < 0) putchar('-'), x = -x;
	if (x >= 10) putint(x / 10);
	putchar(x - x / 10 * 10 + 48);
}

int n, m, a[505][505];
vector <pair <pair <int, int>, pair <int, int> > > cmd;

void Read() {
	n = getint(), m = getint();
	for (int i = 1; i <= n; ++ i) for (int j = 1; j <= m; ++ j)
		a[i][j] = getint();
}

void Init() {
}

void Solve() {
	for (int i = 1; i <= n; ++ i) for (int j = 1; j < m; ++ j)
		if (a[i][j] & 1) {
			a[i][j] --;
			a[i][j + 1] ++;
			cmd.push_back(make_pair(make_pair(i, j), make_pair(i, j + 1)));
		}
	for (int i = 1; i < n; ++ i)
		if (a[i][m] & 1) {
			a[i][m] --;
			a[i + 1][m] ++;
			cmd.push_back(make_pair(make_pair(i, m), make_pair(i + 1, m)));
		}
//	for (int i = 1; i <= n; ++ i) for (int j = 1; j <= m; ++ j)
//		fprintf(stderr, "%d%c", a[i][j], " \n"[j == m]);
	putint(cmd.size()), putchar('\n');
	rep(i, cmd.size()) {
		putint(cmd[i].first.first), putchar(' ');
		putint(cmd[i].first.second), putchar(' ');
		putint(cmd[i].second.first), putchar(' ');
		putint(cmd[i].second.second), putchar('\n');
	}
}

int main() {
	int T = 1;
//	int T = getint();
	for (; T; -- T) {
		Read();
		Init();
		Solve();
	}
	IO :: flush();
	return 0;
}


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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)

ll n, c, g, a, we, le, wc, L[7], p[7], k;

signed main()
{
    cin >> n >> c, c *= n, k = (1 << (n - 1));
    forn(i, n) cin >> L[i], L[i] *= n;
    sort(L, L + n);
    iota(p, p + n - 1, 0);
    do {
        vector<vector<ll> > dp(c + 1, vector<ll>(k));
        dp[L[n - 1]][0] = 1;
        forn(i, c)
        {
            if (i % n == 0) continue;
            we = p[i % n - 1], le = L[we];
            forn(mask, k)
            {
                if ((1 << we) & mask) continue;
                for (ll ac = i; ac <= c; ac++)
                {
                    wc = max(ac, min(c, le + i));
                    dp[wc][mask + (1 << we)] += dp[ac][mask];
                }
            }
        }
        g += dp[c][k - 1], a++;
    } while (next_permutation(p, p + n - 1));
    printf("%.15f", 1.0 * g / a / pow(c / n, n - 1));
}


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

int main(){
	int n; cin >> n ; 
	vector<int>dp(3, 0);
	for(int days = 0; days < n; days++){
		vector<int>c(3); 
		for(int i=0; i<3; i++){
			cin >> c[i];
		}
		vector<int>temp_dp(3,0);
		for(int i=0; i<3; i++){
			for(int j=0; j<3; j++){
				if(i != j){
					temp_dp[j] = max(temp_dp[j],dp[i]+c[j]);
				}
			}
		}
		dp = temp_dp;

	}
	cout << max({dp[0] , dp[1] , dp[2] } );
	cout << endl;

}


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

int main() {
  int n, min=1000001, max=-1000001;
  long long tot = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    tot += a[i];
    min > a[i] ? min = a[i] : min;
    max < a[i] ? max = a[i] : max;
  }
  cout << min << " " << max << " " << tot << endl;
  return 0;
}

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

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    rep(i, N) cin >> p[i];

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

    ll ans = 0;
    for(int i = 0; i < N-1; i++){
        ans += p[i];
    }

    ans += p[N-1] / 2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
def solve(balls):
    if distribute(balls, [], []): print('YES')
    else: print('NO')
        
def distribute(balls, R, L):    
    if len(balls) != 0:
        next = balls[0]
        if isMutch(next, R):
            neoR = R
            neoR.append(next)
            if distribute(balls[1:], neoR, L): return True
        
        if isMutch(next, L):
            neoL = L
            neoL.append(next)
            if distribute(balls[1:], R, neoL): return True
    else:
        return True

def isMutch(next, lis):
    if len(lis) != 0:
        return next >= lis[len(lis)-1]
    return True

sys.setrecursionlimit(2**11)
size = int(input());
for i in range(size):
    balls = []
    for a in input().split(' '):
        balls.append(int(a))   
    solve(balls)

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

#ifdef _DEBUG
    #include "/home/v-o_o-v/deb.h"
    #define deb(x...)cerr << "[" << #x << "] = [";_print(x);
#else
    #define deb(x...)
#endif

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

bool used[100050];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    int a[n + 1];
    for(int i = 1; i <= n; i++)cin >> a[i];
    int st = 1;
    used[1] = true;
    vector<int> order;
    while(true){
        st = a[st];
        if(used[st])break;
        used[st] = true;
        order.pb(st);
        if(st == 2)break;
    }
    if(find(all(order), 2) == order.end())puts("-1");
    else cout << order.size() << '\n';
    return 0;
}
// Write Here


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, x, y, t;

int main() {
    cin >> n >> m >> x >> y;
    for (int i = 0; i < n; ++i) {
        cin >> t;
        x = max(x, t);
    }
    for (int i = 0; i < m; ++i) {
        cin >> t;
        y = min(y, t);
    }
    if (x < y)
        cout << "No War" << endl;
    else
        cout << "War" << endl;
    return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>

int main(){
  long long n,a,b; scanf("%lld%lld%lld",&n,&a,&b);
  if ((a+b)==0) printf("0\n");
  else{
  	if (n%(a+b)>a) printf("%lld",a+a*(n/(a+b)));
  	else printf("%lld\n", a*(n/(a+b))+n%(a+b));
  }
  return 0;
}

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

typedef long long ll;

int main() {
    int N, M, a, b;
    cin >> N >> M;
    scc_graph g(N);
    rep(i, M) {
        cin >> a >> b;
        g.add_edge(a, b);
    }
    auto ans = g.scc();
    cout << ans.size() << "\n";
    rep(i, ans.size()) {
        cout << ans[i].size();
        rep(j, ans[i].size()) {
            cout << " " << ans[i][j];
        }
        cout << "\n";
    }
}

Measured memory_bytes: 40084
n=int(input())
a1=0
a2=0
a3=0 
a4=0
i=1 
while(i<=n):
    s=input()
    if(s=='AC'):
        a1+=1 
    elif(s=='WA'):
        a2+=1 
    elif(s=="TLE"):
        a3+=1 
    else:
        a4+=1 
    i+=1 
print("AC x",a1)
print("WA x",a2)
print("TLE x",a3)
print("RE x",a4)

Measured memory_bytes: 9212
let l, r = Scanf.scanf " %d %d" @@ fun a b -> a, b
let ans = ref max_int
let r = min r @@ l + 2019
let _ =
  for i = l to r do
    for j = i + 1 to r do
      ans := min !ans @@ i * j mod 2019 done done;
  Printf.printf "%d\n" !ans

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

int main() {
  int n;
  cin >> n;
  set<int> s;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    s.insert(a);
  }
  cout << s.size() << endl;
  return 0;
}

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

int main(){
  
  int N,M;
  cin >> N >> M;
  int L[M];
  int R[M];
  for (int i = 0; i < M; ++i){
    cin >> L[i] >> R[i];
  }
  int max = L[0];
  int min = R[0];
  
  for(int i = 1; i < M; ++i){
    if(max < L[i]) max = L[i];
    if(min > R[i]) min =R[i];
  }
  
  if(min >= max){
  	cout << min - max + 1 << endl;
  }
  else{
    cout << 0 << endl;
  }
  
}
  

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define loop(i, n) for(int i = 0;i < n;i++)
#define INF 1000000000

int n, m, x;

int ans = INF;


void dfs(int i, vector<int> c, vector<vector<int>> a, int total, vector<int> check){
    bool ok = true;
    loop(j, m){
        if(check[j] < x) ok = false;
    }
    if(ok) ans = min(ans, total);

    if(i == n) return;

    dfs(i+1, c, a, total, check);

    loop(j, m){
        check[j] += a[i][j];
    }
    total += c[i];
    dfs(i+1, c, a, total, check);

    
}

int main(void){

    cin >> n >> m >> x;

    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> check(m);
    loop(i, n){
        cin >> c[i];
        loop(j, m){
            cin >> a[i][j];
        }
    }

    dfs(0, c, a, 0, check);

    if(ans == INF){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}


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

/*店iとjoisinoの店が、いくつの同じ時間帯で営業しているかを調べる(dfs)*/
//時間帯の数は10以下なので全探索(0 1 0 0 0 1 0 0 0 0 のように営業するなら1　　しないなら0　として全パターン試す)

vector<vector<ll>> f;//店がある時刻に営業しているか
vector<vector<ll>> p;//利益

ll n,output=-INF;

void dfs(ll time,bool OPEN,vector<bool> &open){//time:何番目の時間帯まで調べたか　OPEN:timeの時間帯に開いているか　
	if(time==10){
		bool all_close=true;//joisinoの店が全て閉まっていることは許されない
		for(ll i=0;i<10;i++){
			if(open[i]!=false){all_close=false;break;}
		}
		if(all_close){return;}


		ll answer=0;
		for(ll i=0;i<n;i++){//店iについて
			ll how_many_one=0;//共通の時刻は何個か
			for(ll j=0;j<10;j++){
				if(f[i][j] && open[j]){how_many_one++;}
			}
			answer+=p[i][how_many_one];
		}
		output=max(output,answer);

		return;
	}

	if(OPEN){open[time]=true;}
	else{open[time]=false;}

	dfs(time+1,true,open);
	dfs(time+1,false,open);

	return;
}

int main(){
	cin>>n;
	f.assign(n,vector<ll>(10,0));//n個の店について、10個の時間帯に対し、開いているか
	p.assign(n,vector<ll>(11,0));//n個の店について、joisinoと同じ時間帯の個数に対する、利益

	for(ll i=0;i<n;i++){
		for(ll j=0;j<10;j++){
			cin>>f[i][j];
		}
	}

	for(ll i=0;i<n;i++){
		for(ll j=0;j<=10;j++){
			cin>>p[i][j];
		}
	}

	vector<bool> open(10,false);
	dfs(0,true,open);
	dfs(0,false,open);


	cout<<output<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,sum=0,max=0;
    cin >> n;
    for(int i=0;i<n;i++){
        int a=0;
        cin >> a;
        sum+=a;
        if(a>max){
            max=a;
        }
    }
    cout << sum-(max/2);
}

Measured memory_bytes: 256
l = [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]
K = int(input())
print(l[K-1])
# print(l)
# print(len(l))

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int n, m;
    map<int, int> have;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        have[x]++;
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        if (have[x] == 0) {
            cout << "NO\n";
            return 0;
        }
        have[x]--;
    }
    cout << "YES\n";
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A;
  int B;
  cin >> A;
  cin >> B;
  int n=0;
  for(int i=A;i-1<B;i++){
    
    int a = i % 10000;
    int b = a % 1000;
    int c = b % 100;
    int G = c % 10;
    int F = (c - G) / 10;
    int E = (b - G - F*10) / 100;
    int D = (a - G - F*10 - E*100) / 1000;
    int C = (i - G - F*10 - E*100 - D*1000) / 10000;
    
    if(C==G && D==F){
      n=n+1;
    }
  }
  cout << n <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; 
	int A[110] = {}; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	double ans = 0; 
	for(int i = 0; i < N; i++){
		ans += 1.0 / (double) A[i]; 
	}
	cout.precision(15); 
	cout << 1.0 / ans << endl; 
}

Measured memory_bytes: 256
import math

n = int(input())
count = 0

def w(a) :
    for i in range(2, int(math.sqrt(a))+1):
        if a % i == 0:
            return False
    return True

for i in range(n):
    a = int(input())
    if w(a):
        count += 1
        
print(count)


Measured memory_bytes: 5676
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int matiCount = int.Parse(Reader.ReadLine());
        long[,] Road = new long[matiCount, matiCount];
        for (int i = 0; i < matiCount; i++) {
            long[] inpt = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
            for (int j = 0; j < matiCount;j++) {
                Road[i, j] = inpt[j];
            }
        }

        bool[,] IsFuyo = new bool[matiCount, matiCount];
        for (int i = 0; i < matiCount; i++) {
            for (int j = 0; j < matiCount; j++) {
                if(i==j) {
                    continue;
                }
                for (int k = 0; k < matiCount; k++) {
                    if(i==k||j==k) {
                        continue;
                    }
                    long direct = Road[j, k];
                    long conn = Road[j, i] + Road[i, k];
                    if(direct>conn) {
                        Console.WriteLine(-1);
                        return;
                    }
                    if(direct==conn) {
                        IsFuyo[j, k] = true;
                    }
                }
            }
        }
        long ans = 0;
        for (int i = 0; i < matiCount; i++) {
            for (int j = 0; j < matiCount; j++) {
                if(!IsFuyo[i,j]) {
                    ans += Road[i, j];
                }
            }
        }
        Console.WriteLine(ans / 2);
    
    }




    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


5
0 21 18 11 28
21 0 13 10 26
18 13 0 23 13
11 10 23 0 17
28 26 13 17 0


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


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

public class AtCoder_156_C
{
    public static void Main()
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        int n = int.Parse(Console.ReadLine());
        int[] line1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).OrderBy(x => x).ToArray();
        int[] x2 = new int[101];
        for (int i = 0; i < 101; i++)
        {
            x2[i] = i * i;
        }

        int min = 10000 * 100000;
        for (int i = line1[0]; i <= line1[n - 1]; i++)
        {
            int sum = 0;
            for (int j = 0; j < n; j++)
            {
                sum += x2[Math.Abs(line1[j] - i)];
            }
            if (min > sum)
            {
                min = sum;
            }
        }
        Console.WriteLine(min);
    }
}


Measured memory_bytes: 13396
n,s=map(int,input().split())
a=list(map(int,input().split()))
mod=998244353
dp0=[[0 for i in range(s+1)] for j in range(n+1)]
dp1=[[0 for i in range(s+1)] for j in range(n+1)]
dp2=[[0 for i in range(s+1)] for j in range(n+1)]
dp0[0][0]=1
for i in range(n):
  for j in range(s+1):
    if j>=a[i]:
      dp1[i+1][j]=(dp0[i][j-a[i]]+dp1[i][j-a[i]]+dp0[i][j]+dp1[i][j])%mod
      dp2[i+1][j]=(dp0[i][j-a[i]]+dp1[i][j-a[i]]+dp0[i][j]+dp1[i][j]+dp2[i][j])%mod
    else:
      dp0[i+1][j]=dp0[i][j]%mod
      dp1[i+1][j]=(dp0[i][j]+dp1[i][j])%mod
      dp2[i+1][j]=(dp0[i][j]+dp1[i][j]+dp2[i][j])%mod
print(dp2[n][s])

Measured memory_bytes: 270344
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque as d

N, M = map(int, readline().split())
m = map(int, read().split())
AB = zip(m, m)
graph = [[] for _ in range(N + 1)]

for a, b in AB:
  graph[a].append(b)
  graph[b].append(a)
que = d([1])
ans = [0]*(N+1)
while que:
  x = d.popleft(que)
  for i in graph[x]:
    if ans[i] != 0:
        continue
    ans[i] = x
    que.append(i)
if 0 in ans[2:]:
    print('No')
    exit()
print('Yes')
print('\n'.join(map(str, ans[2:])))


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int x,y;
  cin >> x >> y;
  if(y >= x*2 && y <= x*4 && y%2 == 0)
  {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 3624
N = int(input())

ans = [0]*N
for i in range(N-1):
    c, s, f = map(int, input().split())
    ans[i] += c+s
    for j in range(i):
        ans[j] = max((ans[j]+f-1)//f*f, s)+c
for a in ans:
    print(a)
    

Measured memory_bytes: 3060
D = [0 for i in range(26)]
while True:
    s = ''
    try:
        s = raw_input()
    except (EOFError):
        break
        
    for c in s:
        d = ord(c)
        idx = -1
        if d >= ord('a') and d <= ord('z'):
            idx = d - ord('a')
        if d >= ord('A') and d <= ord('Z'):
            idx = d - ord('A')
        if idx >= 0:
            D[idx] = D[idx] + 1

for i in range(0,26):
    c = chr(i + ord('a'))
    print c + " : " + str(D[i])

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

typedef long long int ll;
typedef long double ld;

using namespace std;


int main()
{
    int s,w;
    cin>>s>>w;
    if(w>=s){
        cout<<"unsafe"<<endl;
    }
    else{
        cout<<"safe"<<endl;
    }
    
    
    //cout<<"Case "<<cn<<": "<<"good"<<endl;
    return 0;
}

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

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  int n; cin >> n;
  int ans = INT_MAX;
  ll sum = 0;
  rep(i, n) {
    int a, b; cin >> a >> b;
    if (a>b) {
      chmin(ans, b);
    }
    sum += a;
  }
  if (ans == INT_MAX) {
    cout << 0 << endl;
  } else {
    cout << sum-ans << endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl


int main() {
	int N;
	
	rd(N);
	repi(i, 0, N) {
		char ch;
		rd(ch);
		if (ch == 'Y') {
			wrln("Four");
			return 0;
		}
	}

	wrln("Three");

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
x, n = map(int, input().split())
p = [int(s) for s in input().split()]
p_abs = [abs(s-x) for s in p]
if 0 not in p_abs:
  print(x)
  sys.exit()
for j in range(1, 101):
  ans = [i for i, x in enumerate(p_abs) if x == j]
  # print(ans)
  if len(ans)==1:
    print(x + (x - p[ans[0]]))
    sys.exit()
  if len(ans)==0:
    print(x-j)
    sys.exit()

Measured memory_bytes: 9224
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int c[3][3];
int b[3];
int a[3];

int main() {
	
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[i][j];
		}
	}

	for (int i = 0; i < 101; i++) {
		for (int j = 0; j < 101; j++) {
			for (int k = 0; k < 101; k++) {
				b[0] = c[0][0] - i;
				b[1] = c[0][1] - i;
				b[2] = c[0][2] - i;

				a[0] = i;
				a[1] = j;
				a[2] = k;

				bool ok = true;

				for (int x = 0; x < 3; x++) {
					for (int y = 0; y < 3; y++) {
						if (c[x][y] != a[x] + b[y]) {
							ok = false;
						}
					}
				}

				if (ok) {
					cout << "Yes" << endl;
					return 0;
				}
				
			}
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  int N;
  cin >> N;
  vi L(N);
  for(int i = 0; i < N; i++){
    cin >> L.at(i);
  }
  sort(ALL(L));
  ll counter = 0;
  for(int i = 0; i < N-2; i++){
    for(int j = i+1; j < N-1; j++){
      int x = L.at(i) + L.at(j);
      counter += N - 1 - j - distance(lower_bound(ALL(L), x), L.end());
    }
  }
  cout << counter << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	
	int N,M,C;
	cin>>N>>M>>C;
	int ans=0;
	vector<int> B(M);
	FDS(i,M){
		cin>>B[i];
	}
	FDS(i,N){
		vector<int> A(M);
		FDS(j,M){
			cin>>A[j];
		}
		int sub=C;
		FDS(k,M){
			sub+=A[k]*B[k];
		}
		if(sub>0){
			ans++;
		}
		
	}
	cout<<ans<<endl;
}	

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

template<class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int N;
int D[13];
int res=0;

void input() {
	cin>>N;
}

void solve() {
	D[0]=2; D[12]=1;
	for(int i=0; i<N; i++) {
		int d; cin>>d;
		D[d]++;
		if(D[d]>2) {
			cout<<0<<endl;
			return;
		}
	}

	for(int bit=0; bit<(1<<24); bit++) {
		if(!(bit&1)) continue;
		if((D[12]==2) ^ ((bit>>12)&1)) continue;
		bool fault=false;
		for(int i=1; i<12; i++) {
			switch(D[i]) {
				case 0: {
					if((bit>>i)&1 || (bit>>(24-i))&1) fault=true;
					break;
				}
				case 1: {
					if(!( ((bit>>i)&1) ^ ((bit>>(24-i))&1) )) fault=true;
					break;
				}
				case 2: {
					if(!((bit>>i)&1) || !((bit>>(24-i))&1) ) fault=true;
					break;
				}
				default: {
					cout<<-1<<endl;
					return;
				}
			}
			if(fault) break;
		}
		if(fault) continue;

		int restmp=24;
		int tmp=0;
		for(int i=1; i<=24; i++) {
			tmp++;
			if((bit>>(i%24))&1) {
				chmin(restmp,tmp);
				tmp=0;
			}
		}
		chmax(res,restmp);
	}
	cout<<res%24<<endl;
}

int main() {
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


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

int main() {
    int a, b;
    char op;
    while (true) {
        cin >> a >> op >> b;

        if (op == '?') {
            break;
        }

        switch (op) {
            case '+':
                cout << a + b;
                break;
            case '-':
                cout << a - b;
                break;
            case '*':
                cout << a * b;
                break;
            case '/':
                cout << a / b;
                break;
        }
        cout << endl;
    }

    
}


Measured memory_bytes: 3080
import sys

N,K=map(int,input().split())
S=input()

if not ("1" in S):
    print(N)
    sys.exit()

D=[]
NOW=1
S+="!"


for i in range(1,N+1):
    if S[i]==S[i-1]:
        NOW+=1

    else:
        D.append([S[i-1],NOW])
        NOW=1
    

if D[0][0]=="0":
    D=[["1",0]]+D

if D[-1][0]=="0":
    D.append(["1",0])

if K>=(len(D)-1)//2:
    print(N)
    sys.exit()

SUM=[0]
for i in range(len(D)):
    SUM.append(SUM[-1]+D[i][1])


ANS=0

for i in range(K*2+1,len(SUM),2):
    ANS=max(ANS,SUM[i]-SUM[i-K*2-1])

print(ANS)

Measured memory_bytes: 17664
# arc 061 Many Formulas
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

S = read().rstrip().decode('utf-8')

def F(S):
    total = 0
    for i in range(2 ** (len(S) - 1)):
        operator_list = format(i, 'b').zfill(len(S)) # 最大桁は必ず0
        sum_ = 0
        num = 0
        for j, operator in zip(S, operator_list):
            if operator == "0":
                num = num * 10 + int(j)
            else:
                sum_ += num
                num = int(j)
        sum_ += num

        total += sum_
    return total

ans = F(S)
print(ans)

Measured memory_bytes: 3064
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in).useDelimiter("[\\s,]+");
		TreeMap<Integer, List<Integer>> map = new TreeMap<Integer, List<Integer>>();
		int c = 0;
		while (true) {
			int v = sc.nextInt();
			int k = sc.nextInt();
			if (k == 0 && v == 0)
				break;
			List<Integer> list = map.get(k);
			if (list == null) {
				list = new LinkedList<Integer>();
				map.put(k, list);
			}
			list.add(v);
			c++;
		}
		int[] r = new int[c + 1];
		int n = map.size();
		while (!map.isEmpty()) {
			Entry<Integer, List<Integer>> e = map.pollFirstEntry();
			for (Integer i : e.getValue()) {
				r[i.intValue()] = n;
			}
			n--;
		}
		while (sc.hasNextInt()) {
			System.out.println(r[sc.nextInt()]);
		}
	}
}

Measured memory_bytes: 12000
D, G = map(int, input().split())

pc_dic = {i+1: tuple(map(int, input().split())) for i in range(D)}

complete_solving = {i: pc_dic[i][0]*100*i + pc_dic[i][1] for i in pc_dic}

min_count = 10**9 + 7
for i in range(2**D):
    count = 0
    score = 0
    partially_solve = 0
    for j in range(D):
        if i >> j & 1:
            count += pc_dic[j+1][0]
            score += complete_solving[j+1]
        else:
            partially_solve = j+1
    if score < G:
        if score + complete_solving[partially_solve] - partially_solve*100 < G:
            continue
        count += (G-score+100*partially_solve-1)//(100*partially_solve)
    min_count = min(min_count, count)

print(min_count)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
	if(n==2)ans.pb(2);
	else
    {for(ll i=2;i*i<=n;i++){if(n%i==0 && n%i!=i){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}ans.pb(n);}
    return ans;
}
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i; 
    return res; } 
  
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r)); } 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 

ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol(const vector<int>& v1, 
               const vector<int>& v2){ 
 return v1[0] < v2[0]; } 

 ll degit(ll n)
 {
 	ll t=0;
 	while(n>0)
 	{
 		t++;
 		n/=10; 	}
 		return t;
 }
void ff() {
	cout << "FastestFinger" << endl;
}
 
void aa() {
	cout << "Ashishgup" << endl;
}
 
void solve()
{
	ll n,k;
	cin>>n>>k;
	vll a(n);
	for(ll i=0;i<n;i++)
		cin>>a[i];
	sort(all(a));
	ll sum=0;
	for(ll i=0;i<k;i++)
		sum+=a[i];
	cout<<sum;
}
int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3684
#include<iostream>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

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

    int t[w+1][h+1]={0}, a[110] ={0};

    int x[110] = {0},y[110]={0};
    for(int i=1;i<=n;i++) cin >> x[i] >> y[i] >> a[i];

    for(int i=1;i<=n;i++){

        switch(a[i]){
            case 1:
                for(int k=1;k<=w;k++) {
                    for(int j=1;j<=h;j++){
                        if(k<=x[i]) t[k][j] = 1;
                    }
                }
            break;
            case 2:
                for(int k=1;k<=w;k++) {
                    for(int j=1;j<=h;j++){
                        if(k>x[i]) t[k][j] = 1;
                    }
                }
            break;
            case 3:
                for(int k=1;k<=w;k++) {
                    for(int j=1;j<=h;j++){
                        if(j<=y[i]) t[k][j] = 1;
                    }
                }
            break;
            case 4:
                 for(int k=1;k<=w;k++) {
                    for(int j=1;j<=h;j++){
                        if(j>y[i]) t[k][j] = 1;
                    }
                }           
            break;
            default:
            break;
        }
    }

    int cnt =0;
    for(int i= 1; i<=w;i++){
        for(int j = 1;j<=h;j++){
            if(t[i][j] == 0) cnt++;
        }
    }
    
    cout << cnt << endl;


    return 0;
}


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

#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define INF (INT_MAX/3)

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

using namespace std;

#define N_MAX 100

int main(void)
{
    int N; cin >> N;

    vector<int> pos;
    pos.resize(N);

    REP(i, N)
        cin >> pos[i];

    sort( ALL(pos) );

    cout << pos[N-1] - pos[0] << endl;

    return 0;
}

// 00:02:00


Measured memory_bytes: 256
fun main(args: Array<String>){
    val (N, M, L) = listOfInt()
    val INF = 1001001001
    var D = Array<Array<Int>>(N) { Array<Int>(N) { INF } }
    repeat(N) { D[it][it] = 0 }
    repeat(M) {
        var (a, b, c) = listOfInt()
        a -= 1; b -= 1
        D[a][b] = c; D[b][a] = c
    }
    for (k in 0 until N) {
        for (i in 0 until N) {
            for (j in 0 until N) {
                D[i][j] = Math.min(D[i][j], D[i][k] + D[k][j])
            }
        }
    }

    var D2 = Array<Array<Int>>(N) { Array<Int>(N) { INF } }
    repeat(N) { D2[it][it] = 0 }
    for (i in 0 until N) {
        for (j in 0 until N) {
            if (D[i][j] <= L) D2[i][j] = 1
        }
    }
    for (k in 0 until N) {
        for (i in 0 until N) {
            for (j in 0 until N) {
                D2[i][j] = Math.min(D2[i][j], D2[i][k] + D2[k][j])
            }
        }
    }
    val Q = nextInt()
    repeat(Q) {
        val (s, t) = listOfInt(-1)
        val ans = if (D2[s][t] == INF) -1 else D2[s][t] - 1
        println(ans)
    }
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { it.toInt() + delta }

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

int main(){
  int A,B,K,i;
  cin>> A >> B >> K;
  int Ablock[K];
  int Bblock[K];
  for(i=0;i<K;i++){
    Ablock[i] = A+i;
  }
  for(i=0;i<K;i++){
    Bblock[K-i-1]= B-i;
  }

  if(Ablock[K-1] >= Bblock[0]){
    for(i=A;i<=B;i++){
      cout<<i<<endl;
    } 
  }//end if
  else{
    for(i=0;i<K;i++){
      cout<<Ablock[i]<<endl;
    }
    for(i=0;i<K;i++){
      cout<<Bblock[i]<<endl;
    }
  }
  return 0;
}


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

int main() {
  int N, L;
  cin >> N >> L;

  int ans = 0;

  for (int i = 0; i < N; i++) {
    if (i == 0 && (i + L) >= 0) continue;
    else if (i == N - 1 && (i + L) < 0) continue;
    else ans += i + L;
  }

  cout << ans << endl;
}

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)

int main() {
	int n, k;
	string s;
	cin >> n >> k >> s;
	vector<int> b;
	vector<int> w;
	int cnt = 0;
	int bcnt, wcnt;
	while (1) {
		bcnt = 0;
		wcnt = 0;
		while (cnt<=n-1 && s[cnt] == '1') {
			bcnt++;
			cnt++;
		}
		b.push_back(bcnt);
		if (cnt == n) {
			break;
		}
		while (cnt <= n - 1 && s[cnt] == '0') {
			wcnt++;
			cnt++;
		}
		w.push_back(wcnt);
		if (cnt == n) {
			b.push_back(0);
			break;
		}
	}

	if (SZ(w) == 0) {
		pv(bcnt);
		return 0;
	}

	k = min(ll(k), SZ(w));
	int res = 0;
	int lim = SZ(w) - k;
	FOR(i, 0, lim) {
		int tmp = 0;
		FOR(j, i, i+k-1) {
			tmp += b[j];
			tmp += w[j];
		}
		tmp += b[i + k];
		res = max(res, tmp);
	}

	pv(res)
}

Measured memory_bytes: 1020
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	var tmp = ReadIntArray();
	int t = tmp[0], a = tmp[1];
	var h = ReadIntArray();

	int ans = 0;
	double diff = 1000000000.0;
	for (int i = 0; i < n; i++)
	{
	    double tx = t - h[i] * 0.006;
	    double dx = Math.Abs(tx - a);
	    if (dx < diff)
	    {
		ans = i + 1;
		diff = dx;
	    }
	}

	WriteLine(ans);
    }
}


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

int top, S[1000];

void push(int x){
    S[++top]=x;
}

int pop(){
    top--;
    return S[top+1];
}

int main(){
    int a, b;
    top=0;
    char s[100];

    while(scanf("%s", s) != EOF){
        if(s[0]=='+'){
            a=pop();
            b=pop();
            push(a+b);
        }
        else if(s[0]=='-'){
            b=pop();
            a=pop();
            push(a-b);
        }
        else if(s[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);
        }
        else push(atoi(s)); //atoi();string-->int
    }

    cout << pop() << endl;
    
}


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


int main() {

    int a, b;
    string s;
    cin >> a >> b >>s;
    if (s[a] == '-') {
        for (int i = 0; i < a; ++i) {
            if (s[i] == '-') {
                cout << "No" << endl;
                return 0;
            }
        }
        for (int i = a+1; i < a+b+1; ++i) {
            if (s[i] == '-') {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect
a, b = [int(item) for item in input().split()]
kbs = [item * 100 + int(str(item)[1])*10 + int(str(item)[0]) for item in range(100,1000)]
print(bisect.bisect_right(kbs,b) - bisect.bisect_left(kbs,a))

Measured memory_bytes: 3060
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    int ans;
    int n = 1;
    for (ans = 0; n < B; ans++) {
        n += A-1;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll cnt(10101010);
        rep(i, 1, N+1) {
                rep(j, 1, inf) {
                        if (i * j > N) break;
                        cnt[i * j]++;
                }
        } 
        ll ans = 0;
        rep(i, 1, N+1) {
                ans += i * cnt[i];
        }

        cout << ans << endl;
}

Measured memory_bytes: 82140