akhauriyash/Code-Regression huggingface dataset:
import sys

N = int(input())
h = [int(i) for i in input().split()]
ans = 0
check = [0] * N
ind = 0
judge = 0


for i in range(10**5):
    judge = 0
    for j in range(N):
        if 1 <= h[j]:
            h[j] -= 1

            if judge == 0:
                ans += 1
                judge = 1
            else:
                judge = 1

        else:
            judge = 0

    if max(h) == 0:
        print(ans)
        sys.exit()


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

using namespace std;

void split(string line, string separator, vector<string>& v) {
    if(!separator.size()) v.push_back(line);
    else {
        int offset = 0;
        while(1) {
            int pos = line.find(separator, offset);
            if(pos == string::npos) {
                v.push_back(line.substr(offset));
                break;
            }
            v.push_back(line.substr(offset, pos - offset));
            offset = pos + separator.size();
        }
    }
}

int main() {
    string S; cin >> S;
    vector<string> v(0);

    split(S, "/", v);

    if(stoi(v[0]) == 2019) {
        if(stoi(v[1]) == 4) {
            if(stoi(v[2]) == 30) {
                cout << "Heisei" << endl;
                return 0;
            } else {
                if(stoi(v[2]) < 30) {
                    cout << "Heisei" << endl;
                    return 0;
                } else {
                    cout << "TBD" << endl;
                    return 0;
                }
            }
        } else {
            if(1 <= stoi(v[1]) && stoi(v[1]) < 4) {
                cout << "Heisei" << endl;
                return 0;
            } else {
                cout << "TBD" << endl;
                return 0;
            }
        }
    } else {
        if(stoi(v[0]) < 2019) {
            cout << "Heisei" << endl;
            return 0;
        } else {
            cout << "TBD" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, x, sum = 0, sqSum = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        sum += x;
        sqSum += x * x;
    }
    int P = sum / n;
    if ((P * 2 + 1) * n - sum * 2 < 0) P++;
    int res = sqSum + P * P * n - 2 * P * sum;
    cout << res << endl;
}


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

int index(const vector<int> &xs, int x){
	return lower_bound(xs.begin(), xs.end(), x) - xs.begin();
}

int main(){
	int w, h, n;
	
	int dx[] = {-1, 0, 1, 0};
	int dy[] = {0, -1, 0, 1};
	
	while( scanf("%d%d%d", &w, &h, &n) == 3 ){
		vector<int> xs, ys;
		xs.reserve(3010);
		ys.reserve(3010);
		
		vector<int> x1(n), x2(n), y1(n), y2(n);

		xs.push_back(w - 1);
		ys.push_back(h - 1);
		
		for(int i = 0; i < n; ++i){
			scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]);
			--x2[i];
			--y2[i];
			
			xs.push_back(x1[i]);
			ys.push_back(y1[i]);
			if( x1[i] > 0 ){ xs.push_back(x1[i] - 1); }
			if( y1[i] > 0 ){ ys.push_back(y1[i] - 1); }
			
			xs.push_back(x2[i]);
			ys.push_back(y2[i]);
		}
		
		sort(xs.begin(), xs.end());
		sort(ys.begin(), ys.end());
		xs.erase( unique(xs.begin(), xs.end()), xs.end());
		ys.erase( unique(ys.begin(), ys.end()), ys.end());

		vector<vector<char> > clr(xs.size(), vector<char>(ys.size()) );
		for(int i = 0; i < n; ++i){
			x1[i] = index(xs, x1[i]);
			x2[i] = index(xs, x2[i]);
			y1[i] = index(ys, y1[i]);
			y2[i] = index(ys, y2[i]);
			
			for(int j = x1[i]; j <= x2[i]; ++j)
			for(int k = y1[i]; k <= y2[i]; ++k){
				clr[j][k] = 1;
			}
		}

		int ans = 0;
		for(int i = 0; i < xs.size(); ++i)
		for(int j = 0; j < ys.size(); ++j){
			if( clr[i][j] == 0 ){
				++ans;
				clr[i][j] = 2;
				
				queue<pair<int,int> > q;
				q.push( make_pair(i, j) );
				while( !q.empty() ){
					for(int k = 0; k < 4; ++k){
						int x = q.front().first + dx[k];
						int y = q.front().second + dy[k];
						
						if( x >= 0 && x < xs.size() )
						if( y >= 0 && y < ys.size() )
						if( clr[x][y] == 0 ){
							clr[x][y] = 1;
							q.push( make_pair(x, y) );
						}
					}
					
					q.pop();
				}
			}
		}
		
		printf("%d\n", ans);
	}
}

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

using namespace std;

