akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n: usize,
      m: usize,
      p: [Usize1; n],
      xy: [(Usize1, Usize1); m]
   }

   let mut uf = (0..n).collect::<Vec<_>>();
   for &(x, y) in xy.iter() {
      uf.unite(x, y);
   }

   let mut nums = vec![BTreeSet::<usize>::new(); n];
   for i in 0..n {
      let r = uf.root(i);
      nums[r].insert(p[i]);
   }

   let mut ans = 0;
   for (i, r) in (0..n).map(|i| (i, uf.root(i))) {
      if nums[r].contains(&i) {
         ans += 1;
      }
   }
   println!("{}", ans);
}

trait UnionFind {
   fn unite(&mut self, x: usize, y: usize);
   fn same(&mut self, x: usize, y: usize) -> bool;
   fn root(&mut self, x: usize) -> usize;
}
impl UnionFind for [usize] {
   fn unite(&mut self, x: usize, y: usize) {
      let rx = self.root(x);
      let ry = self.root(y);
      if rx == ry {
         return;
      }
      self[ry] = rx;
   }
   fn same(&mut self, x: usize, y: usize) -> bool { self.root(x) == self.root(y) }
   fn root(&mut self, x: usize) -> usize {
      if self[x] == x {
         x
      } else {
         self[x] = self.root(self[x]);
         self[x]
      }
   }
}


Measured memory_bytes: 19764
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define MA 10e17
int va=10e8+7;
ll int dp[100004]={0};
using namespace std;
//Conditional Operator (condition?true part:false part) eg : cout<<(y<=3?"YES":"NO")<<endl;
//string s(3,'1');
// if number of elements in array >10^5 then declare global array.
ll getmul(ll n){ll int k{0};while(n>0){k+=n%10;n=n/10;}return k;}//Sum OF n DIGITS 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t{1};
    //cin>>t;
    while(t--){
        string s,t;
        cin>>s>>t;
        int ans=INT_MAX;
        for(int i=0;i+sz(t)<=sz(s);i++){
            string k=s.substr(i,sz(t));
            //cout<<k<<endl;
            int cnt{0};
            for(int j=0;j<sz(t);j++){
                if(k[j]!=t[j]) cnt++;
            }
            ans=min(cnt,ans);
        }
        cout<<ans<<endl;
    }
 return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define  point complex<double>
#define  pi acos(-1)
#define  ll long long
const ll mod=1e9+7 ;
const ll N=2e5+5;

        double dot (point a,point b){
            return  (conj(a)*b).real();
        }
        double cross(point a,point b){
            return  (conj(a)*b).imag();
        }
double angle(point a, point b)
{
    double dt = dot(a, b);
    dt /= abs(a);
    dt /= abs(b);
    return acos(dt) * 180.0 / pi;
}
ll d, x, y;
void extendedEuclid(ll A, ll B) {
    if (B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        extendedEuclid(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A / B)*y;
    }
}
ll modInverse(ll A, ll M)
{
    extendedEuclid(A, M);
    return (x%M + M) % M;
}
ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}

