akhauriyash/Code-Regression huggingface dataset:
use std::io::*;

fn count(comb: usize, s_arr: &Vec<usize>) -> usize {
    let mut result = 0;
    for s in s_arr {
        if (comb & (1usize << s)) != 0 {
            result += 1;
        }
    }
    result
}

fn solve(n: usize, m: usize, s_arr_arr: Vec<Vec<usize>>, p: Vec<usize>) ->
 usize {
    let mut comb: usize = 0;
    let end: usize = 1 << n;
    let mut result = 0;
    while comb < end {
        if (0..m).map(|i| {
            count(comb, &s_arr_arr[i]) % 2 == p[i]
        }).all(|a| { a })
        {
            result += 1;
        }
        comb += 1;
    }
    result
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();
    let s: Vec<Vec<usize>> = (0..m).map(|_| {
        let k: usize = iter.next().unwrap().parse().unwrap();
        (0..k).map(|_| {
            iter.next().unwrap().parse::<usize>().unwrap() - 1usize
        }).collect()
    }).collect();
    let p: Vec<usize> = (0..m).map(|_| {
        iter.next().unwrap().parse().unwrap()
    }).collect();
    println!("{}", solve(n, m, s, p));
}

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

int main(){
  char b;
  char ans;
  cin >> b;
  if(b == 'A') ans = 'T';
  else if(b == 'T') ans = 'A';
  else if(b == 'G') ans = 'C';
  else ans = 'G';
    
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;


int gcd(long long a, long long b) {
    return b != 0 ? gcd(b, a%b) : a;
}

int main() {
    long long a, b;
    cin >> a >> b;
    
    cout << a*b/gcd(a, b) << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

res = 'APPROVED'
for i in range(len(A)):
  if A[i] % 2 == 0 and A[i] % 3 != 0 and A[i] % 5 != 0:
    res = 'DENIED'

print(res)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define for1(n) for(i=1; i<=(n); i++)


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>n;
    ll aa[n];
    vector<ll> v(1000005);
    for0(n)
    {
        cin>>aa[i];
        if(v[aa[i]]==0)
        {
            for(j=aa[i];j<1000003;j+=aa[i])v[j]++;
        }
        else v[aa[i]]=5;
    }
    for0(n)if(v[aa[i]]==1)c++;
    cout<<c<<endl;


}



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

typedef unsigned uint;
typedef long long INT;
typedef unsigned long long UINT;
const int INF = 1001001001;
const INT INFLL = 1001001001001001001LL;

 int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
INT lin() { INT x; scanf("%lld", &x); return x; }
UINT luin() { UINT x; scanf("%llu", &x); return x;}

int main(){
    int a, b, c;
    double fa, fb, fc;
    char S[128], sa[128], sb[128], sc[128];
    // int N = in();
    // int K = in();
    // scanf("%s", S);

    UINT A = luin();
    UINT B = luin();
    UINT N = luin();

    UINT x = min(N, B-1);
    UINT MAX = (A * x) / B;

    printf("%llu", MAX);




    return 0;
}







Measured memory_bytes: 3792
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            total = i*500 + j*100 + k*50
            if total == x:
                ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int 
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
int v[100000]={};
int a[100000] = {};

int main(){
    fast;
    int n,k; cin >> n >> k;
    for(int i=0 ; i<n ; i++){
        cin >> v[i];
    }
    for(int i=1 ; i<n ; i++){
        a[i] = a[i-1] + abs(v[i]-v[i-1]);
        for(int j= max(0,i-k) ; j<i ; j++)
            a[i] = min(a[i],a[j]+abs(v[i]-v[j]));
    }
    cout << a[n-1] << endl;

}

Measured memory_bytes: 1024
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	string res = "Yes";
	long N; cin >> N;
	long t[100009], x[100009], y[100009]; for (int i = 1; i <= N; i++) cin >> t[i] >> x[i] >> y[i];
	t[0] = 0; x[0] = 0; y[0] = 0;
	long mydis;

	for (int i = 1; i <= N; i++) {
		mydis = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
		if (mydis > t[i] - t[i - 1] || mydis % 2 != (t[i] - t[i - 1]) % 2) res = "No";
	}
	
	cout << res << endl;
}

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

