akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int n; cin >>n;
  vector<string> s(n);
  vector<ll> t(5);
  for (int i=0; i<n; i++){
    cin >>s.at(i);
    if (s.at(i).at(0) == 'M') t.at(0)++;
    else if (s.at(i).at(0) == 'A') t.at(1)++;
    else if (s.at(i).at(0) == 'R') t.at(2)++;
    else if (s.at(i).at(0) == 'C') t.at(3)++;
    else if (s.at(i).at(0) == 'H') t.at(4)++;
  }
  ll ans = 0;
  for (int i=0; i<3; i++){
    for (int j=i+1; j<4; j++){
      for (int k=j+1; k<5; k++){
        ans += t.at(i)*t.at(j)*t.at(k);
      }
    }
  }

  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 6144
s = input()
k = int(input())
st = set()
for i in range(len(s)):
    j = 1
    while j <= k and i+j <= len(s):
        st.add(s[i:i+j])
        j += 1
for _ in range(k-1):
    m = min(st)
    st = [x for x in st if x != m]
print(min(st))

Measured memory_bytes: 4464
//(UNCOMMENT WHEN SUBMITTING)
//#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
// #pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)
// #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

// clang-format off
#define range(i) for (int _ = 0; _ < i; _++)
#define vprnt(v) for (auto vi : v) cout << vi << " "; cout << endl;
#define fastio() ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define all(x) (x).begin(), (x).end()
using namespace ::std;
int nxt() {int x;cin >> x;return x;}
ll nxtll() {ll x;cin >> x;return x;}
// clang-format on

int main() {
    fastio();

    int N, X, T;

    cin >> N >> X >> T;

    cout << (N / X) * T + (N % X ? T : 0) << endl;

    return 0;
}


Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };
	int  M = 10000000;

	void run() {
		for (;;) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if ((n | m) == 0) {
				return;
			}
			int[][] cost = new int[n + 1][n + 1];
			int[] min = new int[n + 1];
			boolean[] use = new boolean[n + 1];

			for (int i = 0; i <= n; i++) {
				Arrays.fill(cost[i], M);
				cost[i][i] = 0;
			}
			Arrays.fill(min, M);
			for (int i = 0; i < m; i++) {
				int s = sc.nextInt();
				int t = sc.nextInt();
				int c = sc.nextInt();
				cost[s][t] = c;
				cost[t][s] = c;
			}
			min[1] = 0;
			ArrayList<Integer> list = new ArrayList<Integer>();
			for (;;) {
				int v = -1;
				for (int j = 1; j <= n; j++) {
					if (!use[j] && (v == -1 || min[v] > min[j])) {
						v = j;
					}
				}
				if (v == -1) {
					break;
				}
				if (min[v] != 0) {
					list.add(min[v]);
				}
				use[v] = true;
				for (int j = 1; j <= n; j++) {
					if (!use[j] && min[j] > cost[v][j]) {
						min[j] = cost[v][j];
					}
				}
			}
			Collections.sort(list);
			System.out.println(list.get((n-1)/2));
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

Measured memory_bytes: 68832
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main(){
  int m[2];
  int d[2];
  cin >> m[0] >> d[0];
  cin >> m[1] >> d[1];
  cout << (m[0] != m[1]) << endl;

}

// EOF

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl

int N;

int main() {
    cout << fixed << setprecision(15);
    cin >> N;
    N %= 10;
    if (N == 3) {
        cout << "bon" << endl;
    } else if (N == 0 || N == 1 || N == 6 || N == 8) {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>
#include <cassert>

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

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    for(;;){
        c -= b;
        if(c <= 0){
            cout << "Yes\n";
            return 0;
        }
        a -= d;
        if(a <= 0){
            cout << "No\n";
            return 0;
        }
    }
    return 0;
}


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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);

    for (int i = 0; i < M; i++) {
        cin >> A.at(i);
    }

    int count = 0;
    for (int i = 0; i < M; i++) {
        count += A.at(i);
    }

    int res = (N - count >= 0) ? N - count : -1;

    cout << res << endl;

    return 0;
}

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

int main() {
  int64_t N,M;
  cin >> N >> M;
  
  vector<pair<int64_t,int64_t>> pairs(N);
  for(int i = 0;i < N;i++){
    int64_t A,B;
    cin >> A >> B;
    pairs[i] = make_pair(A,B);
  }
  sort(pairs.begin(),pairs.end());
  int64_t sum = 0;
  
  for (int i = 0; i < N; i++) {
    if(M <= 0){
      break;
    }
    int64_t m = min(M,pairs[i].second);
    sum += pairs[i].first * m;
    M -= m;
  }
  
  cout << sum << endl;
  
}
  


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int> >;