int main() {
ll n,k;
cin >>n>>k;
calcFacAndInv(1000000);
for (ll i=1;i<=k;++i) {
if (n-k+1<i){
    cout <<0<<endl;
}
else
    cout <<( ncr(n-k+1,i)*ncr(k-1,i-1))%mod<<endl;
}
    return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<cstdio>
#include<cstring>
#define maxn 10010
using namespace std;
int n,q;
int father[maxn];
int rank[maxn];

void init()
{
    for(int i=0; i<n; ++i)
    {
        father[i]=i;
        rank[i]=0;
    }
}

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

void same(int x,int y)
{
	if(find(x)==find(y))
	  printf("1\n");
	else
	  printf("0\n");
}

void unite(int x,int y)
{
	father[find(x)]=find(y);
}

int main()
{
    scanf("%d%d",&n,&q);
    init();
    for(int i=0; i<q; ++i)
    {
        int com,x,y;
        scanf("%d%d%d",&com,&x,&y);
        if(com)
            same(x,y);
        else
            unite(x,y);
    }
    return 0;
}

Measured memory_bytes: 3276
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

signed main() {
	cout << setprecision(20) << fixed;
	string s;
	cin >> s;
	//int res = s.size();
	//rep(i, s.size()-1) {
	//	if (s.substr(i, 2) == "ST") {
	//		res -= 2;
	//		i++;
	//	}
	//}
	//cout << res << endl;

	//rep(i, s.size() - 1) {
	//	if (s.substr(i, 2) == "ST") {
	//		s.erase(s.begin() + i, s.begin() + i + 2);
	//	}
	//}
	//cout << s.size() << endl;

	int S_cnt = 0;
	int res = 0;
	rep(i, s.size()) {
		if (s[i] == 'S') S_cnt++;
		if (s[i] == 'T') {
			if (S_cnt > 0) S_cnt--;
			else res++;
		}
	}
	res += S_cnt;
	cout << res << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long 
#define pb push_back
#define fr first
#define sc second
#define sz(v) ((int)(v).size())
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repd(i,a,p) for(int i=a-1;i>=p;i--) 
#define M 1000000007
#define vi vector<int>
#define vp vector<pair<int,int> >
#define ml map<int,int>
#define MPI 3.1415926536
using namespace std;
int temp=0,r,l,w,k=0,m1,e,p,q,ans,k1=0,k2=0,d=0,a=0,b=0,s=0,x,y,min1=1000000010,max1=0,m,c=0,t=0,i,n,c1=0,tot=0,t1,k4=0,c2=0,j=0,k3=0;char ch,ch1,ch2;string s1,s2,s3;
signed main()
{
cin>>n>>k;
vi v(n),dp(n,INT_MAX);
dp[0]=0;
rep(i,0,n)cin>>v[i];
rep(i,0,n)
{
	for(j=i+1;j<=i+k;j++)
	{
	if(j<n)
	dp[j]=min(dp[j],dp[i]+abs(v[j]-v[i]));} 
}
cout<<dp[n-1];
}

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

int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> sum(N);
  for (int i = 0; i < N - 1; i++) {
    sum[i + 1] = sum[i] + (S.substr(i, 2) == "AC");
  }
  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    cout << sum[r - 1] - sum[l - 1] << endl;
  }
}


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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    string s, t;
    cin >> s >> t;

    int offset = s.size() - t.size();
    int len = 0;
    while (offset >= 0)
    {
        len = 0;
        while (len < t.size())
        {
            if (s[offset + len] == '?' || s[offset + len] == t[len])
            {
                ++len;
            }
            else
            {
                break;
            }
        }
        if (len == t.size()) break;
        --offset;
    }

    if (offset < 0)
    {
        cout << "UNRESTORABLE\n";
    }
    else
    {
        rep (i, s.size())
        {
            if (i == offset)
            {
                cout << t;
                i += t.size() - 1;
            }
            else
            {
                if (s[i] == '?')
                {
                    cout << 'a';
                }
                else
                {
                    cout << s[i];
                }
            }
        }
        cout << "\n";
    }
    return 0;
}



Measured memory_bytes: 256
import sys

n, m = map(int, input().split())

num = [[0] for i in range(n)]
s = []
if(n != 1):
  num[0][0] = 1

test = list(list(map(int, input().split())) for i in range(m))

for i in test:
  num[i[0] - 1].append(i[1])

for i in range(len(num)):
  if(len(set(num[i])) >= 3):
    print(-1)
    sys.exit()
  elif(i == 0 and min(num[i]) == 0 and n != 1):
    print(-1)
    sys.exit()
  s.append(str(max(num[i])))

print(''.join(s))


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N;
	while(~scanf("%d", &N)) {
		int A; int B;
		scanf("%d%d", &A, &B);
		int ans = 0;
		rep(i, N) {
			int t;
			scanf("%d", &t);
			ans += !(A <= t && t < B);
		}
		printf("%d\n", ans);
	}
	return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] a_asArgs)
        {
			Console.ReadLine();
			string[] l_asArare = Console.ReadLine().Split(' ');

			foreach (string l_sArare in l_asArare)
			{
				if (l_sArare == "Y")
				{
					Console.WriteLine("Four");
					return;
				}
			}
			Console.WriteLine("Three");
		}
	}
}


Measured memory_bytes: 11092
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    N = input()

    hon = [2, 4, 5, 7, 9]
    pon = [0, 1, 6, 8]
    bon = [3]

    one = int(N[-1])
    if one in hon:
        print('hon')
    elif one in pon:
        print('pon')
    else:
        print('bon')

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9132
#include <iostream>
#include <vector>
#include <string>
#define input std::cin

using vector = std::vector<int>;
using lint = long long int;
using string = std::string;

int main() {
  int d, t, s; input >> d >> t >> s;
  bool reachable = t * s >= d;
  if (reachable)
	std::cout << "Yes" << std::endl;
  else
	std::cout << "No" << std::endl;
}



Measured memory_bytes: 3672
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = 1e+5;

int N, M, P, A, B;
int T[10];
int cost[31][31];

