akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	fsc := NewFastScanner()
	N, A, B := fsc.NextInt(), fsc.NextInt(), fsc.NextInt()
	A -= B
	if A >= 0 {
		fmt.Println("delicious")
		os.Exit(0)
	}
	if IntAbs(A) <= N {
		fmt.Println("safe")
	} else {
		fmt.Println("dangerous")
	}
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))

A.sort(reverse=True)
print(sum(A[1:2*N:2]))


Measured memory_bytes: 41492
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // #ifndef ONLINE_JUDGE
    // freopen("inp.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif

    string s;
    cin>>s;

    int sum = 0;
    for(int i=0;i<s.size();++i) {
        sum += (s[i] - '0');
    }

    if(sum%9 == 0)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}

Measured memory_bytes: 3764
//#include <GOD>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define len length	
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define freo freopen("output.txt","w",stdout)

const ll inf=1e18;
const ll mod=1e9+7;
const ll maxn=1e6+10,maxt=100+10;

ll n,dp[maxn];
ll power(ll a,ll b){
	if(!b){
		return 1;
	}
	ll c=power(a,(int)b/2);
	if(b%2){
		return c*c%mod*a%mod;
	}else{
		return c*c%mod;
	}
}
int main(){
	FAST_IO;
	dp[1]=0;
	dp[2]=2;
	for(int i=3;i<maxn;i++){
		dp[i]=(dp[i-1]*10)%mod;
		ll tmp=power(9,i-1)-power(8,i-1)+mod;
		tmp%=mod;
		tmp*=2;
		tmp%=mod;
		dp[i]+=tmp;
		dp[i]%=mod;
	}
	cin>>n;
	cout<<dp[n]<<endl;
}


Measured memory_bytes: 11440
# -*- coding: utf-8 -*-
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    n=int(input())
    a=list(map(int,input().split()))
    q=deque()
    for i in range(n):
        if i%2==0:
            q.append(a[i])
        else:
            q.appendleft(a[i])
    l=list(q)
    if n%2:
        l.reverse()
    print(*l)

if __name__ == '__main__':
    main()


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

int main(void){
    double a,b,x;
    cin >> a >> b >> x;
    x /= a;
    double PI = acos(-1);
    double t1 = atan(2.0/a * (b - x/a));
    double t2 = atan(b*b/(2*x));
    printf("%.10f\n",  ( b <= a * tan(t2) ? t2 : t1) * 180.0/PI);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] H = new int[N];
        for (int i = 0; i < H.length; i++) {
            H[i] = sc.nextInt();
        }
        boolean[] isGood = new boolean[N];
        for (int i = 0; i < isGood.length; i++) {
            isGood[i] = true;
        }
        for (int i = 0; i < M; i++) {
            int A = sc.nextInt();
            int B = sc.nextInt();
            if (H[A - 1] > H[B - 1]) {
                isGood[B - 1] = false;
            } else if (H[A - 1] < H[B - 1]) {
                isGood[A - 1] = false;
            } else {
                isGood[A - 1] = false;
                isGood[B - 1] = false;
            }
        }
        int counter = 0;
        for (int i = 0; i < isGood.length; i++) {
            if (isGood[i]) {
                counter++;
            }
        }
        System.out.println(counter);
        sc.close();
    }
}

Measured memory_bytes: 59144
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
long N,W;
long w,v;
long wf;
vector<long> w0,w1,w2,w3;