char field[20][20];
int H,W;
queue<pair<int,int>> Q;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
int bfs(int init_x,int init_y,int end_x,int end_y){
 
    Q.push(mp(init_x,init_y));
 
    int dist[20][20];
    rep(i,H){
        rep(j,W){
            dist[i][j]=-1;
        }   
    }
    dist[init_y][init_x]=0;
 
    while(!Q.empty()){
        auto val=Q.front();
        int x=val.first;
        int y=val.second;
        Q.pop();
        
        rep(i,4){
        int _x=x+dx[i];
        int _y=y+dy[i];
        if(dist[_y][_x]>=0)continue;
        if(_x<0||_x>=W||_y<0||_y>=H)continue;
        if(field[_y][_x]=='#')continue;
 
        dist[_y][_x]=dist[y][x]+1;
        if(_x==end_x && _y==end_y){
            break;
        }
 
        Q.push(mp(_x,_y));
        }
    }
 
    return dist[end_y][end_x];
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

cin>>H>>W;

rep(i,H){
    rep(j,W){
        cin>>field[i][j];
    }
}

int ans=0;
rep(st_y,H){
    rep(st_x,W){
        if(field[st_y][st_x]=='#')continue;
        rep(ed_y,H){
            rep(ed_x,W){
                if(field[ed_y][ed_x]=='#')continue;
                ans=max(bfs(st_x,st_y,ed_x,ed_y),ans);
            }
        }
        
    }
}
cout<<ans<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
import { count } from 'console';

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const [n, m] = inputs[0].split(' ').map(Number);
  const highList = inputs[1].split(' ').map(Number);
  const maxList = initMaxList(inputs, highList);
  let count = 0;

  // MAX標高と対象展望台を比較し、等しい展望台が良い展望台
  for (let i = 0; i < n; i++) {
    if (highList[i] === maxList[i]) {
      count++;
    }
  }

  console.log(count);
}

// 対象の展望台(from)と繋がる展望台(to)を比較し、最大の標高を設定する
function initMaxList(inputs: string[], highList: number[]): number[] {
  let maxList = inputs[1].split(' ').map(Number);

  for (let i = 2; i < inputs.length; i++) {
    let [from, to] = inputs[i].split(' ').map((value) => Number(value) - 1);

    if (highList[from] < highList[to]) {
      maxList[from] = highList[to];
    } else if (highList[from] > highList[to]) {
      maxList[to] = highList[from];
    } else {
      // 標高が等しい時点で「良い展望台」対象外
      maxList[to] = 0;
      maxList[from] = 0;
    }
  }

  return maxList;
}


Measured memory_bytes: 62464
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  double xs, ys, xt, yt;
  cin >> xs >> ys >> xt >> yt;
  ll n;
  cin >> n;

  vector<double> x(n + 2), y(n + 2), r(n + 2, 0);
  vector<vector<double>> edge(n + 2, vector<double>(n + 2, 0));

  x[0] = xs;
  y[0] = ys;
  x[n + 1] = xt;
  y[n + 1] = yt;
  for (int i = 1; i <= n; i++){
    cin >> x[i] >> y[i] >> r[i];
  }

  for (int i = 0; i < n + 2; i++){
    for (int j = i + 1; j < n + 2; j++){
      edge[i][j] = max(0.0, sqrt(pow((x[i] - x[j]), 2) + pow(y[i] - y[j], 2)) - r[i] - r[j]);
      edge[j][i] = max(0.0, sqrt(pow((x[i] - x[j]), 2) + pow(y[i] - y[j], 2)) - r[i] - r[j]);
    }
  }

  priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> Q;
  vector<double> dist(n + 2, INF);
  dist[0] = 0;
  Q.push(make_pair(0, 0));
  while(!Q.empty()){
    pair<double, int> p = Q.top();
    Q.pop();
    double d = p.first;
    int u = p.second;
    if (dist[u] < d){
      continue;
    }
    for (int i = 0; i < n + 2; i++){
      if (i != u && dist[i] > d + edge[u][i]){
        dist[i] = d + edge[u][i];
        Q.push(make_pair(d + edge[u][i], i));
      }
    }
  }


  printf("%.10lf\n", dist[n + 1]);

  return 0;
}


Measured memory_bytes: 14196
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<usize>();

    for n in 1..=N {
        let mut count = 0_usize;
        let mut x = 1;
        while x * x <= n {
            let x2 = x * x;

            let mut y = 1;
            while x2 + y * y <= n {
                let y2 = y * y;

                let mut z = 1;
                while x2 + y2 + z * z <= n {
                    let z2 = z * z;

                    if x2 + y2 + z2 + x * y + y * z + z * x == n {
                        count += 1;
                    }

                    z += 1;
                }

                y += 1;
            }

            x += 1;
        }

        println!("{}", count);
    }
}


