akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>

#define INF INT_MAX>>1

using namespace std;

int main(void){
	while(1){
		int n, m, c, s, g; 
		cin >> n >> m >> c >> s >> g;
		if(!n && !m && !c && !s && !g) break;
		s--; g--;

		static int dist[100][100][20];
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				for(int k=0; k<c; k++){
					if(i==j) dist[i][j][k] = 0;
					else dist[i][j][k] = INF;
				}
			}
		}
		for(int i=0; i<m; i++){
			int x, y, d, c;
			cin >> x >> y >> d >> c;
			x--; y--; c--;
			dist[x][y][c] = dist[y][x][c] = min(dist[x][y][c], d);
		}
		int p[20];
		for(int i=0; i<c; i++) {
			cin >> p[i];
		}
		vector< pair<int, int> > fare[20];
		for(int i=0; i<c; i++){
			fare[i].assign(p[i]+1, make_pair(0, 1));
			for(int j=0; j<p[i]-1; j++){
				int q; cin >> q;
				fare[i][j+1].first = q;
			}
			for(int j=0; j<p[i]; j++){
				int r; cin >> r;
				fare[i][j+1].second = r;
			}
			fare[i].back().first=INF;
		}

		for(int l=0; l<c; l++){
			//ワーシャルフロイド
			for(int k=0; k<n; k++) for(int i=0; i<n; i++) for(int j=0; j<n; j++)dist[i][j][l] = min(dist[i][j][l], dist[i][k][l]+dist[k][j][l]);
		}

		static int cost[100][100][20];
		for(int l=0; l<c; l++){
			for(int i=0; i<n; i++){
				for(int j=0; j<n; j++){
					int d = dist[i][j][l];
					if(d == INF){
						cost[i][j][l] = INF;
						continue;
					}
					int tmp=0;
					for(int k=0; k<fare[l].size()-1; k++){
						tmp += fare[l][k+1].second*max(min(fare[l][k+1].first, d)-fare[l][k].first, 0);
					}
					cost[i][j][l] = tmp;
				}
			}
		}

		int ans[100][100];
		fill(ans[0], ans[100], INF);
		for(int i=0; i<n; i++) for(int j=0; j<n; j++) for(int k=0; k<c; k++) ans[i][j] = min(ans[i][j], cost[i][j][k]);
		for(int k=0; k<n; k++) for(int i=0; i<n; i++) for(int j=0; j<n; j++) ans[i][j] = min(ans[i][j], ans[i][k]+ans[k][j]);

		if(ans[s][g] != INF) cout << ans[s][g] << endl;
		else cout << -1 << endl;
	}

	return 0;
}


Measured memory_bytes: 4692
class PriorityQueue
  MIN = -(1 << 60)

  attr_reader :size

  def initialize(&block)
    @size = 0
    @heap = Array.new
    @get_key = block || :itself.to_proc
  end

  def empty?
    size == 0
  end

  def pop
    return nil if @size <= 0
    max = @heap[1]
    @heap[1] = @heap[@size]
    @size -= 1
    max_heapify(1)
    max
  end

  def push(x)
    @size += 1
    i = @size
    @heap[i] = x
    while i > 1 && @get_key.call(@heap[i / 2]) < @get_key.call(@heap[i])
      t = @heap[i / 2]
      @heap[i / 2] = @heap[i]
      @heap[i] = t
      i = i / 2
    end
  end

  def top
    return nil if @size <= 0
    @heap[1]
  end

  def to_a
    return [] if @size == 0
    @heap[1..@size]
  end

  private

  def max_heapify(i)
    l = 2 * i
    r = 2 * i + 1
    largest =
      l <= @size && @get_key.call(@heap[l]) > @get_key.call(@heap[i]) ? l : i
    largest = r \
      if r <= @size && @get_key.call(@heap[r]) > @get_key.call(@heap[largest])
    unless largest == i
      t = @heap[i]
      @heap[i] = @heap[largest]
      @heap[largest] = t
      max_heapify(largest)
    end
  end
end

require 'set'

X, Y, Z, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
C = gets.split.map(&:to_i)

sorted_a = A.sort_by { |n| -n }
sorted_b = B.sort_by { |n| -n }
sorted_c = C.sort_by { |n| -n }

used = Set.new
pq = PriorityQueue.new { |(ai, bi, ci, sum)| sum }
pq.push([0, 0, 0, sorted_a[0] + sorted_b[0] + sorted_c[0]])
used.add([0, 0, 0])
K.times do
  ai, bi, ci, sum = pq.pop
  puts sum
  if ai + 1 < sorted_a.size
    key = [ai + 1, bi, ci]
    if !used.include?(key)
      sum = sorted_a[ai + 1] + sorted_b[bi] + sorted_c[ci]
      pq.push(key + [sum])
      used.add(key)
    end
  end
  if bi + 1 < sorted_b.size
    key = [ai, bi + 1, ci]
    if !used.include?(key)
      sum = sorted_a[ai] + sorted_b[bi + 1] + sorted_c[ci]
      pq.push(key + [sum])
      used.add(key)
    end
  end
  if ci + 1 < sorted_b.size
    key = [ai, bi, ci + 1]
    if !used.include?(key)
      sum = sorted_a[ai] + sorted_b[bi] + sorted_c[ci + 1]
      pq.push(key + [sum])
      used.add(key)
    end
  end