int main(){
  char A[10],B[10],C[10];
  cin >> A >> B >> C;

  int a = strlen(A)-1;
  int b = strlen(B)-1;
  int c = strlen(C)-1;

  if(A[a] == B[0] && B[b] == C[0])
    cout << "YES\n";

  else
    cout <<"NO\n";
}

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

int main()
{
	int a, b;
	cin >> a >> b;
	if (a + b == 15)cout << "+" << endl;
	else if (a*b == 15)cout << "*" << endl;
	else
	{
		cout << "x" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import numpy as np

n,d=map(int,input().split())
arr=[]
for i in range(n):
  arr.append(list(map(int,input().split())))
arr =np.array(arr)
ans=0
for i in range(n):
  for j in range(i,n):
    if j!=i:
      k = np.linalg.norm(arr[i]-arr[j],ord=2)
    else:
      k=0.5
    if k==int(k):
      ans +=1
print(ans)


Measured memory_bytes: 12468
/*
  -> ossan
  -> Do Good Die Great
*/
#include <bits/stdc++.h>
#define int long long int
#define pii pair<int, int>
#define ff first
#define ss second
#define eb emplace_back
#define pb push_back
#define MOD 1000000007
#define Hiraishin                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr);
#define tests \
    int t;    \
    cin >> t; \
    while (t--)
using namespace std;

// global

int binpow(int a, int b)
{
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = ((res % MOD) * (a % MOD)) % MOD;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void solve()
{
    int n;
    cin >> n;
    string s;
    while (n) {
        n--;
        s += (char('a' + n % 26));
        n /= 26;
    }
    reverse(s.begin(), s.end());
    cout << s << '\n';
}

signed main()
{
    Hiraishin
    // tests
    solve();
    return 0;
}

Measured memory_bytes: 3660
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for (ll i = 0LL; i<(ll)(n); i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }

int main(void) {
	int N;
	cin >> N;
	map<string, int> mp;
	string S;
	cin >> S;
	mp[S]++;
	REP(i, N - 1) {
		string T;
		cin >> T;
		if (mp[T] != 0) {
			OUT("No");
			return 0;
		}
		mp[T]++;
		if (T.front() != S.back()) {
			OUT("No");
			return 0;
		}
		S = T;
	}
	OUT("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

    int n,k;
    cin>>n>>k;
    vector<int> v(n);
   // ll sum=0;

    rep(i,n){
        cin>>v[i];
        //sum+=v[i];
    }

    int ans=0;
    int lim=min(n,k);
    for(int l=0;l<=lim;l++){

        for(int r=0;r<=lim-l;r++){

            vector<int> te;
            int sum=0;

        for(int i=0;i<l;i++){
            sum+=v[i];
            if(v[i]<0) {
                te.push_back(v[i]);
            }
        }
            for(int i=0;i<r;i++){
                sum+=v[n-i-1];
                if(v[n-i-1]<0) {
                    te.push_back(v[n - i - 1]);
                }
            }
            int a=k-(l+r);
            int b=te.size();
            sort(te.begin(),te.end());

            for(int tt=0;tt<min(a,b);tt++){
             //if(tt!=0){
                 sum-=te[tt];
             //}
             //cout<<l<<" "<<r<<" "<<sum<<endl;
               
            }
            if(ans<sum){
                ans=sum;
            }

        }
    }

    cout<<ans<<endl;



    return 0;
}


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

int main(){
    int n, m; cin >> n >> m;
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> b(m);
    vector<int> c(n, 0);
    for(int i = 0; i< n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    for(int j = 0; j < m; j++) cin >> b[j];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            c[i] += a[i][j] * b[j];
        }
        cout << c[i] << endl;
    }
}




Measured memory_bytes: 3140
#include<stdio.h>
int a(int);

main(){
  int i,x;
  while(scanf("%d",&x) != EOF){
     i=a(x);
     if(i<=9){
       printf("3C0%d\n",i);
     }
     else{
       printf("3C%d\n",i);
     } 
  }
  return 0;
}

int a(int x){
  int i;
  while(1){   
    for(i=1;i<=39;i++){
      x--;
      if(x==0){ 
	return i;
      }
    }
  }
}

Measured memory_bytes: 0
package main

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

var r = bufio.NewReader(os.Stdin)

func main(){
    var a,b,c int 
    fmt.Fscan(r, &a)
    fmt.Fscan(r, &b)
    fmt.Fscan(r, &c)
    
    if a < b {
        if a < c {
            if c < b{
                fmt.Println(a, c, b)
            }else{
                fmt.Println(a, b, c)
            }
        }else{
            fmt.Println(c, a, b)
        }
    }else{
        if b < c {
            if c < a {
                fmt.Println(b, c, a)
            }else{
                fmt.Println(b, a, c)
            }
        }else{
            fmt.Println(c, b, a)
        }
    }
}


Measured memory_bytes: 1128
#include <stdio.h>

int main(void) {
    int a, b, d, r;
    double f;
    scanf("%d %d", &a, &b);

    d = a / b;
    r = a % b;
    f = (double)a / (double)b;
    
    printf("%d %d %f\n", d, r, f);

    return 0;
}


Measured memory_bytes: 1992
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

#include <iomanip>

#include <algorithm>

#include <vector>

#include <stack>

#include <queue>

#include <cmath>

#include <set>

#include <map>

#include <string>

#include <numeric>

#include <cstdio>

#include <cstdlib>

using namespace std;


const int INF = 10000000;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back

//char maze[100][101];

ll n, m;

int sx, sy;

int gx, gy;

int qqq;

//各座標までの最短距離

int d[100][100];


//移動方向のベクトル

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

int ans = 0;
pair<int, int> red[101], blue[101];
//ll a[200000], b[20000];

//ユークリッドの互除法
ll gcd(ll x, ll y) {
	if (x < y) swap(x, y);
	if (y == 0) return x;
	return gcd(y, x%y);
}

//エラトステネスの篩 prime(n)[k]で1~nまで探索して(k+1)番目の素数を出力
vector<int> prime(int n) {
	vector<int> erst;
	for (int i = 0; i < n; ++i) erst.PB(i);
	erst[0] = erst[1] = NULL;
	auto dmax = sqrt(n);

	for (int dx = 2; dx < dmax; ++dx) {
		if (erst[dx] == NULL) continue;
		for (int i = dx * 2; i < n; i += dx) erst[i] = NULL;
	}

	vector<int> erstlist;
	for (auto i : erst) if (i) erstlist.PB(i);

	return erstlist;
}

ll v_find(std::vector<ll> vec, ll 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;
	}
}

ll BIG = 10000000000;

ll POW(ll a, ll b) {
	if (b == 0) return 1;
	return (a*POW(a, b - 1)) % BIG;
}

int Kaijou(int a) {
	if (a < 2) return 1;
	return a * Kaijou(a - 1);
}


ll aa[51];

int main() {
	int n;
	cin >> n;
	int a[100000] = { 0 };
	int t = 0;
	int least = 0;
	int f = 0,ff=0;
	for (int i = 0; i < n; ++i) {
	   cin >> a[i];
	   if (a[i] % 4 == 0) {
		   least = 1; t++;
	   }
	   else if (a[i] % 4 != 2) {
		   t--;
		   if (!ff) ff = 1;
	   }
	   else {
		   if(!f) f = 1;
	   }

	}

	if (t + least - (f*ff) >= 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	std::cin >> qqq;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
		int D, G;
		cin >> D >> G;
		int p[D], c[D];
		for (int i = 0; i < D; i++) cin >> p[i] >> c[i];

		int ans = 1e9;
		for (int mask = 0; mask < (1<<D); mask++) {
				int score = 0, solved = 0, max_i;
				for (int i = 0; i < D; i++) {
						if (mask & (1<<i)) {
								score += (c[i] + 100 * (i+1) * p[i]);
								solved += p[i];
						} else {
								max_i = i;
						}
				}

				if (G - score > 0) {
						int t = (G - score + (100 * (max_i+1)) - 1) / ((max_i+1) * 100);
						if (t >= p[max_i]) continue;
						else solved += t;
				}

				ans = min(solved, ans);
		}

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

//********************************template END****************************************//

void solve(void){
	ll I, O, T, J, L, S, Z;
	cin >> I >> O >> T >> J >> L >> S >> Z;
	ll ans = O + I + J + L;
	int f = 0;
	f += I & 1;
	f += J & 1;
	f += L & 1;
	if (f != 0 && f != 3)
	{
		if (min({I, J, L}) == 0 && f == 2)
		{
			ans -= 2;
		}
		else
		{
			ans--;
		}
	}
	cout << ans << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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


int main() {
    string s;
    cin>>s;
    string t;
    for(int i=0;i<4;i++) t+=s[i];
    t+=' ';
    for(int i=4;i<12;i++) t+=s[i];
    cout<<t<<endl;
	// your code goes here
	return 0;
}


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

int op(int x, int a, int b){
  if (x == 0){
    return a + b;
  }
  else{
    return a - b;
  } 
}

void ch(int x){
  if (x == 0){
    cout << "+";
  }
  else{
    cout << "-";
  }
}

int main(){
  int N;
  cin >> N;
  
  int a = N / 1000;
  int b = N / 100 - 10 * a;
  int c = N / 10 - (100 * a + 10 * b);
  int d = N - (1000 * a + 100 * b + 10 * c);
  
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < 2; j++){
      for(int k = 0; k < 2; k++){
        int n = op(i,a,b);
        int m = op(j,n,c);
        int l = op(k,m,d);
        if (l == 7){
          cout << a;
          ch(i);
          cout << b;
          ch(j);
          cout << c;
          ch(k);
          cout << d << "=" << 7 << endl;
          j = 5;
          i = 5;
          break;
          }
      }
    }
  }
}

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

int main(void)
{
	string s;
	cin >> s;

	bool ans=true;
	int i,j;
	for(i=0; i<s.length(); i++)
		for(j=0; j<s.length(); j++)
			if(s[i]==s[j] && i != j) ans=false;

	ans ? cout << "yes" : cout << "no";
	cout << endl;
}

Measured memory_bytes: 256
use std::io::*;

fn read_str() -> String {
  let mut buf = String::new();
  stdin().read_line(&mut buf).ok();
  buf.trim().to_string()
}

fn main() {
  let s = read_str();
  let ans = if s.contains("9") {"Yes"} else {"No"};
  println!("{}", ans);
}


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



int main() {
	int A, B;
	int coin = 0;
	cin >> A>>B;
	for (int i = 1; i < 3; ++i) {
		if (A > B) {
			coin += A;
			--A;
		}
		else if (A < B) {
			coin += B;
			--B;
		}
		else if (A == B) {
			coin += A;
			--A;
		}
	}
	cout << coin << endl;
}

Measured memory_bytes: 256
N, K, C = map(int, input().split())
S = [c == "o" for c in input().strip()]

prev = -C - 1
count = 0
work_l = []
for i, c in enumerate(S):
	if c:
		if i > prev + C:
			count += 1
			prev = i
			work_l.append(i)

prev = -C - 1
count = 0
work_r = []
for i, c in enumerate(reversed(S)):
	if c:
		if i > prev + C:
			count += 1
			prev = i
			work_r.append(N - 1 - i)

work_r.reverse()

if len(work_l) == K and len(work_l) == len(work_r):
	for l, r in zip(work_l, work_r):
		if l == r:
			print(l + 1)



Measured memory_bytes: 22000
/** 	Author: Apoorva Mittal  **/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define nl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pair<int, int>>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repD(i, a, b) for (int i = a; i >= b; i--)
#define speed                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define init(i, k) memset(i, k, sizeof i)
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define inp(a) rep(i, 0, a.size()) cin >> a[i];
#define out(a)                               \
    cout << #a << ": " << endl;              \
    rep(i, 0, a.size()) cout << a[i] << " "; \
    cout << endl;
#define out2d(a)                \
    cout << #a << ": " << endl; \
    rep(i, 0, a.size())         \
    {                           \
        rep(j, 0, a[0].size())  \
                cout            \
            << a[i][j] << " ";  \
        cout << endl;           \
    }
#define flush fflush(stdout);
#define lb lower_bound
#define ub upper_bound
#define maxe *max_element
#define mine *min_element
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define pqueue priority_queue
#define precise(x) cout << fixed << showpoint << setprecision(x);
#define setbit(x) __builtin_popcountll(x)
#define gcd(a, b) __gcd(a, b)
#define deb(x) cout << #x << " " << x << endl;
#define Y "YES"
#define N "NO"
const int mod = 1e9 + 7;
// ====== Useful functions begin ======
inline int add(int a, int b) { return ((a % mod) + (b % mod)) % mod; }
inline int sub(int a, int b) { return ((a % mod) - (b % mod) + mod) % mod; }
inline int mul(int a, int b) { return ((a % mod) * (b % mod)) % mod; }
// ====== Useful functions end ======
const int inf = 1e18;
const int maxn = 1e3 + 5;

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

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

void solve()
{
    int n,K;
    cin >> n;
    K=2;
    vi arr(n);
    inp(arr)
        vector<int>
            dp(n, 0);
    
    for(int i=n-2;i>=0;i--)
    {
        int&v = dp[i];
        v=inf;
        for(int k=1;k<=K;k++)
        {
            if(i+k<n)
            {
                v = min(v,abs(arr[i+k]-arr[i])+dp[i+k]);
            }
        }
        // deb(dp[i])
    }
    cout<<dp[0]<<endl;

    // cout<<dp[0]<<endl;
}
signed main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    speed;
    int t = 1;
    // cin >> t;

    for (int tt = 1; tt <= t; tt++)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
    }
}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
  int N;
  double M;
  double com;
  double sum = 0.0;
  int count = 0;
  scanf("%d", &N);
  scanf("%lf", &M);
  int A[N+1];
  for(int i = 0; i < N; i++){
    scanf("%d", &A[i]);
    sum += A[i];
  }
  com = sum / (4 * M);
  for(int i = 0; i < N; i++){
    if(A[i] >= com){
      count += 1;
    }
  }
  if(count >= M){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }

  return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX;
using ll = long long;

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

    int N, tmp;
    cin >> N;
    vector<int> vec(N + 1);
    rep (i, N) {
        cin >> tmp;
        vec[tmp] = i + 1;
    }

    int cnt = 1;
    int max = 1;
    int pre = INF;
    for (int i = 1; i <= N; i++) {
        if (vec[i] > pre) {
            cnt++;
            if (max < cnt) max = cnt;
        } else
            cnt = 1;

        pre = vec[i];
    }

    print(N - max);

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


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

int nIn[20] = { 0 };
int n = 0;

int Solve(int i, int nKey)
{
	if (0 == nKey)
	{
		return 1;
	}
	else if (i >= n)
	{
		return 0;
	}
	int nRet = Solve(i + 1, nKey) || Solve(i + 1, nKey - nIn[i]);
	return nRet;
}

int main()
{
	int q = 0, nKey = 0;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> nIn[i];
	}
	cin >> q;
	for (int i = 0; i < q; ++i)
	{
		cin >> nKey;
		if (Solve(0, nKey))
		{
			cout << "yes" << endl;
		}
		else
		{
			cout << "no" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3100
def main(N):
	a = list(map(int, input().split()))
	if a.count(0) == N:
		print("Yes")
		return
	if N%3 != 0:
		print("No")
		return
	d={}
	for i in a:
		if i in d:
			d[i] = d[i] + 1
		else:
			d[i] = 1
	if 0 in d.keys():
		if d[0] == N//3:
			for i in d.keys():
				if i == 0:
					continue
				elif d[i] % 2 != 0:
					print("No")
					return
			print("Yes")
		else:
			print("No")
	else:
		for i in d.values():
			if i != N//3:
				print("No")
				return
		lst = list(d.keys())
		if (lst[0]^lst[2]!=lst[1]) or (lst[0] != lst[1]^lst[2]) or(lst[2]!=lst[1]^lst[0]):
			print("No")
			return
		print("Yes")
	return
		
	return

main(int(input()))

Measured memory_bytes: 14212
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<deque>
#define ll long long
using namespace std;
#define BUF_SIZE 1048576
char _buf[BUF_SIZE],*_is=_buf,*_it=_buf;
inline char rdc(){
	if (_is==_it) _it=(_is=_buf)+fread(_buf,1,BUF_SIZE,stdin);
	return *_is++;
}
inline void rdi(int &x){
	int f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	if(f) x=-x;
}
inline void rdi(ll &x){
	ll f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	if(f) x=-x;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(int x){
	write(x);
	putchar(' ');
}
inline void print(int x){
	write(x);
	putchar('\n');
}
inline void write(ll x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(ll x){
	write(x);
	putchar(' ');
}
inline void print(ll x){
	write(x);
	putchar('\n');
}
#define int ll
struct ufs{
	int par[200200];
	inline void init(int _n){for(int i=0;i<_n;++i) par[i]=i;}
	inline int find(int now){
		if(par[now]==now) return now;
		return par[now]=find(par[now]);
	}
	inline bool unite(int a, int b){
		int Pa(find(a)),Pb(find(b));
		if(Pa==Pb) return false;
		par[Pa]=Pb;
		return true;
	}
}my;
#define mp make_pair
int n,d;
int a[200200];
vector<pair<int,pair<int,int> > >v;
inline void solve(int l, int r){
	if(l>=r) return;
	int m((l+r)>>1);
	int mnL(1e17),mnposL;
	for(int i=l;i<=m;++i){
		if(a[i]-d*(i+1)<mnL){
			mnL=a[i]-d*(i+1);
			mnposL=i;
		}
	}
	int mnR(1e17),mnposR;
	for(int i=m+1;i<=r;++i){
		if(a[i]+d*(i+1)<mnR){
			mnR=a[i]+d*(i+1);
			mnposR=i;
		}
	}
	for(int i=m+1;i<=r;++i) v.push_back(mp(mnL+a[i]+d*(i+1),mp(mnposL,i)));
	for(int i=l;i<=m;++i) v.push_back(mp(mnR+a[i]-d*(i+1),mp(i,mnposR)));
	solve(l,m);
	solve(m+1,r);
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>d;
	my.init(n);
	int i,j;
	for(i=0;i<n;++i) cin>>a[i];
	solve(0,n-1);
	sort(v.begin(),v.end());
	int ans(0);
	for(i=0;i<v.size();++i){
		if(my.find(v[i].second.first)!=my.find(v[i].second.second)){
			ans+=v[i].first;
			my.unite(v[i].second.first,v[i].second.second);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;


#define pb push_back
#define ff first
#define ss second
#define INF int(3e9)
#define BIG_INF ll(9e18)
#define SIZE 100001
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define len(v) int((v).size())
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout);


ll binpow(ll a, ll b, ll MOD = BIG_INF)
{
    ll res = 1;

    while(b)
    {
        if(b & 1)
            res *= a;
        a *= a;
        b >>= 1;
        a %= MOD;
        res %= MOD;
    }

    return res % MOD;
}

const ll mod = 1e9 + 7;

int T = 1;
ll n, m;
string s;
vector<int> a;

int to[256];



void solve()
{
    cin >> s;
    for(char c: s) if(c == '7'){cout << "Yes\n"; return;}



    cout << "No";
    return;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
//    filein;fileout;

//    cin >> T;

    while(T--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
long i,n,a[100010],ans;
int main(){
  cin>>n;
  for(i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  ans=a[n-1]+a[n-2]-(a[0]*2);
  for(i=1;i<n/2;i++)ans+=a[n-i]+a[n-i-2]-(a[i]*2);
  if(n%2&&a[n/2+1]-a[n/2]>a[n/2]-a[n/2-1])ans+=a[n/2+1]+a[n/2-1]-(a[n/2]*2);
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
use io::*;
use std::*;

fn solve(N: i64, S: Vec<String>) {
    let m = S.iter().fold(collections::HashMap::new(), |mut acc, x| {
        *acc.entry(x).or_insert(0) += 1;
        acc
    });
    let acCount = match m.get(&"AC".to_string()) {
        Some(&count) => count,
        _ => 0,
    };
    let waCount = match m.get(&"WA".to_string()) {
        Some(&count) => count,
        _ => 0,
    };
    let tleCount = match m.get(&"TLE".to_string()) {
        Some(&count) => count,
        _ => 0,
    };
    let reCount = match m.get(&"RE".to_string()) {
        Some(&count) => count,
        _ => 0,
    };
    println!("AC x {}", acCount);
    println!("WA x {}", waCount);
    println!("TLE x {}", tleCount);
    println!("RE x {}", reCount);
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut N: i64;
    N = scanner.next();
    let mut S: Vec<String> = vec![String::new(); (N) as usize];
    for i in 0..(N) as usize {
        S[i] = scanner.next();
    }
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(N, S)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 7928
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll x;
int N,m;
map<ll,int> M;
int main()
{
    scanf("%d",&N);
    for(int i=0;i<N;i++)
    {
        scanf("%lld",&x);
        M[x]++;
    }
    int flag = 0;
    scanf("%d",&m);
    for(int i=0;i<m;i++)
    {
        scanf("%lld",&x);
        M[x]--;
        if(M[x]<0)flag = 1;
    }
    if(flag)printf("NO\n");
    else printf("YES\n");
    return 0;
}


Measured memory_bytes: 14848
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+500;
int A[maxn],B[maxn];
int T,n;
map<string,int> mp;

int main()
{
    int a,b;
    cin>>a>>b;
    if(a<=b) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const int INF = 1e9;
const int MOD = 1e9+7;

ll N, Q, K;
vector<vector<pair<ll, ll>>> G(N+1);
vl d(N+1, 1e18);

void dfs(ll n)
{
    REP(i, G[n].size())
    {
        if(d[G[n][i].first] == 1e18) 
        {
            d[G[n][i].first] = d[n] + G[n][i].second;
            dfs(G[n][i].first);
        }
    }
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll N; cin >> N;
    G.resize(N+1);
    REP(i, N-1)
    {
        ll a, b, c; cin >> a >> b >> c;
        G[a].push_back(make_pair(b, c));
        G[b].push_back(make_pair(a, c));
    }
    cin >> Q >> K;
    d.resize(N+1, 1e18); d[K] = 0;
    dfs(K);
    vl x(Q), y(Q); REP(i, Q) cin >> x[i] >> y[i];
    REP(i, Q)
    {
        cout << d[x[i]] + d[y[i]] << endl;
    }
}

Measured memory_bytes: 15872
import sys
N, Y  = map(int, input().split())
flag = False

for i in range(N+1): # 10000
    for j in range(N-i+1): #5000
        k=N-i-j
            
        total = i*10000 + j*5000 + k*1000
           
        if(0<= k <=2000 and total==Y):
            print(i, j, k)
            exit()

print(-1, -1, -1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
bool check(ve<ve<ll>> &arr, ll num,ll &cost,ll x)
{
    cost=0;
    ll one = 1;
    ve<ll> v1;
    ll sz=arr.size();
    rep(i, 0, sz)
    {
        if (num & (one << i))
        {
            v1.pb(i);
        }
    }
    ll m = arr[0].size();
    ve <ll> v2(m);
    rep(j, 0, v1.size())
    {
        cost+=arr[v1[j]][0];
        rep(i, 1, m)
        {
            v2[i] +=arr[v1[j]][i];
        }
    }
    rep (i,1,m)
    {
        if (v2[i]<x)
        {
            return false;
        }
    }
    return true;
}
int main()
{
    FAST
        // freopen("input1.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
        /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
        ll n,
        m, x;
    cin >> n >> m >> x;
    ve<ve<ll>> arr(n, ve<ll>(m + 1));
    rep(i, 0, n)
    {
        rep(j, 0, m + 1)
        {
            cin >> arr[i][j];
        }
    }
    ll val = pow(2, n),ans=9e15,cost=0;
    rep(z, 1, val + 1)
    {
        if (check(arr,z,cost,x))
        {
            ans = min(ans, cost);
        }
    }
    if (ans==9e15)
    {
        cout<<"-1\n";
        return 0;
    }
    cout << ans << "\n";
}


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



int main() {

    string s; cin >> s;
    stack<char> t,m;
    rep(i,s.length()){
        if(s[i] == 'B'){
            if(!t.empty()) t.pop();
        }else t.push(s[i]);
    }

    while(!t.empty()){
        m.push(t.top());
        t.pop();
    }

    while(!m.empty()) {
        cout << m.top();
        m.pop();
    }
    return 0;
}











Measured memory_bytes: 3640
#include<iostream>

int main(void)
{
	using namespace std;
	int r, c, i, j;
	cin >> r >> c;
	int table[r+1][c+1];
	for(i = 0; i < r; i++)
	{
		for(j = 0; j < c; j++)
		{
			cin >> table[i][j];
		}
	}
	for(i = 0; i < r; i++)
	{
		table[i][c] = 0;
		for(j = 0; j < c; j++)
		{
			table[i][c] += table[i][j];
		}
	}
	for(j = 0; j < c; j++)
	{
		table[r][j] = 0;
		for(i = 0; i < r; i++)
		{
			table[r][j] += table[i][j];
		}
	}
	table[r][c] = 0;
	for(i = 0; i < r; i++)
	{
		table[r][c] += table[i][c];
	}
	for(i = 0; i < r+1; i++)
	{
		for(j = 0; j < c+1; j++)
		{
			cout << table[i][j];
			if(j < c)
			{
				cout << " ";
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 3080
#include <vector>
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> V(N), C(N);
  for(int i = 0; i < N; ++i) cin >> V[i];
  for(int i = 0; i < N; ++i) cin >> C[i];
  int ans = 0;
  for(int i = 0; i < N; ++i) ans += max(0,V[i]-C[i]);
  cout << ans << endl;
}


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
str s;
int val;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>s;
    if(s=="SUN"){val = 0;}
    if(s=="MON"){val = 1;}
    if(s=="TUE"){val = 2;}
    if(s=="WED"){val = 3;}
    if(s=="THU"){val = 4;}
    if(s=="FRI"){val = 5;}
    if(s=="SAT"){val = 6;}
    cout<<7-val<<newl;
}


Measured memory_bytes: 256
void main(){
	long n = _scan();
	long[] a;
	foreach(i; 0..n)a ~= _scan!long();
	a.sort!("a>b");
	long prev=-1, cnt=1, ans;
	foreach(i, elm; a){
		// 数えている途中
		if(prev==elm){
			cnt++;
		}
		if(prev!=elm && i==a.length-1){
			if(cnt&1)ans++;
			// 最後尾の要素は奇数
			ans++;
		}else if(prev!=elm || i==a.length-1){
			if(prev==-1){
				prev = elm;
			}else{
				if(cnt&1)ans++;
				cnt = 1;
				prev = elm;
			}
		}

	}
	ans.writeln();
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 4496
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>
#define rep(i,n) for (int i=0; i <(n); ++i)
using namespace std;


int main() {
  int c[100];
  for (int i=0; i < 5; i++){
    cin >> c[i];
  }


int count = 0;
for (int i=0; i < 5; i++){
  count += 1;
  if(c[i]==0){
    break;
  }
}

cout << count << endl;
return 0;
}



Measured memory_bytes: 3636
#include<iostream>
using namespace std;
  
  int main(){
  int a=0;
  int b=0;
  
  cin>>a;
  cin>>b;
  
  if(a>b){
   for(int i=0;i<a;i++){
    cout<<b; 
   }
  }
  else{
      for(int i=0;i<b;i++){
    cout<<a; 
   }
  }
}

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

counter = 0
best = 0
for _ in range(n):
    x, y = map(int, input().split())
    if x == y:
        counter += 1
    else:
        counter = 0

    best = max([best, counter])

if best >= 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9180
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int x, k, b[100005] = {}, q, z[100005] = {}, c = 1;
    pair<pii, int> a[100005] = {};
    cin >> x >> k;
    int l = 0, r = x, d = 0, u = x;
    for (int i = 1; i <= k; i++) cin >> b[i];
    b[k + 1] = mod + mod;
    cin >> q;
    for (int i = 1; i <= q; i++) cin >> a[i].first.first >> a[i].first.second, a[i].second = i;
    sort(a + 1, a + q + 1);
    for (int i = 1; i <= k + 1; i++) {
        if (i % 2) {
            while (c <= q && a[c].first.first <= b[i]) {
                if (a[c].first.second >= l && a[c].first.second <= r) z[a[c].second] = max(0, d + a[c].first.second - l - a[c].first.first + b[i - 1]);
                else if (a[c].first.second < l) z[a[c].second] = max(0, d - a[c].first.first + b[i - 1]);
                else z[a[c].second] = max(0, u - a[c].first.first + b[i - 1]);
                c++;
            }
            if (b[i] - b[i - 1] < d) {
                d -= b[i] - b[i - 1];
                u -= b[i] - b[i - 1];
            } else if (b[i] - b[i - 1] < u) {
                l += b[i] - b[i - 1] - d;
                d = 0;
                u -= b[i] - b[i - 1];
            } else {
                l = r = d = u = 0;
            }
        } else {
            while (c <= q && a[c].first.first <= b[i]) {
                if (a[c].first.second >= l && a[c].first.second <= r) z[a[c].second] = min(x, d + a[c].first.second - l + a[c].first.first - b[i - 1]);
                else if (a[c].first.second < l) z[a[c].second] = min(x, d + a[c].first.first - b[i - 1]);
                else z[a[c].second] = min(x, u + a[c].first.first - b[i - 1]);
                c++;
            }
            if (b[i] - b[i - 1] < x - u) {
                d += b[i] - b[i - 1];
                u += b[i] - b[i - 1];
            } else if (b[i] - b[i - 1] < x - d) {
                d += b[i] - b[i - 1];
                r -= b[i] - b[i - 1] - x + u;
                u = x;
            } else {
                l = r = d = u = x;
            }
        }
        //cout << l << ' ' << r << ' ' << d << ' ' << u << '\n';
    }
    for (int i = 1; i <= q; i++) cout << z[i] << '\n';
}


Measured memory_bytes: 5600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        int a, b, c, d;
        a = x + r;
        b = x - r;
        c = y + r;
        d = y - r;
        if(a <= W && b >= 0 && c <= H && d >= 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26324
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0;i<n;i++)
        cin >> d[i];
    int res = 0;
    for (int i = 0;i<n;i++){
        for (int j = 0; j < n;j++){
            if(i==j)
                continue;
            res+=d[i]*d[j];
        }
    }
    cout << res / 2 << endl;
}

Measured memory_bytes: 256
use std::collections::HashMap;
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();

    let _n: i32 = s.trim().parse().ok().unwrap();

    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();

    let a: Vec<i32> = s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
    let mut map: HashMap<i32, i32> = HashMap::new();
    for i in a.into_iter() {
        let mut val: i32;
        {
            if let Some(p) = map.get(&i) {
                val = *p;
            } else {
                val = -1;
            }
        }
        if val != -1 {
            map.insert(i, val + 1);
        } else {
            map.insert(i, 1);
        }
    }

    let mut result: i32 = 0;

    for (k, v) in map.into_iter() {
        let r = k - v;
        if r < 0 {
            result += -r;
        } else if r > 0 {
            result += v;
        }
    }

    print!("{}", result);
}

Measured memory_bytes: 10492
n, m = gets.split.map(&:to_i)
s = []
c = []
ans = ['*'] * n
m.times do |i|
  s, c = gets.split.map(&:to_i)
  if s > n
    puts -1
    exit
  end
  if ans[s-1] != '*' && ans[s-1] != c.to_s
    puts -1
    exit
  end
  ans[s-1] = c.to_s
end

if n == 1 && (ans[0] == '0' || ans[0] == '*')
  puts 0
  exit
end

if ans[0] == '0'
  puts -1
  exit
end

ans.each_with_index do |n, i|
  if n == '*'
    if i == 0
      ans[i] = 1
    else
      ans[i] = 0
    end
  end
end

puts ans.join.to_i

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


int main(){
    int N;
    vector<vector<int>>D(100,vector<int>(2));
    cin>>N;
    int cnt=0;
    for(int i=0;i<N;i++){
        cin>>D.at(i).at(0)>>D.at(i).at(1);
    }
    
    for(int i;i<N;i++){
        
        if(D.at(i).at(0)==D.at(i).at(1)){
            cnt++;
            if(cnt>=3){
                cout<<"Yes"<<endl;
                return 0;
            }
        }else{
            cnt=0;
        }

    }
    cout<<"No"<<endl;
    return 0;
}


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

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    sort(A.begin(),A.end());
    for(int i=0;i<N;i++){
        if(A[i]==A[i+1]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 1024