Measured memory_bytes: 2024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def dist(p1, p2):
	return sqrt((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2)

N = INT()
xy = [LIST() for _ in range(N)]

distance = 0
cnt = 0

for p in permutations(xy, N):
	cnt += 1
	for i in range(N-1):
		distance += dist(p[i], p[i+1])

print(distance/cnt)

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

#define INFTY 2000000000
#define MAX 2000000

int A[MAX + 1];
int H = 0;

int p(int u) {
	return u / 2;
}

int l(int u) {
	return (2 * u <= H ? 2 * u : 0);
}

int r(int u) {
	return (2 * u + 1 <= H ? 2 * u + 1 : 0);
}

void maxheapify(int u) {
	int max = u;
	if (l(u) && A[l(u)] > A[u])
		max = l(u);
	if (r(u) && A[r(u)] > A[max])
		max = r(u);
	if (max != u) {
		swap(A[max], A[u]);
		maxheapify(max);
	}
}

void insert(int k) {
	H++;
	A[H] = k;
	int c = H;
	while (c > 1 && A[p(c)] < A[c]) {
		swap(A[p(c)], A[c]);
		c = p(c);
	}
}

int extract() {
	int max = A[1];
	A[1] = A[H];
	H--;
	maxheapify(1);
	return max;
}

int main() {
	string cmd;
	while (true) {
		cin >> cmd;
		if (cmd == "end") {
			break;
		} else if (cmd == "insert") {
			int k;
			cin >> k;
			insert(k);
		} else {
			cout << extract() << endl;
		}
	}
	return 0;
}



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

typedef long long LL;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

#define fast ios_base::sync_with_stdio(0),cin.tie(0)
#define temp template<typename T>
#define debug(x) cerr<<"Line "<<__LINE__<<": "<<#x<<" = "<<x<<'\n'
#define itr(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define rep(i,a,b) for(int i=a;i<=(int)b;i++)
#define repr(i,a,b) for(int i=a;i>=(int)b;i--)
#define cas(n) printf("Case %d:",(int)n)
#define mem(x,v) memset(x,v,sizeof(x))
#define read(x) freopen(x,"r",stdin)
#define write(x) freopen(x,"w",stdout)
#define all(x) x.begin(),x.end()
#define aut(x,v) for(auto &x:v)
#define ini(n) scanf("%d",&n)
#define inl(n) scanf("%lld",&n)
#define ind(n) scanf("%lf",&n)
#define ins(n) scanf("%s",n)
#define insn(n) scanf(" %[^\n]",n)
#define outi(n) printf("%d",(int)n)
#define outl(n) printf("%lld",(LL)n)
#define outd(n,p) printf("%.*lf",p,(double)n)
#define outs(n) printf("%s",n)
#define sz(x) (int)x.size()
#define nl printf("\n")
#define sp printf(" ")
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

const int inf=0x3f3f3f3f;
const int mod=1000000007;
const int mx=100005;
const LL  infL=0xf3f3f3f3f3f3f3f;
const double eps=1e-9;
const double pi=acos(-1.0);

int main()
{
    //read("in.txt"),write("out.txt");
    int a,b,k,ans=1;
    ini(a),ini(b),ini(k);
    repr(i,max(a,b),1)
    if(a%i==0&&b%i==0&&k-->0)
        ans=i;
    outi(ans),nl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
def main():
    import sys
    input = sys.stdin.readline
    h, w, m = map(int, input().split())
    cnt_h = [0] * h
    cnt_w = [0] * w
    bomb = set()
    for _ in range(m):
        y, x = map(lambda x:int(x) - 1, input().split())
        cnt_h[y] += 1
        cnt_w[x] += 1
        bomb.add((y, x))
        
    kouho_h = []
    kouho_w = []
    max_h = max(cnt_h)
    max_w = max(cnt_w)
    for i in range(h):
        if cnt_h[i] == max_h:
            kouho_h.append(i)
    for i in range(w):
        if cnt_w[i] == max_w:
            kouho_w.append(i)
    
    for i in kouho_h:
        for j in kouho_w:
            if (i, j) not in bomb:
                print(max_h + max_w)
                exit()
    print(max_h + max_w - 1)



if __name__ == '__main__':
    main()

Measured memory_bytes: 166520
s = input()
N = len(s)
flag = 0
if N==2:
    if s[0]==s[1]:
        print(*[1,2])
    else:
        print(*[-1,-1])
else:
    for i in range(N-2):
        if s[i]==s[i+1] or s[i+1]==s[i+2] or s[i]==s[i+2]:
            print(*[i+1,i+3])
            flag = 1
            break
    if flag==0:
        print(*[-1,-1])

Measured memory_bytes: 39408
#include <iostream>
#include <vector>
#include <algorithm>
#define loop(a,n) for(long long int i=a;i < n;i ++)

using namespace std;

int main()
{
  long long int n,k;
  cin >> n >> k;
  long long int a,b,temp_b = 0,ans;
  vector<pair<long long int,long long int>> data (n);

  loop(0,n)
  {
    cin >> a >> b;
    data[i] = make_pair(a,b);
  }

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

  loop(0,n)
  {
    if(temp_b < k && k <= temp_b+data[i].second)
    {
      ans = data[i].first;
    }
    else if(k == 0)
    {
      ans = data[i].first;
    }
    temp_b = temp_b + data[i].second;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
from bisect import bisect_left,bisect_right
ans=0
for i in range(n):
  ida=bisect_left(a,b[i])
  idc=bisect_right(c,b[i])
  ans+=ida*(n-idc)
print(ans)

Measured memory_bytes: 22516
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

#define DEBUG

#ifdef DEBUG

#define printd printf

#else

#define printd(...)

#endif

static constexpr int mod = 1'000'000'007;

uint64_t modpow(uint64_t base, uint64_t exp, uint64_t mod)
{
    base %= mod;

    uint64_t ans = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
        {
            ans = ans * base % mod;
        }
        base = base * base % mod;
        exp >>= 1;
    }

    return ans;
}

int main()
{
    int m, n;

    std::cin >> m >> n;

    std::cout << modpow(m, n, mod) << std::endl;

    return 0;
}



Measured memory_bytes: 3092
process.stdin.resume();
process.stdin.setEncoding('utf8');
let input = '';
process.stdin.on('data', function(chunk) {input += chunk;});
process.stdin.on('end', function() {main(input.split("\n"));});
 
function partition(A,p,r) {
	let x = A[r].num;
	let i = p - 1;
	let tmp;
	for (let j = p; j < r; j++) {
		if (A[j].num <= x) {
			i++;
			tmp=A[i]; A[i]=A[j]; A[j]=tmp;
		}
	}
	i++;
	tmp=A[i]; A[i]=A[r]; A[r]=tmp;

	return i;
}

function quickSort(A,p,r) {
	if (p >= r) return;
	let q = partition(A,p,r);
	quickSort(A,p,q-1);
	quickSort(A,q+1,r);
}

function isStable(A,n) {
	let work = null;
	for (let i = 0; i < n; i++) {
		if (work !== null && A[i].num === work.num && A[i].id < work.id) return false;
		work = A[i];
	}
	return true;
}

function main(lines){
	let n = Number(lines[0]);
	let A = [];
	for (let i = 0; i < n; i++) {
		let tmp = {};
		tmp.id = i;
		tmp.pat = lines[i+1].split(" ")[0];
		tmp.num = Number(lines[i+1].split(" ")[1]);
		A.push(tmp);
	}
	quickSort(A,0,n-1);

	if (isStable(A,n)) console.log("Stable");
	else console.log("Not stable");

	for (let i = 0; i < n; i++) {
		console.log(`${A[i].pat} ${A[i].num}`);
	}
}



Measured memory_bytes: 73472
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main() {
	/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    int n;
    cin>>n;
    string a,b,c;
    cin>>a>>b>>c;
    int ans=0;
    for(int i=0;i<n;i++){
        unordered_map<char,bool> m;
        m[a[i]]=true;
        m[b[i]]=true;
        m[c[i]]=true;
        ans+=m.size()-1;
    }
    cout<<ans;
}

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

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> H(N), dist(N,INT_MAX);
	for(int i=0 ; i<N ; i++)
		cin >> H[i];
	dist[0] = 0;
	for(int i=0 ; i<N ; i++)
	{
		for(int j=i+1; j<=min(i+K,N-1) ; j++)
		{
			int a = dist[i] + abs(H[i]-H[j]);
			dist[j] = min(dist[j],a);
		}
	}
	cout << dist[N-1] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());
  ll ans = 0;
  rep(i, n - k) ans += h[i];
  cout << ans << endl;
}

Measured memory_bytes: 3996
N, K = map(int, input().split())
flag = [True]*N
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        flag[a-1] = False
ans = 0
for i in range(N):
    if flag[i]:
        ans += 1
print(ans)

Measured memory_bytes: 9172
#include <stdio.h>
#include <stdlib.h>

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

    int *A = malloc(sizeof(int) * n);
    
    int i;
    for (i = 0; i < n; i++) scanf("%d", A + i);

    int q;
    scanf("%d", &q);

    int b, e, k, cnt;
    while (q--) {
        scanf("%d %d %d", &b, &e, &k);
        cnt = 0;
        for (i = b; i < e; i++) {
            if (A[i] == k) cnt++;
        }
        printf("%d\n", cnt);
    }

    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
const ll INF = 1LL << 60; //MAX 9223372036854775807

struct edge {
    ll to;
    ll cost;
    edge() {}
    edge(ll to, ll cost) : to(to), cost(cost) {};
};
void dfs(ll x, vector<vector<edge>> &g, bool *see)
{
  //点xに対する処理
  see[x] = 1;
  for (auto p : g[x])
  {
    if (see[p.to])
        continue;
    //進む辺に対する処理
    dfs(p.to, g, see);
    //戻る辺に対する処理
  }
}
vector<ll> bellman_ford(ll s, vector<vector<edge>> &g)
{
  //pair.first=距離,pair.second=点
  vector<ll> dist(g.size(), INF);
  dist[s] = 0;
  //頂点数-1回全ての辺を見る操作を繰り返す
  rep(i,g.size()-1){
    rep(j,g.size()){
      if(dist[j]==INF)continue;
      rep(k,g[j].size()){
        dist[g[j][k].to]=min(dist[g[j][k].to],dist[j]+g[j][k].cost);
      }
    }
  }
  //ここで更新があったら負のサイクルがある
  rep(j,g.size()){
    if(dist[j]==INF)continue;
    rep(k,g[j].size()){
      if(dist[g[j][k].to]>dist[j]+g[j][k].cost) return vector<ll>();
    }
  }
  return dist;
}
int main()
{
ll n , m , p ;
cin >> n >> m >> p ;
vector<vector<edge>> g(n);
vector<vector<edge>> gg(n);
rep(i, m)
{
    ll a,b,c;
    cin >> a>>b>>c;
    g[a-1].emplace_back(b-1, -(c-p));
    gg[b-1].emplace_back(a-1, 0);
}
bool see[n]={};
bool see2[n]={};
dfs(0,g,see);
dfs(n-1,gg,see2);
rep(i,n){
  if(!(see[i]==1&&see2[i]==1)){
    g[i].clear();
  }
}
auto v=bellman_ford(0,g);
if(v.size()==0){
  cout << -1 << endl;
  return 0;
}
ans=-v[n-1];
if(ans<0)ans=0;
cout << ans << endl;
return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
const int MAX=100000;
const int NIL=-1;
struct Node
{
    int p,l,r;
};

Node T[MAX];
int n,D[MAX];

void print(int u)
{
    int i,c;
    cout<<"node "<<u<<": ";
    cout<<"parent = "<<T[u].p<<", ";
    cout<<"depth = "<<D[u]<<", ";

    if(T[u].p==NIL)cout<<"root, ";
    else if(T[u].l==NIL)cout<<"leaf, ";
    else cout<<"internal node, ";

    cout<<"[";
    for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r)
    {
        if(i)cout<<", ";
        cout<<c;
    }
    cout<<"]"<<endl;
}

int rec(int u,int p)
{
    D[u]=p;
    if(T[u].r!=NIL)rec(T[u].r,p);
    if(T[u].l!=NIL)rec(T[u].l,p+1);
}

int main()
{
	int i,j,d,v,c,l,r;
	cin>>n;
	for(i=0;i<n;i++)T[i].p=T[i].l=T[i].r=NIL;

	for(i=0;i<n;i++)
    {
        cin>>v>>d;
        for(j=0;j<d;j++)
        {
            cin>>c;
            if(j==0)T[v].l=c;
            else T[l].r=c;
            l=c;
            T[c].p=v;
        }
    }
    for(i=0;i<n;++i)
    {
        if(T[i].p==NIL)r=i;
    }
    rec(r,0);
    for(i=0;i<n;i++)print(i);
 	return 0;
}



Measured memory_bytes: 7756
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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

int main(){
    string S;
    int count=0,MAX=0;
    cin>>S;
    bool check=true;
    for(int i=0;i<S.length();i++){
        if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T'){
            if(check!=false){
                check=false;
                count=1;
            }else{
                count+=1;
            }
        }else if(!check){
            MAX=max(count,MAX);
            check=true;
        }
    }
    MAX=max(count,MAX);
    cout<<MAX<<endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

struct City {
  int64_t index{-1};
  int64_t prefecture{-1};
  int64_t year{-1};
  string id;
};

bool Compare(const City &c1, const City &c2) {
  if (c1.prefecture == c2.prefecture) {
    return c1.year < c2.year;
  } else {
    return c1.prefecture < c2.prefecture;
  }
}

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

  int64_t N, M;
  cin >> N >> M;
  vector<City> cities(M);
  for (int64_t i = 0; i < M; ++i) {
    int64_t p, y;
    cin >> p >> y;
    cities[i].index = i;
    cities[i].prefecture = p;
    cities[i].year = y;
  }
  int64_t x = 1;
  int64_t current_prefecture = -1;
  sort(cities.begin(), cities.end(), Compare);
  char buff[13];
  vector<int64_t> map_from_original_to_sorted(M);
  for (int32_t i = 0; i < M; ++i) {
    if (cities[i].prefecture != current_prefecture) {
      current_prefecture = cities[i].prefecture;
      x = 1;
    } else {
      ++x;
    }
    snprintf(buff, sizeof(buff), "%06ld%06ld", cities[i].prefecture, x);
    cities[i].id = string(buff);
    map_from_original_to_sorted[cities[i].index] = i;
  }

  for (int32_t i = 0; i < M; ++i) {
    cout << cities[map_from_original_to_sorted[i]].id << endl;
  }

  return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

signed main(){
    
    int d; cin >> d;
    string ans = "Christmas";
    for(;d < 25; d++){
        ans = ans + " Eve";
    }
    cout << ans << endl;
    return 0;
}

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

public class Main {

    static class Solution {
        public void find(int reqA, int reqB, int[]A, int B[], int C[]) {
                Arrays.sort(A);
                Arrays.sort(B);

                int total = reqA + reqB + C.length;
            long[] arr = new long[total];
            int i= 0;
            int count = 0;
                    for(int j=A.length-1; j>=0 && count<reqA; j--) {
                        count++;
                        arr[i++] = A[j];
                    }

            count = 0;
                    for(int j=B.length-1; j>=0 && count<reqB; j--) {
                        arr[i++] = B[j];
                        count++;
                    }

                    for(int j=C.length-1; j>=0; j--) {
                        arr[i++] = C[j];
                    }
                //}
                Arrays.sort(arr);
            long res = 0;
                count = 0;
                for( i=arr.length-1; i>=0 && count< (reqA + reqB); i--) {
                    res += arr[i];
                    count++;
                }
                System.out.println(res);
        }

    }

    public static void main(String[] args) throws IOException {
        InputStreamReader r = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(r);
        String s = br.readLine();
        String[] s1 = s.split(" ");
        int reqA = Integer.parseInt(s1[0]);
        int reqB = Integer.parseInt(s1[1]);
        int[]A = new int[Integer.parseInt(s1[2])];
        int[]B = new int[Integer.parseInt(s1[3])];
        int[]C = new int[Integer.parseInt(s1[4])];

        s = br.readLine();
        s1 = s.split(" ");
        for(int i=0; i<s1.length; i++) {
            A[i] = Integer.parseInt(s1[i]);
        }

        s = br.readLine();
        s1 = s.split(" ");
        for(int i=0; i<s1.length; i++) {
            B[i] = Integer.parseInt(s1[i]);
        }

        s = br.readLine();
        s1 = s.split(" ");
        for(int i=0; i<s1.length; i++) {
            C[i] = Integer.parseInt(s1[i]);
        }

        Solution sol = new Solution();
        sol.find(reqA, reqB, A, B, C);

    }
}


Measured memory_bytes: 64268
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
 
    string s,t;
    cin>>s>>t;
    ll i;
    string ha;
    for(i=0;i<t.length()-1;i++) ha.pb(t[i]);
    if(ha==s) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3672
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    a = LI()
    d = collections.defaultdict(int)
    for c in a:
        d[c-1] += 1
        d[c] += 1
        d[c+1] += 1

    return max(d.values())


print(main())



Measured memory_bytes: 22116
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll arr[200005],sum[200005];
int main()
{
    ll n,m,i,j,p,chck,ans,flag;
    while(cin>>n)
    {
        sum[0]=0;

        for(i=1;i<=n;i++)
        {
            cin>>arr[i];
            sum[i]=sum[i-1]+arr[i];
        }
        flag=0;
        ans=99999999999999;
        for(i=n-1;i>=1;i--)
        {
            p=abs(sum[i]-(arr[i+1]+flag));
            //cout<<p<<endl;
            if (p<=ans)
            {
                ans=p;
                //cout<<ans<<endl;
            }
            flag=flag+arr[i+1];
            //cout<<flag<<endl;
        }
        cout<<ans<<endl;


    }
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    // 引数の受け取り
    cin >> N >> K;
    if (N==1){
    N +=13;
    }
    if (K==1){
    K +=13;
    }



    // 出力
    cout << (K==N?"Draw":K>N?"Bob":"Alice") << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define INF 10000000
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
const int max_value = 50;
int N;
//各辺を取り除いたときに、連結になるかどうかをDFSで調べる
//現在みている頂点:v
void dfs(vector<vector<bool>> &graph, vector<bool> &seen, int v){
    //頂点vを訪問済みにする
    seen.at(v)=true;
    //未訪問の次の地点を探索
    rep(u,N){
        if(graph.at(v).at(u)==false) continue;
        if(!seen.at(u)) dfs(graph,seen,u);
    }
    return;
}
int main(){
    int M;
    cin>>N>>M;
    vector<int> A(max_value),B(max_value);
    vector<vector<bool>> graph(max_value,vector<bool>(max_value,false));
    rep(i,M){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        A.at(i)=a;
        B.at(i)=b;
        graph.at(a).at(b)=true;
        graph.at(b).at(a)=true;
    }
    int ans=0;
    rep(i,M){
        //辺を削除
        graph.at(A.at(i)).at(B.at(i)) = false;
        graph.at(B.at(i)).at(A.at(i)) = false;

        vector<bool> seen(max_value);
        rep(i,N) seen.at(i)=false;
        //頂点0からdfs
        dfs(graph,seen,0);
        
        bool bridge=false;
        rep(j,N){
            if(!seen.at(j)){
                bridge=true;
            }
        }
        if(bridge) ans++;

        //辺をつなぎなおす
        graph.at(A.at(i)).at(B.at(i))=true;
        graph.at(B.at(i)).at(A.at(i))=true;
    }
    cout<<ans<<endl;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout << x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

double startTime;
double getCurrentTime() {
	return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->


int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	string s;
	cin >> s;
	string ans;

	rep(i,0,s.length(),2)
	{
		ans += s[i];
	}



  cout<<ans<<endl;



}


Measured memory_bytes: 3716
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String tile = sc.nextLine();
        sc.close();

        int tile_length = tile.length();
        int plan1_pieces = 0;
        int plan2_pieces = 0;

        for(int i = 0; i < tile_length; i++){
            char curTile = tile.charAt(i);
            if(i % 2 == 0){
                if(curTile == '1') plan1_pieces++;
                else plan2_pieces++;
            }
            else{
                if(curTile == '0') plan1_pieces++;
                else plan2_pieces++;
            }
        }

        System.out.println(Math.min(plan1_pieces, plan2_pieces));
    }
}


Measured memory_bytes: 26308
import math
count = 0
x, y = map(int, input().split())
absX = math.fabs(x)
absY = math.fabs(y)
count += int(math.fabs(absX - absY))
if x > y:
    if x >= 0 and y <= 0:
        count += 1
    if x > 0 and y > 0:
        count += 2
    if x < 0 and y < 0:
        count += 2
if x < y:
    if x < 0 and y > 0:
        count += 1
print(count)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

static const int N = 100000;

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

    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    vector<int> v(2 * N);
    int vidx = 2;

    for (int i = 0; i < n; i++)
    {
        if (s[i] - '0' == vidx % 2)
        {
            v[vidx]++;
        }
        else
        {
            vidx++;
            v[vidx]++;
        }
    }

    int maxlen = -1;
    for (int i = 1; i < vidx + 10; i += 2)
    {
        int nowlen = 0;
        for (int j = 0; j < k * 2 + 1; j++)
        {
            nowlen += v[i + j];
        }
        maxlen = max(nowlen, maxlen);
    }

    cout << maxlen << endl;

    return 0;
}


