akhauriyash/Code-Regression huggingface dataset:
def check(x, y)
  2.times do |z|
    4.times do
      return true if x == y
      a, b, c, d, e, f = x
      x = z.zero? ? [e, a, c, d, f, b] : [d, b, a, f, e, c]
      g = x
      4.times do
        i, j, k, l, m, n = g
        g = [i, k, m, j, l, n]
        return true if g == y
      end
    end
  end
  false
end
 
h = $<.map{|i| i.chomp.split}.drop(1)
h.size.times do |j|
  (j+1).upto(h.size - 1) do |k|
    (puts 'No')^exit if check(h[j], h[k])
  end
end
puts 'Yes'

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

typedef long long ll;

const ll MAX_N = 1e5 + 5;
ll n, x, ans;
ll Arr[MAX_N];

int main() {
	cin >> n >> x;
	for (int i = 0; i < n; i++)
		cin >> Arr[i];

	ans = max(0LL, Arr[0] - x);
	Arr[0] = min(Arr[0], x);
	for (int i = 1; i < n; i++) {
		ans += max(0LL, Arr[i] + Arr[i - 1] - x);
		Arr[i] = min(Arr[i], x - Arr[i - 1]);
	}

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

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<cmath>
#include<cstdio>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = n-1; i >=0; i--)
#define lint long long
#define all(x) (x).begin(), (x).end()


int main(){
    int m,k; cin>>m>>k;
    if(m==0){
        if(k==0){ cout<<"0 0"<<endl; return 0;}
        else {cout<<"-1"<<endl; return 0;}
    }
    if(m==1){
        if(k==0){cout<<"0 1 1 0"<<endl; return 0;}
        else {cout<<"-1"<<endl; return 0;}
    }
    if(k >= pow(2, m)) {cout<<"-1"<<endl; return 0;}
    string ans = "";
    int n = pow(2, m);
    rep(i,n){
        if(i!=k) ans += to_string(i) + " ";
    }
    ans += to_string(k) + " ";
    repr(i,n){
        if(i!=k) ans += to_string(i) + " ";
    }
    ans += to_string(k);
    cout<<ans<<endl;
}

Measured memory_bytes: 4852
// Vicfred
// https://atcoder.jp/contests/abc166/tasks/abc166_e
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    long n = readln.chomp.to!long;

    long[] a = readln.split.map!(to!long).array;

    long[long] y;

    foreach(idx; 0..n) {
        long x = idx+1+a[idx];
        if(x in y)
            y[x] += 1;
        else
            y[x] = 1;
    }

    long answer = 0;
    foreach(i; 0..n) {
        long x = i+1-a[i];
        if(x in y)
            answer += y[x];
    }

    answer.writeln;
}


Measured memory_bytes: 23612
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

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

int GCD(int x,int y){
  if(x<y){
    swap(x,y);
  }
  while(x%y!=0){
    int temp=x;
    x=y;
    y=temp%y;
  }
  return y;
}

int digitsum(int x){
  int sum=0;
  while(x>0){
    sum+=(x%10);
    x/=10;
  }
  return sum;
}

int main() {
  int n;
  string s;
  cin>>n>>s;
  ll cr=0,cg=0,cb=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R')cr++;
    else if(s[i]=='G')cg++;
    else cb++;
  }
  ll ans=cr*cg*cb;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if((i+j)%2==0){
        int k=(i+j)/2;
        if(s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]) ans--;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>

main(void)
{

    int x[3000],y[3000];
    int i,l=0,a=0;
    for(i=0;i<3000;i++){
        scanf("%d %d",&x[i],&y[i]);
        if(x[i]==0&&y[i]==0) {
            break;
         }
        l++;

    }
    for(i=0;i<l;i++){
        if(x[i]>y[i]){
            a=y[i];
            y[i]=x[i];
            x[i]=a;
         }
    }
    for(i=0;i<l;i++){
        printf("%d %d\n",x[i],y[i]);
    }
}
            


Measured memory_bytes: 2040
N,M=map(int,input().split())
cakes = [[int(i) for i in input().split()] for N in range(N)]
if M==0:
  print(0)
  quit()
#最大値、最初値計算
score=[0]*8
s=sorted(map(lambda c: c[0]+c[1]+c[2], cakes))
score[0]=sum(s[-M:])
score[1]=-sum(s[:M])
s=sorted(map(lambda c: c[0]+c[1]-c[2], cakes))
score[2]=sum(s[-M:])
score[3]=-sum(s[:M])
s=sorted(map(lambda c: c[0]-c[1]+c[2], cakes))
score[4]=sum(s[-M:])
score[5]=-sum(s[:M])
s=sorted(map(lambda c: c[0]-c[1]-c[2], cakes))
score[6]=sum(s[-M:])
score[7]=-sum(s[:M])
print(max(score))

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

int main() {
	int n; cin >> n;
	int x; cin >> x;
	vector<int >l;
	for (int i = 0; i < n; i++) {
		int ln; cin >> ln;
		l.push_back(ln);
	}
	int d = 0;
	vector<int>D;
	D.push_back(d);
	for (int i = 1; i < n + 1; i++) {
		d = d + l[i - 1];
		D.push_back(d);
	}int num = 0;
	for (int i = 0; i < D.size(); i++) {
		if (D[i] <= x) {
			num += 1;
		}
	}
	cout << num;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		
		int num = scan.nextInt();
		
		if(num < 10){
			System.out.println(num);
		} else if(num >= 10 && num <= 99){
			System.out.println(9);
		} else if(num >= 100 && num <= 999){
			System.out.println(9 + (num - 99));
		} else if(num >= 1000 && num <= 9999){
			System.out.println(909);
		} else if(num >= 10000 && num <= 99999){
			System.out.println(909 + (num - 9999));
		} else if(num == 100000){
			System.out.println(90909);
		}
		
	}
}