int main(){
  while(true){
	cin >> N >> M >> P >> A >> B;
	if(N == 0) break;
	--A, --B;
	REP(i,N) cin >> T[i];
	fill((int*)cost, (int*)cost+31*31, -1);
	REP(i,P){
	  int a, b, c; cin >> a >> b >> c;
	  --a, --b;
	  cost[a][b] = cost[b][a] = c;
	}
	double dp[31][1<<10];
	fill((double*)dp, (double*)dp+31*(1<<10), INF);
	dp[A][(1<<N)-1] = 0.0;

	for(int bit=(1<<N)-1;bit>=0;--bit){
	  for(int s=0;s<M;++s){
		for(int u=0;u<N;++u){
		  if((bit>>u & 1) == 0) continue;
		  for(int to=0;to<M;++to){
			if(cost[s][to] < 0) continue;
			dp[to][bit&~(1<<u)] = min(dp[to][bit&~(1<<u)],
									  dp[s][bit] + (double)cost[s][to] / T[u]);
		  }
		}
	  }
	}

	double ans = INF;
	for(int bit=0;bit<(1<<N);++bit)
	  ans = min(ans, dp[B][bit]);
	if(ans == INF) cout << "Impossible" << endl;
	else printf("%.3lf\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1476
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i(a); i <= (b); ++i)

template <class T> inline bool smin(T&x, const T&y) { return y < x ? x = y, 1 : 0; }
template <class T> inline bool smax(T&x, const T&y) { return x < y ? x = y, 1 : 0; }

typedef long long ll;

const int N(3005);
char a[N], b[N];
int n, m, f[N][N], g[N][N];
void out(int i, int j){
	if (!g[i][j])return;
	if (g[i][j] == 1) out(i - 1, j - 1), putchar(a[i]);
	else if (g[i][j] == 2) out(i - 1, j);
	else out(i, j - 1);
}
int main() {
	scanf("%s%s", a + 1, b + 1);
	n = strlen(a + 1), m = strlen(b + 1);
	REP(i, 1, n)REP(j, 1, m){
		if (a[i] == b[j]) f[i][j] = f[i - 1][j - 1] + 1, g[i][j] = 1;
		if (smax(f[i][j], f[i - 1][j])) g[i][j] = 2;
		if (smax(f[i][j], f[i][j - 1])) g[i][j] = 3;
	}
	out(n, m);
	return 0;
}



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

Measured memory_bytes: 256
import heapq

INF = 2**62-1

def dijkstra(route_map, start_point):
    num_of_city = len(route_map)
    dist = [INF for _ in range(num_of_city)]

    dist[start_point] = 0
    heap_q = []
    heapq.heappush(heap_q, (0, start_point))
    while heap_q:
        prev_cost, src = heapq.heappop(heap_q)

        if dist[src] < prev_cost:
            continue

        for dest, cost in route_map[src].items():
            if dist[dest] > dist[src] + cost:
                dist[dest] = dist[src] + cost
                heapq.heappush(heap_q, (dist[dest], dest))
    return dist

n, m = list(map(int, input().split()))
route_map = [{} for _ in range(n)]

for i in range(m):
    u, v, a = list(map(int, input().split()))
    u, v = u - 1, v - 1
    if v in route_map[u].keys():
        a = min(a, route_map[u][v])
    route_map[u][v] = a

for i in range(n-1):
    u, v = i+1, i
    route_map[u][v] = 0

# ゴールまでの最短経路
dijkstra_result = dijkstra(route_map, 0)

if dijkstra_result[-1] != INF:
    print(dijkstra_result[-1])
else:
    print(-1)


Measured memory_bytes: 49776
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <array>
#include <set>
#include <climits>
#include <cassert>
#include <bitset>
using namespace std;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int h , n; cin>>h>>n;
    vector<int>v(n);
    long long sum{};
    for(auto &itr:v){
        cin>>itr;
        sum+=itr;
    }
    if(sum>=h){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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



int main(){
    string s; cin >> s;
    for(int i = 0; i < s.length(); i++){
        if(s[i]=='7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner;
import java.lang.Math;

public class Main {
  public static void draw(int a, int b)
  {
    for (int i = 0; i < a; i++) {
      for (int j = 0; j < b; j++) {
        System.out.print("#");
      }
      System.out.println();
    }
  }
  public static void main(String[] args)
  {
    Scanner scan = new Scanner(System.in);
    while(true)
    {
      int a = scan.nextInt();
      int b = scan.nextInt();
      if(a ==0 && b == 0) break;
      draw(a,b);
      System.out.println();
    }
    scan.close();
  }
}



Measured memory_bytes: 35340
#pragma GCC optimize(2)
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue<int, vector<int>, greater<int> > q;从小到大
#include <map>
#include <set> //multiset set<int,greater<int>>大到小
#include <vector>// vector<int>().swap(v);清空释放内存
#include <stack>
#include <cmath> // auto &Name : STLName  Name.
#include <utility>
#include <sstream>
#include <string>//__builtin_popcount(ans);//获取某个数二进制位1的个数
#define mod 1000000007
#define mod9 998244353
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ld;
const db eps=1e-7;
#define PII pair<int,int>
//const db pi=acos(-1);
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
#define rep(i,be,en) for (int i=be;i<=en;i++)
#define per(i,be,en) for (int i=en;i>=be;i--)
using namespace std;
const int N=1e4+3;

int T,n,m,k=0,fl=0;

int main(){
    scanf("%d",&n);
    rep(i,1,n){
        scanf("%d",&m);
        k+=m;
        fl=max(fl,m);
    }
    if(k-fl>fl) puts("Yes");
    else puts("No");
    return 0 ;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}

void solve(){
	int n;
	cin>>n;
	int a[n];
	map<int,int>mp;
	int c=0;
	vector<int>u;
	rep(i,n){cin>>a[i];if(mp[a[i]]==0){u.push_back(a[i]);c++;}mp[a[i]]++;}
	//if(n%3){cout<<"No";return;}
	if(u.size()==1&&a[0]){cout<<"No";return;}
  	else if(u.size()==1){cout<<"Yes";return;}
	vector<int>v;
	v.push_back(u[0]);
	v.push_back(u[1]);
	mp[u[0]]--;
	mp[u[1]]--;
	int i=0;
	while(v.size()!=n){
		int x=v[i]^v[i+1];
		if(mp[x]){
			v.push_back(x);
			i++;
			mp[x]--;
		}
		else {cout<<"No";return;}
	}
	//for(int i:v)cout<<i<<" ";cout<<"\n";
	if((v[n-1]^v[n-2])==v[0]&&(v[n-1]^v[0])==v[1])cout<<"Yes";
	else cout<<"No";
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

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

signed main() {
    int N,K;
    cin >> N >> K;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    int dp[100010];
    for(int i = 0;i < N + 1;i++) {
        dp[i] = 1000000000;
    }
    dp[0] = 0;
    for(int i = 1;i < N;i++) {
        for(int j = max(0,i - K);j < i;j++) {
            dp[i] = min(dp[i],dp[j] + abs(vec.at(i) - vec.at(j)));
        }
    }
    cout << dp[N - 1] << endl;
}

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

int main() {
	int n;
	cin >> n;
	int k;
	cin >> k;
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < n-1; i++) {
		if (s[i] == s[i + 1])ans += 1;
	}
	ans = ans + k * 2;
	if (ans >= n)cout << n - 1;
	else cout << ans;
}

Measured memory_bytes: 512
#include <iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
        int n;
        string w[110];

        cin>>n;
        for(int i=0; i<n; ++i) cin>>w[i];

        for(int i=1; i<n; ++i){
                if(w[i][0]!=w[i-1][w[i-1].size()-1]){
                        cout<<"No"<<endl;
                        return 0;
                }
                for(int j=0; j<i; ++j){
                        if(w[i]==w[j]){
                                cout<<"No"<<endl;
                                return 0;
                        }
                }
        }
        cout<<"Yes"<<endl;
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll Nagaemon1;
void swap(ll i,ll j){
  Nagaemon1=i;
  i=j;
  j=Nagaemon1;
}
int main(void){
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll ans=1;
    rep(i,n){
	  cin >> a[i];
      if(a[i]==0){
		cout << 0;
        return 0;
      }
    }
    rep(i,n){
      cin >> a[i];
      if(1000000000000000000/ans<a[i]){
        cout << -1;
        return 0;
      }
      ans*=a[i];
      if(ans==0){
        cout << 0;
        return 0;
      }
    }
    cout << ans;
}

Measured memory_bytes: 4052
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int[] a = new int[300];
		int[] b = new int[300];
		int i = 0;
		
		a[0] = 1;
		b[0] = 1;
		
		while(!(a[i] == 0 && b[i] == 0)){
			i++;
			a[i] = scan.nextInt();
			b[i] = scan.nextInt();}
			
		for(int q=1; q<i; q++){
			for(int j=0; j<a[q]; j++){
				for(int h=0; h<b[q]; h++){
					System.out.print("#");}
				System.out.print("\n");}
				System.out.print("\n");}
	}
}


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

int main(){
    int ca[4][3][10]={};
    int n;
    int b,f,r,v;

    cin >> n;

    for(int i=0;i<n;i++){
        cin >> b >> f >> r >> v;
        ca[b-1][f-1][r-1]+=v;
    }

    for(int x=0;x<4;x++){
        for(int y=0;y<3;y++){
            for(int z=0;z<10;z++){
                cout << " " << ca[x][y][z];
            }
            cout << endl;
        }
        if(x!=3){
            for(int a=0;a<20;a++){
                cout << "#";
            }
            cout << endl;
        }
    }

    return 0;
}


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

int main() {
	int n,x;
	cin>>x>>n;
	int a[n+1];
	set<int>s;
	for(int i=1;i<=n;i++)
	{
	    cin>>a[i];
	    s.insert(a[i]);
	}
	if(s.find(x)==s.end())
	cout<<x;
	else
	{
	    int b=x-1,c=x+1;
	    while(1)
	    {
	         
	    if(s.find(b)==s.end())
	    {
	        cout<<b;
	        return 0;
	    }
	    if(s.find(c)==s.end())
	    {
	        cout<<c;
	        return 0;
	    }
	    b--;
	    c++;
	    }
	   
	}
	return 0;
}


Measured memory_bytes: 3596
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = Integer.parseInt(sc.next());
		Double[] in = new Double[N];
		
		for (int i = 0; i < N; i++) in[i] = Double.parseDouble(sc.next());
		
		List<Double> list = new ArrayList<>(Arrays.asList(in));
		for (int i = 0; i < N-1; i++) {	
			Collections.sort(list);
			Double val = (list.get(0) + list.get(1)) / 2;
			list.remove(0);
			list.remove(0);
			list.add(val);
		}
		
		System.out.println(list.get(0));
	}
}


Measured memory_bytes: 22736
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner (System.in);
	int h = Integer.parseInt(scan.nextLine());
	int[] heap = new int[h+1];
	String[] input = scan.nextLine().split(" ");
	for (int i = 0; i < h; i++) {
	    heap[i+1] = Integer.parseInt(input[i]);
	}
	BinaryHeap bh = new BinaryHeap(h+1, heap);
	bh.printHeap();
    }
}
class BinaryHeap {
    int h;
    int[] heap;
    BinaryHeap (int h, int[] heap) {
	this.h = h;
	this.heap = heap;
    }
    void printHeap () {
	for (int i = 1; i < h; i++) {
	    printNode(i);
	}
    }
    void printNode (int id) {
	StringBuilder sb = new StringBuilder();
	sb.append("node " + id);
	sb.append(": key = " + heap[id] + ", ");
	if (id != 1) {
	    sb.append("parent key = " + heap[id/2] + ", ");
	}
	if (id*2 < h) {
	    sb.append("left key = " + heap[id*2] + ", ");
	}
	if ((id*2)+1 < h) {
	    sb.append("right key = " + heap[id*2+1] + ", ");
	}
	System.out.println(sb);
    }
}