int main(){
    cin >> N >> W;
    rep(i,N){
        cin >> w >> v;
        if(i==0) wf = w;
        if(w-wf==0) w0.pb(v);
        else if(w-wf==1) w1.pb(v);
        else if(w-wf==2) w2.pb(v);
        else w3.pb(v);
    }
    
    sort(ALL(w0)),sort(ALL(w1)),sort(ALL(w2)),sort(ALL(w3));
    
    long pr = 0;
    rep(i,N+1) rep(j,N+1) rep(k,N+1) rep(l,N+1){
        long ans = 0;
        if(i<=w0.size() && j<=w1.size() && k <= w2.size() && l <= w3.size() && i+j+k+l <= N && i*wf+j*(wf+1)+k*(wf+2)+l*(wf+3) <= W){
            rep(a,i) ans += w0[w0.size()-1-a];
            rep(a,j) ans += w1[w1.size()-1-a];
            rep(a,k) ans += w2[w2.size()-1-a];
            rep(a,l) ans += w3[w3.size()-1-a];
        }
        pr = max(pr,ans);
    }
    
    cout << pr << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)  for(ll i=0; i<n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  int x,y; cin >> x >> y;
  rep(i,100+1){
    rep(j,100+1){
      if(i+j==x && i*2+j*4==y){
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
}


Measured memory_bytes: 3616
n = int(input())
s = input()

cnt = 0

ans = []

tmp = 0
now = 1 if s[cnt] == "W" else 0
for i in range(n-1):
    if s[i+1] == "E":
        tmp += 1
ans.append(tmp)

for i in range(n-1):
    tmp += now
    cnt += 1
    now = 1 if s[cnt] == "W" else 0
    tmp += now -1
    ans.append(tmp)
print(min(ans))

Measured memory_bytes: 15520
#include<cstdio>
int main()
{
	int n,m,ans=0;
	double sum=0;
	scanf("%d%d",&n,&m);
	int a[n];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	sum=sum/(m*4);
	for(int i=0;i<n;i++)
	{
		if(a[i]>=sum)
		ans++;
	}
	if(ans>=m)
	printf("Yes\n");
	else
	printf("No\n");
}

Measured memory_bytes: 128
from collections import defaultdict
from collections import deque
from collections import OrderedDict
import itertools
from sys import stdin
input = stdin.readline


def main():
  N, K = list(map(int, input().split()))
  P = list(map(int, input().split()))

  PP = [0]*N
  for i, p in enumerate(P):
    PP[i] = p*(p+1)/(2*p)

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

  max_ = 0
  for i in range(0, N-K+1):
    max_ = max(max_, S[i+K] - S[i])

  print(max_)


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 102200
import math

A, B, H, M = map(int, input().split(" "))

shortHandAngle = math.radians(30*H+float(M/2))
longHandAngle = math.radians(6*M)

x = A * math.cos(shortHandAngle)\
    - B * math.cos(longHandAngle)

y = A * math.sin(shortHandAngle)\
    - B * math.sin(longHandAngle)

d = math.sqrt(x**2 + y**2)

print(d)

Measured memory_bytes: 9508
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=200010;
int a[N];
bool w[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n;
    long long ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) a[i]=gi();
    for(int i=1,j=1;i<=n;i++) {
	for(int k=0;k<20;k++)
	    if((a[i-1]>>k)&1) w[k]=0;
	while(j<=n) {
	    for(int k=0;k<20;k++)
		if((a[j]>>k)&w[k]) goto fal;
	    for(int k=0;k<20;k++) w[k]|=((a[j]>>k)&1);
	    ++j;
	}
    fal:;
	ans+=j-i;
    }
    cout<<ans;
    return 0;
}

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

int main(void){
    int data[3];
    scanf("%d %d %d",&data[0],&data[1],&data[2]);
    int max = 0;
    for(int i = 0;i<3;i++){
        if(data[i]>max){
            max = data[i];
        }
    }
    int ans;
    ans = max * 10 + data[0] + data[1] + data[2] - max;
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
# def main():
#     N, Q = list(map(int, input().split()))
#     parents = [[] for i in range(N+1)]
#     ans = [0] * (N+1)

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

#     for i in range(Q):
#         p, x = list(map(int, input().split()))
#         ans[p] += x

#     print(parents[1:])

#     for i in range(1, N+1):
#         for p in parents[i]:
#             ans[i] += ans[p]

#     print(*ans[1:])

import sys
input = sys.stdin.readline

def main():
    N, Q = map(int, input().split())
    tree = [[] for i in range(N+1)]
    ans = [0] * (N+1)
    visit = [False]*(N+1)

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

    for i in range(Q):
        p, x = map(int, input().split())
        ans[p] += x

    visit[1] = True
    q = [1]

    while len(q) != 0:
        n = q.pop()
        # print(tree[n])
        for i in tree[n]:
            if visit[i] is False:
                ans[i] += ans[n]
                # print(i, '+=', n)
                visit[i] = True
                q.append(i)

    print(*ans[1:])


if __name__ == '__main__':
    main()


Measured memory_bytes: 92876
import sys
def main():
    A,B,C,D=tuple(map(int,sys.stdin.readline().split()))
    t=0
    while True:
        if t==0:
            if C<=B:break
            C-=B
        else:
            if A<=D:break
            A-=D
        t^=1
    print('Yes') if t==0 else print('No')
if __name__=='__main__':main()

Measured memory_bytes: 9168
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const int mod=1000000007;
const double PI = 3.1415926535897932384626433;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k])%mod;
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

vector<long long> enum_divisors(long long N) {
	vector<long long> res;
	for (long long i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			res.push_back(i);
			// 重複しないならば i の相方である N/i も push
			if (N/i != i) res.push_back(N/i);
		}
	}
	// 小さい順に並び替える
	sort(res.begin(), res.end());
	return res;
}

ll zyou(ll x,ll n){
	ll y=1;
	rep(i,0,n){
		y*=x;
	}
	return y;
}

