akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath> 
#include <queue>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
static const int dx[4] = {1, -1, 0, 0};
static const int dy[4] = {0, 0, 1, -1};

void bfs(int s, int t);

int H, W;
vector<string> maze(50);
vector<vector<int> > d(50 ,vector<int>(50, -1));

int main() {

    cin >> H >> W;
    for (int i = 0; i < H; i++)
        cin >> maze[i];

    bfs(0, 0);
    int cnt_wall = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (maze[i][j] == '#')
                cnt_wall++;
        }
    }
    int cnt_route = H * W - cnt_wall;
    if (d[H-1][W-1] == -1) {
        cout << -1 << '\n';
    }
    else {
        cout << cnt_route - d[H-1][W-1] << '\n';
    }

}

void bfs(int s, int t) {
    queue<P> q;
    q.push(P(s, t));
    d[0][0] = 1;
    P p;
    int x, y;
    while (!q.empty()) {
        p = q.front(); q.pop();
        for (int i = 0; i < 4; i++) {
            x = p.first + dx[i];
            y = p.second + dy[i];
            if (x < 0 or x >= H or y < 0 or y >= W) continue;
            if (maze[x][y] == '#') continue;
            if (d[x][y] == -1) {
                d[x][y] = d[p.first][p.second] + 1;
                q.push(P(x, y));
            }
        }
    }
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int n=sc.nextInt();
	  int[] a=new int[n];
	  for(int i=0;i<n;i++) a[i]=sc.nextInt();
	  ArrayDeque<Integer> dq = new ArrayDeque<>();
	  for(int i=0;i<n;i++) {
		  if(i%2==0) {
			  dq.addLast(a[i]);
		  }else {
			  dq.addFirst(a[i]);
		  }
	  }
	  if(n%2==0) {
		  for(int i=0;i<n-1;i++) {
			  System.out.print(dq.pollFirst()+" ");
		  }
		  System.out.println(dq.pollFirst());
	  }else {
		  for(int i=0;i<n-1;i++) {
			  System.out.print(dq.pollLast()+" ");
		  }
		  System.out.println(dq.pollLast());
	  }
  }
}



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

#define inf 0x7f7f7f7f
#define MOD 1000000007
#define LL long long
#define N 2010

LL A[N],n,k,sum[N],T[N],ans,inv;

int main() {
	inv=(MOD+1)/2;
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>A[i];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(A[i]>A[j]) sum[i]++;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(A[i]>A[j]) T[i]++;
	for(int i=1;i<=n;i++) ans=(ans+T[i]%MOD*k%MOD)%MOD;
	for(int i=1;i<=n;i++)
		ans=(ans+k%MOD*(k-1)%MOD*sum[i]%MOD*inv%MOD)%MOD;
	cout<<ans;
}

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

