akhauriyash/Code-Regression huggingface dataset:
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
// #include <atcoder/all>

#define REPI(i, S, N) for(int i=int(S); i<int(N); i++)
#define REP(i, N) REPI(i, 0, N)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
// using mint = atcoder::modint1000000007;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<string> S;
  if (S.back() == 's')
    return S + "es";
  else
    return S + "s";


 
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  int n,p,a;
  cin>>n>>p;
  int ans=1;
  bool f=false;
  rep(i,n){
    cin>>a;
    if(a%2!=0)f=true;
  }
  if(!f){
    if(p==0){
      rep(i,n)ans*=2;
      cout<<ans<<endl;
    }
    if(p==1){
      cout<<0<<endl;
    }
  }else{
    rep(i,n-1)ans*=2;
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main(){
  int i, j, num, n, stc[4][13] = { 0 };
  char rank;

  scanf("%d", &n);
  
  for(i = 0; i < n; i++){
    scanf(" %c %d",&rank ,&num);
	switch(rank){
	case 'S': stc[0][num - 1] = 1;
	  break;
	case 'H': stc[1][num - 1] = 1;
	  break;
	case 'C': stc[2][num - 1] = 1;
	  break;
	case 'D': stc[3][num - 1] = 1;
	  break;
	}
  }
  for(i = 0; i < 4; i++){
    for(j = 0; j < 13; j++){
      if(stc[i][j] == 0){
	    switch(i){
		case 0:
			rank = 'S';
			printf("%c %d\n",rank, j + 1);
			break;
		case 1:
			rank = 'H';
			printf("%c %d\n",rank, j + 1);
			break;
		case 2:
			rank = 'C';
			printf("%c %d\n",rank, j + 1);
			break;
		case 3:
			rank = 'D';
			printf("%c %d\n",rank, j + 1);
			break;
		}
	  }
	}
  }
  return 0;
}

Measured memory_bytes: 596
N, K, Q = map(int, input().split())
A = list(map(int, input().split()))
A_sorted = sorted(A)
ans = 10**10
for m in A_sorted:
    lists = []
    tmp = []
    for a in A:
        if a<m:
            lists.append(tmp)
            tmp = []
        else:
            tmp.append(a)
    lists.append(tmp)
    
    res = []
    for l in lists:
        length = len(l)
        if length<K:
            continue
        l.sort()
        res+=l[:length-K+1]
    res.sort()
    if len(res)>=Q:
        ans = min(ans, res[Q-1]-m)
print(ans)        

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

typedef pair<int, int> P;

struct StronglyConnectedComponents {
    int N;
    vector<vector<int> > g, gr, g2i;
    vector<bool> visited;
    vector<int> i2g;
    vector<P> edges;
    stack<int> st;

    StronglyConnectedComponents(){};
    StronglyConnectedComponents(int n){init(n);}
    void init(int n){
        N = n;
        g.clear();
        g.resize(n);
        gr.clear();
        gr.resize(n);
        edges.clear();
        visited.resize(n);
        i2g.resize(n);
    }
    void add_edge(int u, int v) {
        g[u].push_back(v);
        gr[v].push_back(u);
        edges.push_back(P(u, v));
    }

    void dfs(int x) {
        if (visited[x]) return;
        visited[x] = true;
        for (int i : g[x]) dfs(i);
        st.push(x);
    }

    void rdfs(int x, int k) {
        if (i2g[x] != -1) return;
        i2g[x] = k;
        for (int i : gr[x]) rdfs(i, k);
    }

    void build() {
        fill(visited.begin(), visited.end(), false);
        fill(i2g.begin(), i2g.end(), -1);
        for (int i = 0; i < N; i++) dfs(i);
        int p = 0;
        while (!st.empty()) {
            int v = st.top();
            st.pop();
            if (i2g[v] == -1) {
                rdfs(v, p);
                p++;
            }
        }
        g2i.clear();
        g2i.resize(p);
        for(int i=0;i<N;i++){
            g2i[i2g[i]].push_back(i);
        }
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    StronglyConnectedComponents G(n);
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G.add_edge(a,b);
    }
    G.build();
    for(int i=0;i<n;i++){
        int id = G.i2g[i];
        for(int j=0;j<int(G.g2i[id].size());j++){
            cout << G.g2i[id][j]+1 << " \n"[j==int(G.g2i[id].size())-1];
        }
    }
}


Measured memory_bytes: 5004
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    [n, l] = li()
    sum_taste = (2 * l + n - 1) * n // 2
    if l <= 0 <= l + n - 1:
        print(sum_taste)
    elif l < 0:
        print(sum_taste - (l + n - 1))
    else:
        print(sum_taste - l)

# L, L+1, ..., L+N-1
# (L+L+N-1)*N//2
#


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


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

  string s;
  cin >> s;
  rep(i,3) cout << s[i];
  cout << endl;
  
  return 0;
    

}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define pri 1000000007
using namespace std;
void run(){
	ll n;
	cin>>n;
	string a;
	cin>>a;
	ll r=0,b=0;
	for(ll i=0;i<n;i++){
		if(a[i]=='R')r++;
		else b++;
	}
	if(r>b)cout<<"Yes";
	else cout<<"No";
}
int main() {
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)run();
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
// In the name of Allah the Lord of the Worlds.

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