Measured memory_bytes: 27608
#include<stdio.h>
#include<algorithm>
using namespace std;
int prime[1299709];
int table[100000];

int main(){
	prime[0]=1;
	for(int i=1;i<1299709;i++){
		if(prime[i]==0){
			prime[i]=1;
			for(int j=(i+1)*2-1;j<=1299709;j+=i+1)prime[j]=2;
		}
	}
	int now=0;
	for(int i=0;i<1299709;i++){
		if(prime[i]==1){
			table[now++]=i+1;
		}
	}
	int a;

	while(1){
		scanf("%d",&a);
		if(a==0)return 0;
		int index=(int)(lower_bound(table,table+100000,a)-table);
		if(table[index]==a)printf("0\n");
		else printf("%d\n",table[index]-table[index-1]);
	}
}

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

using namespace std;

int main()
{ 
  typedef long long ll;
  ll taka,aoki,k;
  cin>>taka>>aoki>>k;

if(taka>=k)
{
   taka-=k;
}
else
{
  if(aoki>=k-taka)
  aoki=(aoki)-(k-taka);
else
  aoki=0;
  taka=0;
}
cout<<taka<<" "<<aoki<<endl;

return 0;
}
     


    

Measured memory_bytes: 256
#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 = 1000000001;

double w, h, x, y;