int row[105], col[105];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int h,w;cin>>h>>w;
  string mp[105];
  for(int y=0;y<h;y++){
    cin>>mp[y];
  }
  for(int y=0;y<h;y++){
    for(int x=0;x<w;x++){
      if(mp[y][x]=='#'){row[y]=1;}
    }
  }
  for(int x=0;x<w;x++){
    for(int y=0;y<h;y++){
      if(mp[y][x]=='#'){col[x]=1;}
    }
  }
  for(int y=0;y<h;y++){
    if(!row[y])continue;
    for(int x=0;x<w;x++){
      if(!col[x])continue;
      cout<<mp[y][x];
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001

int main(void) {
	int n,m; cin >> n >> m;
	vi l(m),r(m);
	rep(i,m) cin >> l[i] >> r[i];
	int mn = 1;
	int mx = n;
	rep(i,m){
		mn = max(mn,l[i]);
		mx = min(mx,r[i]);
	}
//	cout << "mn = " << mn << " : mx = " << mx << endl;
	int ans = max(0,mx-mn+1);
	cout << ans << endl;
}




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

int main(){
  int c=0, i=0;
  string s;
  cin >> s;
  while(s[i]=='1'){
    c++;
    i++;
  }
  long k;
  cin >> k;
  if(k<=c)cout << 1;
  else cout << s[i];
  return 0;
}


Measured memory_bytes: 256
alphabet = [chr(i) for i in range(ord("a"), ord("z")+1)]
import collections
alphabet_d = collections.OrderedDict()
for a in alphabet:
    alphabet_d[a] = 0

import sys
S = sys.stdin.readlines()
for s in S:
    sl = s.lower()
    for c in sl:
        if c in alphabet:
            alphabet_d[c] += 1
for k, v in alphabet_d.items():
    print("{0} : {1}".format(k, v))


Measured memory_bytes: 5964
#include<bits/stdc++.h>
using namespace std;
#define int long long
int t, a, b, c, d, g;
int32_t main(){
    cin>>t;
    while(t--){
        cin>>a>>b>>c>>d;
        g=__gcd(d, b);
        if(a<b || d<b || (a-(a-c-1)/g*g)-b<0) cout<<"No\n";
        else cout<<"Yes\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int H, W;
	cin >> H >> W;
	int A[1002][1002] = {};
	vector<pair<int, int>> que;
	rep1(i, H) {
		string S;
		cin >> S;
		rep(j, W) if (S[j] == '#') {
			A[i][j + 1] = 1;
			que.pb(mp(i, j + 1));
		}
	}

	int kotae = 0;
	while (que.size()) {
		int nutta = 0;
		vector<pair<int, int>> que2;
		for (auto p : que) {
			int i = p.first;
			int j = p.second;
			if (i > 1 && A[i - 1][j] == 0) {
				A[i - 1][j] = 1;
				que2.pb(mp(i - 1, j));
				nutta = 1;
			}
			if (i < H && A[i + 1][j] == 0) {
				A[i + 1][j] = 1;
				que2.pb(mp(i + 1, j));
				nutta = 1;
			}
			if (j > 1 && A[i][j - 1] == 0) {
				A[i][j - 1] = 1;
				que2.pb(mp(i, j - 1));
				nutta = 1;
			}
			if (j < W && A[i][j + 1] == 0) {
				A[i][j + 1] = 1;
				que2.pb(mp(i, j + 1));
				nutta = 1;
			}
		}
		if (nutta) kotae++;
		que = que2;
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 16612
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,m,a[101010]={},b[101010]={};
	priority_queue<pair<int,int>> pq;
	cin>>n>>m;
	FOR(i,0,m){
		cin>>a[i]>>b[i];
		pq.push(MP(-b[i],a[i]));
	}
	int t=0,cnt=0;
	while(!pq.empty()){
		int l=pq.top().ND,r=-pq.top().ST;
		pq.pop();
		if(l<t)continue;
		t=r;
		cnt++;
		if(t==n)break;
	}
	cout<<cnt;
    return 0;
}


Measured memory_bytes: 2168
n = [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(n[k-1])

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

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

int main() {
    int n, k;
    cin >> n >> k;
    int ind;
    rep(i, n) {
        int a;
        cin >> a;
    }
    int ans = 0;
    n -= k;
    ans++;
    k--;
    ans += ceil((double)n / k);
    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N, D; cin >> N >> D;
    int ans = ceil(N / double(2 * D + 1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << "\n";
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
#define REP(i,n)    for(int i = 0; i < (int)n; i++)

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

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M = mapint()
AB = [list(mapint()) for _ in range(N)]
CD = [list(mapint()) for _ in range(M)]

for a, b in AB:
    dist = 10**18
    ans = -1
    for i in range(M):
        c, d = CD[i]
        if abs(a-c)+abs(b-d)<dist:
            ans = i+1
            dist = abs(a-c)+abs(b-d)
    print(ans)

Measured memory_bytes: 68116
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CTogether solver = new CTogether();
        solver.solve(1, in, out);
        out.close();
    }

    static class CTogether {
        static final int MAX = 100_000;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] count = new int[MAX + 1];
            for (int i = 0; i < n; i++) {
                count[in.nextInt()]++;
            }

            int answer = 0;
            for (int i = 1; i + 1 <= MAX; i++) {
                answer = Math.max(answer, count[i - 1] + count[i] + count[i + 1]);
            }
            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 33664
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;


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

    int a, b;

    cin >> a >> b;

    int x[3] = {1, 2, 3};

    for (int i = 1; i <= 3; ++i) {
        if (i != a && i != b) {
            cout << i;
        }
    }


    return 0;
}


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

void Main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e - a > k) cout << ":("<< endl;
  else cout << "Yay!" << endl;
}

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

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
  string str;
  bool flg = false;

  cin >> str;

  if((str[0] == str[1] && str[1] == str[2]) || (str[1] == str[2] && str[2] == str[3]))
    flg = true;

  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
package main

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

var (
	h, w int
	s    []string
)

func calcLeft(c chan [][]int) {
	ls := make([][]int, h)
	for i := range ls {
		ls[i] = make([]int, w)
		for j := 0; j < w; j++ {
			if s[i][j] == '#' {
				ls[i][j] = 0
				continue
			}
			if j == 0 {
				ls[i][j] = 1
				continue
			}
			ls[i][j] = ls[i][j-1] + 1
		}
	}
	c <- ls
}

func calcRight(c chan [][]int) {
	rs := make([][]int, h)
	for i := range rs {
		rs[i] = make([]int, w)
		for j := w - 1; j >= 0; j-- {
			if s[i][j] == '#' {
				rs[i][j] = 0
				continue
			}
			if j == w-1 {
				rs[i][j] = 1
				continue
			}
			rs[i][j] = rs[i][j+1] + 1
		}
	}
	c <- rs
}

func calcTop(c chan [][]int) {
	ts := make([][]int, h)
	for i := range ts {
		ts[i] = make([]int, w)
	}
	for j := 0; j < w; j++ {
		for i := 0; i < h; i++ {
			if s[i][j] == '#' {
				ts[i][j] = 0
				continue
			}
			if i == 0 {
				ts[i][j] = 1
				continue
			}
			ts[i][j] = ts[i-1][j] + 1
		}
	}
	c <- ts
}

func calcDown(c chan [][]int) {
	ds := make([][]int, h)
	for i := range ds {
		ds[i] = make([]int, w)
	}
	for j := 0; j < w; j++ {
		for i := h - 1; i >= 0; i-- {
			if s[i][j] == '#' {
				ds[i][j] = 0
				continue
			}
			if i == h-1 {
				ds[i][j] = 1
				continue
			}
			ds[i][j] = ds[i+1][j] + 1
		}
	}
	c <- ds
}

func main() {
	fmt.Scan(&h, &w)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	s = make([]string, h)
	for i := range s {
		sc.Scan()
		s[i] = sc.Text()
	}

	c := make(chan [][]int)
	go calcLeft(c)
	go calcRight(c)
	go calcTop(c)
	go calcDown(c)
	xs1, xs2, xs3, xs4 := <-c, <-c, <-c, <-c

	ans := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if v := xs1[i][j] + xs2[i][j] + xs3[i][j] + xs4[i][j] - 3; v > ans {
				ans = v
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 138236
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
using namespace std;
typedef long long ll;
typedef int Def;
//typedef int ll;
typedef pair<Def,Def> pii;
typedef vector<string> vs;
typedef vector<Def> vi;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#include<tuple>
#include<queue>
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
class DIJ{
public:
  struct edge {
    Def to,cost,tim,r;
  };
  vector<vector<edge> > G;
  Def n,L;
  Def d[110][25][300];////

  DIJ(Def size){
    n=size;
    G=vector<vector<edge> >(n);
  }
  void add_edge(Def a, Def b,Def c,Def d,Def e){///
    edge E={b,c,d,e},ee={a,c,d,e};///
    G[a].push_back(E);
    G[b].push_back(ee);
  }
  void dij(Def s){///
    rep(i,110)rep(j,25)rep(k,300)d[i][j][k]=inf;///
    d[s][0][0]=0;

    int p;cin>>p;
    vi pa(p);
    vi dd(p);
    rep(i,p){
      int l;cin>>l>>dd[i];
      int t=0;
      rep(j,l){
	int a;cin>>a;
	t|=1<<(a-1);
      }
      pa[i]=t;
    }
    rep(i,p)for(int j=255;j>=0;j--){
      d[s][0][j|pa[i]]=min(d[s][0][j|pa[i]],d[s][0][j]+dd[i]);
    }
    
    priority_queue<tp>q;

    rep(i,256)if(d[s][0][i]!=inf){
      q.push(tp(-d[s][0][i],s,0,i));
    }
    while(!q.empty()){
      Def cost,pos,tim,pas;
      tie(cost,pos,tim,pas)=q.top();
      cost*=-1;
      q.pop();
      //      cout<<pos<<" "<<tim<<" "<<pas<<" "<<cost<<endl;
      if(cost>d[pos][tim][pas])continue;
      rep(i,G[pos].size()){
	edge e=G[pos][i];
	Def to=e.to;
	Def ncost=cost;
	if(pas&(1<<e.r));
	else ncost+=e.cost;
	
	Def nt=tim+e.tim;
	if(ncost<d[to][nt][pas]&&nt<=24){
	  d[to][nt][pas]=ncost;
	  q.push(tp(-ncost,to,nt,pas));
	}
      }
      
    }
  }
  void solve(int s,int t,int h){
    dij(s);
    int out=inf;
    rep(i,h+1)rep(j,300)
      out=min(out,d[t][i][j]);
    if(out==inf)out=-1;
    cout<<out<<endl;
  }
};

int main(){
  int n,m,h,k;
  while(cin>>n>>m>>h>>k,n){
    DIJ dij(n);
    rep(i,m){
      int a,b,c,d,e;
      cin>>a>>b>>c>>d>>e;
      a--;b--;e--;
      dij.add_edge(a,b,c,d,e);
    }
    int s,t;cin>>s>>t;
    s--;t--;
    dij.solve(s,t,h);
    
  }
}



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

int main() {
    int n;
    cin >> n;
    int a,b;
    int com=1e6;;
    for(int i=1;i<n;i++){
        int ans=0;
        a=i;
        b=n-i;
        while(a>0){
            ans+=a%10;
            a=a/10;
        }
        while(b>0){
            ans+=b%10;
            b=b/10;
        }
        com=min(ans,com);
    }
    cout << com << endl;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	
	//for(int i=0;i<N;i++) {}
	public static void main(String[] args) {
		String S=sc.next();
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		
		if(S.equals("ABC")) {
			p("ARC");
		}else {
			p("ABC");
		}
		
		
		
		
		
		
	}
	

	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 35648
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(4100000)

def augment(g, src, matchTo, visited):
    if src < 0:
        return True
    for dst in g.get(src, []):
        if not visited[dst]:
            visited[dst] = True
            if augment(g, matchTo[dst], matchTo, visited):
                matchTo[src] = dst
                matchTo[dst] = src
                return True
    return False


def match(g, L):
    n = len(g)
    matchTo = [-1] * n
    m = 0
    for src in range(L):
        visited = [False] * n
        if augment(g, src, matchTo, visited):
            m += 1
    return m


def solve(N, a, b, c, d):
    g = dict()
    for i in range(2*N):
        g[i] = []
    for i in range(N):
        for j in range(N):
            if a[i] < c[j] and b[i] < d[j]:
                g[i].append(N+j)
                g[N+j].append(i)
    print(match(g, N))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))
    a = [int()] * (N)
    b = [int()] * (N)
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    c = [int()] * (N)
    d = [int()] * (N)
    for i in range(N):
        c[i] = int(next(tokens))
        d[i] = int(next(tokens))
    solve(N, a, b, c, d)

if __name__ == '__main__':
    main()


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



using namespace std;


int main (){
	int n, k;
	
	cin >> n >> k;
	int max = n/2 + (n%2!=0);
	
	if(k <= max){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}


















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

int main(){
	int x,y; cin>>x>>y;
	int ans=0;
	
	if(x==1) ans=300000;
	else if(x==2) ans=200000;
	else if(x==3) ans=100000;
	
	if(y==1) ans+=300000;
	else if(y==2) ans+=200000;
	else if(y==3) ans+=100000;
	
	if(x==1&&y==1) ans+=400000;
	
	cout<<ans<<endl;
}

Measured memory_bytes: 3584
N = int(input())
s = str(input())
count_R = 0
count_B = 0
for i in range(0,N):
    if s[i] == 'R':
        count_R += 1
    else:
        count_B += 1


if count_R > count_B:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N=1409;
int n,m,ans;
int grid[N][N], f[N][N];
int solve() {
    int maxw=0;
    for(int i=0; i<n; i++) {  //初始化，没有污点的位置f[i][j]=1
        for(int j=0; j<m; j++) {
            f[i][j] = (grid[i][j]+1)%2;
            if(f[i][j]) maxw=1;
        }
    }
    for(int i=1; i<n; i++) {  //从上向下，从左往右计算状态转移方程
        for(int j=1; j<m; j++) {
            if(grid[i][j]) f[i][j]=0;
            else {
                f[i][j] = min(f[i-1][j-1], min(f[i-1][j], f[i][j-1])) + 1;
                maxw = max(maxw, f[i][j]);
            }
        }
    }
    return maxw*maxw;
}
int main() {
    cin>>n>>m;
    for(int i=0; i<n; i++)
        for(int j=0; j<m; j++)
            cin>>grid[i][j];
    ans = solve();
    cout<<ans<<endl;
}


Measured memory_bytes: 18508
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;
struct node
{
	int x = -1,y = -1;
	node(int x = -1,int y = -1) : x(x),y(y) {};
}start[11];
const int N = 1005;
char g[N][N];
int s[N][N];
int H,W,n,sx,sy,gx,gy;
const int dx[4] = {-1,0,1,0},dy[4] = {0,1,0,-1};
int bfs()
{
	memset(s,0xff,sizeof(s));
	queue<node> q;
	q.push(node(sx,sy));
	s[sx][sy] = 0;
	while(!q.empty())
	{
		node& prev = q.front();q.pop();
		for(int i = 0;i < 4;++i)
		{
			int nx = prev.x + dx[i],ny = prev.y + dy[i];
			if(nx >= 0 && nx < H && ny >= 0 && ny < W && g[nx][ny] != 'X' && s[nx][ny] == -1)
			{
				s[nx][ny] = s[prev.x][prev.y] + 1;
				q.push(node(nx,ny));
				if(nx == gx && ny == gy)
					return s[nx][ny];
			}
		}
	}
}
int main()
{
	cin >> H >> W >> n;
	for(int i = 0;i < H;++i)	cin >> g[i];
	for(int i = 0;i < H;++i)
		for(int j = 0;j < W;++j)
			if(g[i][j] == 'S')
				start[0].x = i,start[0].y = j;
			else if(g[i][j] != '.' && g[i][j] != 'X')
				start[g[i][j]-'0'].x = i,start[g[i][j]-'0'].y = j;
	int res = 0;
	for(int i = 0;i < n;++i)
	{
		sx = start[i].x,sy = start[i].y;
		gx = start[i+1].x,gy = start[i+1].y;
		res += bfs();
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 7940
#include<stdio.h>
int main(void)
{
	int x,a=1000000,b=-1000000,i,num;
	long long int c=0;
	scanf("%d",&x);
	for(i=0;i<x;i++){
		scanf("%d",&num);
		c+=num;
		if(num<=a){
			a=num;
		}
		if(num>=b){
			b=num;
		}
	}
	printf("%d %d %ld\n",a,b,c);
	return 0;
}

Measured memory_bytes: 2752
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define LL long long
#define G  1100020
#define mod 1000000007
LL pri[G];
LL ni[G],ans;
LL pow(LL a,int b)
{
    LL ans=1,base=a;
    while (b>0)
    {
        if (b%2==1)
            ans=(base*ans)%mod;
        base=(base*base)%mod;
        b/=2;
    }
    return ans;
}
void s()   //打表
{
    pri[0]=1;
    ni[0]=1;
    for (int i=1;i<G ;i++)
    {
        pri[i]=pri[i-1]*i%mod;  //N！
        ni[i]=pow(pri[i],mod-2);
    }
}
int main()
{
    s();
    int n1,m1,A,B;
    int n,b;
    long long int s=0;
    scanf("%d%d%d%d",&n1,&m1,&A,&B);
    for(int i=B+1;i<=m1;i++)
    {
        if(i==B+1)
        {
            n=n1-A+i-2;
            b=i-1;
            ans=((pri[n]*ni[b]%mod)*ni[n-b])%mod;
            long long int s1=ans;
            n=A+m1-i;
            b=A;
            ans=((pri[n]*ni[b]%mod)*ni[n-b])%mod;
            long long int s2=ans;
          s=(s+s1*s2%mod)%mod;
        }
        else
        {
            n=n1-A+i-3;
            b=i-1;
            if(n<=0)
            {
                  ans=0;
            }
            else
            {
                 ans=((pri[n]*ni[b]%mod)*ni[n-b])%mod;
            }

            long long int s1=ans;
            n=A+m1-i;
            b=A;
            ans=((pri[n]*ni[b]%mod)*ni[n-b])%mod;
            long long int s2=ans;
          s=(s+s1*s2%mod)%mod;
            }
    }
    printf("%lld\n",s);

     //  ans=((pri[n]*ni[b]%mod)*ni[n-b])%mod; // C（n，m）= n！/（m！*（n-m）！）
    return 0;
}


Measured memory_bytes: 17408
import math
def monsterbattle(th, ts, ahh, ahs):
  tscore = math.ceil(ahh/ts)
  ascore = math.ceil(th/ahs)
  if(tscore<=ascore):
    return "Yes"
  else:
    return "No"

a, b, c, d = map(int, input().split())
print(monsterbattle(a, b, c, d))


Measured memory_bytes: 9108
#include<bits/stdc++.h>
 #define mod 1000000007
 #define int long long int
 #define phi 1.6180339
 #define rep(i,n) for(auto i=0;i<(n);i++)
 #define endl "\n"
 #define For(i,a,b) for(auto i=(a);i<(b);i++)
 #define op1 cin.tie(NULL)
 #define op2 cout.tie(NULL)
 #define op3 std::ios_base::sync_with_stdio(false)
 #define MAXX 1000001
 using namespace std;
 void trozen()
 {
   int n;
   cin>>n;
   int ans=0;
   for(int i=1;i<=n;i++)
   {
     ans=ans+abs(0-((n-1)/i));
   }
   cout<<ans<<endl;
 }
 int32_t main()
 {
     op1;op2;op3;
     /*#ifndef ONLINE_JUDGE
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
     #endif*/
     trozen();
     return 0;
 }
 

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

int main()
{
    int price,num;
    int allPrice=0,allNum=0;
    int ave;
    int count=0;
    char c;
    while(cin>>price>>c>>num,!cin.eof()){
        count++;
        allPrice += price*num;
        allNum += num;
    }
    ave=(double)allNum/count+0.5;
    cout<<allPrice<<endl<<ave<<endl;
    return 0;
}

Measured memory_bytes: 1160
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

# W行H列, x[W][H]
def create_grid(W, H, value = 0):
    return [[ value for _ in range(H)] for _ in range(W)]

########
def warshall_floyd(G):
    # G[i][j]: iからjへの最短距離
    N = len(G)
    for k in range(N):
        for i in range(N):
            for j in range(N):
                G[i][j] = min(G[i][j], G[i][k] + G[k][j])
    return G

if __name__ == "__main__":
    # https://atcoder.jp/contests/abc016/tasks/abc016_3
    H, W = l_inpl()

    # 隣接行列 G, 存在しない辺はINF
    G = []
    for i in range(10):
        l = l_inpl()
        G.append(l)

    
    G = warshall_floyd(G)
    l = []
    for _ in range(H):
        li = l_inpl()
        l.extend(li)
    ans = 0

    for i in range(0, 10):
        if i == 1:
            continue
        ans += G[i][1] * l.count(i)
    print(ans)

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

const int mod = 998244353;

long long binpow(long long b, int e) {
  long long res = 1;
  while (e) {
    if (e & 1) res *= b, res %= mod;
    e >>= 1;
    b *= b;
    b %= mod;
  }
  return res;
}

long long inv(long long x) {
  return binpow(x, mod - 2);
}

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
   if (a + b + c >= 22) cout << "bust";
   else cout << "win";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, K;
    cin >> N >> K;
    map<lint, int> cumulative;
    cumulative[0] = 1;

    lint running = 0, ret = 0;
    VEC(lint) C(N + 1);
    C[0] = 0;
    FOR(i, 1, N + 1) {
        int a;
        cin >> a;
        running += a;
        C[i] = running;
        if (i >= K)
            cumulative[(C[i - K] + K - i) % K]--;

        ret += cumulative[(running + K - i) % K];
        cumulative[(running + K - i) % K]++;
    }

    cout << ret << endl;
    return 0;
};

Measured memory_bytes: 14336
#include <vector>
#include <algorithm>
#include <limits>

template <typename T>
struct FordFulkerson{
    // 行先、容量、逆辺の番号
    struct edge{
        int to, rev;
        T cap;
        edge() = default;
        edge(int to, T cap, int rev) : to(to), cap(cap), rev(rev) {}
    };
    std::vector<std::vector<edge> > G;
    std::vector<bool> used;

    FordFulkerson() = default;
    FordFulkerson(int n) : G(n), used(n) {}
    void init(int n){
        G.clear();
        G.resize(n);
        used.resize(n);
    }
    
    void add_edge(int from, int to, T cap, bool directed = true){
        G[from].emplace_back(to, cap, int(G[to].size()));
        G[to].emplace_back(from, directed?0:cap, int(G[from].size())-1);
    }

    // 増加路の探索
    T dfs(int v, int t, T f){
        if(v == t) return f;
        used[v] = true;
        for(auto &e : G[v]){
            if(!used[e.to] && e.cap > 0){
                T d = dfs(e.to, t, std::min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    T max_flow(int s, int t, T lim){
        T flow = 0;
        while(1){
            std::fill(used.begin(), used.end(), false);
            T f = dfs(s, t, lim);
            if(f==0) break;
            flow += f;
            lim -= f;
        }
        return flow;
    }
    T max_flow(int s, int t){return max_flow(s, t, std::numeric_limits<T>::max());}
};

#include <iostream>

int main() {
    int V, E;
    std::cin >> V >> E;
    FordFulkerson<int> g(V);
    for(int i=0;i<E;i++){
        int u, v, c;
        std::cin >> u >> v >> c;
        g.add_edge(u, v, c);
    }
    std::cout << g.max_flow(0, V-1) << std::endl;
    return 0;
}


Measured memory_bytes: 3164
// Score: /100

#include <iostream>

using namespace std;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << ((abs(a - c) <= d || ((a - b) * (b - c) > 0 && abs(a - b) <= d && abs(c - b) <= d)) ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#include <utility>
#include <numeric>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	map<int, int>mp;
	REP(i, n) {
		cin >> a[i];
		mp[a[i]]++;
	}
	int ans = 0;
	for(auto p:mp) {
		if (p.first <= p.second) {
			ans += p.second - p.first;
		}
		else {
			ans += p.second;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5504
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s1, s2;
	cin >> s1 >> s2;

	reverse(s2.begin(), s2.end());

	if (s1 == s2) cout << "YES" << "\n";
	else cout << "NO" << "\n";

	return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
c = a - b + 1
if c % 2 == 1:
    if a % 2 == 0:
        print((abs(b - a) // 2) % 2 ^ b)
    else:
        print((abs(b - a) // 2) % 2 ^ a)
else:
    if a % 2 == 0:
        print((abs(b - a + 1) // 2) % 2)
    else:
        print((abs(b - a - 1) // 2) % 2 ^ a ^ b)


Measured memory_bytes: 3060
alphabet_lowercase = [(chr(i), 0) for i in range(97, 97 + 26)]
char_count = dict(alphabet_lowercase)
while True:
    try:
        sentence = input()
        for s in sentence:
            char = s.lower()
            if char in char_count:
                char_count[char] += 1
    except:
        break

for k, v in char_count.items():
    print("{} : {}".format(k, v))



Measured memory_bytes: 5564
#include <bits/stdc++.h>
using namespace std;
int main(){
        vector<int> v;
        for (int q = 2; ; ++q){
            bool w = true;
            for (int e = 2; e <= sqrt(q); ++e){
                if (q % e == 0){
                    w = false;
                    break;
                }
            }
            if (w){
                v.push_back(q);
            }
            if (q > 100000 && w){
                break;
            }
        }
        int x; cin >> x;
        auto it = lower_bound(v.begin(), v.end(), x);
        cout << *it << endl;
    return 0;
}


Measured memory_bytes: 3820
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>
#include <time.h>
using namespace std;

int main(){
	int N, h[100], H[100] = {}, M = 0, ans = 0;

	cin >> N;
	for (int i = 0; i < N; ++i){
		cin >> h[i];
		M = max(M, h[i]);
	}

	for (int i = 0; i < M; ++i){
		for (int j = 0; j < N;){
			if (H[j] == h[j]){
				++j;
				continue;
			}
			++ans;
			while (H[j] != h[j] && j < N){
				++H[j];
				++j;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
// using ll = boost::multiprecision::int128_t;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;


int main() {
  ll a; ld b; cin >> a >> b;
  ll c = b * 100 + 0.5;
  ll ans = a * c / 100;

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3712
import sys

n = int(input())
s = [int(i) for i in input().split()]

counter = 0
while True:
    for judge in range(len(s)):
        if s[judge] % 2 != 0:
            print(counter)
            sys.exit()
        else:
            s[judge] = s[judge] / 2
    counter += 1


Measured memory_bytes: 2940
function main(input) {
  const N = parseInt(input, 10);
  let ans = 111;
  
  for (let i = 111; i <= 999; i+=111) {
    if (N <= i) {
      ans = i;
      break;
    }
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

table = [[] for _ in range(N)]
for i in range(N - 1):
	a, b = map(int, input().split())
	a -= 1
	b -= 1
	table[a].append(b)
	table[b].append(a)

c_list = list(map(int, input().split()))

c_list.sort()
c_list.reverse()

d_table = {}
d_rev = [None] * N
for i in range(N):
	d = len(table[i])
	if d in d_table:
		d_table[d].add(i)
	else:
		d_table[d] = {i}
	d_rev[i] = d

scores = [None] * N
for i in range(N):
	if i in d_table:
		n_set = d_table[i]
		while n_set:
			n = n_set.pop()
			scores[n] = c_list.pop()
			for n2 in table[n]:
				d = d_rev[n2]
				d_rev[n2] = d - 1
				n_set2 = d_table[d]
				if n2 in n_set2:
					n_set2.remove(n2)
					if d - 1 in d_table:
						d_table[d - 1].add(n2)
					else:
						d_table[d - 1] = {n2}

for i in range(N):
	if scores[i] == None:
		scores[i] = c_list[0]

score = 0
stack = [0]
visited = set()
visited.add(0)
while stack:
	cur = stack.pop()
	s1 = scores[cur]
	for n in table[cur]:
		if not n in visited:
			s2 = scores[n]
			if s1 < s2:
				score += s1
			else:
				score += s2
			stack.append(n)
			visited.add(n)

print(score)
print(" ".join([str(s) for s in scores]))


Measured memory_bytes: 9756
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

L = [a+i for i, a in enumerate(A)]
R = [j-a for j, a in enumerate(A)]

L, R = Counter(L), Counter(R)

ans = 0

for k in L.keys():
    ans += L[k] * R[k]

print(ans)

Measured memory_bytes: 63348
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	int h,n;cin>>h>>n;
	vector<ll> a(n);
	vector<ll> b(n);
	for(int i = 0; i < n; i++) {
		cin>>a[i]>>b[i];
	}
	vector<vector<ll>> dp(h+ 2,vector<ll>(n +1,INF));
	for(int i = 0; i <= n; i++) {
		dp[0][i] = 0;
	}
	for(int i = 0; i <= h; i++) {
		dp[i][1] = (i + a[0] -1 ) /a[0] * b[0];
	}
	for(ll i = 1; i <= h; i++) {
		for(int j = 2; j <= n; j++) {
			if (i - a[j- 1] < 0){
				dp[i][j] = min(dp[i][j - 1],b[j - 1]);
			}
			else{
				dp[i][j] = min(dp[i][j - 1], dp[i - a[j-1]][j] + b[j-1]);
			}
			// for(int i = 0; i < h+1; i++) {
			// 	for(int j = 0; j < n+1; j++) {
			// 		cout << dp[i][j] << " ";
			// 	}
			// 	cout << endl;
			// }
		}
	}
	// for(int i = 0; i < h+1; i++) {
	// 	for(int j = 0; j < n+1; j++) {
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	cout << dp[h][n] << endl;
	return 0;
}

Measured memory_bytes: 81936