akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cassert>
#include <vector>
#include <algorithm>
#include <complex>
#include <string>
#include <map>
#include <set>
using namespace std;

int h, w, c;
int p[10][10][10];

int dfs(int y, int x, int depth, int from, int to) {
  static const int dy[] = {-1, 0, 1, 0};
  static const int dx[] = {0, -1, 0, 1};
  p[depth][y][x] = to;
  int count = 1;
  for (int i = 0; i < 4; ++i) {
    int ny = y + dy[i], nx = x + dx[i];
    if (ny < 0 || ny >= h || nx < 0 || nx >= w) { continue; }
    if (p[depth][ny][nx] != from) { continue; }
    count += dfs(ny, nx, depth, from, to);
  }
  return count;
}

int calc(int depth) {
  if (depth == 5) {
    return dfs(0, 0, depth, c, 6);
  } else {
    int ret = 0;
    for (int color = 0; color < 6; ++color) {
      if (color == p[depth][0][0]) { continue; }
      memcpy(p[depth+1], p[depth], sizeof(p[depth]));
      dfs(0, 0, depth+1, p[depth+1][0][0], color);
      ret = max(ret, calc(depth+1));
    }
    return ret;
  }
}

int main() {
  while (scanf("%d%d%d", &h, &w, &c), h|w|c) {
    --c;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        scanf("%d", &p[0][i][j]);
        --p[0][i][j];
      }
    }
    printf("%d\n", calc(0));
  }
}

Measured memory_bytes: 0
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,k = inpm()
a = inpl()

for i in range(n - k):
    if a[i + k] > a[i]:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 52736
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <algorithm>

typedef long long ll;