Measured memory_bytes: 1280
import sys

input = sys.stdin.readline
H, W = map(int, input().split())
S = [(input()) for _ in range(H)]
T = [[0 for _ in range(W)] for _ in range(H)]

for h in range(H):
    for w in range(W):
        for i in range(h-1, h+2):
            for j in range(w-1, w+2):
                if i < 0 or j < 0 or i >= H or j >= W:
                    continue
                else:
                    if S[h][w] == '#':
                        T[h][w] = -1
                    elif S[i][j] == '#':
                        T[h][w] += 1

for t in T:
    print((''.join(map(str, t))).replace('-1', '#'))

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

int main(void){
    int a,b,d,r;
    double f;
    cin >> a;
    cin >> b;

    d = a / b;
    r = a % b;
    f = (double)a / b;
    cout << d << " " << r << " " << fixed << f << endl;
    return 0;
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
#define ENDL '\n'
#define io ios_base::sync_with_stdio(false);cin.tie(0);
#define sayy cout<<"YES"<<ENDL;
#define sayn cout<<"NO"<<ENDL;

using namespace std;

int main(){
    io

    string s;
    cin >> s;

    int smaller = INT_MAX;
    for(int i(0); i<s.length()-2; i++){
        char temp[3];
        temp[0] = s[i];
        temp[1] = s[i+1];
        temp[2] = s[i+2];
        int n;
        sscanf(temp, "%d", &n);
        int dif = abs(753 - n);
        if(dif < smaller) smaller = dif;
    }
    cout << smaller << ENDL;

    
    return 0;
}

Measured memory_bytes: 3720
N,K=map(int, input().split())


def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

print(len(Base_10_to_n(N,K)))


Measured memory_bytes: 2940
#include <stdio.h>

int main(void){
	int a[4];
	int b[4];
	int i,j;
	int hits,blows;
	while(1){
		if(scanf("%d%d%d%d",a,a+1,a+2,a+3)==EOF){break;}
		scanf("%d%d%d%d",b,b+1,b+2,b+3);
		hits = 0;
		blows = 0;
		for(i = 0; i < 4; i++){
			for(j = 0; j < 4; j++){
				if(b[i] == a[j]){
					if(i == j){
						hits++;
					}else{
						blows++;
					}
				}
			}
		}
		printf("%d %d\n",hits,blows);
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>

int main() {
	int n, a, b, c;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &a, &b, &c);
		if (a*a == b*b + c*c || b*b == c*c + a*a || c*c == a*a + b*b) {
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2592
s1,s2,t1,t2 = map(int,input().split())
a = ""
a += "U"*(t2-s2)
a += "R"*(t1-s1)
a += "D"*(t2-s2)
a += "L"*(t1-s1)
a += "L"
a += "U"*(t2-s2+1)
a += "R"*(t1-s1+1)
a += "D"
a += "R"
a += "D"*(t2-s2+1)
a += "L"*(t1-s1+1)
a += "U"
print(a)

Measured memory_bytes: 3064
w = int(input())
n = int(input())
a = list(range(w))
for i in range(n):
    k1,k2 = map(int,input().split(","))
    a[k1-1],a[k2-1] = a[k2-1],a[k1-1]
for i in a:
    print(i+1)

Measured memory_bytes: 7564
n = int(input())
*A, = map(int, input().split())
S = [0]
for i in range(n):
    S.append(S[-1] + A[i])
C = {}
for s in S:
    try:
        C[s] += 1
    except BaseException:
        C[s] = 1
print(sum([v * (v - 1) // 2 for v in C.values()]))


Measured memory_bytes: 41052
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main() {
	string s;
	int k;
	int res = 0;
	cin >> s >> k;
	for (int i = 0; i < s.size(); i++){
		if (s[i] == 'a' or 'z'+1-s[i] > k) continue;
		k -= 'z'+1-s[i];
		s[i] = 'a';
	}
	s[s.size()-1] += k % 26; 
	cout << s << endl;

}


Measured memory_bytes: 512
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
using namespace std;

int main(){
	int n;
	cin >> n;
	auto edge = vector<vector<pair<int,int64_t>>>(n, vector<pair<int,int64_t>>(0));
	for (int i = 0; i < n-1; ++i) {
		int a, b;
		int64_t c;
		cin >> a >> b >> c;
		a--; b--;
		edge[a].push_back(make_pair(b,c));
		edge[b].push_back(make_pair(a, c));
	}
	int q, k;
	cin >> q >> k;
	k--;
	auto dis = vector<int64_t>(n, -1);
	queue<int> ok;
	ok.push(k);
	dis[k] = 0;
	while (!ok.empty()) {
		int val = ok.front();
		ok.pop();
		for (auto tar : edge[val]) {
			int u = tar.first;
			int64_t cost = tar.second;
			if (dis[u] == -1) {
				dis[u] = dis[val] + cost;
				ok.push(u);
			}
		}
	}

	for (int i = 0; i < q; ++i) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		cout << dis[x] + dis[y] << endl;
	}
	return 0;
}

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

void explode( int x, int y, char b[14][14] )       //2次元配列の渡し方に注意
{
    //x列目のy行目と渡される
    b[y][x] = '0';
    for( int i = -3; i <= 3; i++ )
    {   
        //縦方向の爆発
        if( b[y][x+i] == '1' )                     //爆発
            explode( x + i, y, b );
        else                                       //爆発しない
            b[y][x+i] = '0';

        //横方向の爆発
        if( b[y+i][x] == '1' )
            explode( x, y + i, b );
        else
            b[y+i][x] = '0';
    }
    return;
}

void initialize( char b[14][14] )
{
    for( int i = 0; i < 14; i++ )
        for( int j = 0; j < 14; j++ )
            b[i][j] = '0';
}

int main()
{
    char b[14][14];
    int n, x, y;

    cin >> n;

    for( int k = 1; k <= n; k++ )
    {
        initialize( b );

        //入力
        for( int i = 3; i <= 10; i++ )
            for( int j = 3; j <= 10; j++ )
                cin >> b[i][j];

        cin >> x >> y;

        cout << "Data " << k << ":" << endl;    //忘れた

        //爆破
        explode( x + 2, y + 2, b );             //x+2列目の、y+2行目と見る
        
        //出力
        for( int i = 3; i <= 10; i++ )
        {
            for( int j = 3; j <= 10; j++ )
                cout << b[i][j];
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2956
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];


ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
        prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
}

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

    prime_factorize(N);

    map<ll, bool> m;

    ll ret = 0;

    for(auto itr = prime.begin(); itr != prime.end(); itr++) {
        ll num = itr->first;
        ll count = itr->second;

        for(ll n = 1;;n++) {
            if(n*(n+1)/2 > count) {
                ret += n-1;
                break;
            } 
        }
    }

    cout << ret << endl;




    return 0;    
}



Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int n,k,a[200001];
long double tot;
int main()
{
	read(n),read(k);
	for(res i=1;i<=n;++i) read(a[i]),a[i]+=a[i-1];
	for(res i=1;i<=n-k+1;++i) chkmax(tot,(long double)k+a[i+k-1]-a[i-1]);
	printf("%.10Lf\n",tot/2.0);
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

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

int main() {
	long n = 0, h = 0, w = 0;
	cin >> n;
	vector<long> s(n);
	for(int i = 0; i < n; i++){
		cin >> s.at(i);
	}
	
	sort(s.begin(), s.end(), std::greater<long>());
	
	for(int i = 0; i < n - 1; i++){
		if(s.at(i) == s.at(i + 1)){
			if (h == 0){
				h = s.at(i);
			}else{
				w = s.at(i);
				cout << h * w << endl;
				return 0;
			}
			i++;
			
		}else{
			
		}
	}
	cout << 0 << endl;
	return 0;
}

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

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

    int ct = 1;
    rep(i,n-1) {
        if (s[i] != s[i+1]) ct++;
    }
    cout << ct << endl;

    return 0;
}

Measured memory_bytes: 512