int main() {
	int s,w;
	cin>>s>>w;
	if(s<=w)print("unsafe");
	else print("safe");

}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	string s;
	int k;cin>>s>>k;
	int l = s.length();
	int u = s[0]-'0';
	int wa = 0;
			for(int i = 1;i < l;i++){
				wa += s[i]-'0';
			}
	if(k==1){
		cout << (l-1)*9+(s[0]-'0') << endl;
	}else if(k==2){
		if(l <= 1){
			cout << 0 << endl;
		}else{
			int memo2 = 81*(l-1)*(l-2)/2 + (u-1)*(l-1)*9;
			s.erase(0, 1);
			rep(i, l-1){
				if(s[0]=='0'){s.erase(0, 1);}else{break;}
			}
			l = s.length();
			if(l == 0) cout << memo2 << endl;
			else cout << memo2 + (l-1)*9+(s[0]-'0') << endl; 
		}
	}else{
		if(l <= 2){
			cout << 0 << endl;
		}else{
			ll memo3 = 9*9*9*(l-1)*(l-2)*(l-3)/6 + (u-1)*(l-1)*(l-2)/2*9*9;
			s.erase(0, 1);
			rep(i, l-1){
				if(s[0]=='0'){s.erase(0, 1);}else{break;}
			}
			l = s.length();
			if(l <= 1){
				cout << memo3 << endl;
				return 0;
			}
			u = s[0] - '0';
			ll memo2 = 81*(l-1)*(l-2)/2 + (u-1)*(l-1)*9;// + (l-2)*9+(s[1]-'0');
			s.erase(0, 1);
			rep(i, l-1){
				if(s[0]=='0'){s.erase(0, 1);}else{break;}
			}
			l = s.length();
			if(l == 0){
				cout << memo3 + memo2 << endl;
				return 0;
			}
			cout << memo2 + memo3 + (l-1)*9+(s[0]-'0')<< endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while(C-=B,A-=D,1){
    if(C<1){
      cout << "Yes" << endl;
      return 0;
    }
    else if(A<1){
      cout << "No" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3636
/*
g++ --std=c++17 A.cpp
*/

#include <iostream>
#include <iomanip> //! for setprecision(20)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < int(n); ++i)
template<class T> inline bool chmax(T& a, T b) { bool ret = (a < b); if (ret) { a = b; } return ret; }
template<class T> inline bool chmin(T& a, T b) { bool ret = (b < a); if (ret) { a = b; } return ret; }
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int INF = 1e9;
const LL INFL = 1e18;
const int MOD = 1000000007;


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

  int h, w, d;
  cin >> h >> w >> d;
  vector<vector<pair<int, int>>> ps(d, vector<pair<int, int>>(1+h*w/d));
  // ps[0][0] = coordinate of 0
  // ps[0][1] = coordinate of D
  // ps[0][2] = coordinate of 2*D
  //  :
  // ps[r][m] = coordinate of m*D + r

  rep(y, h) rep(x, w) {
    int a;
    cin >> a;
    ps[a%d][a/d] = {y, x};
  }

  vector<int> sum(h*w+1);
  rep(r, d) for (int m = 0; d*m+r <= h*w; ++m) {
    if (m == 0) {
      sum[d*m+r] = 0;
    } else {
      sum[d*m+r] = sum[d*(m-1)+r] + abs(ps[r][m].first - ps[r][m-1].first) + abs(ps[r][m].second - ps[r][m-1].second);
    }
  }

  int q;
  cin >> q;
  rep(i, q) {
    int l, r;
    cin >> l >> r;
    cout << (sum[r] - sum[l]) << endl;
  }

  return 0;
}

Measured memory_bytes: 8260
//Zory-2019
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<deque>
using namespace std;
namespace mine
{
	typedef long long ll;
	#define double long double
	const int INF=0x3f3f3f3f;
	const ll LLINF=0x3f3f3f3f3f3f3f3fll;
	ll qread()
	{
		ll ans=0;char c=getchar();int f=1;
		while(c<'0' or c>'9') {if(c=='-') f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num)
	{
		if(num<0) {num=-num;putchar('-');}
		if(num>9) write(num/10);
		putchar('0'+num%10);
	}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);puts("");}
	#define FR first
	#define SE second
	#define MP make_pair
	#define pr pair<int,int>
	#define PB push_back
	#define vc vector
	void chmax(int &x,const int y) {x=x>y?x:y;}
	void chmin(int &x,const int y) {x=x<y?x:y;}
	const int MAX_N=2e5+10;
	const ll MOD=1e9+7;
	void add(int &x,int y){x+=y;if(x>=MOD) x-=MOD;if(x<0) x+=MOD;}
	
	struct BIT
	{
		vc<int> bit[MAX_N];int now[MAX_N];BIT(){memset(now,0,sizeof now);}
		#define lowbit(x) ((x)&-(x))
		void change(int x,int c){while(x<MAX_N) bit[x].PB(max(bit[x][now[x]],c)),now[x]++,x+=lowbit(x);}
		int ask(int x){int ans=-INF;while(x>=1) chmax(ans,bit[x][now[x]]),x-=lowbit(x);return ans;}
		void gaygay(int x){while(x<MAX_N) now[x]--,x+=lowbit(x);}
	}bit[2];
	int a[MAX_N];vc<int> ans;
	int c[2],mi[2],cnt[MAX_N];
	bool check(int i,int now)
	{
		int tmp1=c[now],tmp2=mi[now];
		if(a[i]<mi[now]) c[now]++,mi[now]=a[i];
		//printf("i=%d now=%d\n",i,now);
		for(int j=0;j<=1;j++)
		{
			int wt=c[j]-c[j^1]+cnt[i+1];if(wt<0) continue;
			//printf("mi2=%d j=%d wt=%d 0=%d 1=%d\n",mi[j^1],j,wt,bit[0].ask(mi[j^1]),bit[1].ask(mi[j^1]));
			if(bit[wt&1].ask(mi[j^1])>=wt) return 1;
		}
		c[now]=tmp1;mi[now]=tmp2;
		return 0;
	}
	void main()
	{
		for(int i=1;i<MAX_N;i++) bit[0].bit[i].PB(0);
		for(int i=1;i<MAX_N;i++) bit[1].bit[i].PB(-1);
		
		int n=qread();for(int i=1;i<=n;i++) a[i]=n-qread()+1;
		int lstmi=INF;for(int i=1;i<=n;i++) if(a[i]<lstmi) lstmi=a[i],cnt[i]=1; else cnt[i]=0;
		for(int i=n;i>=1;i--) cnt[i]+=cnt[i+1];
		
		for(int i=n;i>=1;i--)
		{
			int t0=bit[0].ask(a[i]),t1=bit[1].ask(a[i]);if(t1==-1) t1=-INF;
			
			//if(i==2)
			//		puts("");
			
			t0+=1+(cnt[i]-cnt[i+1]);t1+=1+(cnt[i]-cnt[i+1]);
			if((t0&1)==(t1&1)) bit[t1&1].change(a[i],max(t0,t1)),bit[(t1&1)^1].change(a[i],-INF);
			else bit[t0&1].change(a[i],t0),bit[t1&1].change(a[i],t1);
		}
		mi[0]=mi[1]=n+1;
		for(int i=1;i<=n;i++)
		{
			bit[0].gaygay(a[i]);bit[1].gaygay(a[i]);
			
			if(check(i,0)) ans.PB(0);
			else
			{
				if(i>1){if(a[i]<mi[1]) c[1]++,mi[1]=a[i];}
				else if(!check(i,1)) {puts("-1");return;}
				ans.PB(1);//printf("pos[%d]=1\n",i);
			}
			//else if(check(i,1)) ans.PB(1);
			//else {puts("-1");return;}
		}
		for(int t=0;t<n;t++) putchar('0'+ans[t]);
	}
};
signed main()
{
	srand(time(0));
	mine::main();
}


Measured memory_bytes: 50280
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back

using namespace std;

const ll sz=(1e5+5)*2;
const ll szz=1e6+6;
const ll mod=1e9+7;

ll n,k,ar[sz];
bool vis[sz];
vector<ll> path;

ll dfs(ll node)
{
	if(k==0)
		return node;

	if(vis[node])
	{
		vector<ll> v(find(path.begin(),path.end(),node),path.end());
		k%=v.size();
		
		return v[k];
	}
	else
	{
		k--;
		path.pb(node);
		vis[node]=1;
		return dfs(ar[node]);
	}
}

int main()
{
	Ryuga;

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

	clock_t startTime=clock();

	cin>>n>>k;
	rep(i,0,n)
	{
		cin>>ar[i];
		ar[i]--;
	}

	cout<<1+dfs(0)<<endl;

	cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...);

Measured memory_bytes: 16276
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

ll v[55],C[51][51];

void comb_table(int N) {
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= i; j++) {
			if (j == 0 || j == i) {
				C[i][j] = 1LL;
			}
			else {
				C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
			}
		}
	}
}