int main(){
  cin >> w >> h >> x >> y;
  
  int judge = 0;
  if(2*x == w && 2*y == h){
    judge = 1;
  }
  cout << w*h/2 << " " << judge <<endl;
}

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

class Heap<T>
{
    public List<T> list { get; set; }

    public int Count => list.Count;

    public T this[int index] { get { return this.list[index]; } set { list[index] = value; } }

    public Heap(List<T> list)
    {
        this.list = list;
    }

    public void Add(T t)
    {
        list.Add(t);
    }

    public T Parent(int i)
    {
        return list[(i + 1) / 2 - 1];
    }

    public T Left(int i)
    {
        return list[2 * i + 1];
    }

    public T Right(int i)
    {
        return list[2 * (i+1)];
    }
}

class MyClass
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var heap = new Heap<int>(Console.ReadLine().Split().Select(int.Parse).ToList());
        for (int i = 0; i < n; i++)
        {
            var str = "node " + (i + 1) + ": key = " + heap[i] + ", ";
            try
            {
                str += "parent key = " + heap.Parent(i) + ", ";
            }
            catch (Exception)
            {
            }
            try
            {
                str += "left key = " + heap.Left(i) + ", ";
            }
            catch (Exception)
            {
            }
            try
            {
                str += "right key = " + heap.Right(i) + ", ";
            }
            catch (Exception)
            {
            }
            Console.WriteLine(str);
        }
    }
}