Measured memory_bytes: 23892
package main

import "fmt"

func main() {
	var A, B, C, X int
	fmt.Scan(&A)
	fmt.Scan(&B)
	fmt.Scan(&C)
	fmt.Scan(&X)
	count := 0
	for i := 0; i <= A; i++ {
		for j := 0; j <= B; j++ {
			for k := 0; k <= C; k++ {
				if 500*i+j*100+k*50 == X {
					count++
				}
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
N = int(input())
A = [int(a) for a in input().split()]

cum_A = [A[0]] * N
for i in range(1, N):
    cum_A[i] = cum_A[i - 1] + A[i]

cost = None
for i in range(N):
    left = cum_A[i]
    right = cum_A[-1] - cum_A[i]
    if cost is None:
        cost = abs(left - right)
    else:
        cost = min(abs(left - right), cost)

print(cost)

Measured memory_bytes: 105216
let print_ary a =
  Array.iteri (fun i e -> Printf.printf (if i = 0 then "%d" else " %d") e) a;
  print_newline ()

let rev_iter f a =
  let rec doit i =
    if i < 0 then ()
    else (f (Array.get a i); doit (i - 1))
  in
  doit (Array.length a - 1)

let counting_sort a b k =
  let c = Array.make (k + 1) 0 in
  Array.iter (fun e -> c.(e) <- c.(e) + 1) a;
  Array.iteri (fun i _ -> if i = 0 then () else c.(i) <- c.(i) + c.(i - 1)) c;
  rev_iter (fun e -> b.(c.(e) - 1) <- e; c.(e) <- c.(e) - 1) a

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun e -> e)) in
  let k = Array.fold_left max (-1) a in
  let b = Array.make n 0 in
  counting_sort a b k;
  print_ary b

Measured memory_bytes: 36180
import sys
sys.setrecursionlimit(10**6)

N, M = map(int, input().split())
G = [[] for _ in range(N)]
edge = []
for _ in range(M):
    u, v = map(int, input().split())
    G[u-1].append(v-1)
    G[v-1].append(u-1)
    edge.append((u-1, v-1))


# 連結かどうかの判定->DFS, BFS, Dijkstra, UnionFindなどで解ける
def dfs(s, check, a, b):
    for t in G[s]:
        if (s, t) == (a, b) or (s, t) == (b, a):
            continue
        if check[t]:
            continue
        check[t] = 1
        dfs(t, check, a, b)
    if 0 in check:
        return 1
    else:
        return 0

cnt = 0
for a, b in edge:
    check = [1] + [0] * (N-1)
    cnt += dfs(0, check, a, b)
print(cnt)


Measured memory_bytes: 3064
import itertools

def main():
    input_line = map(int,input().split(' '))
    n,m = input_line
    a = list(map(lambda x:int(x)//2,input().split(' ')))

    pre_j = 0
    for i in range(len(a)):
        j=0
        while(a[i]%(2**j)==0):
            j+=1
        if i==0:
            pre_j=j
        if pre_j != j:
            print(0)
            return 0

    glc = 1
    for i in range(len(a)):
        glc = a[i]*glc//GCD(a[i],glc)
    print(((m//glc)+1)//2)
    return 


def GCD(a,b):
    if a < b:
        a,b = b,a
        
    while a % b !=0 :
        n = a % b
        a = b
        b = n
    return b

if __name__ == "__main__":
    main()


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

const ll MX = 1e18;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }
  int cnt = count(a.begin(), a.end(), 0);
  if (cnt > 0){
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  rep(i, n){
    if(a[i] > MX / ans){
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 3996
import itertools

n, m = map(int, input().split())
relation = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    relation[a].append(b)
    relation[b].append(a)

ans = 0
for li in itertools.permutations(range(n), n):
    if li[0] == 0:
        for i in range(n-1):
            if not li[i + 1] in relation[li[i]]:
                break
        else:
            ans += 1

print(ans)


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

int count(const vi& a, const vi& fac) {
    int n = a.size();

    set<int> s;
    rep(i, 0, n) { s.insert(i + 1); }

    int ans = 0;
    rep(i, 0, n) {
        int index = distance(s.begin(), s.lower_bound(a[i]));
        ans += index * fac[n - 1 - i];
        s.erase(a[i]);
    }
    return ans;
}

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

    int n;
    cin >> n;

    vi p(n), q(n);
    rep(i, 0, n) { cin >> p[i]; }
    rep(i, 0, n) { cin >> q[i]; }

    vi fac(n, 1);
    rep(i, 1, n) { fac[i] = i * fac[i - 1]; }

    cout << abs(count(p, fac) - count(q, fac)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

template<class T>
struct CompLeftGreater {
	bool operator() (T l, T r) { return l > r;} 
};

int main() {
	ll X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector<ll> A(X), B(Y), C(Z);
	for (ll i=0; i<X; ++i) cin >> A[i];
	for (ll i=0; i<Y; ++i) cin >> B[i];
	for (ll i=0; i<Z; ++i) cin >> C[i];

	CompLeftGreater<ll> cobj;
	sort(A.begin(), A.end(), cobj); 
	sort(B.begin(), B.end(), cobj); 
	sort(C.begin(), C.end(), cobj); 
	// O(K^2 < 10^7)
	vector<ll> AB(K*K);
	ll idx = 0;
	for (ll i=0; i<X; ++i) {
		for (ll j=0; j<Y; ++j) {
			AB[idx++] = A[i]+B[j];
		}
	}
	sort(AB.begin(), AB.end(), cobj);

	vector<ll> ABC(K*K);
	idx = 0;
	for (ll i=0; i<K; ++i) {
		for (ll j=0; j<Z; ++j) {
			ABC[idx++] = AB[i]+C[j];
		}
	}
	sort(ABC.begin(), ABC.end(), cobj);
	
	for (ll i=0; i<K; ++i) {
		cout << ABC[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 140928
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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

    for i in range(N-K):
        if A[i+K] > A[i]:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


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

template<class CommutativeMonoid> struct UnionFind {
    using M = CommutativeMonoid;
    using T = typename M::value_type;
    vector<int> data; vector<T> val; int sz;
    UnionFind(int sz) : data(sz, -1), val(sz, M::id()), sz(sz) { }
    template<class InputIterator>
    UnionFind(int sz, InputIterator first, InputIterator last)
        : data(sz, -1), val(first, last), sz(sz) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[y] < data[x]) swap(x, y);
        data[x] += data[y]; data[y] = x; sz--;
        val[x] = M::op(val[x], val[y]);
        return true;
    }
    T& operator[](int x) { return val[root(x)]; }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() { return sz; }
};

template <typename T>
struct SumMonoidCtr {
    using value_type = T;
    static constexpr T id() { return {}; }
    static T op(T &a, T &b) {
        a.insert(/*a.end(), */b.begin(), b.end());
        b.clear();
        return a;
    }
};

int main() {
    int n, m, k; cin >> n >> m >> k;
    UnionFind<SumMonoidCtr<set<int>>> uf(n);
    for (int i = 1; i <= k; i++) {
        int type; cin >> type;
        int a, b; cin >> a >> b; a--, b--;
        if (type == 1) {
            uf.unionSet(a, b);
        } else {
            uf[a].emplace(b);
        }
        if (uf[a].size() > 1) return cout << i << endl, 0;
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 12476
#include <stdio.h>
#define N 8
void putQ(int);
int row[N],col[N];
int dpos[2*N-1],dneg[2*N-1];
int already[N];
int main(){
  int i,j;
  int k,r,c;

  for(i = 0; i < N; i++){
    row[i]=0;
    col[i]=0;
    already[i]=0;
  }
  for(i = 0; i < 2*N-1; i++){
    dpos[i]=0;
    dneg[i]=0;
  }
  
  scanf("%d",&k);
  
  for(i = 0; i < k; i++){
    scanf("%d%d",&r,&c);
    row[r]=c;
    col[c]=1;
    dpos[r+c]=1;
    dneg[r-c+N-1]=1;
    already[r]=1;
  }
  
  putQ(0);


  return 0;
}
  

void putQ(int i){
  int j;
  if(i == N){
    for(i = 0; i < N; i++){
      for(j = 0; j < N; j++){
	if(row[i] == j) printf("Q");
	else printf(".");
      }
      printf("\n");
    }
    return;
  }
  if(already[i]==1) putQ(i+1);
  else{
  for(j = 0; j < N; j++){
    if(col[j] != 0 || dpos[i+j] != 0 || dneg[i-j+N-1] != 0)
      continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = 1;
    putQ(i+1);
    col[j] = dpos[i+j] = dneg[i-j+N-1] = 0;
  }
  }
}






    
  
    



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

int main() {
	int h,w;
	cin >> h >> w;
	int c[10][10];
	int a[h][w];
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			cin >> c[i][j];
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> a[i][j];
		}
	}
	
	for(int l=0;l<5;l++){
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				for(int k=0;k<10;k++){
				c[i][j] = min(c[i][j],c[i][k]+c[k][j]);
				}
			}
		}
	}

	int magic = 0;
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			magic = magic + c[a[i][j]][1];
			
		}
	}

	cout << magic << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

int match[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int inf = INT_MIN;

int main() {
  int N, M;
  cin >> N >> M;
  vector<ll> vec(M);
  for (int i = 0; i < M; i++) {
    cin >> vec[i];
  }
  
  vector<int> dp(N + 1);
  for (int i = 0; i <= N; i++) {
    dp[i] = inf;
  }
  
  dp[0] = 0;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j < M; j++) {
      if (i - match[vec[j]] >= 0 && dp[i - match[vec[j]]] != inf) {
        dp[i] = max(dp[i], dp[i - match[vec[j]]] + 1);
      }
    }
  }
  
  sort(vec.rbegin(), vec.rend());
  int remain = N;
  for (int i = 0; i < dp[N]; i++) {
    for (int j = 0; j < M; j++) {
      if (remain - match[vec[j]] >= 0 && dp[remain] == dp[remain - match[vec[j]]] + 1) {
        cout << vec[j];
        remain -= match[vec[j]];
        break;
      }
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class ADuplexPrinting {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            out.println((n + 1) / 2);
        }

    }
}



Measured memory_bytes: 23124
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <iomanip>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <cassert>
#include <stack>
#include <climits>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <memory>
#include <functional>
#include <cfloat>
#include <numeric>
#include <atcoder/mincostflow.hpp>

struct Coordinate {
	int x, y;
	std::vector<Coordinate> next() const {
		return { Coordinate{x + 1, y}, Coordinate{x, y + 1} };
	}
	int manhattan_distance(const Coordinate other) const {
		return std::abs(x - other.x) + std::abs(y - other.y);
	}
};

std::vector<Coordinate> reachable(const Coordinate start, const std::vector<std::string> &state) {
	std::stack<Coordinate> stack;
	std::vector<std::vector<bool>> reach(state.size(), std::vector<bool>(state[0].size(), false));
	stack.push(start);
	reach[start.x][start.y] = true;
	std::vector<Coordinate> result{ start };
	while (!stack.empty()) {
		const auto top = stack.top(); stack.pop();
		for (const auto next : top.next()) {
			if (next.x < state.size() && next.y < state[next.x].size() && state[next.x][next.y] != '#' && !reach[next.x][next.y]) {
				reach[next.x][next.y] = true;
				stack.push(next);
				result.push_back(next);
			}
		}
	}
	return result;
}
std::vector<Coordinate> token_cell(const std::vector<std::string>& state) {
	std::vector<Coordinate> result;
	for (auto i = 0; i < state.size(); ++i) {
		for (auto j = 0; j < state[i].size(); ++j) {
			if (state[i][j] == 'o') {
				result.push_back(Coordinate{ i, j });
			}
		}
	}
	return result;
}
int main() {
	int n, m; std::cin >> n >> m;
	std::vector<std::string> state(n);
	for (auto& line : state) std::cin >> line;
	const auto tokens = token_cell(state);
	atcoder::mcf_graph<int, int> graph(((n * m) << 1) + 2);
	const auto source = (n * m) << 1 ;
	const auto destination = source + 1;
	for (auto i = 0; i < n; ++i) {
		for (auto j = 0; j < m; ++j) {
			graph.add_edge(i * m + j, destination, 1, 0);
		}
	}
	for (const auto token : tokens) {
		graph.add_edge(source, token.x * m + token.y + n * m, 1, 0);
		for (const auto reachable_cell : reachable(token, state)) {
			graph.add_edge(token.x * m + token.y + n * m, reachable_cell.x * m + reachable_cell.y, 1, n + m - token.manhattan_distance(reachable_cell));
		}
	}
	const auto flow = graph.flow(source, destination);
	const auto result = flow.first * (n + m) - flow.second;
	std::cout << result << '\n';
}


Measured memory_bytes: 7212
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){

    vector<int> alphabet(26,0);
    string S;

    while(cin >> S){
        for(int i=0; i<S.size(); i++){
            if(S[i] - 'a' >= 0 && S[i] - 'a' < 26){
                alphabet[S[i] - 'a']++;
            }
            if(S[i] - 'A' >= 0 && S[i] - 'A' < 26){
                alphabet[S[i] - 'A']++;
            }
        }
    }

    string aa = "abcdefghijklmnopqrstuvwxyz";

    for(int i=0; i<26; i++){
        cout << aa[i] << " : " << alphabet[i] << endl;
    }
    


    return 0;
}

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

int main() {
 	long long n, ans = 0;
 	cin >> n;
 	long long a[n + 1];
 	map<long long, long long> mp;
 	map<long long, long long> :: iterator itr;
 	for(long long i = 1; i <= n; i++) {
        cin >> a[i];
        mp[a[i]]++;
 	}
 	for(itr = mp.begin(); itr != mp.end(); itr++) {
        //cout << itr->first << " " << itr->second << endl;
        ans += (itr->second * (itr->second - 1)) / 2;
 	}
 	//cout << ans << endl;
 	for(long long i = 1; i <= n; i++) {
        cout << ans - mp[a[i]] + 1 << endl;
 	}
 	cout << endl;
}


Measured memory_bytes: 11008
n, m = map(int, input().split())
a = list(map(int, input().split()))

total = sum(a)

for i in range(n):
  if a[i] >= total / (4 * m):
    a[i] = "OK"

if a.count("OK") >= m:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, tmp, cnt = 0;
  cin >> N;
  vector<int> arr(N);
  
  for(int i = 0; i < N; i++) cin >> arr.at(i);
  
  tmp = arr.at(0);
  
  while (true) {
    cnt++;
    
    if (tmp == 2) break;
    if (cnt == N) {
      cnt = -1;
      break;
    }
    
    tmp = arr.at(tmp - 1);
  }
  cout << cnt << endl;
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;
 
public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;
 
  private static PrintWriter _err = new PrintWriter(System.err);
 
  private int N;
  private long[] T;
  private int M;
  private int[] P;
  private long[] X;
 
  private void solve(Scanner sc, PrintWriter out) {
    N = sc.nextInt();
    T = new long[N];
    Map<Integer, Long> map = new HashMap<>();
    long total = 0;
    for (int i = 0; i < N; ++i) {
      T[i] = sc.nextLong();
      total += T[i];
      map.put(i + 1, T[i]);
    }
    M = sc.nextInt();
    P = new int[M];
    X = new long[M];
    for (int i = 0; i < M; ++i) {
      P[i] = sc.nextInt();
      X[i] = sc.nextLong();
 
      long newTotal = total - map.get(P[i]) + X[i];
      out.println(newTotal);
    }
  }
  private long C(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    for (long i = r; i > 1; --i) {
      res /= i;
    }
    return res;
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  private long ceil2pow(long n) {
    if (n == 0) {
      return 1;
    }
    n--;
    n |= (n >>> 1);
    n |= (n >>> 2);
    n |= (n >>> 4);
    n |= (n >>> 8);
    n |= (n >>> 16);
    n++;
    return n;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();
 
    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();
 
    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const ll inf = 1e18 ;
int main(){
    ll n , k ;
    cin >> n >> k ;
    map<ll,ll> mp ;
    rep(i,n){
        ll a , b ;
        cin >> a >> b ;
        mp[a] += b ;
    }
    for(auto p : mp ){
        ll c = p.first ;
        ll d = p.second ;
        k -= d ;
        if( k <= 0 ){
            cout << c << endl;
            return 0 ;
        }
    }
}

Measured memory_bytes: 4224
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
n,q=map(int,input().split())
uf=UnionFind(n)
for _ in range(q):
  a,b,c=map(int,input().split())
  if a:print(int(uf.isSameGroup(b,c)))
  else:uf.Unite(b,c)


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

class Program
{
    //ABC043_D
    static void Main()
    {
       var s = Console.ReadLine();
       bool a  = false;
       int i=2;
       if(s.Length==2&&s[0]==s[1])
       {
       a=true;
       Console.WriteLine(1+" "+2);
       }
       else{
       for(i=2;i<s.Length;i++)
       {
           if(s[i]==s[i-2]||s[i-1]==s[i-2]||s[i]==s[i-1])
       {
           a =true;
           break;
       }
       }
       if(a)
       {
           Console.WriteLine((i-1)+" "+(i+1));
       }
       else Console.WriteLine(-1+" "+-1);
       }
    }
}

Measured memory_bytes: 3032
import sys
from math import log10

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 19 + 7
EPS = 10 ** -10

def bisearch_min(mn, mx, func):
    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            ok = mid
        else:
            ng = mid
    return ok

def mat_pow(mat, init, K, MOD):
    """ 行列累乗 """

    def mat_dot(A, B, MOD):
        """ 行列の積 """

        if not isinstance(A[0], list) and not isinstance(A[0], tuple):
            A = [A]
        if not isinstance(B[0], list) and not isinstance(A[0], tuple):
            B = [[b] for b in B]
        n1 = len(A)
        n2 = len(A[0])
        _ = len(B)
        m2 = len(B[0])
        res = list2d(n1, m2, 0)
        for i in range(n1):
            for j in range(m2):
                for k in range(n2):
                    res[i][j] += A[i][k] * B[k][j]
                    res[i][j] %= MOD
        return res

    def _mat_pow(mat, k, MOD):
        """ 行列matをk乗する """

        n = len(mat)
        res = list2d(n, n, 0)
        for i in range(n):
            res[i][i] = 1
        while k > 0:
            if k & 1:
                res = mat_dot(res, mat, MOD)
            mat = mat_dot(mat, mat, MOD)
            k >>= 1
        return res

    res = _mat_pow(mat, K, MOD)
    res = mat_dot(res, init, MOD)
    return [a[0] for a in res]

L, a, b, M = MAP()

A = [0] * 20
for i in range(1, 20):
    x = 10 ** i
    # A[i] = bisearch_min(-1, L, lambda m: ceil(x-a, b) <= m)
    A[i] = max(min(ceil(x-a, b), L), 0)
C = [0] * 20
for i in range(1, 20):
    C[i] = A[i] - A[i-1]

init = [0, a, 1]
for d in range(1, 20):
    K = C[d]
    if K == 0:
        continue
    mat = [
        # dp0[i] = dp0[i-1]*10^d + dp1[i-1]*1 + 1*0
        [pow(10, d, M), 1, 0],
        # dp1[i] = dp0[i-1]*0 + dp1[i-1]*1 + 1*b
        [0, 1, b],
        # 1 = dp0[i-1]*0 + dp1[i-1]*0 + 1*1
        [0, 0, 1],
    ]
    res = mat_pow(mat, init, K, M)
    init[0] = res[0]
    init[1] = res[1]
ans = res[0]
print(ans)

# dp0 = [0] * (L+1)
# dp1 = [0] * (L+1)
# dp0[0] = 0
# dp1[0] = a
# for i in range(1, L+1):
#     dp0[i] = (dp0[i-1]*pow(10, int(log10(dp1[i-1]))+1, M) + dp1[i-1]) % M
#     dp1[i] = dp1[i-1] + b
# ans = dp0[-1]
# print(ans)


Measured memory_bytes: 9556
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;

int main() {
  int n;
  cin >> n;
  map<string,P> ma;
  for(int i=0; i<n; i++) {
    string s;
    cin >> s;
    cin >> ma[s].F >> ma[s].S;
  }
  stack<vector<int> > st;
  cin >> n;
  while(n--) {
    string t;
    cin >> t;
    if(isalpha(t[0])) {
      vector<int> a(256);
      for(int i=ma[t].F; i<=ma[t].S; i++) a[i]=1;
      st.push(a);
    } else if(isdigit(t[0])) {
      stringstream ss;
      int x;
      ss << t;
      ss >> x;
      x%=256;
      vector<int> a(256);
      a[x]=1;
      st.push(a);
    } else {
      vector<int> b=st.top();st.pop();
      vector<int> a=st.top();st.pop();
      vector<int> c(256);
      for(int i=0; i<256; i++) {
        for(int j=0; j<256; j++) {
          if(!a[i]||!b[j]) continue;
          if(t=="+") c[(i+j)%256]=1;
          else if(t=="-") c[(i-j+256)%256]=1;
          else if(t=="*") c[(i*j)%256]=1;
          else {
            if(!j) {
              cout << "error" << endl;
              return 0;
            }
            c[(i/j)%256]=1;
          }
        }
      }
      st.push(c);
    }
  }
  cout << "correct" << endl;
  return 0;
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
LL n,counter=0,array1[2*N],i;
scanf("%lld",&n);
for(i=0;i<n;++i){
    scanf("%lld",&array1[i]);
}
for(i=1;i<n;++i){
    if(array1[i]<array1[i-1]){
        counter+=array1[i-1]-array1[i];
        array1[i]=array1[i-1];
    }
}
printf("%lld",counter);

    return 0;
}


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

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	ll ans =0,x;
	for0(i,n){
		cin >> x;
		if(x%6 ==0 || x%10 == 0){
			ans++;
		}
		if(x%2 == 0){
			ans--;
		}
	}
	if(ans == 0) {
		cout << "APPROVED" << endl;
	}
	else{
		cout << "DENIED" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader alpha = 
         new BufferedReader(new InputStreamReader(System.in));
        
        String a = alpha.readLine();

        if(a == a.toUpperCase()){
            System.out.print("A");
        } else if(a == a.toLowerCase()){
            System.out.print("a");
        }
    }
}

Measured memory_bytes: 32644
h, w = map(int, input().split())
l = []
for i in range(h):
    l.append(list(input()))
for i in range(h):
    for j in range(w):
        num_mine = 0
        if l[i][j] != "#":
            if 0<i and 0<j and l[i-1][j-1] == "#":
                num_mine += 1
            if 0<i and l[i-1][j] == "#":
                num_mine += 1
            if 0<i and j<w-1 and l[i-1][j+1] == "#":
                num_mine += 1
            if 0<j and l[i][j-1] == "#":
                num_mine += 1
            if j<w-1 and l[i][j+1] == "#":
                num_mine += 1
            if i<h-1 and 0<j and l[i+1][j-1]== "#":
                num_mine += 1
            if i<h-1 and l[i+1][j] == "#":
                num_mine += 1
            if i<h-1 and j<w-1 and l[i+1][j+1] == "#":
                num_mine += 1
            l[i][j] = str(num_mine) 
for i in range(h):
    print(''.join(l[i]))           

Measured memory_bytes: 9220
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int K = in.nextInt();
		
		long ans = 0;
		if (K == 0) {
			ans = (long) N * (long) N;
		} else {
			for (int b = 1; b <= N; b++) {
				if (b <= K) {
					continue;
				}
				ans += (b - K) * (N / b);
				if (N % b >= K) {
					ans += N % b - K + 1;
				}
			}
		}
		
		System.out.println(ans);
	}
}

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

const int MAXN = 100100;
int arr[MAXN];
int dp[MAXN];
int main() {
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
	    cin>>arr[i];
	}
	dp[0] = 0;

	for(int i=1;i<n;i++){
	    dp[i] = 1000000000;
	    for(int j=i-1;j>=max(i-k,0);j--){
	        dp[i] = min(dp[j]+abs(arr[j]-arr[i]),dp[i]);
	        
	    }
	}
	cout<<dp[n-1];
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
	int H,W,a,b;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0){
			break;
		}
		for(a=0;a<H;a++){
			for(b=0;b<W;b++){
				if(a==0 || a==H-1 || b==0 || b==W-1){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
import sys




x,k,d=map(int,input().split())
x=abs(x)
if(abs(x%d)<abs(x%d-d)):
  min_num=x%d
  min_num2=x%d-d
else:
  min_num=x%d-d
  min_num2=x%d

kaisuu=(x-min_num)/d
if(kaisuu>k):
  print(abs(x-d*k))
  sys.exit()
if((k%2==0 and kaisuu%2==0)or(k%2==1 and kaisuu%2==1)):
  print(abs(min_num))
else:
  print(abs(min_num2))


Measured memory_bytes: 9168
import java.util.Scanner;

public class Main {

    public Main() {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int Y = scanner.nextInt();

        if(Y % 2 == 1){
            System.out.println("No");
            return;
        }

        int A = 2*X-Y/2;
        int B = Y/2 - X;

        if(A >= 0 && B >= 0){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

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


Measured memory_bytes: 35776
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    string s;
    cin >> s;
    for(int i=1;i<4;i++){
        if(s[i]==s[i-1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a[4];
	cin >> a[0] >> a[1] >> a[2];
	for (int i = 0; i < 2; i++)
		for (int j = i + 1; j < 3; j++)
			if (a[i] > a[j]) swap(a[i], a[j]);
	cout << a[0] << " " << a[1] << " " << a[2] << endl;
	return 0;
}

Measured memory_bytes: 3008
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[N];
		Arrays.setAll(A, i -> sc.nextInt());
		Map<Integer, Long> x = new HashMap<>();
		int[] S = new int[N];
		S[0] = A[0] % M;
		x.put(0, 1L);
		x.put(S[0], x.getOrDefault(S[0], 0L) + 1);
		for(int i = 1; i < N; i++) {
			S[i] = (S[i-1] + A[i]) % M;
			x.put(S[i], x.getOrDefault(S[i], 0L) + 1);
		}
		long ans = 0;
		for(int i : x.keySet())
			ans += x.get(i) * (x.get(i) - 1) / 2;
		System.out.println(ans);
	}

}


Measured memory_bytes: 52924
#include <iostream>
#include <queue>
using namespace std;
int main(){
  int n,t,p,c=0;
  string s;
  cin>>n>>t;
  queue<pair<string,int> >a;
  while(n--){
    cin>>s>>p;
    a.push(make_pair(s,p));
  }
  while(!a.empty()){
    pair<string,int>b=a.front();
    a.pop();
    if(b.second<=t){
      c+=b.second;
      cout<<b.first<<' '<<c<<endl;
    }
    else{
      b.second-=t;
      c+=t;
      a.push(b);
    }
  }
}

Measured memory_bytes: 6220
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#define FAST ios::sync_with_stdio(false)
typedef long long ll;
const int maxn = (int)1e5 + 5;
const int mod = (int)1e9 + 9;
const int inf = 0x3f3f3f3f;
using namespace std;

char s[55][55];

int main()
{
	int h, w;
	cin >> h >> w;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> s[i][j];
		}
	}
	bool flag = true;
	for(int i = 0; i < h && flag; i++){
		for(int j = 0; j < h && flag; j++){
			if(s[i][j] == '#'){
				if(s[i][j+1] == '#' || s[i][j-1] == '#' || s[i-1][j] == '#' || s[i+1][j] == '#') continue;
				else flag = false;
			}
		}
	}
	if(flag == true) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
/*
   Author : tarang
*/
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define PI = acos(-1)
using namespace std ;
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
int main(){
	 fastio ; 
	 ll m = 1000000007;
     ll n ; cin >> n ;
     vector<ll> v(n);
     for(ll i = 0 ; i < n ; i++){
     	cin >> v[i];
	 }
	 ll f[68] = {0};
//	 for(auto x:f) cout << x << " ";
//	 cout << endl;
	 for(ll i = 0 ; i < n ; i++){
	 	  for(ll j = 0 ; j < 61  ; j++){
	 	  	    if((v[i] & (1LL << j)))
	 	  	       f[j]++;
		   }
	 }
	// for(auto x :f) cout << x << " ";
	// cout << endl;
	 ll res = 0 ;
	 for(ll i = 0 ; i < 61 ; i++){
	 	  ll x = f[i];
	 	  ll z = (n-x);
	 	  ll ans = power(2 , i , m);
	 	  //cout << x << " " << z << " " << ans << endl;
	 	  ll ans2 = ( x % m * z % m) % m ;
	 	  ans2 = ( ans2 % m * ans%m) % m ;
	 	  res = ( res % m + ans2%m) %m ;
	 }
	 cout << (res)%m << endl;
}


Measured memory_bytes: 5456
main(f,x){unsigned int u;for(scanf("%d",&x);~scanf("%x",&u);printf("%s%d.%0*d\n",u&(1<<31)?"-":"",u<<1>>8,x,f))for(f=(u&0x7f)*78125,x=7;x>1&&!(f%10);f/=10)x--;exit(0);}

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

int main() {
  int n, i, score_taro = 0, score_hana = 0;
  string str_taro, str_hana;

  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> str_taro >> str_hana;
    if (str_taro > str_hana)
      score_taro += 3;
    else if (str_taro < str_hana)
      score_hana += 3;
    else {
      score_taro += 1;
      score_hana += 1;
    }
  }
  cout << score_taro << " " << score_hana << endl;
  return 0;
}

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

#define lli long long int
#define LLI(n) lli n; cin >> n;
#define STR(n) string n; cin >> s;
#define Sort(n) sort(n.begin(), n.end());
#define Reve(n) reverse(n.begin(), n.end());
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define C45(n) (n + 1) / 2
#define OUT(n) cout << n << endl;

//素数
bool IsPrime(lli num)
{
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)return false;
  }
  return true;
}
//各桁の和
lli Sum(lli n)
{
  lli sum=0;
  if (n<0) return 0;
  while (n>0)
  {
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main(void)
{
  ios::sync_with_stdio(false);
  lli ans = 700;
  STR(s);
  for(lli i = 0;i < s.size();i++) {
    if(s.at(i) == 'o') {
      ans += 100;
    }
  }
  OUT(ans)
  return 0;
}


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

int main()
{
    string a;
    int b;
    b = 0;
    cin >> a;
    if( a[0] == '+' ){
        b++;
    }
    else {b--;};
    if( a[1] == '+' ){
        b++;
    }
    else {b--;};
    if( a[2] == '+' ){
        b++;
    }
    else {b--;};
    if( a[3] == '+' ){
        b++;
    }
    else {b--;};
    cout << b;

    return 0;
}


Measured memory_bytes: 3576
import Data.List
import qualified Data.Map as Map

f::Int->Int->String->Map.Map Int Int->Map.Map Int Int
f _ _ "" ms=ms
f k c1 (c:[]) ms=(Map.insert k c1 ms)
f k c1 ('A':'C':xs) ms=f (k+2) (c1+1) xs (Map.insert (k+1) (c1+1) (Map.insert k c1 ms))
f k c1 (_:xs) ms=f (k+1) c1 xs (Map.insert k c1 ms)

g::[String]->Map.Map Int Int->[String]
g [] _ =[]
g (x:xs) ms=let (a:b:[])=map read (words x)::[Int]
                Just c2=Map.lookup b ms
                Just c1=Map.lookup a ms
            in (show (c2-c1)):g xs ms

main = do
       l1<-getLine
       l2<-getLine
       ls<-getContents
       let ms=f 1 0 l2 (Map.fromList [])
       mapM_ putStrLn $ g (lines ls) ms

Measured memory_bytes: 27260
// see https://github.com/LumaKernel/vimfiles/tree/master/snippets/cp-cpp/temp.snip
/// --- .lumrc Template {{{ ///
#if 0
#define assert(...)
#endif
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = tuple<ll, ll>;
using P3 = tuple<ll, ll, ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VP = vector<P>;
using VS = vector<string>;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define FORI(i,a,b) for(int i=int(a);i<=int(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REPI(i,n) FORI(i,0,n)
#define RFOR(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#define RFORI(i,a,b) for(int i=int(b);i>=int(a);--i)
#define RREP(i,n) RFOR(i,0,n)
#define RREPI(i,n) RFORI(i,0,n)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique(ALL(a)),(a).end())
#define PB push_back
#define EACH(i,c) REP(i,(c).size())
#define REACH(i,c) RREP(i,(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))

#define BR cout<<"\n";

#ifdef DEBUG
#define dump(...) cerr<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<make_tuple(__VA_ARGS__)<<"\n";
#else
#define dump(...)
#endif

#define YES(x) cout<<((x)?"YES":"NO")<<"\n";
#define Yes(x) cout<<((x)?"Yes":"No")<<"\n";
#define yes(x) cout<<((x)?"yes":"no")<<"\n";

inline int omajinai_int_in(){omajinai;int n;cin>>n;return n;}
inline ll omajinai_ll_in(){omajinai;ll n;cin>>n;return n;}
inline string omajinai_string_in(){omajinai;string n;cin>>n;return n;}
inline int int_in(){int n;cin>>n;return n;}
inline ll ll_in(){ll n;cin>>n;return n;}
inline string string_in(){string n;cin>>n;return n;}
#define oini omajinai_int_in()
#define oinl omajinai_ll_in()
#define oins omajinai_string_in()
#define ini int_in()
#define inl ll_in()
#define ins string_in()

#define isInside(y,x) (0<=(y)&&(y)<h&&0<=(x)&&(x)<w)

#define fi(x) (get<0>(x))
#define se(x) (get<1>(x))
#define th(x) (get<2>(x))
#define fo(x) (get<3>(x))
#define fif(x) (get<4>(x))

template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '{'; EACH(i, v) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "}";  return o; }

template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }

template <typename T> inline void smax(T &a, T b) { a = a > b ? a : b; }
template <typename T> inline void smin(T &a, T b) { a = a < b ? a : b; }

constexpr double PI = acos(-1);

/// }}}--- ///

constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr int MOD = 1e9+7;

int main() {
int n=ini;
int a[100000];
REP(i,n)a[i]=ini;
sort(a,a+n);
reverse(a,a+n);
ll ans=0;
REP(i,n)ans+=a[i] * (i%2 ? -1: 1);
cout << ans<<endl;
}

//


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
// #define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int a, b, c; cin >> a >> b >> c;
    if(c >= a && c <= b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	int x[5];
	int k;
	bool ans;

	rep(i, 5){
		cin >> x[i];
	}
	cin >> k;

	sort(x, x + 5);

	if(x[4] - x[0] > k)
		cout << ":(" << endl;
	else
		cout << "Yay!" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string s;
  cin>>s;
int count=0;
  for (int i = 1; i < 4; i++) {
 if(s[0]==s[i]){
   count++;
 }
}
  for (int i = 2; i < 4; i++) {
 if(s[1]==s[i]){
   count++;
 }
}
  for (int i = 3; i < 4; i++) {
 if(s[2]==s[i]){
   count++;
 }
}
  if(s[3]==s[4]){
    count++;
  }
  if(count==2){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
}


Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL a,b,c,d;

LL fun(LL x,LL y)
{
	LL z=__gcd(x,y);
	return z*(x/z)*(y/z);
}

int main()
{
	cin>>a>>b>>c>>d;
	cout<<b-a+1-(b/c+b/d-b/fun(c,d)-((a-1)/c+(a-1)/d-(a-1)/fun(c,d)))<<endl;
	rt0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int X[][] = new int[N][D];
		double dst = 0;
		int answer = 0;

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < D; j++) {
				X[i][j] = sc.nextInt();
			}
		}

		for (int i = 0; i < N - 1; i++) {
			for (int j = i + 1; j < N; j++) {
				dst = 0;
				for (int k = 0; k < D; k++) {
					dst += Math.pow(X[j][k] - X[i][k], 2);
				}
				if (dst == Math.pow((int)Math.sqrt(dst), 2)) answer++;
			}
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 23124