//https://atcoder.jp/contests/abc029/tasks/abc029_d
//https://algo-logic.info/digit-dp/

#include <iostream>
#include <vector>

using namespace std;

//dp[ i ][smaller][ j ] := i 桁目までの各桁の数の0でないj個数。
//ただし smaller が true ならNより小さい場合を考え、
//smallerが false ならNと同じ場合を考える。

long long dp[1005][2][5];

int main(){
    string N; cin >> N;
    int keta = N.size();
    int K; cin >> K;

    dp[0][0][0] = 1;
    //桁数 i
    for(int i=0; i<keta; ++i){
        //条件 j　
        for(int j=0; j<=3; ++j){
            //smaller flag の場合分け

            //1. i桁目まででNより小さいならi+1桁は何でも良い
            // for(int k=0; k<10; ++k){
            //     //fill in the dp below is the example
            //     // dp[i+1][1][ (j+k)%D ] += dp[i][1][j];
            //     // dp[i+1][1][(j+k) % D] %= MOD;
            // }
            dp[i+1][1][j+1] += dp[i][1][j] *9; // i+1桁が1-9;
            dp[i+1][1][j] += dp[i][1][j];  // i+1桁が0

            int ni = (N[i] - '0');
            //2. i桁目までNと同じでi+1はNより小さい
            // for(int k=0; k<ni; ++k){
            //     //fill in the dp below is the example
            //     // dp[i+1][1][ (j+k) % D ] += dp[i][0][j];
            //     // dp[i+1][1][ (j+k) % D ] %= MOD;
            // }
            if(ni >= 1){
                dp[i+1][1][j+1] += dp[i][0][j] *(ni-1);    // j+1は（i+1桁目が1~ni-1）でできる
                dp[i+1][1][j] += dp[i][0][j];               // jも同様に一回加算できる（これは前の桁が0だった場合に対応）
            }

            //3. i桁目めでNと同じで i+1も同じ数
            // fill in the dp below is the example
            // dp[i+1][0][ (j+ni) % D ] = dp[i][0][j];
            if(ni == 0){
                //i+1が0
                dp[i+1][0][j] = dp[i][0][j];
            }else{ 
                dp[i+1][0][j+1] = dp[i][0][j];
            }

        }
    }

    cout << dp[keta][1][K] + dp[keta][0][K] << endl;

}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   cin>>n;
  string s;
  cin>>s;
  int f=0;
  if(n%2==1)
  cout<<"No";
  else
  {for(int i=0;i<n/2;i++)
  {
    if(s[i]!=s[i+n/2])
    {
       f=1;
      break;
    }
  }
   if(f==1)
     cout<<"No";
   else
     cout<<"Yes";
  }
}


Measured memory_bytes: 256
def solve(n, s, d, MOD):
    ttt = [ord(c) - 97 for c in s]

    ttx = []
    c = 1
    for t in ttt[::-1]:
        ttx.append(t * c % MOD)
        c = c * d % MOD
    ttx.reverse()
    ttc = [0]
    for t in ttx:
        ttc.append((ttc[-1] + t) % MOD)

    l, r = 0, n
    while l < r:
        m = (l + r + 1) // 2
        if search(m, d, ttc, MOD):
            l = m
        else:
            r = m - 1

    return l


def search(w, d, ttc, MOD):
    appeared = []
    comparing = set()
    w2 = w * 2
    p = 1

    for i in range(w, n + 1):
        t = (ttc[i] - ttc[i - w]) * p % MOD
        if i >= w2:
            comparing.add(appeared[i - w2])
            if t in comparing:
                return True
        appeared.append(t)
        p = p * d % MOD

    return False


n = int(input())
s = input()
MOD = 10 ** 9 + 7
print(min(solve(n, s, d, MOD) for d in (26, 29, 31)))


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