Measured memory_bytes: 18456
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  double a, b, x;
  cin>>a>>b>>x;
  double theta;
  if(a*a*b/2<=x) {
    theta = atan((a*a*b-x)*2/(a*a*a));
    theta *= 180/PI;
  }
  else {
    theta = atan(2*x/(a*b*b));
    theta *= 180/PI;
    theta = 90 - theta;
  }
  cout<<setprecision(20)<<theta<<endl;
}



Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
typedef long double LD; 
typedef long long ll; 
#define int ll 
#define ff(i,a,b) for (int i = a; i < b; i++) 
#define bf(i,a,b) for (int i = a; i >= b; i--) 
#define all(v) v.begin(),v.end() 
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define F first 
#define S second
#define lb lower_bound   
#define ub upper_bound
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define one cout<<-1<<endl;
#define pi 3.141592653589793238
#define mod 1000000007
int ans=0;
void solve(){
    int n;
    cin>>n;
    int a[n];
    ff(i,0,n){
        cin>>a[i];
    }
    sort(a,a+n);
    ff(i,0,n){
        ff(j,i+1,n){
            ff(k,j+1,n){
                if(a[i]+a[j]>a[k] && a[i]!=a[j] &&a[i]!=a[k] && a[j]!=a[k]){
                    ans++;
                    //cout<<a[i]<<" "<<a[j]<<" "<<a[k]<<endl;
                }
            }
        }
    }
    cout<<ans;
}
signed main() {
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


int main(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);

  ll N,M;
  cin>>N>>M;
  int sum=0;
  vector<int> vec(M);
  for(int i=0;i<M;i++){
    cin>>vec[i];
    sum+=vec[i];
  }
  
  if(N>=sum){
    cout<<N-sum<<endl;
  }else{
    cout<<"-1"<<endl;
  }
  
  
  
  
  
}



Measured memory_bytes: 3672
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }





int N;
vector<int> a;

long long solve() {
    int iter = 1;
    int res = 0;
    for (int i = 0; i < N; ++i) {
        if (a[i] == iter) ++iter;
    }

    if (iter == 1) return -1;
    else return N - iter + 1;
}

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

    while (cin >> N) {
        a.resize(N);
        for (int i = 0; i < N; ++i) cin >> a[i];
        cout << solve() << endl;
    }
}


















Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

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};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
double n, k;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> k;

  double ans = 0;
  FOR(i, 1, n + 1) {
    if(i < k) {
      double count = 1.0;
      int ii = i;
      while(ii < k) {
        ii *= 2;
        count *= 2.0;
      }
      ans += (double)(1.00 / (n * count));
    } else {
      ans += (double)(1.0 / n);
    }
  }

  cout << setprecision(11) << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{

static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split("\\s+");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split("\\s+");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
//......................................@uthor_Alx..............................................
static long mod=(long)1e9+7;

public static void main(String[] args) throws  IOException{
                assign();
                String s=read(),t=read();
                int n=s.length(),m=t.length();
                int[][] dp=new int[n+1][m+1];
                int res=m;
                for(int i=1;i<=n;i++){
                    if(i+m-1>n) continue;
                    int tmp=0;
                    for(int j=i;j<i+m;j++){
                        char c1=s.charAt(j-1),c2=t.charAt(j-i);
                        if(c1!=c2) tmp++;
                    }
                    res=Math.min(res,tmp);
                }
                out.write(res+"");
                out.flush();

    }
}


Measured memory_bytes: 40176
l = input().split(" ")
n = int(l[0])
m = int(l[1])

r = []
l = []

for i in range(m):
    gatei = input().split(" ")
    li = int(gatei[0])
    ri = int(gatei[1])
    l.append(li)
    r.append(ri)

l.sort()
r.sort()

count = r[0] - l[m-1] + 1

if count >= 0:
    print(count)
else:
    print(0)