typedef long long ll;

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

    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a , a+3);
    cout << a[0]+a[1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
    int main(){
        int s , m , h;
        int tmp;
        int time;
        cin >> time;
        s = time % 60;
        tmp = time / 60;
        m = tmp % 60;
        h = tmp / 60;
        cout << h << ":" << m << ":" << s << endl;
        return 0;
    }

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

using namespace std;

const int nax = 50 + 5;
int N, M;

int adj[nax][nax];
vector<pair<int, int> > edges;
bool visited[nax];

int dfs(int k){
  if(visited[k])
    return 0;
  visited[k] = true;
  int c = 1;
  for(int x=1; x<nax; ++x){
    if(adj[k][x]){
      c += dfs(x);
    }
  }
  return c;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N >> M; 
  for(int i=0; i<M; ++i){
    int x, y;
    cin >> x >> y;
    adj[x][y] = 1;
    adj[y][x] = 1;
    edges.push_back({x, y});
  }
  int res = 0;
  while((int)edges.size() > 0){
     memset(visited, false, sizeof(visited));
     auto pii = edges.back();
     adj[pii.first][pii.second] = 0;
     adj[pii.second][pii.first] = 0;
       if(dfs(1) < N)
          ++res;
     adj[pii.first][pii.second] = 1;
     adj[pii.second][pii.first] = 1;
     edges.pop_back();
  }
  cout << res << "\n";
  return 0;
}


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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(In));
        }

        public void Solve(ConsoleInput input)
        {
            var town = input.ReadIntArray(6);

            var count = new int[4] { 0,0,0,0 };
            for(int i=0; i<count.Length; i++)
            {
                foreach(var t in town)
                {
                    if (i+1 == t) count[i]++;
                }
            }

            //foreach (var t in town) Write($"{t} ");
            //WriteLine();
            //foreach (var c in count) Write($"{c} ");
            //WriteLine();

            if (count.Count(i => i == 2) == 2 && count.Count(i => i == 1) == 2)
                WriteLine("YES");
            else
                WriteLine("NO");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private readonly char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            _separator = separator;
            _stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13396
listOutput = list()
listInput = list()
nNum = int(input())
strInput = input()
listInput = strInput.split()



while (len(listInput) > 0) and ((nNum - 1) >= 0):
    if int(listInput[nNum - 1]) == nNum:
        listOutput.insert(0, nNum)
        del listInput[nNum - 1]
        nNum = len(listInput)
        continue
    
    nNum -= 1
# end of while

if len(listInput) == 0:
    while(len(listOutput) > 0):
        print(listOutput.pop(0))
else:
    print('-1')

Measured memory_bytes: 3064
n, m = [int(x) for x in raw_input().split()]
c = [int(x) for x in raw_input().split()]

INF = float("inf")
dp = [INF for i in xrange(n + 1)]
dp[0] = 0
for i in xrange(1, n + 1):
    for j in xrange(m):
        if c[j] <= i:
            dp[i] = min(dp[i], dp[i - c[j]] + 1)

print dp[n]

Measured memory_bytes: 7580
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
	int A, B, K;
	cin >> A >> B >> K;
	int m = 0;
	int i = 1;
	vector<int> big;
	while (true) {
		if (i == min(A, B)) {
			if(A % i == 0 && B % i == 0) big.push_back(i);
			break;
		}
		if (A % i == 0 && B % i == 0) big.push_back(i);
		i++;
	}
	sort(big.begin(), big.end(), greater<int>());
	cout << big[K-1] << endl;
}

Measured memory_bytes: 256
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let a = (0..n).map(|_| read::<usize>()).collect::<Vec<_>>();
    use std::collections::HashMap;
    let mut m = HashMap::new();
    let mut up = 0;

    if a[0] != 0 {
        println!("0");
        return;
    }

    for i in 0..n {
        let k = a[i];
        up = std::cmp::max(up, k);
        if let Some(&c) = m.get(&k) {
            m.insert(k, c + 1);
        } else {
            m.insert(k, 1);
        }
    }

    if let Some(&c) = m.get(&0) {
        if c > 1 {
            println!("0");
            return;
        }
    }

    let mut ans = 1 as usize;
    let mut prev = 1 as usize;
    for i in 0..up + 1 {
        if let Some(&c) = m.get(&i) {
            ans *= pow(prev, c);
            ans = ans % 998244353;
            prev = c as usize
        } else {
            println!("0");
            return;
        }
    }
    println!("{}", ans % 998244353);

    fn pow(a: usize, b: usize) -> usize {
        let mut ans = a;
        for _ in 0..b - 1 {
            ans *= a;
            ans %= 998244353;
        }
        ans
    }
}


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