using namespace std;

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

	int n;
	long double x,y;
	vector <pair<long double,long double>> v;

	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> x >> y;
		v.push_back(make_pair(x,y));
	}

	double res = 1e18;

	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				double x1 = v[i].first;
				double y1 = v[i].second;
				double x2 = v[j].first;
				double y2 = v[j].second;
				double x3 = v[k].first;
				double y3 = v[k].second;
				double D = 2*(x2-x1)*(y3-y2)-2*(y2-y1)*(x3-x2);
				if(D!=0)
				{
					double x = (y3-y2)*(x2*x2-x1*x1+y2*y2-y1*y1) + (y1-y2)*(x3*x3-x2*x2+y3*y3-y2*y2);
					double y = (x2-x3)*(x2*x2-x1*x1+y2*y2-y1*y1) + (x2-x1)*(x3*x3-x2*x2+y3*y3-y2*y2);
					x/=D;
					y/=D;
					double r = sqrt((x-x1)*(x-x1) + (y-y1)*(y-y1));
					bool ok = true;
					for(int l=0;l<n;l++)
					{
						double d = sqrt((v[l].first - x)*(v[l].first - x) + (v[l].second - y)*(v[l].second - y));
						if(d > r)
						{
							ok = false;
							break;
						}
					}
					if(ok)
					{
						res = min(res,r);
					}
				}
			}
		}
	}

	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			long double mx = (v[i].first + v[j].first)/(2.0);
			long double my = (v[i].second + v[j].second)/(2.0);
			long double r = 0;
			for(int k=0;k<n;k++)
			{
				long double dx = abs(mx - v[k].first);
				long double dy = abs(my - v[k].second);
				long double d = sqrt(dx*dx + dy*dy);
				r = max(r,d);
			}
			res = min(res,(double)r);
		}
	}

	cout << fixed;
	cout.precision(18);

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 892
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    s = S()
    s[3] = "8"
    print("".join(s))
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    n, h = LI()
    ab = LIR(n)
    ab.sort(reverse=True)
    amax = ab[0][0]
    ab.sort(key=lambda x: x[1], reverse=True)
    ans = 0
    hp = 0
    for a,b in ab:
        if b <= amax:
            break
        ans += 1
        hp += b
        if hp >= h:
            break
    ans += max(math.ceil((h-hp)/amax),0)    
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38640
n = int(input())
x =[]
for i in range(n):
    a,b=input().split()
    b=int(b)
    x.append([i+1,a,b])
    x.sort(key=lambda x:x[2],reverse = True)
    x.sort(key=lambda x:x[1])
for i in range(n):
    print(x[i][0])

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<queue>

using namespace std;

const int MAXN =1e5+10;

int k;
struct VER{
	int x,w;
};
bool vis[MAXN];
deque<VER> q;

void bfs(){
	VER v;
	v.w=1;//为什么起点是1，权值也是1? 
	v.x=1;
	q.push_front(v);
	
	while(!q.empty()){
		VER t=q.front();
		q.pop_front();
		vis[t.x]=true;
		if(t.x==0){//是k的倍数 
			cout<<t.w<<endl;
			break;
		}
		if(!vis[t.x*10%k]){
			VER m;
			m.x=t.x*10%k;
			m.w=t.w;
			q.push_front(m);
		}
		
		if(!vis[(t.x+1)%k]){
			VER m;
			m.x=(t.x+1)%k;
			m.w=t.w+1;
			q.push_back(m);
		}
		
	}
	
}

int main(){
    cin>>k;
    bfs();
    
    return 0;
} 

Measured memory_bytes: 896
// 深さ優先探索
package main

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

type edge struct {
	To int
	ID int
}

var (
	edges  [][]edge
	colors []int
)