Measured memory_bytes: 11380
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<vector<int>> A(2, vector<int>(N));
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A.at(i).at(j);
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) { 
    int memo = 0;
    for (int j = 0; j < i + 1; j++) {
      memo += A.at(0).at(j);
    }
    for (int j = i; j < N; j++) {
      memo += A.at(1).at(j);
    }
    ans = max(ans, memo);
  }
  cout << ans << endl;
}
          

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    for (int j = 0; j < N; ++j) {
        cin >> B[j];
    }
    long long int ans = 0;
    long long int b = 1 << 29;
    for (int k = 28; k >= 0; --k) {
        for (int i = 0; i < N; ++i) {
            A[i] %= b;
            B[i] %= b;
        }
        sort(B.begin(), B.end());
        long long int qq = 0;
        for (int j: A) {
            int q1 = b / 2;
            int q2 = q1 * 2;
            int q3 = q1 * 3;
            int aa = lower_bound(B.begin(), B.end(), q1 - j) - B.begin();
            int bb = lower_bound(B.begin(), B.end(), q2 - j) - B.begin();
            int cc = lower_bound(B.begin(), B.end(), q3 - j) - B.begin();
            qq += (N - cc + bb - aa);
        }
        b /= 2;
        ans += b * (qq % 2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var s = Console.ReadLine();
        var q = int.Parse(Console.ReadLine());

        Stack<char> front = new Stack<char>();
        Stack<char> back = new Stack<char>();

        foreach (var c in s)
        {
            back.Push(c);
        }
        for (int i = 0; i < q; i++)
        {
            var query = Console.ReadLine();
            if (query == "1")
            {
                var tmp = front;
                front = back;
                back = tmp;
            }
            else
            {
                if (query[2] == '1')
                {
                    front.Push(query[4]);
                }
                else
                {
                    back.Push(query[4]);
                }
            }
        }

        Console.WriteLine(string.Join("", front) + string.Join("",back.Reverse()));
    }
}