end


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

int main(){
  int N,i;
  cin >> N;
  int sum = 0;
  for(i=0;i<N;i++){
    int l,r;
    cin >> l >> r;
    sum +=(r-l +1);
    
    
  }
  cout << sum <<endl;
}

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

//B - Cakes and Donuts
int main(){
    int N, total;
    cin >> N;
    bool res = false;
    for(int i = 0; i < 30; ++i){
        for(int j = 0; j < 20; ++j){
            total = i*4 + j*7;
            if(total == N) res = true;
        }
    }
    if(res){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
k=1;ans=0
c=[]
for i in range(n):
    ans=0
    if a[i]==k:
       ans+=i
       c.append(ans)
       k+=1
if len(c)==0:
    print(-1)
else:
    print(n-len(c))

Measured memory_bytes: 32204
def max(a,b);       a > b ? a : b                              end
def min(a,b);       a < b ?  a : b                             end
def swap(a,b);      a, b = b, a                                end
def gi;             gets.to_i                                  end
def gf;             gets.to_f                                  end
def gs;             gets.chomp                                 end
def gmi(n=nil); n.nil? ? gets.split.map(&:to_i) : n.times.map{ gets.to_i } end
def gmf(n=nil); n.nil? ? gets.split.map(&:to_f) : n.times.map{ gets.to_f } end
def gms(n=nil); n.nil? ? gets.split : n.times.map{ gets.chomp } end
def ga2i(h);        h.times.map{ gets.split.map(&:to_i) }      end
def yn(f); puts f ? "Yes" : "No" end
def YN(f); puts f ? "YES" : "NO" end
def yes(f=nil); f.nil? ? (puts "Yes"; exit) : (puts f ? "Yes" : "No") end
def no(f=nil); f.nil? ? (puts "No"; exit) : (puts f ? "Yes" : "No") end
def yay(f=nil); f.nil? ? (puts "Yay!"; exit) : (puts f ? "Yay!" : ":(") end

n,d,a = gmi
monsters = ga2i(n)

monsters.map!{ |xh| xh[1] = (xh[1]+a-1)/a; xh }.sort_by!{ |xh| xh[0] }

deq = []
acc_damage = 0
ans = 0
monsters.each do |xh|
  
  while deq.size > 0 && deq[0][0] < xh[0] do
    acc_damage -= deq[0][1]
    deq.shift
  end
  
  need = max(0, xh[1]-acc_damage)
  
  if need > 0
    acc_damage += need
    ans += need
    deq.push( [xh[0] + d*2, need] )
  end
end

puts ans

Measured memory_bytes: 22520
#include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<long double> vld;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846
#define sqr(a) ((a) * (a))
#define len(V) (int)V.size()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define fix(a) fixed << setprecision(a)
#define readv(x) for(auto &_ : (x)) {cin >> _;}
#define printv(x) for(auto &_ : (x)) {cout << _ << ' ';} cout << endl
#define EPS 1e-6
#define MAXN 100047

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	vector<vector<int>> a(3);
	vector<vector<bool>> was(3);
	FOR(i, 0, 3){
		int x, y, z; cin >> x >> y >> z;
		a[i].pb(x);
		a[i].pb(y);
		a[i].pb(z);
		was[i].pb(0);
		was[i].pb(0);
		was[i].pb(0);
	}
	
	int n; cin >> n;
	FOR(x, 0, n){
		int t; cin >> t;
		FOR(i, 0, 3)
		FOR(j, 0, 3){
			if (a[i][j] == t) was[i][j] = 1;
		}
	}
	
	if (was[0][0] == 1 && was[1][1] == 1 && was[2][2] == 1) {
		cout << "Yes\n";
		return 0;
	}
	if (was[0][2] == 1 && was[1][1] == 1 && was[2][0] == 1) {
		cout << "Yes\n";
		return 0;
	}
	FOR(i, 0, 3){
		if (was[i][0] == 1 && was[i][1] == 1 && was[i][2] == 1) {
			cout << "Yes\n";
			return 0;
		}
	}
	FOR(i, 0, 3){
		if (was[0][i] == 1 && was[1][i] == 1 && was[2][i] == 1) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	
	return 0;
}


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

int main(void) {
	string s;
	char c;
	int len, ans;

	cin >> s;

	len = s.length();
	c = s[0];
	ans = 0;
	for (int i = 1; i < len; ++i) {
		if (s[i] != c) {
			++ans;
			c = s[i];
		}
	}

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


Measured memory_bytes: 512
local floor = math.floor
-- heap
local Heap = {}
function Heap.new(upper_func)
    local self = setmetatable({}, {__index = Heap})
    self.a = {}
    self.upper_func = upper_func
    self.upper = function(k1, k2)
        assert(k1 < k2)
        if k1 == 0 then
            return false
        else
            return upper_func(self.a[k1], self.a[k2])
        end
    end
    self.lower = function(k1, k2)
        return not self.upper(k1, k2)
    end
    return self
end
 
function Heap:count()
    return #self.a
end
 
function Heap:_swap(k1, k2)
    local old_k1 = self.a[k1]
    self.a[k1] = self.a[k2]
    self.a[k2] = old_k1
end

function Heap:upheap(newk)
    local ku = floor(newk / 2)
    local k = newk
    while ku > 0 and self.lower(ku, k) do
        self:_swap(ku, k)
        k = floor(k/2)
        ku = floor(ku/2)
    end
end
 
function Heap:insertq(e)
    table.insert(self.a, e)
    self:upheap(#self.a)
end
 
function Heap:downheap(newk)
    local k = newk
    while k <= floor(#self.a/2) do
        local kdl = k*2
        local kdr = kdl + 1
        local kd
        if kdr <= #self.a and self.lower(kdl, kdr) then
            kd = kdr
        else
            kd = kdl
        end
        if self.upper(k, kd) then
            break
        end
        self:_swap(k, kd)
        k = kd
    end
end
 
function Heap:top()
    assert(#self.a >= 1)
    return self.a[1]
end
 
function Heap:remove_top()
    assert(#self.a >= 1)
    local v = self.a[1]
    self:_swap(1, #self.a)
    table.remove(self.a)
    self:downheap(1)
    return v
end

---
local N, M = io.read("*n", "*n")
local q = Heap.new(function (x,y) return x > y end)
for i=1,N do
    q:insertq(io.read("*n"))
end
for i=1,M do
    local top = q:remove_top()
    top = top / 2
    q:insertq(top)
end
local sum = 0

for i=1,N do
    local top = q:remove_top()
    sum = sum + floor(top)
end
print(sum)

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

int main(){
    int N, C, K;
    cin >> N >> C >> K;
    int T[N];
    vector<int> v;
    for(int i = 0; i < N; i++){
        cin >> T[i];
        v.push_back(T[i]);
    }
    sort(v.begin(), v.end());

    int ans = 1;
    int human = 1, t = v[0] + K;
    for(int i = 1; i < N; i++){
        if(human < C && v[i] <= t){
            human++;
        }else{
            ans++;
            human = 1;
            t = v[i] + K;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1148
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int n = in.nextInt();
    double t = in.nextDouble();
    int a = in.nextInt();

    double min = Integer.MAX_VALUE;
    int minP = 0;

    for (int i = 1; i <= n; i++) {
      double h = in.nextDouble();
      double diff = Math.abs(t - (h * 0.006) - a);
      if (diff < min) {
        min = diff;
        minP = i;
      }
    }

    out.println(minP);

    out.close();
  }

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

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

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

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

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

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

  static void print(int[] arr) {
    Arrays.stream(arr).forEach(i -> System.out.print(i + " "));
    System.out.println();
  }

  public static int[] mergeSort(int[] a) {
    if (a.length <= 1)
      return a;

    int mid = a.length / 2;
    int[] left = new int[mid];
    int[] right = new int[a.length - mid];

    for (int i = 0; i < mid; ++i)
      left[i] = a[i];

    for (int i = mid; i < a.length; ++i)
      right[i - mid] = a[i];

    return merge(mergeSort(left), mergeSort(right));
  }

  public static int[] merge (int[] l, int[] r) {
    int[] merged = new int[l.length + r.length];

    int i = 0, j = 0, k = 0;
    while (i < l.length && j < r.length) {
      if (l[i] <= r[j])
        merged[k++] = l[i++];
      else
        merged[k++] = r[j++];
    }

    while (i < l.length)
      merged[k++] = l[i++];
    while (j < r.length)
      merged[k++] = r[j++];

    return merged;
  }

}



Measured memory_bytes: 22612
/*input
86
*/

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

typedef double db;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;

#define FOR(i, l, r) for(int i = l; i <= r; ++i)
#define FORD(i, l, r) for(int i = l; i >= r; --i)
#define REP(i, r) for(int i = 0; i < int(r); ++i)
#define REPD(i, r) for(int i = int(r)-1; i >= 0; --i)
#define fi first
#define se second
#define sz size
#define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;

const int Nmax = 1e6 + 10;
const ll inf = 1e9;
const db _eps = 1e-5;

int n;

struct matrix {
	ll val[3][3];
	matrix() { memset(val, 0, sizeof val); }
	matrix operator * (matrix x) {
		matrix c;
		FOR(i, 1, 2) FOR(j, 1, 2) FOR(k, 1, 2)
			c.val[i][j] = (c.val[i][j] + val[i][k] * x.val[k][j]);
		return c;
	} 
};

ll power(int b) {
	matrix A, C;
	C.val[1][1] = C.val[2][2] = A.val[1][1] = A.val[1][2] = A.val[2][1] = 1;
	for (; b; b >>= 1, 	A = A * A) 
		if (b & 1) C = A * C;
	return C.val[1][1] + 2 * C.val[1][2];
}

int main() {
	cin >> n;
	cout << power(n-1);
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        long mod = (long)Math.pow(10,9)+7;
        char[] S = sc.next().toCharArray();
        int len = S.length;
        long[][] dp = new long[len+1][2];
        dp[0][0] = 1;
        for(int i = 0; i < len; i++){
            int c = S[i] - '0';
            //ai+bi = 0;
            if(S[i] == '0'){
                dp[i+1][0] = dp[i][0];
                dp[i+1][1] = dp[i][1];
            }else{
                dp[i+1][1] = (dp[i][0] + dp[i][1]) % mod;
            }
            //ai+bi = 1;
            if(S[i] == '0'){
                dp[i+1][1] += dp[i][1]*2;
                dp[i+1][1] %= mod;
            }else{
                dp[i+1][0] += dp[i][0]*2;
                dp[i+1][0] %= mod;
                dp[i+1][1] += dp[i][1]*2;
                dp[i+1][1] %= mod;
            }
        }
        System.out.println((dp[len][0] + dp[len][1]) % mod);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 31916
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

        int X=gi();
        
        int max=1;
        for(int i=2; i<Math.floorDiv(X, 2)+1; i++) {
        	int z=2;
        	while(true) {
        		int v=(int)Math.pow(i,z);
        		if(v>X) {
        			break;
        		}
        		if(max<v) {
        			max=v;
        		}
        		z++;
        	}
        }


	    System.out.println(max);

//	    if (isNumber(s1) && isNumber(s2) && s.charAt(a) == '-') {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35764
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int n,m;
  	cin >> n;
  	cin >> m;
  	int a,b;
    vector<int> g[n+5];
  	for(int i=0;i<m;i++)
    {
    	cin >> a>> b;
      	g[a].push_back(b);
      	g[b].push_back(a);
    }
  	int check[n+5];
  int top;	
  for(int i=1;i<=n;i++)
    {
    	check[i]=0;
    }
  	stack<int> st;
  	int cn = 0;
  	int max = INT_MIN;
  	for(int i=1;i<=n;i++)
    {
      cn = 0;
    	if(check[i]==0)
        {
        	st.push(i);
          	cn++;
          	while(!st.empty())
            {
              top = st.top();
              st.pop();
              check[top]=1;
              int k = g[top].size();
              for(int j = 0;j<k;j++)
              {
                  if(check[g[top][j]]==0)
                  {
                    cn++;
                      st.push(g[top][j]);
                      check[g[top][j]] = 1;
                  }
              }
            }
          if(cn>max)
          {
            max = cn;
          }
        }
    }
  	cout << max << endl;
}


Measured memory_bytes: 15692
from math import factorial
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = False
show_flg = True

p = None
XY = None
N = None


def main():
    N = I()
    P = LI()
    Q = LI()
    # start = 0
    # finish = 0
    data = sorted(list(itertools.permutations(P, N)))

    for index, arr in enumerate(data):
        tmpS = 0
        tmpE = 0
        for i in range(N):
            if P[i] == arr[i]:
                tmpS += 1
            if Q[i] == arr[i]:
                tmpE += 1

        if tmpS == N:
            start = index

        if tmpE == N:
            finish = index

    print(abs(finish - start))


if __name__ == '__main__':
    main()


Measured memory_bytes: 72428
n = int(input())
list_a = [list(map(int, input().split())) for _ in range(2)]
max_candy = 0
for i in range(n):
  temp_candy = sum(list_a[0][:i+1]) + sum(list_a[1][i:])
  if max_candy < temp_candy:
    max_candy = temp_candy
print(max_candy)

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

int main()
{
	ll x;
	cin >> x;
	ll a=100;
	for(int i = 1;1;i++)
	{
		a+= a/100;
		//cout<<a<<endl;
		if(a>=x)
		{
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3672
n = int(input())
l = [input() for i in range(n)]
d = {}
for i in l:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
d_max = max(d.values())
for i in sorted(d):
    if d[i] == d_max:
        print(i)
        

Measured memory_bytes: 35220
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, temp;

    cin >> n;

    float x = 0.0;

    for (int i = 0; i < n; i++) {
        cin >> temp;

        x += 1.0 / temp;
    }

    cout << 1.0 / x;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K,N;
  cin>>K>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  vector<int> dis(N);
  dis.push_back(K+A.at(0)-A.at(N-1));
  for(int i=0;i<N-1;i++){
    int D = A.at(i+1)-A.at(i);
    dis.push_back(D);
  }
  sort(dis.begin(),dis.end());
  reverse(dis.begin(),dis.end());
  cout<<K-dis.at(0)<<endl;
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)

#include<algorithm>

using namespace std;
typedef long long ll;

int main() {
  ll N,K;
  cin >> N >> K;
  ll p[N];
  REP(i,N) cin >> p[i];
  ll max = 0;
  REP(i,K){
    max = max + p[i];
  }
  ll tmp = max;
  FOR(i,K,N){
    tmp = tmp + p[i] - p[i-K];
    if(max < tmp) max = tmp;
  }
  double ret = 0.0;
  ret = (max+K)/2.0;
  cout << setprecision(10) << ret << endl;
  return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, a, b, result;
  cin >> n;
  rep(i, n) {
    cin >> a >> b;
    result = a % b;
    if(!result) result = b;
    cout << result << endl;
  }
	return 0;
}


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

using namespace std;

int main(){

  int a,b,c;

  cin >> a >> b >> c;

  if(a == b && a != c)
    cout << "Yes\n";
  else if(a == c && a != b)
    cout << "Yes\n";
  else if(b == c && b != a)
    cout << "Yes\n";
  else 
    cout << "No\n";
  

  return 0;
}

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

int main(){
  string s;
  cin >> s;
  int n = s.length();
  long long ret = 0;
  int acnt = 0;
  for(int i = 0;i+2 < n;i++){
    if(s[i] == 'A')acnt++;
    else acnt = 0;
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
      ret += acnt;
      s[i] = 'B';s[i+1] = 'C';s[i+2] = 'A';
      i ++;
      acnt = max(0,acnt-1);
    }
  }
  cout << ret << endl;
}

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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define str string
#define s_vec(data,name,vertical,horizontal) vector<vector<(data)>> (name)((vertical),vector<(data)>((horizontal)));


int counter (int num){
    if(num==0){
        return 0;
    }
    return counter((num>>1)) + (num&1);
}

int main() {

    int n;
    cin>>n;
    vector<int> a(n+5);
    vector<vector<int>> x(n+5,vector<int>(n+5));
    vector<vector<int>> y(n+5,vector<int>(n+5));

    for(int i=1;i<=n;i++){
        cin>>a.at(i);
        for(int j=1;j<=a.at(i);j++){
            cin>>x.at(i).at(j)>>y.at(i).at(j);
        }
    }

    //bit全探索

    bool jud;
    int ans=0;
    for(int bits=1;bits<(1<<n);bits++){
        jud=0;
        for(int i=1;i<=n;i++){
            if(!(bits&(1<<(i-1))))continue;
            for(int j=1;j<=a.at(i);j++){
                if(((bits>>(x.at(i).at(j)-1))&1)^y.at(i).at(j)){
                    jud = 1;
                }
            }
        }
        if(jud==0){
            ans = max(ans,counter(bits));
        }
    }

    cout<<ans<<endl;




}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  int a[100002]={0};
  int b[100002]={0};
  long long ans=0;

  for(int i=0;i<n;i++){
    scanf("%d", &a[i]);
    b[a[i]]++;
    ans+=a[i];
  }  
  
  int q;
  scanf("%d", &q);
  
  int B, C;
  for(int i=0;i<q;i++){
    scanf("%d %d", &B, &C);
    ans = ans + (C-B)*b[B];
    b[C]+=b[B];
    b[B]=0;
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 2932
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    ll i;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=n-1;i>0;i--)
    {
        if(a[i]<a[i-1]) a[i-1]--;
    }
    for(i=0;i<n-1;i++)
    {
        if(a[i]>a[i+1]) {cout<<"No";return 0 ;}
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 1024
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

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

using namespace std;
typedef long long int ll;

int main() {
  string s;
  cin >> s;
  ll k;
  cin >> k;

  vector<string> v;
  for (int i = 0; i < s.size(); ++i) {
    for (int j = 1; j <= k; ++j) {
      string tmp = s.substr(i,j);
      v.push_back(tmp);
    }
  }
  sort(all(v));
  v.erase(unique(all(v)), v.end());

  cout << v.at(k-1) << endl;

  return 0;
}

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

int main(){
    int k, n, a[2000000];
    cin >> k >> n;

    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) a[i+n] = a[i] + k;

    int m = 1000000;

    for (int i = 0; i < n; ++i){
        m = min(m, abs(a[i+n-1] - a[i]));
        
    }

    for (int i = 2*n-1; i >= n; --i){
        m = min(m, abs(a[i] - a[i-n+1]));
    
    }

    cout << m << endl;

}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;

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


Measured memory_bytes: 19056
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n,h;
	while(cin>>n>>h,n+h){
		set<pair<int,pii> >in;
		while(h--){
			string s;int a,b;
			cin>>s>>a>>b;a--;b--;
			rep(i,n){
				if(s=="xy")in.insert(pair<int,pii>(a,pii(b,i)));
				else if(s=="xz")in.insert(pair<int,pii>(a,pii(i,b)));
				else if(s=="yz")in.insert(pair<int,pii>(i,pii(a,b)));
			}
		}
		cout<<n*n*n-in.size()<<endl;
	}
}
 

Measured memory_bytes: 4332
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;
typedef pair<ll, ll> Pll; 
#define PI 3.14159265

ll gcd(ll a, ll b) {
	if (a < b) swap(a,b);
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a * (b / gcd(a,b));
}

int main()
{
	ll a, b;
	while (cin>>a>>b) {
		cout << gcd(a,b) << " " << lcm(a,b) << endl;
	}
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a[] = new int[N+1];
		int cnt = 0;
		
		for(int i=1; i<=N; i++) {
			a[i] = sc.nextInt();
//			System.out.println(a[i] % 2);
//			System.out.println(i % 2);
			if (a[i] % 2 == 1 && i % 2 == 1) {
				cnt += 1;
			} 
		}
				
		System.out.println(cnt);
		sc.close();
	}
}

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

const int M = 2e5+10;
ll ans=0;
int n, b[M];
struct psx{int Q, N;} a[M];

inline void init(){
	scanf("%d", &n);
	a[0].N = 1;
	a[n+1].Q = n;
	for(int i = 1, c; i <= n; i++) {
		scanf("%d", &c);
		a[i].Q = i-1;
		a[i].N = i+1;
		b[c] = i;
	}
}

inline void work(){
	for(int i = n; i >= 1; i--) {
		ans += 1LL * i * (b[i] - a[b[i]].Q) * (a[b[i]].N - b[i]);
		a[ a[b[i]].Q ].N = a[b[i]].N;
		a[ a[b[i]].N ].Q = a[b[i]].Q;
	}
}

inline void outo(){
	printf("%lld\n", ans);
}

int main() {
	init();
	work();
	outo();
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N[3][3];
	rep(i,3)
		rep(j,3)
			cin>>N[i][j];
	bool ans=true;
	rep(i,2){
		if(N[0][i+1]-N[0][i]!=N[1][i+1]-N[1][i] || N[1][i+1]-N[1][i]!=N[2][i+1]-N[2][i]) ans=false;
		if(N[i+1][0]-N[i][0]!=N[i+1][1]-N[i][1] || N[i+1][1]-N[i][1]!=N[i+1][2]-N[i][2]) ans=false;
	}
	cout<<(ans?"Yes":"No");
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
//#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int a,b;
    cin >> a >> b;
    int d = b - a;
    cout << d * (d - 1) / 2  - a << endl;

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int H, W;
  cin >> H >> W;
  for(int i = 0; i < W + 2; i++){
  cout << "#";
  }
  cout << endl;
  for(int j = 0; j < H; j++){
  string S;
  cin >> S;
  cout << "#";
  cout << S;
  cout << "#" << endl;
  }
  for(int i = 0; i < W + 2; i++){
  cout << "#";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

using namespace std;
const int MX = 1e6;
const int inf = 1e9;
//const int mod = 1e9+7;
using ll = long long;
const int mod = 1000000007;

ll ans = 0;
int n;
int a;
int x[MX];
ll dp[52][52][3000];
signed main(){
    cin >> n >> a;
    rep(i,n) {
        cin >> x[i+1];
        //cout << x[i+1] << endl;
    }

    dp[0][0][0]=1;
    FOR(j,1,n+1) {
        rep(k,j+1) {
            rep(s,3000) {
                if(k-1>=0 && s-x[j]>=0) dp[j][k][s]= dp[j-1][k-1][s-x[j]]+dp[j-1][k][s];
                else dp[j][k][s] = dp[j-1][k][s];
                
            }
        }
        //cout << j <<" " <<dp[j][1][7] << endl;
    }
    FOR(i,1,n+1) ans += dp[n][i][i*a];
    //cout << dp[1][1][7] << endl;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 61696
# coding: utf-8

# https://atcoder.jp/contests/abc084/tasks/abc084_d
# 18:49-19:10 中断
# 0:21-1:10 done


def prime_set(limit=10**5):
    ret = [2]
    for x in range(3, limit+1, 2):
        is_prime = True
        sqrtx = int(pow(x, 0.5))

        for p in ret:
            if p > sqrtx:
                break

            if x % p == 0:
                is_prime = False
                break

        if is_prime:
            ret.append(x)

    return ret


def bin_search(xs, start, end, x):
    idx = start + (end-start) // 2
    if x < xs[idx]:
        return bin_search(xs, start, idx, x)
    elif x > xs[idx]:
        return bin_search(xs, idx+1, end, x)
    else:
        return idx


def geq_search(xs, start, end, x):
    if end - start < 2:
        if x <= xs[start]:
            return start
        else:
            return start+1

    idx = start + (end-start) // 2

    if x <= xs[start]:
        return start
    elif xs[idx-1] < x <= xs[idx]:
        return idx

    if x < xs[idx]:
        return geq_search(xs, start, idx+1, x)
    elif x > xs[idx]:
        return geq_search(xs, idx, end, x)
    else:
        return idx


def leq_search(xs, start, end, x):
    if end - start < 2:
        if x >= xs[start+1]:
            return start+1
        else:
            return start

    idx = start + (end-start) // 2

    if x >= xs[end-1]:
        return end-1
    elif xs[idx-1] <= x < xs[idx]:
        return idx-1

    if x < xs[idx]:
        return leq_search(xs, start, idx+1, x)
    elif x > xs[idx]:
        return leq_search(xs, idx, end, x)
    else:
        return idx


def main():
    # primes = prime_set(100)
    # print(primes)
    # print(len(primes))
    # print(leq_search(primes, 0, len(primes), 2))
    # print(leq_search(primes, 0, len(primes), 3))
    # print(leq_search(primes, 0, len(primes), 96))
    # print(leq_search(primes, 0, len(primes), 97))
    # exit()

    primes = prime_set()
    primes_set = set(primes)
    len_primes = len(primes)

    Q = int(input())
    l, r = [None] * Q, [None] * Q
    for i in range(Q):
        l[i], r[i] = map(int, input().split())

    # output = 0
    likes = []
    for x in primes[1:]:
        if (x+1) // 2 in primes_set:
            likes.append(x)
    n_likes = len(likes)
    # print(likes)

    for i in range(Q):
        left_idx = geq_search(likes, 0, n_likes, l[i])
        right_idx = leq_search(likes, 0, n_likes, r[i])

        output = right_idx - left_idx + 1 if right_idx >= left_idx else 0
        print(output)

    # for i in range(Q):
    #     output = 0

    #     left, right = l[i], r[i]
    #     while True:
    #         if left in primes_set:
    #             break

    #         left += 2
    #     while True:
    #         if right in primes_set:
    #             break

    #         right -= 2

    #     left_idx = bin_search(primes, 0, len_primes, left)
    #     right_idx = bin_search(primes, 0, len_primes, right)

    #     for x in primes[left_idx:right_idx+1]:
    #         if (x + 1) // 2 in primes_set:
    #             output += 1

    #     print(output)
    # # return output


main()
# print(main())


Measured memory_bytes: 12636
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
 int main(void){
     string S;
     cin >> S;
     bool s=true;
     for(char a=0; a<S.size()-1; a++){
         for(int b=a+1; b<S.size(); b++){
             if(S[b]==S[a]){
                 s=false;
             }
         }
     }
     if(s) cout << "yes" << endl;
     else cout << "no" << endl;
 }

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

int main(){
  long long H, W;
  cin >> H >> W;
  
  if(H == 1 || W == 1){
    cout << 1 << endl;
  }
  
  else if(H * W % 2 == 0){
    cout << H * W / 2 << endl;
  }
  else{
    cout << H * (W-1) / 2 + H / 2 + 1 << endl;
  }
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		int A = Integer.parseInt(tmp[0]);
		int B = Integer.parseInt(tmp[1]);

		if(A<=5){
			System.out.println(0);
		}else if(A<=12){
			System.out.println(B/2);
		}else{
			System.out.println(B);
		}
	}



}


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

#define rep(i,a,b) for(i=(a);i<=(b);++i)
#define rev(i,a,b) for(i=(a);i>=(b);--i)
#define max2(a,b)  ((a)>(b)?(a):(b))
#define min2(a,b)  ((a)<(b)?(a):(b))
#define all(x) x.begin(),x.end()
#define sz(x) (long long)x.size()
#define fi first
#define se second
#define pb emplace_back // push_back
#define mp make_pair
#define endl '\n'

#ifdef Wild4Stone
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.fi); __p(a.se); cout << "}"; }
template<typename T>
void __f(const char* s, T t) { cout << s << " : "; __p(t); }
template<typename T>
void __t(const char* s, const T &x) { cout << s << " : { "; for (auto it : x) __p(it); cout << "} ";}
template<typename T, typename ... F>
void __f(const char* s, T t, F ... f) {
	int i = 0; for (;; ++i) if (s[i] == ',') break;
	cout.write(s, i) << " : "; __p(t); cout << " | "; __f(s + i + 1, f...);
}
#define trace(...) { cout<<"LINE: "<<__LINE__<<" || "; __f(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
#define autra(...) { cout<<"LINE: "<<__LINE__<<" || "; __t(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
#else
#define trace(...) {}
#define autra(...) {}
#endif

typedef long long int ll;
typedef pair<ll, ll> pll;

const ll mod = 1000000007;  //998244353;
const ll inf = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
const double PI = acos(-1);

ll i, j, k;
void solve(void);
inline bool equal(double a, double b) { return fabs(a - b) < eps; }
// inline ll gcd(ll a, ll b) { a=abs(a); b=abs(b); while(a>0 && b>0) (a>b?a%=b:b%=a); return (a==0?b:a); }
// inline ll power(ll x, ll n, ll m = LLONG_MAX)
//        {  ll res=1; x = (x%m + m)%m;
//             while(n) { if(n&1) res=(res*x)%m;  x=(x*x)%m;  n >>= 1; }  return res;
//        }

int main()
{
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(10);
  int t = 1;
  // cin>>t;
  while (t--)  solve();
  return 0;
}

//***************** Code Starts Here *******************//

void solve()
{
	string s; cin>>s;
	if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    
    int d;
    cin >> d;
    if (d == 25){
        cout << "Christmas" << endl;
    }
    if (d == 24){
        cout << "Christmas Eve" << endl;
    }
    if (d == 23){
        cout << "Christmas Eve Eve" << endl;
    }
    if (d == 22){
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc100c()
}

// 各要素に付き、何回2で割れるかの合計を取ればいい
fun abc100c() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map { it.toInt() }

    val answer = aList.map { calc(it) }.sum()

    println(answer)
}

// 何回2で割れるかを計算
private fun calc(a: Int): Int {
    if (a == 0) return 0 // 制約上起きないけど気持ち悪いので

    var temp = a
    var cnt = 0
    while (temp % 2 == 0) {
        temp /= 2
        cnt++
    }
    return cnt
}


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

int main(){
	int n,l;
	cin>>n>>l;
	string s[100];
	REP(i,n) cin>>s[i];
	
	sort(s,s+n);
	
	REP(i,n) cout<<s[i];
	cout<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int N, A[100001];
ll dp[100001][3];
const ll MI = LONG_MIN / 3;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> N;
    cin >> A[0];
    FOR(i, 1, N) {
        char c; cin >> c;
        cin >> A[i];
        if(c == '-')A[i] = -A[i];
    }

    rep(i, N + 1)rep(j, 3)dp[i][j] = MI;

    dp[0][0] = 0;
    rep(i, N) rep(j, 3) if(dp[i][j]>MI){
        for(int nj = 0; nj <= min(j + (A[i]<0), 2); ++nj) {
            smax(dp[i + 1][nj], dp[i][j] + ((j & 1) ? -A[i] : A[i]));
        }
    }

    cout << dp[N][0] << endl;
}

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

int main() {
	int s, m, h;

	cin >> s;

	h = s / 3600;
	s %= 3600;
	m = s / 60;
	s %= 60;


	cout << h << ":" << m << ":" << s << endl;
	
	return 0;
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int m, n;
  map<string, pair<int, int> > mp;
  vector<string> es;

  cin >> m;
  rep(i, m) {
    string name; int lb, ub;
    cin >> name >> lb >> ub;
    mp[name] = make_pair(lb, ub);
  }
  cin >> n;
  es.resize(n);
  rep(i, n) cin >> es[i];

  string ops = "+-*/";
  stack<int> stk;
  vector< unordered_set<int> > vec(n);

  rep(i, n) {
    string e = es[i];

    if(ops.find(e) == -1) {
      if(mp.count(e) == 0) vec[i].insert(stoi(e));
      else reps(j, mp[e].first, mp[e].second+1) vec[i].insert(j);
    } else {
      int bi = stk.top(); stk.pop();
      int ai = stk.top(); stk.pop();
      for(int a : vec[ai]) {
	for(int b : vec[bi]) {
	  int res;
	  if(e == "+") {
	    res = (a + b) % 256;
	  } else if(e == "-") {
	    res = (a - b + 256) % 256;
	  } else if(e == "*") {
	    res = (a * b) % 256;
	  } else if(e == "/") {
	    if(b == 0) {
	      puts("error");
	      return 0;
	    }
	    res = (a / b) % 256;
	  }
	  vec[i].insert(res);
	}
      }
    }
    stk.push(i);
  }

  puts("correct");

  return 0;
}

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

long long md(pair<long long,long long> x,pair<long long,long long> y){
    return max(x.first,y.first)-min(x.first,y.first)+max(x.second,y.second)-min(x.second,y.second);
}

int main(){
    int N;
    cin >> N;
    vector<int> T(N);
    for(int i=0;i<N;i++){
        cin >> T[i];
    }
    int M;
    cin >> M;
    vector<pair<int,int>> vec(M);
    for(int i=0;i<M;i++){
        int P,X;
        cin >> P >> X;
        vec[i]=make_pair(P,X);
    }
    int sum=0;
    for(int i=0;i<N;i++){
        sum+=T[i];
    }
    for(int i=0;i<M;i++){
        int K=sum;
        K-=T[vec[i].first-1];
        K+=vec[i].second;
        cout << K << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define diff(a, b) ((a > b) ? (a - b) : (b - a))

long double	minute_hand_degree(int m)
{
	return ((long double)m * 6);
}

long double	hour_hand_degree(int h, int m)
{
	return ((long double)h * 30 + (long double)m / 2);
}

long double	triangle_len(long double a, long double b, long double degree)
{
	return (sqrt(a * a + b * b - 2 * a * b * cos(degree * M_PI / 180)));
}

int		main(void)
{
	int			A, B, H, M;
	long double	deg, len;

	scanf("%d %d %d %d", &A, &B, &H, &M);
	deg = diff(hour_hand_degree((long double)H, (long double)M), minute_hand_degree((long double)M));
	len = triangle_len((long double)A, (long double)B, deg);
	printf("%20.20Lf\n", len);
	return (0);
}

Measured memory_bytes: 2544
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main()
{
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double result = sqrt(pow(x2-x1, 2)+pow(y2-y1, 2));
    printf("%f\n", result);
    return 0;
}


Measured memory_bytes: 3188