using namespace std;
int main()
{
  string s;
  cin >> s;
  char c = 'a';
  for (int i=0;i<4;i++)
  {
    if (c == s[i]) {
      printf("Bad\n");
      return 0;
    }
    c = s[i];
  }
  printf("Good\n");
  return 0;
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
cnt = 0
for i in range(0, N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            ssum = L[i] + L[j] + L[k]
            mmax = max(L[i], L[j], L[k])
            if mmax < ssum - mmax and L[i] != L[j] and L[j] != L[k] and L[i] != L[k]:
                cnt += 1

print(cnt)

Measured memory_bytes: 9204
#include <iostream>
#include <vector>

using namespace std;

int main() {
    unsigned long long n;
    cin >> n;
    vector<unsigned long long> a(n);
    for (size_t i = 0; i < n; ++i) cin >> a[i];
    bool isGE = false;
    bool isLE = false;
    unsigned long long counter = 1;
    for (size_t i = 0; i < n - 1; ++i) {
        if (!isGE && !isLE) {
            if (a[i] > a[i + 1]) isLE = true;
            else if (a[i] < a[i + 1]) isGE = true;
        }
        else if (isGE) {
            if (a[i] <= a[i + 1]) continue;
            else {
                isGE = false;
                ++counter;
            }
        }
        else if (isLE) {
            if (a[i] >= a[i + 1]) continue;
            else {
                isLE = false;
                ++counter;
            }
        }
    }
    cout << counter << endl;
    return EXIT_SUCCESS;
}

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

namespace ITP1_4_D
{
	class Program
	{
		static void Main(string[] args)
		{
			int.Parse(Console.ReadLine());

			string[] buf = Console.ReadLine().Split(' ');
			List<long> vs = new List<long>();
			foreach(string s in buf) {
				vs.Add(long.Parse(s));
			}

			Console.WriteLine($"{vs.Min()} {vs.Max()} {vs.Sum()}");
		}
	}
}



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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (b / a <= c) cout << b / a << endl;
  else cout << c << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;

struct Process {
  char name[10];
  int time;

  void print() {
    printf("name: %s, time: %d\n", name, time);
  }
};

template <typename M>
struct Queue {
  vector<M> members;
  int push_index = 0;

  void push(M m) {
    members.push_back(m);
    push_index++;
  }

  M pop() {
    M m = members[0];
    rotate(members.begin(), members.begin() + 1, members.end());
    members.pop_back();
    push_index--;
    return m;
  }

  int size() {
    return push_index;
  }

  bool empty() {
    return push_index == 0;
  }
};

void print(Queue<Process> queue, int n) {
  printf("[ ");
  for (int i = 0; i < queue.size(); i++) {
    Process p = queue.members[i];
    printf("[ %s %d ] ", p.name, p.time);
  }
  printf("]\n");
}

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

  Queue<Process> processes;

  for (int i = 0; i < n; i++) {
    Process p;
    scanf("%s %d", &p.name, &p.time);
    processes.push(p);
  }

  int time_consumed = 0;
  while (!processes.empty()) {
    Process p = processes.pop();
    if (p.time <= q) {
      time_consumed += p.time;
      printf("%s %d\n", p.name, time_consumed);
    } else {
      p.time -= q;
      time_consumed += q;
      processes.push(p);
    }
  }

  return 0;
}



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

int main(){
  char s[100];
  scanf("%s",s);
  if(strcmp(s,"AAA")==0||strcmp(s,"BBB")==0){
    printf("No");
  }else{
    printf("Yes");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;

int f(int x){
  return x*x ;
}


int main(){
  int d;
  while(cin >>d){
    int sum = 0;
    int x=0;
    while(x < 600){
      sum+=f(x)*d;
      x+= d;
    }
    cout << sum <<endl;
  }
}

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

typedef long long ll;
const int MAX_N = 100000;

int main() {
  int N, p[MAX_N];
  std::cin >> N;
  for(int i = 0; i < N; ++i) {
    std::cin >> p[i];
  }

  int ans = 0;
  for(int i = 0; i < N; ++i) {
    if(p[i] == i + 1) {
      if(i + 1 < N) {
        std::swap(p[i], p[i + 1]);
        ++ans;
      } else {
        std::swap(p[i - 1], p[i]);
        ++ans;
      }
    }
  }
  std::cout << ans << std::endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

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

    const string s[10] = {"pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon"};

    int n;
    cin >> n;

    cout << s[n%10] << endl;

    return 0;
}


Measured memory_bytes: 3648
def get():
    a=input()
    b=[int(i) for i in a.split()]
    return b[0],b[1]

n,q=get()
s=input()

a=[0]
b=[]

for i in range(n-1):
    if s[i:i+2]=="AC":
        a.append(a[-1]+1)
        b.append(1)
    else:
        a.append(a[-1])
        b.append(0)

for i in range(q):
    l,r=get()
    l-=1
    r-=1
    print(a[r]-a[l])


Measured memory_bytes: 6976
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define x first
#define y second
#define pb push_back
#define ll long long
#define ld long double
#define ii pair<int, int>
#define iii pair<int, ii>
#define vi vector<int>
#define vii vector<ii>
#define pq priority_queue
using namespace std;
const int ms = 2e5+100;
const int mod = 1e9+7;
const int inf = 1e9;
const int sigma = 30;
int n, m, k, t = 1;

int dp[ms];
int ele[ms];

void solve(){
  cin>>n>>k;
  for(int i=0; i<n; i++){
    cin>>ele[i];
    dp[i] = inf;
  }
  dp[0] = 0;
  for(int i=0; i<n; i++){
    for(int j = i+1; j<min(i+k+1, n); j++){
      dp[j] = min(dp[j], dp[i] + abs(ele[i] - ele[j]));
    }
  }
  cout<<dp[n-1]<<endl;
  
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  while(t--){
    solve();
  }
}

Measured memory_bytes: 1024
import sys

def _i(): return int(sys.stdin.readline().strip())


def gcd(x, y):
    if x < y:
        x, y = y, x
    if x % y == 0:
        return y
    else:
        return gcd(y, x % y)


def main():
    a = _i()
    return 360 // gcd(360, a)


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 61700
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()

using namespace std;
ll n,m,x,y,mn,cnt;
double a[1005],p[1005];
multiset <int> st;
vector <int> v;
string s,c[10];
const double P = acos(-1.0);
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("collect.in", "r", stdin);
    //freopen("collect.out", "w", stdout);
    cin >> n;
    cnt += (n / 500) * 1000;
    n %= 500;
    if (n >= 5){
        cnt += (n / 5) * 5;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int MN=200000+5,P=1000000007;
using namespace std;
typedef long long ll;
template<typename T>inline T&IN(T&in){
	in=0;char c=getchar();int f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))in=in*10+c-'0',c=getchar();
	return in*=f;
}
int n,ans;
int c[MN],f[MN],h[MN];
void input(){
	IN(n);
	f[0]=1;
	for(int i=1;i<=n;++i){
		IN(c[i]);
		if(c[i-1]!=c[i]){
			f[i]=(f[i-1]+h[c[i]])%P;
		}
		else f[i]=f[i-1];
		h[c[i]]=f[i];
	}
	printf("%d\n",f[n]);
}
int main(){
	input();
	return 0;
}

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

int main()
{
  int N;

  cin >> N;

  int ret = 0;

  for(int c=1; c<N; ++c){
    for(int a=1; a*a<=N-c; ++a){
      if((N-c)%a == 0){
        ++ret;

        if((N-c)/a != a) ++ret;
      }
    }
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
int main(void){
  int num,i;
  scanf("%d",&num);
  char str[100];
  scanf("%s",str);
  if(strlen(str)<=num){
    printf("%s",str);
  }else{
    for(i=0;i<num;i++){
      printf("%c",str[i]);
    }
    printf("...");
  }
  return 0;
}

Measured memory_bytes: 1732
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
const ll mod = 1000000007;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<int> k(n);
  int s[3] = {0, 0, 0};
  rep(i, n) {
    int cnt = 0;
    int nc = 4;
    rep(col, 3) {
      if(s[col] == a[i]) {
        cnt++;
        nc = min(nc, col);
      }
    }
    k[i] = cnt;
    if(nc > 3) break;
    dbg(nc);
    s[nc]++;
  }
  ll ans = 1LL;
  rep(i, n) ans = (ans * k[i]) % mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#include <numeric>
#include <stdio.h>
#include <map>
#include <iomanip>
#include <sstream>
//#include <boost/math/common_factor_rt.hpp>
#include<fstream>
#define EPS (1e-7)
using namespace std;
#define ll long long



class Employee {
public:
	int id;
	int parent;
	vector<int> children;
	int salary;

	Employee() {
		
	}

	Employee(int num, int nparent) {
		id = num;
		parent = nparent;
		salary = -1;
	}



};



template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}



int main() {

	string S,T;
	cin >> S >> T;

	int ans = 0;
	for (auto i = 0; i < 3; i++)
	{
		if (S[i] == T[i]) ans += 1;
	}

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

Measured memory_bytes: 760
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    long H = scan.nextInt();
    long W = scan.nextInt();
    scan.close();

    if(H == 1 || W == 1) {
      System.out.println(1);
    }
    else if(H%2 == 0) {
      System.out.println((H/2) * W);
    }
    else {
      System.out.println(H * (W/2) + ((H+1)/2) * (W%2));
    }
  }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

const ll mod=1000000007LL;
ll x[100010];
ll fact[100010];

int main(void){
	ll n;
	cin >> n;
	rep(i,n) cin >> x[i];

	fact[0]=1LL;
	rep(i,1,n+1) fact[i]=1LL*i*fact[i-1]%mod;

	ll ans=1LL,used=0LL;
	x[n]=1LL<<30;

	int pos=0;
	while(pos<n){
		while(pos < n and 2*(pos-used)<x[pos]) pos++;
		pos++;
		if(n<=pos) break;
		ans=1LL*ans*(pos-used)%mod;
		used++;
	}

	ans=1LL*ans*fact[n-used]%mod;;
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main()
{
    char stringS[110],stringT[110],string[220];
    scanf("%s",stringS);
    scanf("%s",stringT);
    int i=0,j,v,flag=1;
    while(stringT[i]!='\0')
    {
        string[i]=stringS[i];
        i++;
    }
    for(j=0;stringS[j+1]!='\0';j++,i++)
    {
        string[i]=stringS[j];
    }
    for(i=0;string[i]!='\0';i++)
    {
        if(string[i]==stringT[0])
        {

            v=i+1;
            for(j=1;stringT[j]!='\0';j++,v++)
            {

                if(string[v]!=stringT[j])
                {
                    flag=0;
                    break;
                }
            }
            if(flag==1)
            {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
from bisect import *

n = int(input())
(*A, ) = map(int, input().split())
(*B, ) = map(int, input().split())
S = [A[i] - B[i] for i in range(n)]
if sum(S) < 0:
    print(-1)
    exit()
S.sort()
neg = bisect_left(S, 0)
pos = bisect_right(S, 0)
ne = sum(S[:pos])
rui = [0]
for i in reversed(S[pos:]):
    rui.append(rui[-1] + i)
print(neg + bisect_left(rui, -ne))


Measured memory_bytes: 24308
#include<bits/stdc++.h>
#include<string>
typedef long long ll;
const int mod = 1e9 + 7;
using namespace std;

void solve() {
	ll n; 
	cin >> n;
	ll xxor = 0;
	int arr[n];
	for(int i = 0; i < n; ++i) {
		int x; 
		cin >> x;
		arr[i] = x;
		xxor ^= x;
		}
		ll ans = 0;
		for(int i = 0; i < n; ++i) {
			ans = xxor ^ arr[i];
			cout << ans << " ";
			}
			cout << endl;
}

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.precision(20);
		solve();
	return 0;
}
 















Measured memory_bytes: 4260
#include <cstdint>
#include <iostream>

using namespace std;

int main() {
  int64_t r, D, x;
  cin >> r >> D >> x;
  
  for (int i = 1; i <= 10; ++i) {
    x = r * x - D;
    cout << x << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3584
# Problem - 標準偏差

import math

while True:
    # input
    n = int(input())
    if n==0:
        break
    s_list = list(map(int, input().split()))

    # initialization
    average = sum(s_list) / n
    dispersion = 0
    for i in range(n):
        dispersion += (s_list[i] - average)**2
    dispersion = dispersion / n
    ans = math.sqrt(dispersion)

    # output
    print(ans)



Measured memory_bytes: 5696
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    h, w = nm()
    s = [['.'] * (w+1)]
    for _ in range(h):
        temp = ['.']
        temp.extend(list(ns()))
        temp.extend(['.'])
        s.append(temp)
    s.append(['.'] * (w+1))

    flag = True
    for i in range(1, h+1):
        for j in range(1, w+1):
            if (
                s[i][j] == '#' and
                s[i-1][j] == '.' and
                s[i][j-1] == '.' and
                s[i+1][j] == '.' and
                s[i][j+1] == '.' 
            ):
                flag = False

    print('Yes' if flag else 'No')
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
char s[600005],c,s1[600005]; long long f,q,t,z=0,l,r,i;
int main()
{

 cin>>s1;
 for(i=0;i<strlen(s1);i++)
 {
  s[i+250000]=s1[i];
 }
 l=250000;
 r=l+strlen(s1)-1;
 cin>>q;
 while(q--)
 {
  cin>>t;
  if(t==1)
  {
   z++;
  }
  if(t==2)
  {
   cin>>f;
   if(f==1)
   {
    cin>>c;
    if(z%2==0)
    {
     l--;
     s[l]=c;
    }
    if(z%2==1)
    {
     r++;
     s[r]=c;
    }
   }
   if(f==2)
   {
    cin>>c;
    if(z%2==0)
    {
     r++;
     s[r]=c;
    }
    if(z%2==1)
    {
     l--;
     s[l]=c;
    }
   }
  }
 }
 if(z%2==0)
 {
  for(i=l;i<=r;i++)
   cout<<s[i];
 }
 else
 {
  for(i=r;i>=l;i--)
   cout<<s[i];
 }
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int hs[n];
    for (auto i = 0; i < n; i++) {
        cin >> hs[i];
    }
    auto val = 0;
    for (auto i = 0; i < n; i++) {
        bool visible = true;
        for (auto j = 0; j < i; j++) {
            if (!(hs[j] <= hs[i])) {
                visible = false;
                break;
            }
        }
        if (visible) {
            val += 1;
        }
    }
    cout << val;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    REP(i, n){
        cin >> a.at(i);
    }
    REP(i, m){
        cin >> b.at(i);
    }

    vector<ll> cb(m);
    REP(i, m){
        cb.at(i) = b.at(i);
        if(i > 0){
            cb.at(i) += cb.at(i - 1);
        }
    }

    ll ans = 0;
    ll cur_total = 0;
    REP(i, n + 1){
        const ll rest = k - cur_total;
        const ll j = upper_bound(ALL(cb), rest) - cb.begin();
        if(j == 0){
            ans = max(ans, i);
        }else{
            ans = max(ans, i + j);
        }
        if(i < n){
            cur_total += a.at(i);
            if(cur_total > k){ break; }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8012
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <deque>
#include <cstdio>
using namespace std;

bool cmp(pair<int,double> A ,pair<int,double> B){
	return A.second < B.second;
}
int main(){
	int t;
	double td;
	deque < pair<int,double> > a;
	vector< pair<int,double> > b;
	vector< pair<int,double> > ret;
	for(int i=0;i<8;i++){
		cin >> t >> td;
		a.push_back(make_pair(t,td));
	}
	sort(a.begin(),a.end(),cmp);
	ret.push_back(a[0]);a.pop_front();
	ret.push_back(a[0]);a.pop_front();
	for(int i=0;i<6;i++){
		b.push_back(a[i]);
	}
	a.clear();
	for(int i=0;i<8;i++){
		cin >> t >> td;
		a.push_back(make_pair(t,td));
	}
	sort(a.begin(),a.end(),cmp);
	ret.push_back(a[0]);a.pop_front();
	ret.push_back(a[0]);a.pop_front();
	for(int i=0;i<6;i++){
		b.push_back(a[i]);
	}
	a.clear();
	for(int i=0;i<8;i++){
		cin >> t >> td;
		a.push_back(make_pair(t,td));
	}
	sort(a.begin(),a.end(),cmp);
	ret.push_back(a[0]);a.pop_front();
	ret.push_back(a[0]);a.pop_front();
	for(int i=0;i<6;i++){
		b.push_back(a[i]);
	}
	sort(b.begin(),b.end(),cmp);
	for(int i=0;i<2;i++){
		ret.push_back(b[i]);
	}
	for(int i=0;i<ret.size();i++){
		printf("%d %.2lf\n",ret[i].first,ret[i].second);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())

int n;
string s;

void init() {

}

void input() {
	cin >> n >> s;
}

void solve() {
	int res = 0;
	REP(i, n) {
		int l[26], r[26];
		MSET(l, 0);
		MSET(r, 0);
		REP(j, i) l[s[j]-'a']++;
		FOR(j, i, n) r[s[j]-'a']++;
		int tmp = 0;
		REP(j, 26) if(l[j]>0 && r[j]>0) tmp++;
		chmax(res, tmp);
	}
	cout << res << endl;
}

int main() {
	init();
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
x,y,z,k = map(int,input().split())
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
    for nu in lisa:
        an.append(num+nu)
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for num in lisc:
    for nu in an:
        ans.append(num+nu)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])
#sample code.

Measured memory_bytes: 160340
N = int(input())
A, B = (int(i) for i in input().split())
P = list(map(int, input().split()))
P.sort()
num1 = 0
num2 = 0
num3 = 0
for i in range(len(P)):
    if P[i] <= A:
        num1 = i + 1
    elif P[i] > A and P[i] <= B:
        num2 = i + 1 - num1
    elif P[i] > B:
        num3 = N - num1 - num2
        break
print(min([num1, num2, num3]))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

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

//------------------------------------------------
int main(){
  int n,ans;
  ans=0;
  cin>>n;
  int p[n];
  rep(i,0,n) cin>>p[i];
  rep(i,1,n-1){
    if(p[i-1]<p[i]&&p[i]<p[i+1]) ans+=1;
    if(p[i+1]<p[i]&&p[i]<p[i-1]) ans+=1;
    if(p[i-1]==p[i+1]&&p[i]<p[i-1]) ans+=1;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*
AC
h2*w2内の総和がどこを見ても-1になるようにする
正の部分と負の部分を偏らせる（大きい数字を左上に寄せて，小さい数字が右下に来るようにする）
*/


int main(void){
	bool ok=true;
	ll h,w,h2,w2,ans[510][510];
	cin>>h>>w>>h2>>w2;
	if(h%h2==0 && w%w2==0)ok=false;
	rep(i,h)rep(j,w)ans[i][j]=0;
	rep(i,h/h2+1)rep(j,w/w2+1)ans[i*h2][j*w2]=9999;
	reg(i,1,h/h2)reg(j,1,w/w2)ans[i*h2-1][j*w2-1]=-10000;
	if(ok){
		cout<<"Yes"<<endl;
		rep(i,h){
			rep(j,w)cout<<ans[i][j]<<" ";
			cout<<endl;
		}
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3712
n=int(input())
A=[[0]*2 for i in range(n)]
for i in range(n):
  A[i][0]=int(input())
  A[i][1]=i%2
A.sort(key=lambda x:x[0])
ans=0
for i in range(n):
  if i%2==0:
    ans=ans+A[i][1]
print(ans)

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

using namespace std;

using ll = long long;

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

    ll L, R;
    cin >> L >> R;

    ll min_v = 2018;
    R = min(L + 2019, R);
    for (ll i = L; i < R; ++i)
        for (ll j = i + 1; j <= R; ++j)
            min_v = min(min_v, (i * j) % 2019);

    cout << min_v << endl;

    return 0;
}


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

int main(){
  int L1 , L2 , R1 , R2;
  
  cin >> L1 >> L2 >> R1 >> R2;
  
  if (L1 + L2 == R1 + R2){
    cout << "Balanced" << endl;
  } else if (L1 + L2 > R1 + R2){
    cout << "Left" << endl;
  } else if (L1 + L2 < R1 + R2){
    cout << "Right" << endl;
  }
}
  

Measured memory_bytes: 256
import java.util.ArrayDeque

fun main() {
    val builder = StringBuilder()

    val n = readInputLine().toInt()

    val aArr = readInputLine().split(" ").map { it.toInt() }

    val edges = Array(n) { mutableListOf<Int>() }

    repeat(n - 1) {
        val (u, v) = readInputLine().split(" ").map { it.toInt() - 1 }
        edges[u].add(v)
        edges[v].add(u)
    }

    val ans = IntArray(n)
    val dp = IntArray(n) { Int.MAX_VALUE }

    // (親, ノード, 深さ)のstack
    val stack = ArrayDeque<Triple<Int, Int, Int>>()
    // 巻き戻し用(index, 値, 深さ)のstack
    val rollbackStack = ArrayDeque<Triple<Int, Int, Int>>()

    stack.addFirst(Triple(-1, 0, 0))

    while (stack.isNotEmpty()) {
        val (parent, node, depth) = stack.pollFirst()

        while (rollbackStack.isNotEmpty() && rollbackStack.peekFirst().third >= depth) {
            val (index, value, _) = rollbackStack.pollFirst()
            dp[index] = value
        }

        val writeIndex = lowerBound(dp, aArr[node])

        rollbackStack.addFirst(Triple(writeIndex, dp[writeIndex], depth))

        dp[writeIndex] = aArr[node]

        ans[node] = lowerBound(dp, Int.MAX_VALUE)

        for (e in edges[node]) {
            if (e != parent) {
                stack.addFirst(Triple(node, e, depth + 1))
            }
        }
    }

    for (a in ans) {
        builder.appendln(a)
    }

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}

fun lowerBound(arr: IntArray, value: Int): Int {
    var l = -1
    var r = arr.size

    while (r - l > 1) {
        val mid = (r + l) / 2
        if (arr[mid] >= value) {
            r = mid
        } else {
            l = mid
        }
    }

    return r
}


Measured memory_bytes: 107036
var n,i,j,k,num:longint;
begin
  read(n);
  for i:=1 to 3500 do
  for j:=i to 3500 do
  begin
    if (4*i*j-n*i-n*j)<=0 then continue;
    num:=trunc((n*i*j)/(4*i*j-n*i-n*j));
  if ((n*i*j)/(4*i*j-n*i-n*j)=num) then begin writeln(i,' ',j,' ',num);exit;end;
  end;
end.

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int main()
{
	int num;
	scanf("%d", &num);
	string s[2];
	cin >> s[0] >> s[1];
	ll ans = 1;
	int mode = -1;
	for (int i = 0; i < s[0].size(); i++)
	{
		if (mode == -1)
		{
			if (s[0][i] == s[1][i])mode = 0, ans *= 3;
			else mode = 1, ans *= 6;
		}
		else if (mode == 0)
		{
			if (s[0][i] == s[1][i])mode = 0, ans *= 2;
			else mode = 1, ans *= 2;
		}
		else if (mode == 1)
		{
			mode = 2;
		}
		else
		{
			if (s[0][i] == s[1][i])mode = 0;
			else mode = 1, ans *= 3;
		}
		ans %= mod;
	}
	printf("%lld\n", ans);
}

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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    if(s[n-1] == 's') cout << s << "es" << endl;
    else cout << s << "s" << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#define MAX 500000
int A[MAX];
int H;

void swap(int *a,int *b){
  int c=*a;*a=*b;*b=c;
}

void maxHeapify(int *A,int i){//iと子供だけを整列させる、下が小さい、左小さい、右大きい
 int l = 2*i;
  int r = 2*i+1;
  int largest;
  // 左の子、自分、右の子で値が最大のノードを選ぶ
  if(l <= H && A[l] > A[i])largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest])largest = r;

  // i の子の方が値が大きい場合//子供と、その子孫を再帰的に治す
    if(largest != i){
	swap(&A[i],&A[largest]); 
	maxHeapify(A, largest); // 再帰的に呼び出し
      }
}

      
void buildMaxHeap(int *A){
  int i;
  for (i = H/2;i>= 1;i--)maxHeapify(A, i);//最後の親からだんだん頂上へ範囲を広げる
}

int main(){
  int n;
  int i;
  int x;
  
  scanf("%d",&n);
  H=n+1;//１オリジン
  for(i=1;i<H;i++){
      scanf("%d",&A[i]);
    }

  buildMaxHeap(A);

  for(i=1;i<H;i++){
      printf(" %d",A[i]);
    }

  printf("\n");
  return 0;
}




Measured memory_bytes: 3688
n,x = map(int,input().split())
dp_a=[1]
dp_p=[1]
for i in range(1,n):
  dp_a.append(2*dp_a[i-1] + 3)
  dp_p.append(2*dp_p[i-1] + 1)  
  
def burger(n,x):
  if n==0:
    if x <= 0:      
      return 0
    else:
      return 1
    
  if x <= dp_a[n-1]+1:
    return burger(n-1, x-1)
  else:
    return dp_p[n-1] +1 +burger(n-1, x-dp_a[n-1]-2)  

print(burger(n,x))

Measured memory_bytes: 3064
from collections import OrderedDict

N, M = [int(x) for x in input().split()]
AB = sorted([[int(x) for x in input().split()] for _ in range(N)], key=lambda x: x[0])

y = 0
for ab in AB:
    n = min(ab[1], M)
    y += ab[0] * n
    M -= n

    if M == 0:
        break
print(y)


Measured memory_bytes: 23864
S=list(input())
F=int(''.join(S[0:2]))
B=int(''.join(S[2:4]))
if 0<F<13:
  if 0<B<13:
    ans='AMBIGUOUS'
  else:
    ans='MMYY'
else:
  if 0<B<13:
    ans='YYMM'
  else:
    ans='NA'
print(ans)
  

Measured memory_bytes: 2940
stdin = open(0).read().split('\n')
N = int(stdin[0])
X = list(map(int,stdin[1].split()))
min=9999999
for i in range(1,101):
    sum=0
    for j in range(len(X)):
        sum+=(i-X[j])**2
    if sum<min:min=sum
print(min)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
// rep(i, 1, 4) --> {1,2,3,4}
// rep(i, 4, 1) --> {4,3,2,1}
// rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<pair<int,int>> v;
    vector<int> a(n, -1);
    rep(i, 0, m)
    {
        int s, c;
        cin >> s >> c;
        v.push_back({s, c});
    }
    bool ans = true;
    
    rep(i, 0, v.size())
    {
        int index = v[i].first-1;
        int number = v[i].second;
        if (a[index] == -1)
            a[index] = number;
        else 
            if (a[index] != number)
            ans = false;
    }
    if (n != 1 && a[0] == 0)
        ans = false;
    if (n==1 && m==0)
        return cout << 0, 0;
    if (ans == false)
        cout << -1;
    else 
        rep(i, 0, a.size())
        {
            if (a[i] == -1 && i==0)
                cout << 1;
            else if ((a[i] == -1 && i!=0))
                cout << 0;
            else 
                cout << a[i];
        }
    return 0;
}

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

int main() {
	int n,m;
	cin >> n >> m;
	cout << (n-1) * (m-1) << endl;
	return 0;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    for(int i = 0; i < 20; i++){
        if(n < (1 << (i + 1))) {
            cout << (1 << i) << "\n";
            break;
        }
    }
    return 0;
}


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

using namespace std;
 
#define endl '\n'
#define ll long long
#define int long long
const int32_t INFint = 1e9;
const ll INFll = 1e18;
#define MOD 1000000007ll
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define foreach(it,v) for( __typeof((v).begin())it = (v).begin() ; it != (v).end() ; it++ )
 
#define deb1(x)                cout<<#x<<": "<<x<<endl
#define deb2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
#define For(i, a, b) for (ll i = a; i < b; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define gll(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define gint(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define setZero(a,n) for(int i=0;i<n;i++) a[i]=0;
#define printArray(a,s,e) for(int i=s;i<e;i++) {cout << a[i] << " ";} cout << endl;
//---------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------------------------- 
int32_t main(){fast;
	int a,b,c;
	cin >> a >> b >> c;
	int ans;
	ans = ((c - a + b) > 0) ? c + b - a : 0;
	cout << ans << endl;
}
 
 
 
 
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
using namespace std;

int main(){
	int n, k;
	while(1){
		scanf("%d %d", &n, &k);
		if(n == 0 && k == 0) break;

		vector<int> a;
		for(int i=0; i<n; i++){
			int tmp;
			scanf("%d", &tmp);
			a.push_back(tmp);
		}
		int ans = 0;
		for(int i=0; i<k; i++){
			ans += a[i];
		}
//		printf("%d\n", ans);
		int temp = ans;
		for(int i=0; i+k<n; i++){
			temp -= a[i];
			temp += a[i+k];
			ans = max(ans, temp);
//			printf("%d %d\n", temp, ans);
		}
		printf("%d\n", ans);

	}

	return 0;
}

Measured memory_bytes: 1564
/*input
2 0
*/
#include "bits/stdc++.h"
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;
int len(int k){
	return k?1+len(k/2):0;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	long long q,m,k,h,ans=0,sum=0,p,x,y;
	cin>>m>>k;
	if(len(k)>m || (m==1 && k==1)) cout<<"-1";
	else if(!k ){
		for(int i=0;i<(1<<m);++i)
			cout<<i<<' '<<i<<' ';
	}
	else{
		cout<<k<<' ';
		for(int i=0;i<(1<<m);++i) if(i!=k) cout<<i<<' ';
		cout<<k<<' ';
		for(int i=(1<<m);i--;) if(i!=k) cout<<i<<' ';
	}
}

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

using namespace std;

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

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

int can[110000];
int cnt[110000];
int n,m;

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) {
		cnt[i] = 1;
	}
	can[0] = 1;

	for (int i = 0; i < m; i++) {
		int x,y;
		scanf("%d %d", &x ,&y); x--; y--;

		if (can[x]) can[y] = 1;
		if (cnt[x]==1) can[x] = 0;
		cnt[x]--;
		cnt[y]++;
	}

	int ans = 0;
	for (int i = 0; i < n; i++) ans += can[i];
	printf("%d\n", ans);
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
using ull = unsigned long long;
#define rep(i,n) for(ull i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<ull> a(n);rep(i,n){cin>>a[i];}
#define in(a) ull a;cin>>a;
int main()
{
	in(n);
	int max1 = 0;
	int max2 = 0;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (max1 < a[i]) {
			max2 = max1;
			max1 = a[i];
		}
		else if (max2 < a[i]) {
			max2 = a[i];
		}
	}

	for (int i = 0; i < n; i++) {
		if (a[i] < max1) {
			printf("%d\n", max1);
		}
		else {
			printf("%d\n", max2);
		}
	}
}


Measured memory_bytes: 2432
array =  []
n = gets.to_i
array = gets.chomp.split(" ").map(&:to_i)

max = 0
min = 10**9
for i in 0...n
  if array[i] > max
    max = array[i]
  end
  if array[i] < min
    min = array[i]
  end
end
puts max - min


Measured memory_bytes: 3836
str_list = input().split()
num_list =  [int(i) for i in input().split()]
del_boll = input()

boll_dic = {str_list[0]:num_list[0],str_list[1]:num_list[1]}
boll_dic[del_boll] -= 1

print(boll_dic[str_list[0]],boll_dic[str_list[1]])

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0.0));
    dp[0][0] = 1.0;
    for (int i = 1; i < n + 1; i++) {
        double p;
        cin >> p;
        for (int j = 0; j < n + 1; j++) {
            if (j == 0) dp[i][j] = dp[i - 1][j] * (1.0 - p);
            dp[i][j] = dp[i - 1][j] * (1.0 - p) + dp[i - 1][j - 1] * p;
        }
    }
    double ans = 0.0;
    for (int j = (n + 1) / 2; j < n + 1; j++) { ans += dp[n][j]; }
    cout << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 70784
n,k=map(int,input().split())
P=list(map(int,input().split()))

S=[0]*(n+1)
S[1]=P[0]
for i in range(2,n+1):
        S[i]=S[i-1]+P[i-1]
ma=0
for i in range(k,n+1):
       s=S[i]-S[i-k]
       if ma<s:
              ma=s
print((ma+k)/2)

Measured memory_bytes: 71792
N = int(input())
l = [int(i) for i in input().split()]
l.sort()
if N < 3:
    s = (l[0] + l[1]) / 2
else:
    s = (l[0] + l[1]) / 2
    for i in range(2, N):
        s = (s + l[i]) / 2
print(s)

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

using namespace std;

int main()
{
    string S;
    cin >> S;
    if(S[2]==S[3] && S[4]==S[5])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

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

void printArray(int a[], int n) {
    string sep = "";
    for (int i = 0; i < n; i++) {
        cout << sep << a[i];
        sep = " ";
    }
    cout << endl;
}

void insertionSort(int a[], int n) {
    printArray(a, n);

    for (int i = 1; i < n; i++) {
        int v = a[i];
        int j = i - 1;

        while (j >= 0 && v < a[j]) {
            a[j+1] = a[j];
            j--;
        }

        a[j+1] = v;

        printArray(a, n);
    }
}

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

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

    insertionSort(a, n);
}

Measured memory_bytes: 3112
<?php
list($n,$k)=explode(' ',trim(fgets(STDIN)));
$h=explode(' ',trim(fgets(STDIN)));
if($n<=$k){
  echo $h[$n-1]-$h[0];
  exit;
}
$ans[0]=0;
$ans=array_pad($ans,$n,1000000007);
$i=1;
while($i<$k){
  $ans[$i]=abs($h[$i]-$h[0]);
  ++$i;
}
while($i<$n){
  $j=1;
  while($j<=$k){
    $c=$ans[$i-$j]+abs($h[$i]-$h[$i-$j]);
    if($ans[$i]>$c){
      $ans[$i]=$c;
    }
    ++$j;
  }
  ++$i;
}
echo $ans[$n-1];

Measured memory_bytes: 16884
#include<bits/stdc++.h>
using namespace std;
int a,b,k;
int main() {
	scanf("%d%d%d",&k,&a,&b);
	for(int i=0;i<=1000;i+=k) {
		if(a<=i&&i<=b) return printf("OK"),0;
	}
	printf("NG");
	return 0;
} 

Measured memory_bytes: 3748
N,D=(int(x) for x in input().split())
data_list=[]

for i in range(N):
    row=[]
    data=input().split()
    for j in data:
        row.append(int(j))
    data_list.append(row)

count=0
for i in range(N-1):
    for j in range(i+1,N):
        a=data_list[i]
        b=data_list[j]
        square=0
        for k in range(D):
            square+=(a[k]-b[k])**2
        index=1
        while (True):
            if(index*index>square):
                break
            elif(index*index==square):
                count+=1
                break
            else:
                index+=1

print(count)



Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
int read()
{
    int x = 0,f = 0;char c = getchar();
    while(!isdigit(c)){if(c=='-')f=1;c=getchar();}
    while(isdigit(c)){x=x*10+c-'0';c=getchar();}
    return f?-x:x;
}
const int N = 2e5 + 1000,mod = 998244353;
int n,m,Pow[N][12],lazy[N<<2],t[N<<2];
void push(int u,int l,int r) {
    if(lazy[u]) {
        int d = lazy[u],mid = l + r >> 1;
        lazy[u<<1|1] = lazy[u<<1] = d;
        t[u<<1] = Pow[mid-l+1][d];
        t[u<<1|1] = Pow[r-mid][d];
        lazy[u] = 0;
    }
}
void change(int u,int l,int r,int L,int R,int val) {
    if(r < L || l > R) return;
    if(L <= l && r <= R) {
        t[u] = Pow[r-l+1][val];lazy[u] = val;return;
    }
    // cout << u <<" "<<l<<" "<<r << endl;
    push(u,l,r);
    int mid = l + r >> 1;
    change(u<<1,l,mid,L,R,val);change(u<<1|1,mid+1,r,L,R,val);
    t[u] = (1LL * t[u<<1] * Pow[r - mid][10] % mod + t[u<<1|1]) % mod;
}
void build(int u,int l,int r) {
    if(l==r) {
        t[u] = 1;return;
    }
    // cout << "now "<< u << " " << endl; 
    int mid = l + r >> 1;
    build(u<<1,l,mid);build(u<<1|1,mid+1,r);
    t[u] = (1LL * t[u<<1] * Pow[r - mid][10] % mod + t[u<<1|1]) % mod;
}
int main()
{
    n = read();m = read();
   
    Pow[0][10] = 1;
    for(int i = 1;i <= n;i++) {
        for(int j = 1;j < 10;j++) Pow[i][j] = (10LL * Pow[i-1][j] % mod + j) % mod;
        Pow[i][10] = 10LL * Pow[i-1][10] % mod; 
    } 
    build(1,1,n);
    while(m--)
    {
        int a = read(),b = read(),c = read();
        // cout << "deg "<< t[1] << endl;
        change(1,1,n,a,b,c);
        printf("%d\n",t[1]);
    }
}

Measured memory_bytes: 17240
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VI a(n);
  INPUT(a);
  int now = 1, ans = 0;
  REPx(x, a)
  {
    if (x == now) now++;
    else ans++;
  }
  if (now == 1) cout << -1;
  else cout << ans;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <algorithm>
using namespace std;

using ll = long long;

#define MOD 1000000007

#define FOR(i, m, n) for (ll i = m; i <= n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)

ll gcd(ll a, ll b) { if (a < b) { a ^= b; b ^= a; a ^= b; } return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

ll P[100010];
ll Q[100010];
ll R[100010];
ll S[300010];

int main() {
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    FOR(i, 1, A) cin >> P[i];
    FOR(i, 1, B) cin >> Q[i];
    FOR(i, 1, C) cin >> R[i];

    sort(&P[1], &P[A + 1], greater<ll>());
    sort(&Q[1], &Q[B + 1], greater<ll>());
    sort(&R[1], &R[C + 1], greater<ll>());

    /*
    ll p = 1;
    ll q = 1;
    ll r = 1;
    ll x = 0;
    ll y = 0;

    while (x < X || y < Y) {
        if (x < X && y < Y) {
            if (P[p] > Q[q] && P[p] > R[r]) {
                p++;
                x++;
            }
            else if (Q[q] > P[p] && Q[q] > R[r]) {
                q++;
                y++;
            }
            else if (R[r] > P[p] && R[r] > Q[q]) {
                r++;
                P[p] < Q[q] ? x++ : y++;
            }
            else if (P[p] == Q[q]) {
                p++;
                x++;
            }
            else if (P[p] == R[r]) {
                p++;
                x++;
            }
            else if (Q[q] == R[r]) {
                q++;
                y++;
            }
            else {
                cout << -1 << endl;
                return 0;
            }
        }
        else if (x < X) {
            if (P[p] > R[r]) {
                p++;
                x++;
            }
            else if (R[r] > P[p]) {
                r++;
                x++;
            }
            else {
                p++;
                x++;
            }
        }
        else {
            if (Q[q] > R[r]) {
                q++;
                y++;
            }
            else if (R[r] > Q[q]) {
                r++;
                y++;
            }
            else {
                q++;
                y++;
            }
        }
    }

    ll ans = 0;

    FOR(i, 1, p - 1) ans += P[i];
    FOR(i, 1, q - 1) ans += Q[i];
    FOR(i, 1, r - 1) ans += R[i];
    
    cout << ans << endl;
    */
    
    ll j = 1;
    FOR(i, 1, X) S[j++] = P[i];
    FOR(i, 1, Y) S[j++] = Q[i];
    FOR(i, 1, C) S[j++] = R[i];

    sort(&S[1], &S[j], greater<ll>());

    ll ans = 0;
    FOR(i, 1, X + Y) ans += S[i];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4992