func main() {
	defer flush()

	N := readInt()

	edges = make([][]edge, N)
	for i := 0; i < N-1; i++ {
		a := readInt() - 1
		b := readInt() - 1
		edges[a] = append(edges[a], edge{To: b, ID: i})
		edges[b] = append(edges[b], edge{To: a, ID: i})
	}

	colors = make([]int, N)
	q := make([][3]int, 1, N)
	q = append(q, [3]int{0, -1, -1})
	for len(q) != 0 {
		current, usedColor, from := q[len(q)-1][0], q[len(q)-1][1], q[len(q)-1][2]
		q = q[:len(q)-1]
		color := 1
		for _, e := range edges[current] {
			if e.To == from {
				continue
			}
			if color == usedColor {
				color++
			}
			colors[e.ID] = color
			q = append(q, [3]int{e.To, color, current})
			color++
		}
	}

	K := -1
	for _, color := range colors {
		if color > K {
			K = color
		}
	}
	println(K)

	for i := 0; i < N-1; i++ {
		println(colors[i])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdoutWriter, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


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

int main(){
  int A, B, C, D;
  cin>>A>>B>>C>>D;
  if(A*B>C*D)cout<<A*B<<endl;
  else if(A*B<C*D)cout<<C*D<<endl;
  else cout<<A*B<<endl;


       return 0;
     }



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

long long nC2(long long n){
	return(n*(n-1))/2;
}


int main() {
	int N;
	cin >> N;
	vector<long long> a(N);
	for(int i=0;i<N;i++){
		cin >> a.at(i);
	}
	vector<long long> sum(N);
	sum.at(0)=a.at(0);
	for(long long i=1;i<N;i++){
		sum.at(i)=sum.at(i-1)+a.at(i);
	}
	map<long long,long long> ans;
	vector<long long> ele(0);
	long long count=0;
	for(auto i:sum){
		if(ans.count(i)){
			ans[i]++;
			if(i==0){
				count++;
			}
			
		}
		else{
			ans[i]=1;
			ele.push_back(i);
			if(i==0){
				count++;
			}
			
		}
	}
	
	for(auto i:ele){
		// cout<<"ans;"<<ans[i]<<endl;
		if(ans[i]>=2){
			count+=nC2(ans[i]);
		}
	}
		
	cout<<count<<endl;
}

Measured memory_bytes: 17392
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>

using namespace std;

typedef pair<long long int,int> P;


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

	int n;

	cin >> n;

	int a;
	int ans=0;
	for(int i=0;i<n;i++){
		cin >> a;
		ans += a-1;
	}
	cout << ans << "\n";

			
			
	return 0;
}

Measured memory_bytes: 256
k,n=map(int,input().split())
A=list(map(int,input().split()))
sum=0
max=A[0]+(k-A[n-1])

for i in range(1,n):
    if max<A[i]-A[i-1]:
        max=A[i]-A[i-1]
print(k-max)




Measured memory_bytes: 78412
import math

n  = int(input())
ps = []
ds = []
a  = 1
b  = 1

for _ in range(0, n):
	x, y = [int(x) for x in input().split()]
	ps.append((x, y))

for i in range(1, n):
	a *= i
	b *= i

b *= n

for i in range(0, n):
	for j in range(0, n):
		if i != j:
			dx = ps[i][0] - ps[j][0]
			dy = ps[i][1] - ps[j][1]
			ds.append(math.sqrt(dx * dx + dy * dy) * a)

print(sum(ds) / b)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
string S,T;int n,p;
int main(){
	cin>>n>>S>>p;T=S;
	for(int i=0;i<S.size();i++){
		if(p>=1 && S[i]=='0'){T[i]='1';p--;}
	}
	for(int i=S.size()-1;i>=0;i--){
		if(p>=1 && S[i]=='1'){T[i]='0';p--;}
	}
	cout<<T<<endl;return 0;
}

Measured memory_bytes: 3192
n, k = map(int, input().split())
a = [(int(i) + 1)/2 for i in input().split()]
ans = 0
s = sum(a[:k])
ans = s
for i in range(k, n):
	s -= a[i - k]
	s += a[i]
	ans = max(ans, s)
print(ans)

Measured memory_bytes: 31804
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
	cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	print(min(a, b) + min(c, d));
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

#define repeat(n, i) for(int i=0; i<(n); i++)
int w, h;
int xs, ys;
int xg, yg;
int n;

int st_color;

int board[300][300];

#define VISITED 6

bool get_input() {
    memset(board, 0, sizeof(board));
    cin >> w >> h;
    if (w == 0 && h == 0) return false;
//    board.resize(h);
//    repeat(h, i) board[i].resize(w);
    cin >> xs >> ys;
    cin >> xg >> yg;
    cin >> n;
    repeat(n, i) {
        int c, d, x, y;
        cin >> c >> d >> x >> y;
        if (d == 1) {
            for (int j = y-1; j < y-1+4; j++) {
                for (int k = x-1; k < x-1+2; k++) {
                    board[j][k] = c;
                }
            }
        } else {
            for (int j = y-1; j < y-1+2; j++) {
                for (int k = x-1; k < x-1+4; k++) {
                    board[j][k] = c;
                }
            }
        }
    }
    st_color = board[ys-1][xs-1];
    return true;
}

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

bool possible;
void dfs(int x, int y) {
    board[y-1][x-1] = VISITED;
    if (x == xg && y == yg) {
        possible = true;
        return;
    }
    repeat(4, i) {
        int nx = x+dx[i], ny = y+dy[i];
        if (1 <= nx && nx <= w && 1 <= ny && ny <= h) {
            if (board[ny-1][nx-1] == st_color) {
                dfs(nx, ny);
            }
        }
    }
}

// debug 
//void solve() {
//    repeat(h, i) {
//        repeat(w, j) {
//            cout << board[i][j] << ' ';
//        }
//        cout << endl;
//    }
//}

void solve() {
    possible = false; dfs(xs, ys);
    if (possible) cout << "OK" << endl;
    else cout << "NG" << endl;
}

int main() {
    while (get_input()) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int n;
string a[21],b[21];
string f,t;
bool used[21];
int res;
void dfs(string v,int c){
	//cout << v << endl;
	if(v==t){
		res=min(res,c);
		return;
	}
	if(v.size()>=t.size() || c>=res)return;
	for(int i=0;i<n;i++){
		memset(used,0,sizeof(used));
		bool flag=false;
		if(v.size()<a[i].size())continue;
		for(int j=0;j<=v.size()-a[i].size();j++){
			if(v.substr(j,a[i].size())==a[i]){
				used[j]=true;
				j+=a[i].size()-1;
				flag=true;
			}
		}
		if(!flag)continue;
		string next="";
		for(int j=0;j<v.size();j++){
			if(!used[j])next+=v[j];
			else{
				next+=b[i];
				j+=a[i].size()-1;
			}
		}
		dfs(next,c+1);
	}
}

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin >> a[i] >> b[i];
		}
		cin >> f;
		cin >> t;
		res=t.size()-f.size()+1;
		dfs(f,0);
		printf("%d\n",res==t.size()-f.size()+1?-1:res);
	}
	return 0;
}