Measured memory_bytes: 22740
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

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

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair



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

	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= m; j++) {
			if (i * (m - j) + (n - i) * j == k) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
import sys

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

n = int(input())
Arr = get_array()
ans = 0
mini = float('inf')
for i in range(n):
    mini = min(mini, Arr[i])
    if Arr[i]==mini:
        ans+=1
print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  
  if(n == 1){
    cout << a.at(0) << endl;
  }
  
  else if(n%2 == 0){
    vector<int> b(n/2);
    vector<int> c(n/2);
    for(int i=0;i<n;i++){
      if(i%2 == 0){
        c.at(i/2) = a.at(i);
      }
      else {
        b.at(i/2) = a.at(i);
      }
    }
    reverse(b.begin(), b.end());
    for(int i=0;i<n/2;i++){
      cout << b.at(i) << " ";
    }
    for(int i=0;i<n/2;i++){
      cout << c.at(i) << " ";
    }
    cout << endl;
  }
  
  else {
    vector<int> b(n/2);
    vector<int> c(n/2 +1);
    for(int i=0;i<n;i++){
      if(i%2 == 0){
        c.at(i/2) = a.at(i);
      }
      else {
        b.at(i/2) = a.at(i);
      }
    }
    reverse(c.begin(), c.end());
    for(int i=0;i< n/2 +1;i++){
      cout << c.at(i) << " ";
    }
    for(int i=0;i<n/2;i++){
      cout << b.at(i) << " ";
    }
    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define ll  long long
#define out(a) printf("%d",a)
#define writeln printf("\n")
using namespace std;
int h,w;
char str[55][55];
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
ll readl()
{
	ll s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int main()
{
	h=read(); w=read();
	for (int i=0;i<h;i++)
	  scanf("%s",str[i]);
	for (int i=0;i<h;i++)
	  for (int j=0;j<w;j++)
	    if (str[i][j]=='#'&&str[i+1][j]!='#'&&str[i-1][j]!='#'&&str[i][j+1]!='#'&&str[i][j-1]!='#') {
	    	puts("No");
	    	return 0;
	    }
	    puts("Yes");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		char[] c = new char[s.length()];
		for (int i = 0; i < s.length(); i++) {
			c[i] = s.charAt(i);
		}
		int[] x = new int[4];
		for (int i = 0; i < s.length(); i++) {
			x[i] = Character.getNumericValue(c[i]);
		}

		int[] a = new int[8];
		a[0] = x[0]-x[1]-x[2]-x[3];
		a[1] = x[0]-x[1]-x[2]+x[3];
		a[2] = x[0]-x[1]+x[2]-x[3];
		a[3] = x[0]+x[1]-x[2]-x[3];
		a[4] = x[0]-x[1]+x[2]+x[3];
		a[5] = x[0]+x[1]+x[2]-x[3];
		a[6] = x[0]+x[1]-x[2]+x[3];
		a[7] = x[0]+x[1]+x[2]+x[3];

		for (int i = 0; i < 8; i++) {
			if (a[0] == 7) {
				System.out.printf("%d-%d-%d-%d=7", x[0], x[1], x[2], x[3]);
				return;
			} else if (a[1] == 7) {
				System.out.printf("%d-%d-%d+%d=7", x[0], x[1], x[2], x[3]);
				return;
			} else if (a[2] == 7) {
				System.out.printf("%d-%d+%d-%d=7", x[0], x[1], x[2], x[3]);
				return;
			} else if (a[3] == 7) {
				System.out.printf("%d+%d-%d-%d=7", x[0], x[1], x[2], x[3]);
				return;
			} else if (a[4] == 7) {
				System.out.printf("%d-%d+%d+%d=7", x[0], x[1], x[2], x[3]);
				return;
			} else if (a[5] == 7) {
				System.out.printf("%d+%d+%d-%d=7", x[0], x[1], x[2], x[3]);
				return;
			} else if (a[6] == 7) {
				System.out.printf("%d+%d-%d+%d=7", x[0], x[1], x[2], x[3]);
				return;
			} else if (a[7] == 7) {
				System.out.printf("%d+%d+%d+%d=7", x[0], x[1], x[2], x[3]);
				return;
			}
		}
	}
}


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

using namespace std;

typedef long long ll;

int const N = 100 * 1000 + 16;

int n, m, k;
ll cnt[N];

struct node {
  int x, y = rand(), s = 1;
  ll sum = 0;
  node* l = 0;
  node* r = 0;

  node(int v) {
    x = v;
    sum = v;
  }

  ~node() {
    delete l;
    delete r;
  }

  void update() {
    s = 1;
    sum = x;
    if(l) {
      s += l->s;
      sum += l->sum;
    }
    if(r) {
      s += r->s;
      sum += r->sum;
    }

  }
};

struct treap {
  node* root = nullptr;

  ~treap() {
    delete root;
  }

  node* join(node* l, node* r) {
    if(!l || !r)
      return l ?: r;
    if(l->y < r->y) {
      l->r = join(l->r, r);
      l->update();
      return l;
    } else {
      r->l = join(l, r->l);
      r->update();
      return r;
    }
  }

  void split(int x, node* p, node*& l, node*& r) {
    l = r = 0;
    if(not p)
      return;

    if(x < p->x) {
      r = p;
      split(x, r->l, l, r->l);
    } else {
      l = p;
      split(x, l->r, l->r, r);
    }
    p->update();
  }

  void insert(int x) {
    node*l,*r;
    split(x, root, l, r);
    root = join(l, join(new node(x), r));
  }

  void remove(int x) {
    node*l,*r,*l2,*l3;
    split(x, root, l, r);
    split(x-1, l, l2, l3);
    if(l3)
      l3 = join(l3->l, l3->r);
    l = join(l2, l3);
    root = join(l, r);
  }

  ll query(int x) {
    node*l,*r;
    split(x, root, l, r);
    
    ll cnt = r ? r->s : 0;
    ll ans = r ? r->sum : 0;

    root = join(l, r);

    return ans-x*cnt;
  }
};

int a[N];
int st[18][N];

void build() {
  for(int i = 0; i < n; ++i)
    st[0][i] = i;

  for(int j = 1; (1<<j) <= n; ++j) {
    int b = 1 << j-1;
    int lim = b + b -1;

    for(int i = 0; i + lim < n; ++i) {
      int x = st[j-1][i];
      int y = st[j-1][i+b];
      if(x > y) swap(x, y);
      st[j][i] = (a[x] >= a[y]) ? x : y;
    }
  }
}

int query(int l, int r) {
  if(l>r)
    return -1;
  int b = 31 - __builtin_clz(r-l+1);
  int x = st[b][l];
  int y = st[b][r-(1<<b)+1];
  if(x > y) swap(x, y);
  return (a[x] >= a[y]) ? x : y;
}

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  cin >> n;
  for(int i = 0; i < n; ++i)
    cin >> a[i];

  build();
  int in = n-1;
  treap t;
  int l = 0;
  int r = n-1;
  ll prev = 0;

  while(1) {

    int idx = query(l, r);
    int lidx;

    if(idx > 0) {
      while(in >= idx)
        t.insert(a[in--]);
      lidx = query(l, idx-1);
      int mn = a[idx];
      cnt[idx+1] = t.query(a[lidx])-prev;
      prev += cnt[idx+1];
      r = lidx;

    } else {
      lidx = n;
      a[lidx] = 0;
      while(in >= idx)
        t.insert(a[in--]);
      int mn = a[idx];
      cnt[idx+1] = t.query(a[lidx])-prev;
      break;
    }
  }

  for(int i = 1; i <= n; ++i)
    cout << cnt[i] << "\n";
}

Measured memory_bytes: 13952
/*
 *  Lang    : C++
 *  Author  : little_angel
 */
#include <bits/stdc++.h>

using namespace std;
#define int long long

int dp[401][401];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)cin >> a[i];
    for (int l = n - 1; l >= 0; --l) {
        for (int r = l + 1; r < n; ++r) {
            dp[l][r] = 1e18L + 5;
            int sum = 0;
            for (int k = l; k <= r; ++k)sum += a[k];
            for (int k = l; k <= r - 1; ++k)dp[l][r] = min(dp[l][r], dp[l][k] + dp[k + 1][r] + sum);
        }
    }
    cout << dp[0][n - 1] << endl;
}

Measured memory_bytes: 1536