bool solve(){
    int n, m;
    cin >> n >> m;
    if(n == 0) return false;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    sort(p.rbegin(), p.rend());
    int ans = 0;
    for(int i=0;i<n;i++){
        if((i+1)%m==0) continue;
        ans += p[i];
    }
    cout << ans << endl;
    return true;
}

int main() {
    while(solve());
    return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
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;}
typedef pair<ll,ll> P;

int main(){
    ll L,R;
    cin >> L >> R;
    R = min(R,L+4038);
    ll ans = 2018;
    for(ll i=L;i<=R;i++){
        for(ll k=i+1;k<=R;k++){
            ll x = i*k%2019;
            ans = min(ans,x);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  bool zen = false, kou = false;
  if (N / 100 > 0 && N / 100 <= 12) zen = true;
  if (N % 100 > 0 && N % 100 <= 12) kou = true;
  if (zen && kou) puts("AMBIGUOUS");
  else if (zen) puts("MMYY");
  else if (kou) puts("YYMM");
  else puts("NA");
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long a,b,i=0;
    cin>>a>>b;
    if(a<b){
        swap(a,b);
    }
    while(1){
        i++;
        if(i*a%b==0){
            break;
        }
    }
    cout<< i*a <<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool f(int x){
    int d = 0;
    while(x > 0){
        d++;
        x /= 10;
    }
    return (d % 2 == 1);
}
int main(void){
    int n, ans = 0;
    cin >> n;
    for(int i=1;i<=n;i++){
        if(f(i))ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>

using namespace std;

static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

//次の辺があれば返す
int next(int u){
    for(int v = nt[u]; v < n; ++v){
        nt[u] = v + 1;
        if( M[u][v] )
            return v;
    }
    return -1;
}

void dfs_visit(int r){
    for(int i = 0; i<n; i++)
        nt[i] = 0;

    stack<int> S;
    S.push(r);
    color[r] = GRAY;
    d[r] = ++tt;

    while( !S.empty() ){
        int u = S.top();
        int v = next(u);
        if( v != -1 ){
            if( color[v] == WHITE ){
                color[v] = GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        }else{
            S.pop();
            color[u] = BLACK;
            f[u] = ++tt;
        }
    }
}

void dfs(){
    for (int i = 0; i < n; i++){
        color[i] = WHITE;
        nt[i] = 0;
    }
    tt = 0;

    for (int u = 0; u < n; u++){
        if(color[u] == WHITE)
            dfs_visit(u);
    }
    for (int i = 0; i < n; ++i){
        cout << i + 1 << " " << d[i] << " " << f[i] << endl;
    }
}

int main()
{
    int u, k, v;

    cin >> n;
    for (int i = 0; i < n; ++i){
        for (int j = 0; j < n; j++)
        {
            M[i][j] = 0;
        }
    }
    for (int i = 0; i < n; ++i){
        cin >> u >> k;
        for (int j = 0; j < k; ++j){
            cin >> v;
            M[u - 1][v - 1] = 1;
        }
    }

    dfs();

    return 0;
}


Measured memory_bytes: 3152
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
    
    public static void main(String[] args) {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            
            String strDataNum = br.readLine();
            int dataNum = Integer.parseInt(strDataNum);
            
            for (int itr = 0; itr < dataNum; itr ++) {
                String replacedLine = br.readLine().replace("Hoshino", "Hoshina");
                System.out.println(replacedLine);
            }
            
        } catch(Exception e) {
            e.printStackTrace();
        } finally {
        }
        
    }
    
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;

ll dp[100050][2];
ll dpsum[100050][2];

int main() {
    //cout.precision(10);
    ll N, A, B;
    cin >> N >> A >> B;
    if(A > B) swap(A, B);
    vector<ll> S(N + 1);
    S[0] = -2000000000;
    for(int i = 1; i <= N; i++) {
        cin >> S[i];
    }
    for(int i = 3; i <= N; i++) {
        if(S[i] - S[i - 2] < A) {
            cout << "0" << endl;
            return 0;
        }
    }
    dp[1][0] = 1;
    dp[1][1] = 1;
    //dp[0][1] = 1;
    dpsum[1][0] = 1;
    //dpsum[0][1] = 1;
    dpsum[1][1] = 1;
    int A_index = -1;
    dp[2][0] = 1;
    if(S[2] - S[1] >= A) dp[2][0]++;
    dp[2][1] = 1;
    if(S[2] - S[1] >= B) dp[2][1]++;
    dpsum[2][0] = dpsum[1][0] + dp[2][0];
    dpsum[2][1] = dpsum[1][1] + dp[2][1];
    //for(int index = 2; index <= N; index++) {
    for(int index = 3; index <= N; index++) {
        //cout << index - 1 << " " << dp[index - 1][0] << " " << dp[index - 1][1] << endl;
        if(S[index - 1] - S[index - 2] < A) {
            A_index = index - 3;
        }
        if(S[index] - S[index - 1] >= B) {
            ll val = (dp[index - 1][0] + dp[index - 1][1]) % mod;
            dp[index][0] = val;
            dp[index][1] = val;
            for(int i = 0; i <= 1; i++) {
                dpsum[index][i] = (dpsum[index - 1][i] + dp[index][i]) % mod;
            }
            continue;
        }
        if(S[index] - S[index - 1] >= A) {
            dp[index][0] = (dp[index - 1][0] + dp[index - 1][1]) % mod;
            dpsum[index][0] = (dpsum[index - 1][0] + dp[index][0]) % mod;
        } else {
            dp[index][0] = dp[index - 1][1];
            dpsum[index][0] = (dpsum[index - 1][0] + dp[index][0]) % mod;
        }
        int upper = distance(S.begin(), upper_bound(S.begin(), S.end(), S[index] - B)) - 1;
        //cout << index << " " << A_index << " " << upper << endl;
        if(A_index >= 0) dp[index][1] = (dpsum[upper][1] - dpsum[A_index][1] + mod) % mod;
        else dp[index][1] = (dpsum[upper][1] - dpsum[0][1] + 1 + mod) % mod;
        if(upper < A_index) dp[index][1] = 0;
        //if(A_index == 0) dp[index][1]++;
        dpsum[index][1] = (dpsum[index - 1][1] + dp[index][1]) % mod;
    }
    cout << (dp[N][0] + dp[N][1]) % mod << endl;
    return 0;
}


Measured memory_bytes: 4224
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

// ----------------------------------------------------------------

func main() {
	var a int
	var b int
	var c int
	fmt.Scan(&a, &b, &c)

	if a-b >= c {
		fmt.Println(0)
	} else {
		fmt.Println(c - a + b)
	}
}

// ----------------------------------------------------------------

var dx = []int{0, 1, 0, -1, 0}
var dy = []int{1, 0, -1, 0, 0}
var inf = int(1e9)

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}

func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

var nextReader func() []byte

func init() {
	nextReader = newScanner()
	log.SetFlags(log.Lshortfile)
}

func newScanner() func() []byte {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() []byte {
		r.Scan()
		return r.Bytes()
	}
}

func nextBytes() []byte {
	return nextReader()
}

func nextString() string {
	return string(nextReader())
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(string(nextReader()), 10, 64)
	return v
}

func nextInt() int {
	v, _ := strconv.Atoi(string(nextReader()))
	return v
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(string(nextReader()), 64)
	return f
}


Measured memory_bytes: 640
#include <stdio.h>

#define SIZE 10
int main(void){
    int paper[SIZE+4][SIZE+4];
    int x, y, s;
    int branks, darkest;
    
    for (int i=0; i<SIZE+4; i++){
        for (int j=0; j<SIZE+4; j++){
            paper[i][j]=0;
        }
	}
	
    while (scanf("%d,%d,%d", &x, &y, &s)!= EOF){
        x+=2; y+=2;
        switch (s){
        case 3:
            paper[x  ][y-2]++;
            paper[x-2][y  ]++;
            paper[x  ][y+2]++;
            paper[x+2][y  ]++;
        case 2:
            paper[x-1][y-1]++;
            paper[x-1][y+1]++;
            paper[x+1][y+1]++;
            paper[x+1][y-1]++;
        case 1:
            paper[x  ][y-1]++;
            paper[x-1][y  ]++;
            paper[x  ][y  ]++;
            paper[x+1][y  ]++;
            paper[x  ][y+1]++;
            break;
        }
    }

    branks=0; darkest=0;
    for (int i=2; i<SIZE+2; i++){
        for (int j=2; j<SIZE+2; j++){
            if (paper[i][j]==0) branks++;
            if (paper[i][j]>darkest) darkest=paper[i][j];
        }
	}
    printf("%d\n%d\n", branks, darkest);
    return 0;
}

Measured memory_bytes: 1024
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
ab.sort()

l,r = ab[0][0],ab[0][1]-1

ans = 1

for i in range(1,m):
    l = max(l,ab[i][0])
    r = min(r,ab[i][1]-1)
    if l > r:
        ans += 1
        l,r = ab[i][0],ab[i][1]-1

print(ans)

Measured memory_bytes: 27872
# -*- coding: utf-8 -*-
import itertools
N = input()
Nlen = len(N)
N = int(N)
l = ["3","5","7"]

ans = 0
for k in range(3,Nlen+1):
    for cs in itertools.product(l,repeat=k):
        tmp_num = ""
        for i, c in enumerate(cs):
            tmp_num = c + tmp_num

        if tmp_num.count("3") == 0 or tmp_num.count("5") == 0 or tmp_num.count("7") == 0:
            continue

        if int(tmp_num) <= N:
            ans += 1

print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define LL long long
#define N 200005
using namespace std;
int nx[N],n;
LL a[200][26],le[200],l,r;
char ch[N];
void kmp()
{
    int j=0;
    fo(i,2,n/2)
    {
        while(j&&ch[j+1]!=ch[i]) j=nx[j];
        if(ch[j+1]==ch[i]) j++;
        nx[i]=j;
    }
}
LL calc(int c,LL w)
{
    int id=1;
    if(le[id]>=w) 
    {
        int s=0;
        fo(i,1,w)
        {
            if(ch[i]-'a'==c) s++;
        }
        return s;
    }
    while(w>=le[id])
    {
        a[id+1][c]=a[id][c]+a[id-1][c];
        le[id+1]=le[id]+le[id-1];
        id++;
    }
    LL s=a[id-1][c];
    if(w==le[id-1]) return s;
    else return s+calc(c,w-le[id-1]);
}
int main()
{
    scanf("%s",ch+1);
    n=strlen(ch+1);
    kmp();
    cin>>l>>r;
    le[0]=n/2-nx[n/2];
    le[1]=n/2;
    fo(i,1,n/2) 
    {
        a[1][ch[i]-'a']++; 
        if(i<=le[0]) a[0][ch[i]-'a']++;
    }
    fo(i,0,25) printf("%lld ",calc(i,r)-calc(i,l-1));
}

Measured memory_bytes: 896
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int num;
	ll mok;
	scanf("%d%lld", &num, &mok);
	vector<pii>v;
	for (int i = 0; i < num; i++)
	{
		ll za, zb;
		scanf("%lld%lld", &za, &zb);
		v.push_back(make_pair(za, zb));
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < v.size(); i++)
	{
		if (mok <= v[i].second)
		{
			printf("%lld\n", v[i].first);
			return 0;
		}
		mok -= v[i].second;
	}
}

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

N,M = list(map(int, input().rstrip().split()))
X_list = list(map(int, input().rstrip().split()))
#-----

X_list.sort()

diff_list=[0]
for i in range(1,len(X_list)):
    diff = X_list[i] - X_list[i-1]
    diff_list.append(diff)

diff_list.sort()

if N > M:
    ans = 0
elif N==1:
    ans = sum(diff_list[1:])
else:
    ex_num = N-1
    ans = sum(diff_list[1:]) - sum( diff_list[-ex_num:] )

print(ans)


Measured memory_bytes: 13960
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    int p[n], q[n];
    int a[n];
    for (int i=  0; i < n; i++) scanf("%d",&p[i]);
    for (int i=  0; i < n; i++) scanf("%d",&q[i]);
    for (int i=  0; i < n; i++) a[i] = i+1;
    int x, y;
    int cur = 0;
    do {
        for (int i = 0; i < n; i++){
            if (a[i] != p[i]) goto done1;
        }
        x = cur;
        done1:;
        for (int i = 0; i < n; i++){
            if (a[i] != q[i]) goto done2;
        }
        y = cur;
        done2:;
        cur++;

    }
    while (next_permutation(a,a+n));
    printf("%d",abs(x-y));



}


Measured memory_bytes: 256
Module Module1

    Sub Main()

        Dim nN As Integer
        nN = CInt(Console.ReadLine())

        Dim nPower As Double
        nPower = 1

        Dim nDivider As Double
        nDivider = 10.0 ^ 9.0 + 7.0

        Dim ii As Integer
        For ii = 1 To nN
            nPower = (nPower * ii) Mod nDivider
        Next


        Console.WriteLine(CLng(nPower))

    End Sub

End Module


Measured memory_bytes: 11220
n,m,x=gets.split.map(&:to_i)
a=[]
n.times do
  a << gets.split.map(&:to_i)
end
ans = Float::INFINITY
(1...2**n).each do |i|
  list=[]
  i.to_s(2).rjust(n,"0").each_char.with_index do |s,i|
    list << a[i] if s==?1
  end
  flag=true
  list=list.transpose
  money=list.shift
  list.each do |l|
    flag = false if l.sum < x
  end
  ans = [ans,money.sum].min if flag
end
p ans==Float::INFINITY ? -1 : ans


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n, m;
pair<PI, li> data[100100];

li res[100100];

li cnt[100100] = {0};

int main() {
    cin >> n >> m;
    rep(i, m) {
        cin >> data[i].F.F >> data[i].F.S;
        data[i].S = i;
    }
    sort(data, data + m);
    li now = 1;
    rep(i, m) {
        if (i > 0 && data[i].F.F == data[i - 1].F.F) {
            ++now;
        } else {
            now = 1;
        }
        res[data[i].S] = data[i].F.F * 1000000ll + now;
    }
    rep(i, m) {
        printf("%012lld\n", res[i]);
    }

    return 0;
}

Measured memory_bytes: 4608
#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int h[n+1],ans=0;
    h[n]=0;
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    while(1){
        int l=0;
        while(l<n&&h[l]==0){
            l++;
        }
        if(l==n)break;
        int r=l;
        while(r<n&&h[r]>0){
            r++;
        }
        for(int j=l;j<r;j++){
            h[j]--;
        }
        ans++;
        
    }
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 128
from itertools import product
s = input()
ans = 0
op = ["", "+"]
for b in product(range(2), repeat = len(s) - 1):
    v = s[0]
    for j in range(1, len(s)):
        v += op[b[j - 1]] + s[j]
    ans += eval(v)

print(ans)


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

int main(){
  int N, K;
  cin >> N >> K;
  int x = 1;
  
  for(int i = 0; i < N; i++){
    if(x + K >= 2*x){
      x = 2*x;
    }
    else{
      x = x + K;
    }
  }
  cout << x << endl;
}

  

Measured memory_bytes: 256
N = int(input())
S = list(int(input()) for _ in range(N))

A = []
ans = sum(S)
if ans % 10 == 0:

    for s in S:
        if s % 10 != 0:
            A.append(s)

    if len(A) == 0:
        ans = 0
    else:
        ans -= min(A)


print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <map>
#include <queue>
using namespace std;

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    map<string, priority_queue<pair<int, int>>> ans;

    int N;
    cin >> N;

    for(int i = 1; i <= N; i++) {
        string S;
        int P;
        cin >> S >> P;

        auto itr = ans.find(S);
        if(itr != ans.end()) {
            itr->second.push(make_pair(P, i));
        } else {
            ans[S].push(make_pair(P, i));
        }
    }

    for(auto itr = ans.begin(); itr != ans.end(); itr++) {
        while(!itr->second.empty()) {
            IFD cout << itr->first << " " << itr->second.top().first << endl;
            cout << itr->second.top().second << endl;
            itr->second.pop();
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String word;
		int count = 0;
		word = in.readLine();
		while (true) {
			String[] text;
			text = in.readLine().split(" ");
			if (text[0].equals("END_OF_TEXT")) {
				break;
			}
			for (String str : text) {
				str = str.toLowerCase();
				if (str.matches(word)) {
					count++;
				} else {
					continue;
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 17056
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;

struct Node{
	long key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x){
	while (x->left != NIL) x = x->left;
	return x;
}

Node * find(Node *u, int k){
	while (u != NIL && k != u->key){
		if (k < u->key) u = u->left;
		else u = u->right;
	}
	return u;
}

Node * treeSuccessor(Node *x){
	if (x->right != NIL) return treeMinimum(x->right);
	Node *y = x->parent;
	while (y != NIL && x == y->right){
		x = y;
		y = y->parent;
	}
	return y;
}

void treeDelete(Node *z){
	Node *y;
	Node *x;

	if (z->left == NIL || z->right == NIL) y = z;
	else y = treeSuccessor(z);

	if (y->left != NIL) x = y->left;
	else x = y->right;

	if (x != NIL) x->parent = y->parent;

	if (y->parent == NIL) root = x;
	else {
		if (y == y->parent->left) y->parent->left = x;
		else y->parent->right = x;
	}

	if (y != z) z->key = y->key;
	free(y);
}

void insert(int k){
	Node *y = NIL;
	Node *x = root;
	Node *z;

	z = new Node;
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL){
		y = x;
		if (z->key < x->key) x = x->left;
		else x = x->right;
	}
	z->parent = y;

	if (y == NIL) root = z;
	else {
		if (z->key < y->key) y->left = z;
		else y->right = z;
	}
}

void inorder(Node *u){
	if (u == NIL) return;
	inorder(u->left);
	cout << " " << u->key;
	inorder(u->right);
}

void preorder(Node *u){
	if (u == NIL) return;
	cout << " " << u->key;
	preorder(u->left);
	preorder(u->right);
}

int main(){
	int n, i, x;
	string com;

	cin >> n;

	for (i = 0; i < n; i++){
		cin >> com;
		if (com[0] == 'f'){
			cin >> x;
			Node *t = find(root, x);
			if (t != NIL) cout << "yes" << endl;
			else cout << "no" << endl;
		}
		else if (com == "insert"){
			cin >> x;
			insert(x);
		}
		else if (com == "print"){
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
		else if (com == "delete"){
			cin >> x;
			treeDelete(find(root, x));
		}
	}
	
	return 0;
}

Measured memory_bytes: 19960
(defun App (n)
    (let ((ans 1)
        (a Nil))

    (loop for i below n
        do (push (read) a)
    )

    (setf a (sort a #'<))

    (loop for i in a
        do (progn
            (if (and (= ans 0))
            (return)
            (progn (setf ans (* ans i))
                (if (> ans 1000000000000000000)
                (progn 
                    (setq ans -1)
                    (return)
                )
                )
            )
            )
        )
    )   
    ans)
)
(format t "~D~%" (App (read)))


Measured memory_bytes: 78456
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;


int main() {
	
	string S;
	cin >> S;

	vector<ll> dp(100010, -1), a(100010, -1), ab(100010, -1), sum(100010, -1);
	dp[0] = 0; a[0] = 0; ab[0] = 0; sum[0] = 1;

	rep(i, S.size()) {
		dp[i + 1] = dp[i]; a[i + 1] = a[i]; ab[i + 1] = ab[i]; sum[i + 1] = sum[i];
		if (S[i] == '?') {
			a[i + 1] += (sum[i] + 2 * a[i]) % MOD;
			ab[i + 1] += (a[i] + 2 * ab[i]) % MOD;
			dp[i + 1] += (ab[i] + 2 * dp[i]) % MOD;

			sum[i + 1] = sum[i] * 3 % MOD;
		}
		else {
			if (S[i] == 'A') {
				a[i + 1] += sum[i] % MOD;
			}
			else if (S[i] == 'B') {
				ab[i + 1] += a[i] % MOD;
			}
			else if (S[i] == 'C') {
				dp[i + 1] += ab[i] % MOD;
			}
		}
	}

	cout << dp[S.size()] % MOD << endl;

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll mod = 1000000007;

ll n, mem[64][2][2];

ll compute(int ind, bool flg, int carry){
	if(ind == -1){
		return (carry == 0);
	}
	if(mem[ind][flg][carry] != -1)return mem[ind][flg][carry];
	ll &ret = mem[ind][flg][carry]; ret = 0;
	int bit = (n>>ind)&1;
	for(int pc : {0, 1}){
		for(auto v : {0, 1, 2}){
			int nc = (pc + v)/2;
			int dig = (pc + v)%2;
			if(nc != carry)continue;
			if(flg){
				if(dig < bit)ret += compute(ind - 1, false, pc);
				if(dig == bit)ret += compute(ind - 1, true, pc);
			}else{
				ret += compute(ind - 1, false, pc);
			}
			if(ret >= mod)ret -= mod;
		}
	}
	return ret;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	cin>>n;
	memset(mem, -1, sizeof(mem));
	cout<<compute(59, true, 0)<<'\n';

	return 0;
}

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

char s[100005];
int main(){
	scanf("%s",s+1);
	int n = strlen(s+1);
	int ans=n,ans2=n;
	for(int i=1;i<=n;i++){
		if(s[i] == '1') ans = min(ans, max(n-i,i-1));
		else if(s[i] == '0') ans2 = min(ans2, max(n-i,i-1));
	}
	printf("%d\n",max(ans,ans2));
	return  0;
}

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

int first_x,first_y;
int zyuden_x,zyuden_y;
int soko_x,soko_y;
double map[16][3][3];

void get_where(int* x,int* y,char c) {
	if(c=='A'){*x=0;*y=0;}
	if(c=='B'){*x=1;*y=0;}
	if(c=='C'){*x=2;*y=0;}
	if(c=='D'){*x=0;*y=1;}
	if(c=='E'){*x=1;*y=1;}
	if(c=='F'){*x=2;*y=1;}
	if(c=='G'){*x=0;*y=2;}
	if(c=='H'){*x=1;*y=2;}
	if(c=='I'){*x=2;*y=2;}
}

int canmove(int x,int y) {
	if(x<0 || x>=3 || y<0 || y>=3)return 0;
	if(x==soko_x && y==soko_y)return 0;
	return 1;
}

int main(void) {
	int battery;
	char first[2],zyuden[2],soko[2];
	int i,j,k;
	while(1) {
		scanf("%d",&battery);
		if(battery==0)break;
		scanf("%s%s%s",first,zyuden,soko);
		get_where(&first_x,&first_y,first[0]);
		get_where(&zyuden_x,&zyuden_y,zyuden[0]);
		get_where(&soko_x,&soko_y,soko[0]);
		memset(map,0,sizeof(map));
		map[0][first_x][first_y]=1;
		for(i=0;i<battery;i++) {
			for(j=0;j<3;j++) {
				for(k=0;k<3;k++) {
					if(canmove(j-1,k))map[i+1][j-1][k]+=map[i][j][k]/4;
					else map[i+1][j][k]+=map[i][j][k]/4;
					if(canmove(j+1,k))map[i+1][j+1][k]+=map[i][j][k]/4;
					else map[i+1][j][k]+=map[i][j][k]/4;
					if(canmove(j,k-1))map[i+1][j][k-1]+=map[i][j][k]/4;
					else map[i+1][j][k]+=map[i][j][k]/4;
					if(canmove(j,k+1))map[i+1][j][k+1]+=map[i][j][k]/4;
					else map[i+1][j][k]+=map[i][j][k]/4;
				}
			}
		}
		printf("%.15f\n",map[battery][zyuden_x][zyuden_y]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
#include <queue>
#include <iostream>
using namespace std;
//#define DEBUG
struct Path{
    int city;
    double cost;
    int v;
    int pre;
    Path(int pr,int ci,double co,int sp):pre(pr),city(ci),cost(co),v(sp){}

    bool operator>(const Path &b) const{
        return cost<b.cost;
    }

    bool operator<(const Path &b) const{
        return !this->operator>(b);
    }
};
priority_queue<Path> heap;
double dp[31][31][31];
int map[31][31],lim[31][31];
int n,m,s,g;
int main(){
    #ifdef DEBUG
        freopen("in.txt","r",stdin);
    #endif
    bool p = 0;
    while(scanf("%d%d",&n,&m)&& n ){
        memset(map,-1,sizeof(map));
        bool visited[31][31][31] = {false};
        for(int i=0;i<31;i++)
            for(int j=0;j<31;j++)
                for(int k=0;k<31;k++)
                    dp[i][j][k] = 1e9;
        scanf("%d%d",&s,&g);
        for(int i=0;i<m;i++){
            int v,w;
            scanf("%d%d",&v,&w);
            scanf("%d%d",map[v]+w,lim[v]+w);
            map[w][v]=map[v][w];lim[w][v]=lim[v][w];
        }
        heap.push(Path(0,s,0.0,0));
        dp[0][s][0]=0.0;
        while(!heap.empty()){
            int city = heap.top().city;
            int v = heap.top().v;
            int pre = heap.top().pre;
            heap.pop();

            if(visited[city][v][pre]) continue;
            else visited[city][v][pre] = true;

            for(int i=-1;i<=1;i++){
                if(v+i>0){
                    for(int j=1;j<=n;j++){
                        if(j==pre) continue;
                        if(map[j][city]!=-1&&lim[j][city]>=v+i&&!visited[j][v+i][city]){
                            if(dp[city][j][v+i]>=dp[pre][city][v]+map[city][j]/(double)(v+i)){
                                dp[city][j][v+i]=dp[pre][city][v]+map[city][j]/(double)(v+i);
                                heap.push(Path(city,j,dp[city][j][v+i],v+i));
                            }
                        }

                    }
                }
            }
        }
        double min = 1e9;
        for(int i=1;i<31;i++) min = min<dp[i][g][1]?min:dp[i][g][1];
        if(min==1e9)printf("unreachable\n");
        else printf("%.5lf\n",min);
    }
    return 0;
}


Measured memory_bytes: 6292
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	char c;
	cin >> c;
	cout << (char)(c + 1);	
	
}





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

class Magatro
{
    static int a, b, c;
    static void Main()
    {
        Read();
        if (c == a + b)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
    static void Read()
    {
        int[] q = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        Array.Sort(q);
        a = q[0];
        b = q[1];
        c = q[2];
    }
}

Measured memory_bytes: 3032
def solve():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))

    now = 1
    n_move = 0
    graph = []
    visited = set()
    while True:
        graph.append(now)
        visited.add(now)
        now = A[now-1]
        n_move += 1
        if now in visited:
            break

    loop_start = now
    to_loop_start = 0
    for i in range(len(graph)):
        if graph[i] == loop_start:
            to_loop_start = i
    
    per_loop = n_move - to_loop_start
    
    if K <= to_loop_start:
        print(graph[K])
    else:
        print(graph[to_loop_start + (K-to_loop_start) % per_loop])

if __name__ == '__main__':
    solve()

Measured memory_bytes: 124544
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};

int H, W;
int c[10][10];


signed main()
{
  cin >> H >> W;
  REP(i,10) REP(j,10) cin >> c[i][j];

  REP(k,10) REP(i,10) REP(j,10) {
    c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
  }

  int ans = 0;
  REP(i,H) REP(j,W) {
    int A;
    cin >> A;
    if (A != -1) {
      ans += c[A][1];
    }  
  }

  cout << ans << endl;
}


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

using namespace std;

long long int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

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

   string strN = to_string(N);
   long long int size = strN.size();
   if (size == 1) {
      cout << N << endl;
      return 0;
   }
   
   bool flg = true;
   for (int i = 1; i < size; i++) {
      if (strN[i] != '9') flg = false;
   }
   
   int ans = 0;
   if (flg) {
      ans += ctoi(strN[0]);
      for (int i = 1; i < size; i++) ans += 9;
   } else {
      ans += ctoi(strN[0]) - 1;
      for (int i = 1; i < size; i++) ans += 9;
   }

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


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

using namespace std;

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    string x, y;
    cin >> n >> x >> y;

    for(int i=0;i<n;++i)
        cout << x[i] << y[i];
    
    cout << '\n';

    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7; 

fn main(){
    let n: usize = read();
    let mut h: Vec<usize> = (0..n).map(|_| read()).collect();
    h.push(1<<30);
    let mut ans = 0;
    let mut cnt = 0;
    for i in 1..n+1{
        if h[i - 1] >= h[i] {
            cnt += 1;
        }else{
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    println!("{}", ans);
}

fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define display(v) for (auto x : v) cout << x << ", "
#define dbg(x) cout << (#x) << " = " << (x) << "\n"
#define dbgp(x) cout << (#x) << " = {" << (x.first) << ", " << (x.second) << "}\n";
#define print(x) cout << (#x) << " = [ ";display(x); cout << "]\n"
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

int main()
{
	fastio;

    int n;
    cin >> n;
    ll a[n + 1], b[n], tot = 0;
    for (auto &x : a)
    {
        cin >> x;
        tot += x;
    }
    for (auto &x: b)
    cin >> x;
    for (int i = 0; i < n; i++)
    {
        if (b[i] >= a[i])
        {
            b[i] -= a[i];
            a[i] = 0;
        }
        else
        {
            a[i] -= b[i];
            b[i] = 0;
        }
        if (b[i] >= a[i + 1])
        {
            b[i] -= a[i + 1];
            a[i + 1] = 0;
        }
        else{
            a[i + 1] -= b[i];
            b[i] = 0;
        }
    }
    for (auto x : a)
        tot -= x;
    cout << tot;
    return 0;
}


Measured memory_bytes: 1792