akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
 #include <vector>
 using namespace std;

 bool BinarySearch(int t, vector<int>& S)
 {
 	int start = 0;
 	int end = S.size() - 1;
 	do{
 		int middle = (end - start) / 2 + start;
 		if(t == S[middle]){
 			return true;
 		}else if(t < S[middle]){
 			end = middle - 1;
 		}else if(t > S[middle]){
 			start = middle + 1;
 		}
 //		cout << t << " " << start << " " << middle " " << end << endl;
 	}while(end - start >= 0);
 	return false;
 }

 int main()
 {
 	int Count = 0;
 	int n;
 	cin >> n;
 	vector<int> S;
 	for(int i = 0; i < n; i++){
 		int s;
 		cin >> s;
 		S.push_back(s);
 	}
 	int q;
 	cin >> q;
 	for(int i = 0; i < q; i++){
 		int t;
 		cin >> t;
 		if(BinarySearch(t, S)){
 			Count++;
// 			cout << "t:" << t << endl;
 		}
 	}
 	cout << Count << endl;
 	return 0;
 }

Measured memory_bytes: 1672
from heapq import heappop, heappush
from collections import defaultdict

class MeldableHeap():
    def __init__(self):
        self.size = 0
        self.heap = list()
        self.added = 0

    def top(self):
        if not self.heap:
            return None
        return self.heap[0] + self.added

    def pop(self):
        if not self.heap:
            return None
        res = heappop(self.heap)
        self.size -= 1
        return res + self.added

    def push(self, x):
        heappush(self.heap, x - self.added)
        self.size += 1

    def add(self, x):
        self.added += x

    def meld(self, other): #破壊的
        res = MeldableHeap()
        if self.size < other.size:
            self, other = other, self
        res.heap = self.heap
        res.size = self.size
        for _ in range(other.size):
            res.push(other.pop() - self.added)
        return res

N, M = map(int, input().split())
A = list(map(int, input().split()))
edge = [tuple(map(int, input().split())) for _ in range(M)]

graph = [[] for _ in range(N)]

for x, y in edge:
    graph[x].append(y)
    graph[y].append(x)

used = [0 for _ in range(N)]
heap = defaultdict(MeldableHeap)
roots = []

for root in range(N):
    if used[root]:
        continue
    roots.append(root)
    heap[root].push(A[root])
    used[root] = 1
    stack = [root]
    while stack:
        node = stack.pop()
        for adj in graph[node]:
            if used[adj]:
                continue
            used[adj] = 1
            heap[root].push(A[adj])
            stack.append(adj)

single = set()

for k, v in heap.items():
    if v.size == 1:
        single.add(k)

roots.sort(key=lambda x: x in single)

res = 0
tmp = heap[roots[0]]

for i in range(1, len(roots)):
    if tmp.size == 0:
        print('Impossible')
        break
    v = heap[roots[i]]
    a = tmp.pop()
    b = v.pop()
    tmp = tmp.meld(v)
    res += a + b
else:
    print(res)

Measured memory_bytes: 134492
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            
            var n = cin.nextInt();
            var m = cin.nextInt();




            Console.WriteLine(n == m ? "Yes":"No");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13140
def check(x) :
    if x % 4 == 0 :
        if   x % 100 != 0 : return x
        elif x % 400 == 0 : return x

def make(a, b):
    count = 0
    for _ in range(a, b+1) :
        if box[0] <= _ <= box[-1] :
            if _ in box :
                count = 1
                print(_)
        else :
            temp = check(_)
            if temp != None : 
                box.append(temp)
                count = 1
                print(_)
    if count == 0 : print('NA')
    
from sys import stdin
box = [2004]
a, b = map(int, input().split())
for _ in stdin.readlines() :
    make(a, b)
    a, b = map(int, _.split())
    if a == b == 0 : break
    print()

Measured memory_bytes: 7772
using System;

namespace _20200711_A
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力部
            int N;
            string input;
            int[] a;
            string[] input2;
            int anser = 0;

            input = System.Console.ReadLine();
            N = int.Parse(input);
            a = new int[N];
            input = System.Console.ReadLine();
            input2 = input.Split(' ');
            for(int i=0;i<N; i++)
            {
                a[i] = int.Parse(input2[i]);
            }

            //計算部
            for(int i = 0; i < N; i++)
            {
                if (!((i+1) % 2 == 1)) continue;
                if (!(a[i] % 2 == 1)) continue;
                anser++;
            }



            Console.WriteLine(anser.ToString());
        }
    }
}