int main()
{
	int N,A,B;
	double ave=0;
	cin >> N >> A >> B;

	for (int i = 0; i < N; i++)
		cin >> v[i];

	comb_table(N);
	sort(v, v + N);
	reverse(v, v + N);

	for (int i = 0; i < A; i++) {
		ave += v[i];
	}

	int num = 0, pos = 0;
	for (int i = 0; i < N; i++) {
		if (v[i] == v[A - 1]) {
			num++;
			if (i < A) {
				pos++;
			}
		}
	}

	ll cnt = 0LL;
	if (pos == A) {
		for (pos = A; pos <= B; pos++) {
			cnt += C[num][pos];
		}
	}else {
		cnt += C[num][pos];
	}

	printf("%.10f\n",ave/A);
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<deque>
#include<algorithm>
#include<functional>
#include<string>
#include<unordered_map>
using namespace std;

unordered_map<char, string>U;
string b[26] = {
	"100101",//A
	"10011010",//B
	"0101",//C
	"0001",//D
	"110",//E
	"01001",//F
	"10011011",//G
	"010000",//H
	"0111",//I
	"10011000",//J
	"0110",//K
	"00100",//L
	"10011001",//M
	"10011110",//N
	"00101",//O
	"111",//P
	"10011111",//Q
	"1000",//R
	"00110",//S
	"00111",//T
	"10011100",//U
	"10011101",//V
	"000010",//W
	"10010010",//X
	"10010011",//Y
	"10010000",//Z
};
string k = " .,-'?";
signed main() {
	U[' '] = "101";
	U['\''] = "000000";
	U[','] = "000011";
	U['-'] = "10010001";
	U['.'] = "010001";
	U['?'] = "000001";
	string a;
	while (getline(cin,a)) {
		string d;
		for (char c : a) {
			if (c >= 'A'&&c <= 'Z')d += b[c - 'A'];
			else d += U[c];
		}
		while (d.length() % 5)d += "0";
		string ans;
		for (int i = 0; i < d.length() / 5; i++) {
			string e = d.substr(i * 5, 5);
			reverse(e.begin(), e.end());
			int S = 0;
			for (int j = 0; j < 5; j++) {
				if (e[j] == '1')S += 1 << j;
			}
			if (S <= 25)ans += S + 'A';
			else ans += k[S - 26];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
string s,t;
bool use[30];
set<string>st;
int main()
{
	ios::sync_with_stdio(false);
	cin>>s;
	if(s=="zyxwvutsrqponmlkjihgfedcba")
	{
		cout<<-1;
		return 0;
	}
	if(s.size()==26)
	{
		string ans="zz";
		for(int i=0;i<26;i++)
		{
			for(int j=i+1;j<26;j++)
			{
				if(s[i]<s[j])
				{
					string t=s;
					swap(t[i],t[j]);
					t.erase(i+1,t.size()-i-1);
					ans=min(ans,t);
				}
			}
		}
		cout<<ans<<endl;
	}
	else
	{
		for(int i=0;i<s.size();i++)use[s[i]-'a']=1;
		for(int i=0;i<26;i++)
		{
			if(!use[i])
			{
				cout<<s<<char(i+'a')<<endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
    int a, b, c, d, e, f;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    if(a >= d){
        printf("%d\n", d);
    }
    else if( (a + b) >= d ){
        printf("%d\n", a);
    }
    else{
        f = a - (d - (a + b));
        printf("%d\n", f);
    }    
    return 0;
}

Measured memory_bytes: 1724
#include <cstdio>
#include <algorithm>

double tsurai(int K, double L, double R, double P, double E, double T) {
  //fprintf(stderr,"K=%d> %d, %d\n", K, L, R);
  if (T-E <= L && R < T+E) {
    //fprintf(stderr, "1> %d %.3f (%d, %d) %.3f\n", K, T-E, L, R, T+E);
    return 1.0;
  }

  if (R < T-E || T+E < L) {
    //fprintf(stderr, "2> %d (%d, %d)\n", K, L, R);
    return 0.0;
  }

  double H=(L+R)/2;

  if (K == 0) {
    if (T-E <= H && H <= T+E) {
      return 1.0;
    } else {
      return 0.0;
    }
  }

  double PL=tsurai(K-1, L, H, P, E, T);
  double PR=tsurai(K-1, H, R, P, E, T);

  //fprintf(stderr, "%d: %.20f %.20f\n", K, PL, PR);

  if (T <= H) {
    return (1-P)*PL + P*PR;
  } else {
    return P*PL + (1-P)*PR;
  }
}

int main() {
  int K, L, R;
  scanf("%d %d %d", &K, &L, &R);

  double P, E, T;
  scanf("%lf %lf %lf\n", &P, &E, &T);

  printf("%.16f\n", tsurai(K, L, R, P, E, T));
  return 0;
}

Measured memory_bytes: 2748
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int x, y;
    
    cin >> x >> y;
    vector<string> data(x);
    vector<int> a(x, 0);
    vector<int> b(y, 0);
    int i = -1, j;
    while (++i < x)
    {
        cin >> data.at(i);
        j = -1;
        while (++j < y)
            data.at(i).at(j) == '.' ? a[i]++, b[j]++ : 0;
    }
    i = -1;
    while (++i < x)
    {
        if (a[i] == y)
            continue;
        j = -1;
        while (++j < y)
        {
            if (b[j] == x)
                continue;
            cout << data.at(i).at(j);
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
N = int(input())
A = [1]
for i in range(1,7):
    A.append(6 ** i)
for i in range(1, 6):
    A.append(9 ** i)


A = sorted(A)
dp = [float("inf")] * (N+1)
dp[0] = 0

for i in range(1,N+1):
    for k, v in enumerate(A):
        if i >= v:
            dp[i] = min(dp[i], dp[i-v]+1)


print(dp[N])

Measured memory_bytes: 44624
#include<stdio.h>
int main(){
  int n,m,s=0,t=0;
  scanf("%d %d",&n,&m);
  int a[n+1];
  for(int i=1;i<=n;i++)scanf("%d",&a[i]);
  
  for(int i=1;i<=n;i++){
    s+=a[i];
  }
  for(int i=1;i<=n;i++){
    if(s%(4*m)==0){
      if(a[i]>=s/(4*m))t+=1;
    }
    if(s%(4*m)!=0){
      if(a[i]>s/(4*m))t+=1;
    }
  }
  if(t>=m){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <queue>
 
int main(){
    std::priority_queue<u_int> prices;
    u_int num_of_item, size_of_bag, price;
    
    while(1){
        std::cin >> num_of_item >> size_of_bag;
        if(num_of_item == 0 && size_of_bag == 0)
            break;
            
        for(u_int i = 0; i < num_of_item; ++i){
            std::cin >> price;
            prices.push(price);
        }
        
        u_int sum = 0;
        while(!prices.empty()){
            for(u_int i = 0; i < size_of_bag; ++i){
                if(i != size_of_bag - 1){
                    sum += prices.top();
                }
                prices.pop();
                if(prices.empty()){
                    break;
                }
            }
        }
        std::cout << sum << std::endl;
    }
 
    return 0;
}

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

using namespace std;

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

    int n, q;
    string b;
    cin >> n >> q;
    vector<int> l(q), r(q);
    vector<int> cumsum(n+1);
    cin >> b;
    for (int i = 0; i < q; i++)
    {
        cin >> l[i] >> r[i];
    }

    // for (int i = 0; i < q; i++)
    // {
    //     int count = 0;
    //     for (int j = l[i] - 1; j < r[i] - 1; j++)
    //     {
    //         if (b[j] == 'A' && b[j + 1] == 'C')
    //             count++;
    //     }
    //     a[i] = count;
    // }
    cumsum[0] = 0;
    for (int i = 0; i < n - 1; i++)
    {
        if (b[i] == 'A' && b[i + 1] == 'C')
            cumsum[i + 1] = cumsum[i] + 1;
        else
            cumsum[i + 1] = cumsum[i];
    }
    cumsum[n] = cumsum[n - 1];

    for (int i = 0; i < q; i++)
    {
        int ans = cumsum[r[i] - 1] - cumsum[l[i] - 1];
        cout << ans << endl;
    }

    return 0;
}


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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int start = h1 * 60 + m1;
  int end = h2 * 60 + m2;
  int mod = 60 * 24;
  if(end < start) end += mod;
  cout << max(0, end - start - k) << '\n';
}

Measured memory_bytes: 3648
//周♂雨扬是最强的！！！
//大佬祝您AK
//沈哲♂贝是最强的！！！
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<fstream>
using namespace std;
//ifstream fin(.in);
//ofstream fout(.out);
int n,head,tail;
int num[800003];
int main(){
	cin>>n;
	int head=300001,tail=300000;
	bool ok=!(n&1);
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(ok){
			num[head++]=x;
		}else{
			num[tail--]=x;
		}
		ok^=1;
	}
	for(int i=tail+1;i<=head-1;i++){
		cout<<num[i]<<" ";
	}
	return 0;
}
//沈♂哲贝是最强的！！！
//大佬祝您AK
//周♂雨扬是最强的！！！

Measured memory_bytes: 2944
#include<bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
//using namespace atcoder;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n;
  cin >> n;
  vec a(n),b(n);
  for(ll i=0;i<n;i++)cin >> a[i];
  for(ll i=0;i<n;i++)cin >> b[i];

  vec x(n+1),y(n+1);
  for(ll i=0;i<n;i++){
    x[a[i]]++;
    y[b[i]]++;
  }

  mat z(n+1);
  for(ll i=1;i<=n;i++)z[i]={x[i]+y[i],i};
  sort(z.begin(),z.end());
  reverse(z.begin(),z.end());

  if(z[0][0]>n)cout << "No" << endl;
  else{
    cout << "Yes" << endl;
    reverse(b.begin(),b.end());
    for(ll i=0;i<n;i++){
      if(a[i]!=b[i])continue;
      else{
        bool ok=false;
        for(ll j=n-1;j>i;j--){
          if(a[i]!=b[j]){
            swap(b[i],b[j]);
            ok=1;
            break;
          }
        }
        if(!ok){
          for(ll j=0;j<i;j++){
            if(a[i]!=b[j] && b[i]!=a[j]){
              swap(b[i],b[j]);
            }
          }
        }
      }
    }

    for(ll i=0;i<n;i++)cout << b[i]  << " ";
    cout << endl;

  }




  return 0;
}

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

int main() {
 string S, ans;
  cin >> S;
  ans = "Good";
  for (int i = 0; i < 3; i++) {
  	if (S.at(i) == S.at(i + 1)) {
      ans = "Bad";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def frog1(h):
    dp = [float('inf')]*3
    dp[0] = 0
    for i in range(1,len(h)):
        dp[i%3] = min([dp[(i-j)%3] + abs(h[i]-h[i-j]) for j in range(1,3)])
    return dp[(len(h)-1)%3]
    
n = input()
vals = list(map(int, input().split()))

print(frog1(vals))

Measured memory_bytes: 13980
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define Sort(a)   sort(a.begin(), a.end())
const int INF = INT_MAX;
const ll  MOD = 1000000007;

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

    cout << ((n/2) + ((n%2==0)? 0: 1));
}

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

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, K;
    cin >> A >> B >> K;
    ll p = min(A, K);
    A -= p;
    K -= p;
    B -= min(B, K);
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<vector<int> > adj;
vector<int> siz, visited;

void dfs(int cur, int parent) {
	visited[cur] = 1;
	siz[cur] = 1;
	for (auto u : adj[cur]) {
		if (!visited[u] && u != parent) {
			dfs(u, cur);
			siz[cur] += siz[u];
		}
	}
	return ;
}

void solve() {
	int n, m; cin >> n >> m;
	adj.resize(n);
	siz.resize(n, 0);
	visited.resize(n, 0);
	map<pair<int, int> , bool> mapp;
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		if (a > b)swap(a, b);
		if (mapp[ {a, b}])continue;
		adj[a].push_back(b);
		adj[b].push_back(a);
		mapp[ {a, b}] = 1;
	}
	for (int i = 0; i < n; i++)if (!visited[i])dfs(i, -1);
	int ans = *max_element(siz.begin(), siz.end());
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t; cin >> t;
	// while (t--)
	solve();

}

Measured memory_bytes: 40672
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);
		int a[]=new int[4];
		int b[]=new int[4];

		while(sc.hasNext())
		{
			int hi =0;
			int bl =0;
			for(int i=0; i<4;i++)
				a[i]=sc.nextInt();
			for(int i=0; i<4;i++)
				b[i]=sc.nextInt();

			for(int i=0;i<4; i++)
				if(a[i]==b[i])
					hi++;

			for(int i=0; i<4; i++)
				for(int j=0; j<4; j++)
				{
					if(i==j)
						continue;
					if(a[i]==b[j])
						bl++;
				}
			System.out.println(hi+" "+bl);
		}

	}

}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 200000 + 1;
vector<int> G[maxn];
int d[maxn], p[maxn];
stack<int> A[2];
stack<int> B[3];
void DFS(int u, int par = 0){
    A[d[u]].push(u);
    for(int v : G[u]) if(v != par){
        d[v] = d[u] ^ 1;
        DFS(v, u);
    }
}
void fuck(stack<int>& A, stack<int>& B){
    while(not A.empty() and not B.empty()){
        p[A.top()] = B.top();
        A.pop();
        B.pop();
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N;
    cin >> N;
    for(int i = 1, u, v; i < N; i += 1){
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    DFS(1);
    for(int i = 1; i <= N; i += 1) B[(i + 2) % 3].push(i);
    if(A[0].size() >= B[0].size() and A[1].size() >= B[1].size()){
        fuck(A[0], B[0]);
        fuck(A[1], B[1]);
        fuck(A[0], B[2]);
        fuck(A[1], B[2]);
    }
    else if(A[0].size() >= B[1].size() and A[1].size() >= B[0].size()){    
        fuck(A[1], B[0]);
        fuck(A[0], B[1]);
        fuck(A[0], B[2]);
        fuck(A[1], B[2]);
    }
    else if(B[2].size() >= A[0].size()){
        fuck(A[0], B[2]);
        fuck(A[1], B[0]);
        fuck(A[1], B[1]);
        fuck(A[1], B[2]);
    }
    else if(B[2].size() >= A[1].size()){
        fuck(A[1], B[2]);
        fuck(A[0], B[0]);
        fuck(A[0], B[1]);
        fuck(A[0], B[2]);
    }
    else assert(0);
    for(int i = 1; i <= N; i += 1) cout << p[i] << " ";
    return 0;
}


Measured memory_bytes: 20200
#include<stdio.h>
int main(){
	int i;
    char a, b, c;
    scanf("%c%c%c", &a, &b, &c);	
	if(a == 'A' && b == 'B' && c == 'C'){
	    printf("ARC");
   	}
	else if(a == 'A' && b == 'R' && c == 'C') {
	    printf("ABC");
    }
	return 0;
} 

Measured memory_bytes: 1660
import java.util.*;

public class Main{
	public static void main(String[] args){
		HashMap<String,Character> map1 = new HashMap<String,Character>();
		map1.put("101",' ');
		map1.put("000000",'\'');
		map1.put("000011",',');
		map1.put("10010001",'-');
		map1.put("010001",'.');
		map1.put("000001",'?');
		map1.put("100101",'A');
		map1.put("10011010",'B');
		map1.put("0101",'C');
		map1.put("0001",'D');
		map1.put("110",'E');
		map1.put("01001",'F');
		map1.put("10011011",'G');
		map1.put("010000",'H');
		map1.put("0111",'I');
		map1.put("10011000",'J');
		map1.put("0110",'K');
		map1.put("00100",'L');
		map1.put("10011001",'M');
		map1.put("10011110",'N');
		map1.put("00101",'O');
		map1.put("111",'P');
		map1.put("10011111",'Q');
		map1.put("1000",'R');
		map1.put("00110",'S');
		map1.put("00111",'T');
		map1.put("10011100",'U');
		map1.put("10011101",'V');
		map1.put("000010",'W');
		map1.put("10010010",'X');
		map1.put("10010011",'Y');
		map1.put("10010000",'Z');

		HashMap<Character,String> map2 = new HashMap<Character,String>();
		map2.put('A',"00000");
		map2.put('B',"00001");
		map2.put('C',"00010");
		map2.put('D',"00011");
		map2.put('E',"00100");
		map2.put('F',"00101");
		map2.put('G',"00110");
		map2.put('H',"00111");
		map2.put('I',"01000");
		map2.put('J',"01001");
		map2.put('K',"01010");
		map2.put('L',"01011");
		map2.put('M',"01100");
		map2.put('N',"01101");
		map2.put('O',"01110");
		map2.put('P',"01111");
		map2.put('Q',"10000");
		map2.put('R',"10001");
		map2.put('S',"10010");
		map2.put('T',"10011");
		map2.put('U',"10100");
		map2.put('V',"10101");
		map2.put('W',"10110");
		map2.put('X',"10111");
		map2.put('Y',"11000");
		map2.put('Z',"11001");
		map2.put(' ',"11010");
		map2.put('.',"11011");
		map2.put(',',"11100");
		map2.put('-',"11101");
		map2.put('\'',"11110");
		map2.put('?',"11111");

		Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()){
			String s = sc.nextLine();
			String out = "";

			for(char ch : s.toCharArray())
				out += map2.get(ch);

			for(int i=0;i<out.length();){
				int len = 1;
				while(i+len<=out.length() && map1.get(out.substring(i,i+len)) == null) len++;
				if(i+len > out.length()) break;
				System.out.print(map1.get(out.substring(i,i+len)));
				i += len;
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

using namespace std;

using ll = long long;
using PII = pair<int, int>;

template<typename T>
void chmax(T &a, T &b){
	a = max(a, b);
}

template<typename T>
void chmin(T &a, T &b){
	a = min(a, b);
}

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll s, c;
	cin >> s >> c;
	ll res = min(s, c/2);
	c -= s*2;
	if(c >= 0)
		res += c/4;
	cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <assert.h>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

struct SqrtDecomposition2{
    const ll INF = 1e18;
    int n, sqrtn, k;
    VL dat, buk, lazy;
    vector<bool> lazyflag;

    void init(int x){
        n = x;
        sqrtn = sqrt(n);
        k = (n + sqrtn - 1) / sqrtn;
        dat.assign(sqrtn * k, 0);
        buk.assign(k, 0);
        lazy.assign(k, 0);
        lazyflag.assign(k, false);
    }

    void eval(int b){
        if (!lazyflag[b]) return;
        lazyflag[b] = false;
        FOR(i, sqrtn * b, sqrtn * (b+1) - 1){
            dat[i] += lazy[b];
        }
        lazy[b] = 0;
    }

    // [l, r)
    void add(int l, int r, ll x){
        REP(b,k){
            int p = sqrtn * b;
            int q = sqrtn * (b+1);
            if (q <= l || r <= p) continue;
            if (l <= p && q <= r){
                buk[b] += x;
                lazyflag[b] = true;
                lazy[b] += x;
            }else{
                eval(b);
                FOR(i,max(l,p),min(r,q)-1){
                    dat[i] += x;
                }
                buk[b] = INF;
                FOR(i,p,q-1){
                    buk[b] = min(buk[b], dat[i]);
                }
            }
        }
    }

    // [l, r)
    ll query(int l, int r){
        ll ret = INF;
        REP(b,k){
            int p = sqrtn * b;
            int q = sqrtn * (b+1);
            if (q <= l || r <= p) continue;
            if (l <= p && q <= r){
                ret = min(ret, buk[b]);
            }else{
                eval(b);
                FOR(i,max(l,p),min(r,q)-1){
                    ret = min(ret, dat[i]);
                }
            }
        }
        return ret;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<P> p(n);
    REP(i,n){
        p[i].first = in();
        p[i].second = in();
    }
    sort(ALL(p));

    SqrtDecomposition2 sd;
    sd.init(m+2);

    REP(i,m+2){
        sd.add(i, i+1, m+1-i);
    }

    int ans = n - m;

    int j = 0;
    REP(i,m+1){
        while (j < n && p[j].first <= i){
            sd.add(0, p[j].second+1, -1);
            j++;
        }
        int x = sd.query(i+1, m+2);
        ans = max(ans, -x - i);
    }
    cout << ans << endl;

    return 0;
}

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

using ll = long long;
#define rep(n, i) for(ll i = 0; i < n; ++i)

void solve(void){
  char c; cin >> c;
  if (c - 'A' >= 26) cout << 'a' << endl;
  else cout << 'A' << endl;
}

int main(void) {
  solve();
  return 0;
}

Measured memory_bytes: 3632
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

cnt = defaultdict(int)
for i in range(n):
    cnt[a[i] - 1] += 1
    cnt[a[i]] += 1
    cnt[a[i] + 1] += 1

ans = 0
for i in cnt:
    ans = max(ans, cnt[i])

print(ans)

Measured memory_bytes: 20064
#include <iostream>
// #inclu
using namespace std;

const int MAX_N = 100;
int a[MAX_N];

int selectionSort(int a[], int n);

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)  cin >> a[i];
	int ex = selectionSort(a, n);
	for(int i = 0; i < n; i++) {
		if (i) cout << " ";
		cout << a[i];
	}
	cout << endl;
	cout << ex << endl;

	return 0;
}

int selectionSort(int a[], int n){
	int ex = 0;
	for(int i = 0; i < n; i++){
		int minj = i;
		for(int j = i + 1; j < n; j++){
			if(a[j] < a[minj]) minj = j;
		}
		swap(a[i],a[minj]);
		if (i != minj) ex++;
	}
	return ex;
}

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

int main()
{ 
  int a, b, k, k_count = 0, i;

  cin >> a >> b >> k;
  i = min(a, b);
  while (true)
  {
    if (a % i == 0 && b % i == 0)
    {
      k_count++;
      if (k_count == k)
        break;
    }
    i--;
  }
  cout << i << endl;
}

Measured memory_bytes: 256
# 最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# 最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)

if __name__ == "__main__":
    input_list = list(map(int, input().split()))
    a, b, c = input_list

    result = False
    lcm_of_ab = lcm(a, b)
    for i in range(lcm_of_ab // a + 1):
        if (not i):
            continue

        if (a * i) % b == c:
            result = True
            break

    if result:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 3064
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// MOD :
var MOD = 1000000007

const size = 2100000

// Fac :
var Fac [size + 1]int

// IFac :
var IFac [size + 1]int

// 乗数計算（MOD)
func mpow(x, n int) int {
	ans := 1
	for n != 0 {
		if n&1 == 1 {
			ans = ans * x % MOD
		}
		x = x * x % MOD
		n = n >> 1
	}
	return ans
}

// コンビネーション計算
func comb(a, b int) int {
	if (a == 0) && (b == 0) {
		return 1
	}
	if (a < b) || (a < 0) {
		return 0
	}
	tmp := IFac[a-b] * IFac[b] % MOD
	return tmp * Fac[a] % MOD
}

func initPow() {
	Fac[0] = 1
	IFac[0] = 1
	for i := 0; i < size; i++ {
		Fac[i+1] = Fac[i] * (i + 1) % MOD            // n!(mod M)
		IFac[i+1] = IFac[i] * mpow(i+1, MOD-2) % MOD // k!^{M-2} (mod M) ←累乗にmpowを採用
	}
}

func main() {
	initPow()

	sc.Split(bufio.ScanWords)

	r1, c1, r2, c2 := getInt(), getInt(), getInt(), getInt()

	x00 := comb(r1+c1, c1)
	x10 := comb(r2+c1+1, c1)
	x01 := comb(r1+c2+1, c2+1)
	x11 := comb(r2+c2+2, c2+1)

	ans := (x11 + x00) % MOD
	ans = ans - x01
	if ans < 0 {
		ans += MOD
	}
	ans = ans - x10
	if ans < 0 {
		ans += MOD
	}
	out(ans)
}


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

int main()
{
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    if((e-a) > k) {
        cout << ":(" << endl;
        return 0;
    }
    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 3592
import Data.Array.IO
import Data.Array.Unboxed
import Data.List
import Control.Monad
import Control.Applicative

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

main = do
  (n:c:_) <- getLine >>= return . map read . words :: IO [Int]
  darr <- newArray ((1,1),(c,c)) 0 :: IO (IOUArray (Int, Int) Int)

  forM_ [1..c] $ \i -> do
    temp <- getLine >>= return . map read . words :: IO [Int]
    forM_ (zip [1..c] temp) $ \(j, d) -> do
      writeArray darr (i,j) d

  countArray <- newArray ((0,1),(2,c)) 0 :: IO (IOUArray (Int,Int) Int)
  
  forM_ [1..n] $ \i -> do
    temp <- getLine >>= return . map read . words :: IO [Int]
    forM_ (zip [1..n] temp) $ \(j, c) -> do
      modifyArray countArray (mod (i+j) 3, c) (+1)

  s <- forM [[i,j,k]| i<-[1..c], j<-[1..c], k<-[1..c], i/=j, j/=k, i/=k] $ \colors -> do
    c <- forM [0..2] $ \m -> do
      forM [1..c] $ \x -> do
        count <- readArray countArray (m,x)
        d <- readArray darr (x,colors!!m)
        return $ d * count
    return $ (sum . map sum) c

  print $ minimum s


Measured memory_bytes: 174716