Measured memory_bytes: 1256
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

using pii = pair<ll, ll>;

ll f[100001];

int main()
{
  int n, K;
  cin >> n >> K;
  vector<pii> v(n);
  for (int i = 0; i < n; ++i)
  {
    ll t, d;
    cin >> t >> d;
    v[i] = {d, t};
  }
  sort(v.begin(), v.end(), greater<pii>());
  ll kind = 0;
  ll st = 0;
  for (int i = 0; i < K; ++i)
  {
    if (f[v[i].second] == 0)
    {
      kind++;
    }
    f[v[i].second]++;
    st += v[i].first;
  }
  queue<ll> yobi;
  for (int i = K; i < n; ++i)
  {
    if (f[v[i].second] == 0)
    {
      yobi.push(v[i].first);
      f[v[i].second]++;
    }
  }
  ll ans = st + (ll)kind * kind;
  for (int i = K - 1; i >= 0; --i)
  {
    if (yobi.empty())
      break;
    if (f[v[i].second] > 1)
    {
      kind++;
      st -= v[i].first;
      st += yobi.front();
      yobi.pop();
      ans = max(ans, st + (ll)kind * kind);
      f[v[i].second]--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3072
n = int(input())
l = [[-1 for _ in range(n)] for _ in range(n)]
for i in range(n):
    m = int(input())
    for j in range(m):
        x,y = [int(i) for i in input().split()]
        l[i][x-1] = y
        
ans = 0
for i in range(1<<n):
    honests = [0 for _ in range(n)]
    for j in range(n):
        if (i >> j) & 1:
            honests[j] = 1
    flg = 1
    for k in range(n):
        if honests[k]:
            for h in range(n):
                if l[k][h] == -1 : continue
                if l[k][h] != honests[h] : flg = 0
    
    if flg:
        ans = max(ans,sum(honests))
        
print(ans)
    
    
    


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

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = 1e18 + 7;


signed main(){
    i64 n, a, b;
    cin >> n >> a >> b;
    vector<i64> v(n);
    for(auto& x : v)
        cin >> x;

    auto f = [&](i64 val){
        i64 cnt = 0;
        for(auto& x : v){
            i64 res = max(0L, x - b * val);
            cnt += (res + a - b - 1) / (a - b);
        }
        return cnt <= val;
    };

    i64 ok = MOD, ng = 0;
    while(abs(ok - ng) > 1){
        i64 mid = (ok + ng) >> 1;
        (f(mid) ? ok : ng) = mid;
    }
    cout << ok << endl;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


const ll MOD = 1e9 + 7;
const int MAX_N = 112345;
ll dp[MAX_N][2];

int main2() {
  CLR(dp, 0);
  string L; cin >> L;
  int N = L.size();

  dp[0][0] = 1;
  for (int i = 0; i < N; i++) {
    dp[i+1][0] += dp[i][0] * (L[i] == '0' ? 1 : 2);
    if (L[i] == '1') {
      dp[i+1][1] += dp[i][0];
    }
    dp[i+1][1] += dp[i][1] * 3;

    dp[i+1][0] %= MOD;
    dp[i+1][1] %= MOD;
  }
  ll ans = dp[N][0] + dp[N][1];
  ans %= MOD;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	string S, T; cin >> S >> T;
	bool flag = false;

	rep(i, 0, S.size()) {
		if (S == T) {
			flag = true;
			break;
		}
		else {
			S = S[S.size() - 1] + S;
			S.erase(S.size() - 1);
		}
	}
	cout << (flag ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>

double round(double r) {
    return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
}

using namespace std;




int main() {
	
string s;
cin>>s;
int g[50]={};
for(int i=0;i<s.size();i++){
	g[s[i]-'a']++;

}
for(int i=0;i<28;i++)
	if(g[i]%2){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
    return 0;
}

	
	


	

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

const int MAXN = 2 * 100000;
vector<int> g[MAXN + 1];
int color[MAXN + 1], comp, ans[MAXN + 1], used[MAXN + 1], sz;
vector<int> cur;

void dfs(int v) {
    color[v] = comp;
    for(auto u: g[v])
        if(!color[u])
            dfs(u);
}

void dfs1(int v) {
    used[v] = true;
    sz++;
    cur.push_back(v);
    for(auto u: g[v])
        if(!used[u])
            dfs1(u);
}

int main() {
    //ios_base::sync_with_stdio(false);
   // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, k, l;
    scanf("%d%d%d", &n, &k, &l);
    for(int i = 0; i < k; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i = 1; i <= n; i++) {
        if(!color[i]) {
            comp++;
            dfs(i);
        }
    }
    for(int i = 1; i <= n; i++)
        g[i].clear();
    for(int i = 0; i < l; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i = 1; i <= n; i++) {
        if(!used[i]) {
            sz = 0;
            cur.clear();
            dfs1(i);
            map<int, int> cnt;
            for(auto x: cur) {
                cnt[color[x]]++;
            }
            for(auto x: cur)
                ans[x] = cnt[color[x]];
        }
    }
    for(int i = 1; i <= n; i++)
        printf("%d ", ans[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 14976
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007


void solve(void)
{ 

  string S;
  cin>>S;
  int ANS = 0;
  for (int i = 0; i < S.size() - 1; i++)
  {
    if(S[i] != S[i+1])ANS++;
  }

  cout<<ANS;
  
  return;  
}



int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

 
  return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  int N;
  while (cin >> N) {
    vector<int> H(N);
    for (int& x : H) cin >> x;
    int res = 0;
    int mx = 0;
    for (int x : H) {
      if (x >= mx) {
        ++res;
        mx = x;
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n + k];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        int[] dp = new int[n + k];
        for (int i = 0; i < n; i++) {
            dp[i] = Integer.MAX_VALUE;
        }

        dp[0] = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 1; j <= k; j++) {
                int a = dp[i] + Math.abs(h[i] - h[i + j]);
                if (dp[i + j] > a) {
                    dp[i + j] = a;
                }
            }
        }

        System.out.println(dp[n - 1]);
    }
}


Measured memory_bytes: 52104
// AOJ 2030: Ruins
// 2017.10.1 bal4u@uu

#include <stdio.h>
#include <math.h>

int main()
{
	int a, b, sa, sb;
	int a1, a2, b1, b2;
	int t1, t2, t3, t4, t, ans;

	while (scanf("%d%d", &a, &b) && a > 0) {

		sa = (int)sqrt((double)a)+1, sb = (int)sqrt((double)b)+1;
		while (sa*sa > a) sa--; while (sb*sb > b) sb--;

		for (ans = 0x7fffffff, a1 = 1; a1 <= sa; a1++) {
			if (a % a1) continue;
			a2 = a / a1;
			for (b1 = 1; b1 <= sb; b1++) {
				if (b % b1) continue;
				b2 = b / b1;

				if (a1 > b1) t1 = b1, t2 = a1;
				else         t1 = a1, t2 = b1;
				if (a2 > b2) t3 = b2, t4 = a2;
				else         t3 = a2, t4 = b2;
				if (t2 > t3) t = t2, t2 = t3, t3 = t;
				t = (t2-t1)*(t2-t1)+(t3-t2)*(t3-t2)+(t4-t3)*(t4-t3);
				if (t < ans) ans = t;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int a,b;
	while(~getII(a,b)){
		if(a+b==15) puts("+");
		else if(a*b==15) puts("*");
		else puts("x");
	}
}


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

const int N = 105;

int n, ind[N], p[N];
string s[N];

int main()
{
  	cin >> n;
  	for (int i = 1; i <= n; i++)
    {
      	cin >> s[i] >> p[i];
      	ind[i] = i;
    }
  	sort(ind + 1, ind + n + 1, [](const int &x, const int &y) {
      	return s[x] < s[y] || (s[x] == s[y] && p[x] > p[y]);
    });
  	for (int i = 1; i <= n; i++)
      	cout << ind[i] << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;

long long a[N];
int n;
long long Minus[N];

int main() {
    int n, k, q;
    scanf("%d%d%d", &n, &k, &q);
    for (int i = 1; i <= n; i++) a[i] = 1LL * k;
    for (int i = 1; i <= q; i++) {
        int x;
        scanf("%d", &x);
        Minus[1]--;
        Minus[x]++;
        Minus[x+1]--;
    }
    for (int i = 1; i <= n; i++) {
        Minus[i] = Minus[i] + Minus[i-1];
    }
    for (int i = 1; i <= n; i++) {
        a[i] = 1LL*a[i] + Minus[i];
    }
    //for (int i = 1; i <= n; i++) printf("%lld ", Minus[i]);
    for (int i = 1; i <= n; i++) {
        if (a[i] > 0) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MOD2 100000000
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define all(v) v.begin(),v.end()
ll mod=MOD;
using namespace std;
long long int fast_exp(long long int base,long long int ex) {
    long long int res=1;
    while(ex>0) {
       if(ex%2==1) res=(res*base)%mod;
       base=(base*base)%mod;
       ex/=2;
    }
    return res%mod;
}
long long int gcd(long long int a, long long int b)
{
    if(b==0)return a;
     return gcd(b,a%b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,w;
    cin>>n>>w;
    ll a[n]; ll b[n];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];
    ll dp[100001];
    memset(dp,0,sizeof(dp));
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=w;j>=0;j--)
            if((j+a[i])<=w&&dp[j]!=-1)
                dp[j+a[i]]=max(dp[j+a[i]],dp[j]+b[i]);
    }
    ll ans=0;
    for(int i=0;i<=w;i++)
      {
          ans=max(ans,dp[i]);
      }
    cout<<ans;
    return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, Q;
    cin >> N >> Q;

    string S;
    cin >> S;

    vector<ll> s(N+1, 0);
    rep (i, N) {
        if (i+1 < N && S[i] == 'A' && S[i+1] == 'C') {
            s[i+1] = s[i] + 1;
        } else {
            s[i+1] = s[i];
        }
    }

    rep (i, Q) {
        ll l, r;
        cin >> l >> r;
        cout << s[r-1] - s[l-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1872
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextInt();
            }

            Arrays.sort(A);

            int count = 0;
            boolean[] used = new boolean[(int) (1e6 + 1)];
            for (int i = 0; i < N; i++) {
                if (i + 1 < N && A[i] == A[i + 1]) {
                } else if (i - 1 >= 0 && A[i] == A[i - 1]) {
                } else if (used[A[i]]) {
                } else {
                    count++;
                }
                if (!used[A[i]]) {
                    for (int j = A[i]; j < used.length; j += A[i]) {
                        used[j] = true;
                    }
                }
            }

            System.out.println(count);
        }
    }
}


Measured memory_bytes: 49928
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


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

    ll ans = (x/500) * 1000;
    x %= 500;
    ans += (x/5) * 5;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
	string S, T;
	cin >> S >> T;
	int ans = T.length();
	int Slen = S.length();
	int Tlen = T.length();
	for (int i = 0; i < Slen - Tlen + 1; i++) {
		int tmp = 0;
		for (int j = 0; j < T.length(); j++) {
			if (S[i + j] != T[j]) tmp++;
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    long long n;
    cin>>n;
    string s;
    while(n){
        n--;
        s+=char('a'+(n%26));
        n/=26;
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3592
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

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

int main() {
	vector<int>data(3);
	for (int i = 0; i < 3; i++) {
		cin >> data[i];
	}
	sort(data.begin(), data.end());
	if (data[0] == 5 && data[1] == 5 && data[2] == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

nr = s.count("R")
ng = s.count("G")
nb = s.count("B")

count = nr * ng * nb

for i in range(n-2):
    for j in range(i+1, (n+i+1)//2):
        if s[i] == s[j]:continue
        else:
            k = 2*j - i # k - j = j - i
            if s[i] == s[k]:continue
            if s[j] == s[k]:continue
            count -= 1

print(count)


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

int main() {
    vector<vector<vector<int> > > m(4, vector<vector<int> >(3, vector<int>(10, 0)));
    int n;
    cin >> n;
    REP(i,n) {
        int b, r, f, v;
        cin >> b >> r >> f >> v;
        m[b-1][r-1][f-1] += v;
    }
    REP(j,4) {
        REP(k,3) {
            REP(l,10) {
                cout << " " << m[j][k][l];
                if(l == 9) cout << endl;
            }
        }
        if(j != 3) cout << "####################" << endl;
    }
}





Measured memory_bytes: 3172
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// ****************************************CODE***************************************//


ll n, k;
ll h[110000];
ll dp[110000];

ll rec(ll i) {
    if(dp[i] != inf) return dp[i];

    ll res = inf;
    res = min(res, rec(i-1) + abs(h[i] - h[i-1]));
    if(i>1) res = min(res, rec(i-2) + abs(h[i] - h[i-2]));

    return dp[i] = res;
}

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 0; i < 110000; i++) dp[i] = inf;

    dp[0] = 0;

    cout << rec(n-1) << endl;
    return 0;
}

Measured memory_bytes: 5120
from collections import deque
S = str(input());s = []
for i in range(len(S)):
  s.append(S[i])
s = deque(s)
Q = int(input())
eo = 0
for query in range(Q):
  temp = list(map(str,input().split()))
  if temp[0] == "1":
    eo += 1 #反転したということになる
  else:
    if temp[1] == "1":
      if eo%2 == 0:
        s.appendleft(temp[2])
      else:
        s.append(temp[2])
    else:
      if eo%2 == 0:
        s.append(temp[2])
      else:
        s.appendleft(temp[2])
#print(s)
s = list(s)
if eo%2 == 0:
  ans = "".join(s)
else:
  s = s[::-1]
  ans = "".join(s)
print(ans)

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    int a;
    cin>>s;
    if(s[2]==s[3])
    {
    	if(s[4]==s[5])
        	{
        	    cout<<"Yes"<<"\n";
        	}
        	else
            {
            	cout<<"No"<<"\n";
            }
        
    }
    else
    {
    	cout<<"No"<<"\n";
    }


    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  string s; cin >> s;
  int ans = 0;
  int l = 0; int r = s.size() - 1;
  while(true) {
    if(l == r) break;
    if(s[l] != s[r]) {
      if(s[l] == 'x') {
        ans++; l++;
      } else if(s[r] == 'x') {
        ans++; r--;
      } else {
        ans = -1;
        break;
      }
    } else {
      if(r - l <= 1) break;
      l++; r--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3740
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

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

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

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		string s,t;
		cin>>s>>t;
		int n = s.length();
		int m = t.length();
		int ans  = INT_MAX;
		for(int i=0; i<n-m+1; i++) {
			int c = 0;
			for(int j=0; j<m; j++) {
				if(t[j] != s[j+i]) {
					c++;
				}
			}
			ans = min(ans,c);
		}
		cout<<ans<<"\n";
 	}
 	return 0;
}


Measured memory_bytes: 3616