Measured memory_bytes: 27552
#include<bits/stdc++.h>
using namespace std;
int q;
int main() {
	cin>>q;
	for(int i=1;i<=9;i++)
		for(int j=i;j<=9;j++) 
			if(i*j==q) {
				cout<<"Yes";
				return 0;
			}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

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

func main() {
	n, err := strconv.Atoi(input())
	if err != nil {
		log.Fatalln(err)
	}

	a, err := strconv.Atoi(input())
	if err != nil {
		log.Fatalln(err)
	}

	b, err := strconv.Atoi(input())
	if err != nil {
		log.Fatalln(err)
	}

	if (a%2 == 0 && b%2 == 0) || (a%2 != 0 && b%2 != 0) {
		fmt.Println((b - a) / 2)
		return
	}

	fmt.Println(Min(a-1, n-b) + 1 + (b-a-1)/2)
}

func Min(x, y int) int {
	if x < y {
		return x
	}
	return y
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N;
	cin >> N;
	vector<pii>a;
	vector<pii>b;
	for (int i = 0; i < N; ++i) {
		int x, y;
		cin >> x >> y;
		a.push_back({ y,x });
	}
	for (int i = 0; i < N; ++i) {
		int x, y;
		cin >> x >> y;
		b.push_back({ x,y });
	}
	sort(a.begin(), a.end(), greater<pii>());
	sort(b.begin(), b.end());
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < b.size(); ++j) {
			if (a[i].first < b[j].second&&a[i].second < b[j].first) {
				ans++;
				b.erase(b.begin() + j);
				break;
			}
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#define LONG_INF 10000000000000000
#define REP(i,N) for(int i = 0; i < (N); i++)

using namespace std;

int main(void) {
    int n=0,m,a;
    string s;

	cin >> s;

    sscanf(s.c_str(),"%d",&m);

    for (int i = s.length()-1; i >=0 ; i--) {
        sscanf(&s[i],"%d",&a);
        s[i] = '\0';
        n += a;
	}

	if(m%n==0) 	cout << "Yes" << endl;
	else cout << "No" << endl;



	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(50, vector<ll>(50, INF));
  
ll parent(ll num) {
  if (v[num] == num) return num;
  else {
    ll res = parent(v[num]);
    v[num] = res;
    return res;
  }
}
  
ll same(ll v01, ll v02) {
  if (parent(v01) == parent(v02)) return 1;
  else return 0;
}
  
void unionn(ll v01, ll v02) {
  v[parent(v02)] = parent(v01);
}
  
int main() {
  cin >> n >> k;
  v.resize(n);
  REP(i, n) v[i] = i;
  vector<tuple<ll, ll, ll>> vt;
  REP(i, k) {
    ll a, b, c;
    cin >> a >> b >> c;
    if(!a) unionn(b,c);
    else cout<<(same(b,c)?"1":"0")<<endl;
  }
   
}

Measured memory_bytes: 3284
N = int(input())

flg = False
cnt = 0
for i in range(N):
    d1, d2 = map(int, input().split())
   
    if(d1 == d2):
        cnt += 1
    else:
        cnt = 0
    
    if(cnt >= 3):
        flg = True


print("Yes" if flg else "No")

Measured memory_bytes: 9168
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    ans=[]
    h,w=INTM()
    for i in range(h):
        temp=STR()
        ans.append(temp)
        ans.append(temp)
    for i in range(2*h):
        print(*ans[i],sep='')
if __name__ == '__main__':
    do()

Measured memory_bytes: 4480
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
#include <map>
using namespace std;
using P=pair<int,int>;
using lint=long long;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    lint ret=0;
    for(int i=0;i<n;i++){
        bool ok=true;
        for(int j=0;j<30;j++){
            if(((a[i]>>j)&1)&&(!((k>>j)&1))){
                ok=false;
            }
        }
        if(ok)ret+=b[i];
    }
    int now=0;
    while(k>=(1<<now)){
        lint cnt=0;
        if((1<<now)&k){
            for(int i=0;i<n;i++){
                bool ok=true;
                if(a[i]&(1<<now))ok=false;
                for(int j=now;j<30;j++){
                    if(((a[i]>>j)&1)&&(!((k>>j)&1)))ok=false;
                }
                if(ok)cnt+=b[i];
            }
        }
        ret=max(ret,cnt);
        now++;
    }
    cout<<ret<<endl;
}

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

int main(){
    char s;
    cin >> s;

    if(s == 'A') cout << 'T' << endl;
    else if(s == 'T') cout << 'A' << endl;
    else if(s == 'C') cout << 'G' << endl;
    else if(s == 'G') cout << 'C' << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <list>

#define MAX_N 105

using namespace std;
typedef long long ll;

int main() {
    int N;
    int ans = -1;
    string s,t;
    cin>>N;
    cin>>s;
    cin>>t;
    list<int> s_,t_;
    s_.push_back(0);
    t_.push_back(0);
    for(int i = 0;i < N-1;i++){
        if(s[i]!=s[i+1]){
            s_.push_back(i+1);
        }
        if(t[i]!=t[i+1]){
            t_.push_back(i+1);
        }
    }
    s_.push_back(N);
    t_.push_back(N);
    if(s_.size()>t_.size()){
        swap(s_,t_);
    }
    if(s[0]!=t[0]){
        t_.push_front(0);
    }
    int count = ((t_.size()+1)/2)*2;
    for(int c = 0;c<count;c++){
        s_.push_front(0);
    }
    list<int>::iterator it1=s_.begin(),it2=t_.begin();
    while(t_.size()!=s_.size()){
        t_.push_back(N);
    }
//    for(int x=0;x<t_.size();x++){
//        cout<<*it1<<" "<<*it2<<endl;
//        it1++,it2++;
//    }
    
    while(1){
        int ans_ = 0;
        it1=s_.begin(),it2=t_.begin();
        while(it1!=s_.end()&&!(*it1==N&&*it2==N)){
            ans_ += abs((*it1)-(*it2));
            it1++;
            it2++;
        }
        if(ans>=0){
            ans = min(ans,ans_);
        }else{ans = ans_;}
        
        it1 = s_.begin();
        if(*it1==0&&(++it1)!=s_.end()&&*it1==0) {
            s_.erase(it1);
            s_.erase(s_.begin());
            s_.push_back(N);
            s_.push_back(N);
        }else{
            it2=t_.end();
            it2--,it2--;
            if(*it2==N&&++it2!=t_.end()&&*it2==N){
                t_.erase(it2);
                it2=t_.end();
                it2--;
                t_.erase(it2);
                t_.push_front(0);
                t_.push_front(0);
            }else{
                break;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,ans=0;
    scanf("%lld",&n);
    if(n>=500)
    {
        ll k=n/500;
        n-=k*500;
        ans+=k*1000;
    }
    if(n>=5)
    {
        ll k=n/5;
        n-=k*5;
        ans+=5*k;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX_NUM 10e9

int main(void) {
  long x, y, flag;
  scanf("%ld %ld", &x, &y);
  if(!(1 <= x && x <= MAX_NUM)) {
    return 0;
  }

  if(!(1 <= y && y <= MAX_NUM)) {
    return 0;
  }

  do {
    flag = x % y;
    x = y;
    if (flag != 0)
      y = flag;
  } while (flag != 0);

  printf("%ld\n", x);

  return 0;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<cassert>
using namespace std;
#define DMAX 370
#define SMAX 4096
#define SIZE 16

static const int nextP[9+2][5] = {{0, 1, 2, 4, 8},
                                 {0, 1, 2, 5, 9},
                                 {0, 1, 2, 6, 10},
                                 {-1, -1, -1, -1 -1},
                                 {0, 4, 5, 6, 8},
                                 {1, 4, 5, 6, 9},
                                 {2, 4, 5, 6, 10},
                                 {-1, -1, -1, -1 -1},
                                 {0, 4, 8, 9, 10},
                                 {1, 5, 8, 9, 10},
                                 {2, 6, 8, 9, 10}};

int nday;
int schedule[DMAX][SIZE];
int no_rainy[SIZE];
bool visited[DMAX][11][SMAX];

bool checkFestival(int pos, int day ){
    if ( schedule[day][pos + 0] == 1 ||
        schedule[day][pos + 1] == 1 ||
        schedule[day][pos + 4] == 1 ||
        schedule[day][pos + 5] == 1 ) return true;
    return false;
}

bool check7NoRainy(){
    for ( int i = 0; i < SIZE; i++ ){
        if ( no_rainy[i] >= 7 ) return true;
    }
    return false;
}

int getState(){
    return no_rainy[0] + no_rainy[3]*8 + no_rainy[12]*64 + no_rainy[15]*512;
}

bool recursive( int pos, int day ){
    if ( day == nday ) return true;
    visited[day][pos][getState()] = true;

    int tmp[SIZE];
    for ( int i = 0; i < SIZE; i++ ) tmp[i] = no_rainy[i];

    for ( int n = 0; n < 5; n++ ){
        if ( checkFestival( nextP[pos][n], day+1 ) ) continue;
    
        for ( int i = 0; i < SIZE; i++ ) no_rainy[i] = tmp[i];
    
        for ( int i = 0; i < SIZE; i++ ){
            if ( i == pos || i == pos + 1 || i == pos + 4 || i == pos + 5 ) {
                no_rainy[i] = 0;
            } else no_rainy[i]++;
        }

        if ( check7NoRainy() ) continue;
        if ( visited[day+1][nextP[pos][n]][getState()] ) continue;
    
        if ( recursive( nextP[pos][n], day+1 ) ) return true;
    }

    return false;
}

void compute(){
    for ( int i = 0; i < SIZE; i++ ) no_rainy[i] = 0;
    for ( int i = 0; i < DMAX; i++ ){
        for (int  j = 0; j < 11; j++ ){
            for ( int k = 0; k < SMAX; k++ ) visited[i][j][k] = false;
       }
    }

    if ( !checkFestival( 5, 0 ) && recursive( 5, 0 ) ) cout << 1 << endl;
    else cout << 0 << endl;
}

bool input(){
    cin >> nday;
    if ( nday == 0 ) return false;
    for ( int i = 0; i < nday; i++ ){
        for ( int j = 0; j < SIZE; j++ ) cin >> schedule[i][j];
    }
    for ( int j = 0; j < SIZE; j++ ) schedule[nday][j] = 0;

    return true;
}

main(){
    while ( input() ) compute();
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

int main() {
    int a;
    cin >> a;
    vector<int> x(a);
    for (int i = 0; i < a-1; i++) {
        int y;
        cin >> y;
        x.at(y - 1)++;
    }

    for (int i = 0; i < a; i++) {
        cout << x.at(i) << endl;
    }
}

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

int main()
{
    lli a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0)
    cout<<1;
    if(b==0)
    cout<<2;
    if(c==0)
    cout<<3;
    if(d==0)
    cout<<4;
    if(e==0)
    cout<<5;
		
}
	

Measured memory_bytes: 3552
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

n,t = map(int,input().split())
T = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    d = T[i+1] - T[i]
    ans += min(d,t)
print(ans+t)

Measured memory_bytes: 26072
#include <iostream>
#define ll long long
using namespace std;
int main(void){
    ll n; cin>>n;
    ll data[n];
    for(ll i=0; i<n; i++) cin>>data[i];
    ll max=data[0];
    ll ans=0;
    for(ll i=0; i<n; i++){
        if(max>data[i]) ans+=max-data[i];
        else max=data[i];
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 5200
//
//  CPlibrary
//
//  Created by Tanmay Singh on 3/03/2020.
// INDIAN INSTITUTE OF TECHNOLOGY (BHU) , VARANASI
//  Copyright © 2020 Tanmay Singh. All rights reserved.
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
 
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <climits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
#define FAST(); ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define mod 1000000007
typedef long long int  bigint ;
typedef std::vector< int > vi;
typedef std::vector< long long int > vll;
typedef std::vector< vi > vvi;

using namespace std ;
bigint dp[100001] ;
bigint frogJump( bigint arr[] , int N ){
    if( N == 1 ){
        return 0 ;
    }
    if( dp[N] != -1 )
        return dp[N] ;
    bigint second = INT_MAX ;
    bigint first = frogJump(arr , N - 1 ) + abs( arr[N] - arr[N-1] ) ;
    if( N > 2 )
        second = frogJump(arr, N - 2 ) + abs( arr[N] - arr[N-2] ) ;
    return dp[N] = min( first , second ) ;
}
int main(){
    FAST();
    memset(dp, -1, sizeof(dp) ) ;
    int N ; cin >> N ;
    bigint arr[N+1] ;
    for( int i = 1 ; i <= N ; i++ ){
        cin >> arr[i] ;
    }
    cout << frogJump(arr, N) << endl ;
    return 0 ;
}



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

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

using namespace std;

int main(){
  string s;
  getline(cin,s);
  string ans = "";
  rep(i,4) ans += s[i];
  ans += " ";
  REP(i,4,(int)s.size()) ans += s[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int dep = 12;
		int wid = 12;
		int output = 0;
		int[][] island;

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);
			island = new int[wid][dep];
			String line = null;
			while (sc.hasNext()) {

				//?????¢??????????????????
				for (int i = 0; i < dep; i++) {
					line = sc.next();
					String[] lineList = line.split("");
					for (int j = 0; j < lineList.length; j++) {

						island[i][j] = Integer.parseInt(lineList[j]);
					}
				}
				//??¶????\????????????????????????????
				for (int i = 0; i < island.length; i++) {
					for (int j = 0; j < island[0].length; j++) {

						output += islandCount(island,i,j);
					}

				}
				System.out.println(output);
				//???????????¨???????????????????????????
				output = 0;
			}

		} finally {
			sc.close();
		}
	}
	//??¶????¢??????????????????????
	public static int islandCount(int[][] map, int dep, int wid){

		int count = 0;
		int[][] checkmap = map;

		//??¶?????¢???
		if (checkmap[dep][wid] == 1) {
			checkmap[dep][wid] = -1;

			//??????????????§??????
			if (wid != checkmap[0].length - 1) {
				if (checkmap[dep][wid + 1] == 1) {
					islandCount(checkmap, dep, wid + 1);
				}
			}
			if (wid != 0) {
				if (checkmap[dep][wid - 1] == 1) {
					islandCount(checkmap, dep, wid - 1);
				}
			}

			if (dep != checkmap.length - 1) {
				if (checkmap[dep + 1][wid] == 1) {
					islandCount(checkmap, dep + 1, wid);
				}
			}

			if (dep !=0) {
				if (checkmap[dep - 1][wid] == 1) {
					islandCount(checkmap, dep - 1, wid);
				}
			}

			count++;
		}
		return count;
	}
}

Measured memory_bytes: 26916
while True:
	n = raw_input()
	if n == "0000": break
	if len(set(iter(n))) == 1:
		print "NA"
		continue
	count = 0
	while n != "6174":
		s = int("".join(sorted(n)))
		l = int("".join(sorted(n, reverse=True)))
		n =  "%04d" % (l - s)
		count += 1
	print count

Measured memory_bytes: 4228
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    // fastIO();
    
    int n, a, b;
    cin >> n >> a >> b;
    
    cout << (((a^b)&1) ? "Borys" : "Alice") << "\n";
    
    return 0;
}

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

using namespace std;

int main() {
  string a, b;
  cin >> a >> b;
  size_t as = a.size();
  size_t bs = b.size();

  if (as > bs) {
    cout << "GREATER" << endl;
  } else if (as < bs) {
    cout << "LESS" << endl;
  } else {
    bool eq = true;
    for (int i = 0; i < as; i++) {
      if (a[i] > b[i]) {
        cout << "GREATER" << endl;
        eq = false;
        break;
      } else if (b[i] > a[i]) {
        cout << "LESS" << endl;
        eq = false;
        break;
      }
    }
    if (eq) {
      cout << "EQUAL" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3132
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <string>
#define pii pair<int,int>
#define fi first
#define se second
#define pcc pair<char,char>

using namespace std;

typedef long long ll;

int main(){
        int a, b, c;
        while(cin >> a >> b >> c){
                if(a != b && a != c) cout << a << endl;
                else if(b != a && b != c) cout << b << endl;
                else cout << c << endl;
        }
        return 0;
}


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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int maxn = 1 << 19;
const int INF = 1e9 + 7;

inline void uadd(int &x, int y){ (x += y) %= INF; return; }
inline void umul(int &x, int y){ x = 1ll * x * y % INF; return; }
inline int mul(int x, int y){ return 1ll * x * y % INF; }

int n, h, ans;
int f[maxn], g[maxn], vis1[maxn], vis2[maxn], a[maxn], p[maxn], inv[maxn], dis[maxn];
vector<int> tmp1, tmp2;

inline int qpow(int x, int y){
	int res = 1;
	for(; y; y >>= 1){
		if(y & 1)
			umul(res, x);
		umul(x, x);
	}
	return res;
}

inline void dfs1(int u){
	if(u >= (1 << h - 1)){
		for(int v = p[u]; v; v >>= 1){
//			printf("u = %d v = %d\n", u, v);
			if(!vis1[v]){
				tmp1.PB(v);
				vis1[v] = true;
			} 
			uadd(f[v], a[u]);
		}
		return;
	}
	dfs1(u << 1);
	dfs1(u << 1 | 1);
	return;
}

inline void dfs2(int u){
	if(u >= (1 << h - 1)){
		for(int v = p[u]; v; v >>= 1){
			if(!vis2[v]){
				tmp2.PB(v);
				vis2[v] = true;
			}
			uadd(g[v], a[u]); 
		}
		return;
	}
	dfs2(u << 1);
	dfs2(u << 1 | 1);
	return;
}

int main(){
	scanf("%d", &h);
	FOR(i, 1 << h - 1, 1 << h){
		scanf("%d", p + i); p[i] += (1 << h - 1) - 1;
		a[i] = 1;
		for(int j = i; j; j >>= 1)
			umul(a[i], j);
		for(int j = p[i]; j; j >>= 1)
			umul(a[i], j);
	}
	
	dis[0] = 1;
	FOR(i, 1, 1 << h){
		inv[i] = qpow(i, INF - 2); 
		dis[i] = mul(inv[i], dis[i >> 1]);
	}
	
	FOR(i, 1, 1 << h - 1){
		dfs1(i << 1);
		dfs2(i << 1 | 1);
		FOR(j, 0, tmp1.size()){
			int r = tmp1[j];
			if(!(vis1[r] && vis2[r]))
				continue;
			if(r >= (1 << h - 1))
				continue;
			int res = 0;
			uadd(res, mul(f[r << 1], g[r << 1 | 1]));
			uadd(res, mul(f[r << 1 | 1], g[r << 1]));
			umul(res, dis[r]);
			if(r != 1)
				umul(res, dis[r >> 1]);
			umul(res, dis[i]);
			if(i != 1)
				umul(res, dis[i >> 1]);
			uadd(ans, res);
		}
		FOR(j, 0, tmp1.size()){
			int v = tmp1[j];
			vis1[v] = f[v] = 0;
		}
		FOR(j, 0, tmp2.size()){
			int v = tmp2[j];
			vis2[v] = g[v] = 0;
		}
		tmp1.clear(); tmp2.clear();
	}
	
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 12752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 2000000000;

int a, b, x;

int main(){
  cin >> a >> b >> x;
  
  cout << (a - b)%x<<endl;
}

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

int main(){
  string s;
  cin >> s;
  int ans = 0;
  for(int i = 0;i < 4;i++){
    if(s[i] == '+'){
      ans++;
    }
    else if(s[i] == '-'){
      ans--;
    }
  }
  cout << ans;
}
    
      

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int A[3];
    cin>>A[0]>>A[1]>>A[2];
    sort(A,A+3);
    cout<<A[0]+A[1];
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as C
import Data.List
import Data.Complex

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

main :: IO ()
main = do
    [a,b,h,m] <- map fromIntegral <$> r'

    let a' = a :+ 0
        b' = b :+ 0

        h' = (60 * h + m) / 60 / 12
        m' = m / 60

    print $ magnitude (rotate h' a' -  rotate m' b')

rotate :: Double -> Complex Double -> Complex Double
rotate ofFullCirc = (* (0 :+ 1) ** (4 * ofFullCirc :+ 0))

Measured memory_bytes: 4440
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>

using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;

  double probability = 0;
  for (int i = 1; i <= N; ++i)
  {
    int a = i;
    double temp = 1 / (double)N;

    while (a < K)
    {
      a *= 2;
      temp /= 2;
    }
    probability += temp;
  }
  cout << setprecision(10) << probability << endl;
}

Measured memory_bytes: 256
x,n = map(int,input().split())
p = list(map(int,input().split()))
if n == 0:
    print(x)
    exit()
if x not in p:
    print(x)
    exit()
dif = 2**60
ans = 2**60
for u in range(201):
    if u in p:
        continue
    else:
        tmp = abs(x-u)
        if tmp < dif:
            dif = tmp
            ans = u
for a in range(1,201):
    if a+x == dif:
        ans = -a
        break
print(ans)

Measured memory_bytes: 9232
program lake
  implicit none

  integer :: k, n, i
  integer, allocatable :: a(:), b(:)

  read *, k, n
  allocate(a(n), b(n))
  read *, a

  do i = 1, n-1
     b(i) = a(i+1) - a(i)
  end do
  b(n) = k - a(n) + a(1)

  print *, k - maxval(b)

  deallocate(a, b)

  stop
end program lake


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <map>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

int main(){
  string S,T;
  cin >> S >> T;
  char data[26]={};
  char ddata[26]={};
  bool ans = true;
  LOOP(i,S.length()){
    if(data[S[i]-'a']==0){
      data[S[i]-'a']=T[i];
    }else if(data[S[i]-'a']!=T[i]){
      ans = false;
      break;
    }

    if(ddata[T[i]-'a']==0){
      ddata[T[i]-'a']=S[i];
    }else if(ddata[T[i]-'a']!=S[i]){
      ans = false;
      break;
    }
  }
  if(ans==false){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
}
// ;;


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin>>N;
    vector<int> p(N);
    for(int i=0;i<N;i++){
        cin>>p[i];
    }
    sort(p.begin(),p.end());
    p[N-1]=p[N-1]/2;
    int ans=0;
    for(int i=0;i<N;i++){
        ans=ans+p[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    double a[n];
    double sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    sort(a, a + n);
    printf("%.0f %.0f %.0f\n", a[0], a[n-1], sum);
}

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

using namespace std;

typedef long long ll;

int main()
{
    ll n, m;    cin >> n >> m;

    ll Ans = (n * m + 1) / 2;

    if(n == 1 || m == 1)    Ans = 1;

    cout << Ans << endl;
}


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

int main(){
    char ch;
    int alfa[26]={};

    while (cin >> ch){
        ch = tolower(ch);
        if(isalpha(ch)){
            alfa[ch-'a']++;
        }
    }
    
    for(int i=0;i<26;i++){
        cout << char(i+'a') << " : " << alfa[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3088
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().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
inf = 1e10

#solve
def solve():
    a, b, c = LI()
    print("Yes" if a <= c <= b else "No")
    return


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


Measured memory_bytes: 38512
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
N = int(readline())

def sum(l, r, d):
    return (l+r)*((r-l)//d+1)//2

print(sum(1,N,1) - sum(3,N-N%3,3) - sum(5,N-N%5,5) + sum(15,N-N%15,15))

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16

typedef vector<int> vec;
typedef vector<vec> mat;

ll M;
mat operator*(const mat& a,const mat& b){
  mat res(3,vec(3,0));
  rep(i,3)rep(j,3)rep(k,3){
    (res[i][j]+=(a[i][k]%M)*(b[k][j]%M)%M)%=M;
  }
  return res;
}

mat pow(mat A,ll n){
  mat res(3,vec(3,0));
  rep(i,3)res[i][i]=1;
  while(n>0){
    if(n&1)res=res*A;
    A=A*A;
    n>>=1;
  }
  return res;
}

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

  ll N,A,B;
  cin>>N>>B>>A>>M;

  ll res=0;
  rep(i,18){
    ll p1=pow(10LL,i);
    ll p2=pow(10LL,i+1);
    if(p2<=B||A*(N-1)+B<p1)continue;
    ll l=max(0LL,(p1-B+A-1)/A);
    ll r=min((p2-B+A-1)/A,N);
    mat C(3,vec(3,0));
    C[0][0]=1;C[0][1]=A%M;C[0][2]=0;
    C[1][0]=0;C[1][1]=1;C[1][2]=0;
    C[2][0]=1;C[2][1]=0;C[2][2]=p2%M;
    mat D=pow(C,r-l);
    ll a=(B+A*l)%M;
    res=((a*D[2][0]%M)+D[2][1]+(D[2][2]*res%M))%M;
  }
  cout<<res<<endl;

  return 0;
}


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

#define ll long long

void solve() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;
}

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

Measured memory_bytes: 3668
/*
 
*/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <deque>
 
#define ll long long
#define cint const int
#define ld long double
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
 
using namespace std;
 
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, long long> pil;
typedef pair <int, string> pis;
typedef pair <int, char> pic;
typedef pair <long long, int> pli;
typedef pair <long long, string> pls;
typedef pair <long long, char> plc;
typedef pair <string, int> psi;
typedef pair <string, long long> psl;
typedef pair <string, char> psc;
typedef pair <char, int> pci;
typedef pair <char, long long> pcl;
typedef pair <char, string> pcs;
 
int n, m;
 
int main () {
	cin >> n >> m;
	if (n > 9 || m > 9) {
	    cout << -1;
	    return 0;
	}
	cout << n * m;
	return 0;
}

Measured memory_bytes: 256
//    Have a nice day
//    ∠( ᐛ 」∠)

#include<bits/stdc++.h>

#define mp make_pair
#define pb push_back
#define x first
#define y second

using namespace std;

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

template <typename T> inline T read()
{
	T sum=0, fl=1; char ch=getchar();
	for(; !isdigit(ch); ch=getchar()) if(ch=='-') fl=-1;
	for(; isdigit(ch); ch=getchar()) sum=(sum<<3)+(sum<<1)+ch-'0';
	return sum*fl;
}

const int maxn=2000+5;
int n, m, ans;
char s[maxn][maxn];
int l[maxn], r[maxn], h[maxn], c[maxn][maxn];

void Solve()
{
	n=read<int>(), m=read<int>(); ans=max(n, m);
	for(int i=1; i<=n; ++i) scanf("%s", s[i]+1);
	--n, --m;
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=m; ++j)
			if(((s[i][j]=='#')+(s[i+1][j]=='#')+(s[i][j+1]=='#')+(s[i+1][j+1]=='#'))&1);
			else c[i][j]=1;

	for(int i=1; i<=m; ++i) l[i]=r[i]=maxn;
	for(int i=1; i<=n; ++i)
	{
		for(int j=1, p=0; j<=m; ++j)
		{
			if(c[i][j]) ++p; else p=0;
			l[j]=min(l[j], p);
		}
		for(int j=m, p=0; j>=1; --j)
		{
			if(c[i][j]) ++p; else p=0;
			r[j]=min(r[j], p);
		}
		for(int j=1; j<=m; ++j) 
		{
			if(c[i][j]) ++h[j], ans=max(ans, (l[j]+r[j])*(h[j]+1));
			else l[j]=r[j]=maxn, h[j]=0;
		}
	}
	printf("%d\n", ans);
}

int main()
{

   // freopen("081d.in","r",stdin);
    //freopen("081d.out","w",stdout);

    Solve();

    return 0;
}



Measured memory_bytes: 19840
n=int(input())
s = [''.join(sorted(input())) for i in range(n)]
s.sort()
s.append("a")
b=1
c=0
for i in range(n):
    if s[i]!=s[i+1]:
        c+=(b*(b-1))//2
        b=1
    else:
        b+=1
print(c)

Measured memory_bytes: 57944
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

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

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

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

using namespace std;

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

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

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int a[4],b[4] = {1,4,7,9};

int main(void){
	rep(i,4) cin >> a[i];
	sort(a, a + 4);
	bool ok = true;
	rep(i,4) if(a[i] != b[i]) ok = false;
	puts(ok?"YES":"NO");
	return 0;
}

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

namespace AtCoderBeginnerContest149
{
	class Program
	{
		static void Main(string[] args)
		{
			var numbers = Console.ReadLine().Split(' ').ToList().Select(x => int.Parse(x)).ToList();
			var points = Console.ReadLine().Split(' ').ToList().Select(x => int.Parse(x)).ToList();
			var hands = Console.ReadLine().ToArray();

			var totalScore = 0;
			for (var i = 0; i < numbers[0]; i++)
			{
				switch (hands[i])
				{
					case 'r':
					{
						if (i >= numbers[1] && hands[i - numbers[1]] == 'r')
						{
							hands[i] = 'a';
						}
						else
						{
							totalScore += points[2];
						}
						break;
					}
					case 's':
					{
						if (i >= numbers[1] && hands[i - numbers[1]] == 's')
						{
							hands[i] = 'a';
						}
						else
						{
							totalScore += points[0];
						}
						break;
					}
					default:
					{
						if (i >= numbers[1] && hands[i - numbers[1]] == 'p')
						{
							hands[i] = 'a';
						}
						else
						{
							totalScore += points[1];
						}
						break;
					}
				}
			}
			Console.WriteLine(totalScore);
		}
	}
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    int a[50], b[50];
    int e[10][10];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            e[i][j] = 0;
        }
    }
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        e[a[i]][b[i]]++;
        e[b[i]][a[i]]++;
    }
    int ans = 0;
    int seq[10];
    for(int i = 0; i < n; i++){
        seq[i] = i;
    }
    do{
        bool f = true;
        for(int i = 0; i < n - 1; i++){
            if(e[seq[i]][seq[i + 1]] == 0){
                f = false;
            }
        }
        if(f){
            ans++;
        }
    }
    while(next_permutation(seq + 1, seq + n));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>

using namespace std;

int main() {
	int i, j, N;
	int g = 0, p = 0, ten = 0;
	string S;

	cin >> S;

	for (i = 0; i < S.length(); i++) {
		if (S[i] == 'g') {
			if (g > p) {
				p++;
				ten++;
			}
			else if (g <= p) {
				g++;

			}
		}
		else if (S[i] == 'p') {
			if (g > p) {
				p++;

			}
			else if (g <= p) {
				g++;
				ten--;
			}

		}

	}

	cout << ten << endl;



	return 0;
}


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

judge = 'APPROVED'

for a in A:
    if a % 2 == 0:
        if a % 3 == 0 or a % 5 == 0:
            pass
        else:
            judge='DENIED'
            print(judge)
            exit()

print(judge) 

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int main(){
  long a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a, a+3);

  set<pair<long,pair<long,long>>> m;
  m.insert(mp(a[0],mp(a[1],a[2])));

  int ans = 0;
  long b[3];
  while(a[0]%2==0 && a[1]%2==0 && a[2]%2==0){
    b[0] = (a[0]+a[1])/2;
    b[1] = (a[2]+a[1])/2;
    b[2] = (a[0]+a[2])/2;
    sort(b,b+3);
    pair<long,pair<long,long>> p = mp(b[0], mp(b[1],b[2]));
    ans++;
    if(m.count(p)==1){ans=-1; break;}
    swap(a,b);
  }

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


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

using namespace std;

int main() {
    vector<int> A(3);
    for(int i=0; i<3; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<int>());
    
    cout << A[0]*10+A[1]+A[2] << endl;


    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define round(x, y) ((2 * x + y) / (2 * y))
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template <typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template <typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

void solve() {
    ll h, n;

    cin >> h >> n;
    vpll data(n);
    for (ll i = 0; i < n; i++) {
        cin >> data[i].first >> data[i].second;
    }

    v dp(h + 1, 1e15);
    for (ll i = 0; i < n; i++) {
        for (ll health = 1; health <= h; health++) {
            ll cost = data[i].second;
            if (data[i].first < health) {
                cost += dp[health - data[i].first];
            }

            amin(dp[health], cost);
        }
    }

    cout << dp[h] << endl;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // freopen("file", "r", stdin);
    // freopen("file", "w", stdout);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 384