akhauriyash/Code-Regression huggingface dataset:
#include <array>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <limits>
#include <fstream>
#include <numeric>
#include <stack>
#include <queue>
#include <list>
#include <cstring>

namespace
{
	template<int N>
	std::array<int, N> GetValue(std::istream& stream)
	{
		std::string buf;
		std::getline(stream, buf);

		std::stringstream sstr(buf);
		std::array<int, N> retval;

		for (int i = 0; i < N; ++i)
		{
			std::getline(sstr, buf, ' ');
			retval[i] = std::stoi(buf);
		}

		return retval;
	}

	std::vector<int> GetValue(std::istream& stream, int num)
	{
		std::string buf;
		std::getline(stream, buf);
		std::stringstream sstr(buf);

		std::vector<int> retval;
		retval.reserve(num);

		int input;
		for (int i = 0; i < num; ++i)
		{
			sstr >> input;
			retval.push_back(input);
		}

		return retval;
	}

	int GetValue(std::istream& stream)
	{
		int in;
		stream >> in;

		return in;
	}

	std::vector<std::string> GetValueString(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<std::string> retval;
		retval.reserve(num);

		std::getline(stream, buf);
		std::stringstream sstr(buf);

		for (int i = 0; i < num && std::getline(sstr, buf, delim); ++i)
		{
			retval.push_back(std::move(buf));
		}

		return retval;
	}

	template<typename T>
	void PrintLine(const std::vector<T>& sequence)
	{
		std::cout << sequence[0];

		for (size_t i = 1; i < sequence.size(); ++i)
		{
			std::cout << ' ' << sequence[i];
		}

		std::cout << std::endl;
	}

	template<typename T>
	void Print(const std::vector<T>& sequence)
	{
		for (const auto& e : sequence)
		{
			std::cout << e << '\n';
		}

		std::cout << std::flush;
	}
}

int main(int argc, char* argv[])
{
	auto file = (argc == 1) ? std::ifstream() : std::ifstream(argv[1]);
	std::istream& stream = (argc == 1) ? std::cin : file;
	if (argc == 1)
	{
		std::cin.tie(0);
		std::ios::sync_with_stdio(false);
	}

	int s_num = GetValue<1>(stream)[0];
	std::vector<int> s = GetValue(stream, s_num);
	int t_num = GetValue<1>(stream)[0];

	//std::sort(s.begin(), s.end());
	int count = 0;
	int t;

	for (int i = 0; i < t_num; ++i)
	{
		stream >> t;
		if (std::binary_search(s.begin(), s.end(), t))
		{
			++count;
		}
	}

	std::cout << count << std::endl;
}



Measured memory_bytes: 5028
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	int n;
	cin >> n;
	int A[110];
	rep(i, n) cin >> A[i];

	sort(A, A+n);
	int res = A[n-1] - A[0];
	cout << res << endl;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function solve(N, K, A)
    for _ in 1:K
        tmp = zeros(Int64, N)
        for i in 1:N
            to = max(1, i - A[i])
            en = min(N, i + A[i])
            tmp[to] += 1
            (en + 1 <= N) && (tmp[en + 1] -= 1)
        end
        for i in 2:N
            tmp[i] += tmp[i - 1] 
        end
        if A == fill(N, N)
            return A
        else
            A = tmp
        end
    end
    return A
end


function print_ans(A)
    for a in A
        print(a, " ")
    end
    println()
end



function main()

N, K = parseMap(split(readline()))

A = parseMap(split(readline()))


print_ans(solve(N, K, A))

end

main()

Measured memory_bytes: 263660
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main(void){
    char A[1010],S[1010],Q[110],T[10];
    int a,b,q;
    int i,j;

    scanf("%s%d",S,&q);
    for(i=0;i<q;i++){
        scanf("%s%d%d",T,&a,&b);
        
        if(!strcmp(T,"print")){
            for(j=a;j<b+1;j++){
                printf("%c",S[j]);
            }
            printf("\n");
        }

        if(!strcmp(T,"reverse")){
            strcpy(A,S);
            for(j=a;j<b+1;j++){
                S[j]=A[a+b-j];
            }
        } 

        if(!strcmp(T,"replace")){
            scanf("%s",A);
            for(j=0;j<b-a+1;j++){
                S[a+j]=A[j];
            }
        }            
    }
    return 0;
}


Measured memory_bytes: 2104
begin
	writeln('1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1');
end.


Measured memory_bytes: 1392
#include<bits/stdc++.h>
 
using namespace std;
 
typedef unsigned long long ll;

ll modpow(ll a, ll b){
    ll x=1, y=a; 
    while (b > 0) {
        if (b%2 == 1) {
            x = (x*y) ; // multiplying with base
        }
        y = (y*y) ; // squaring the base
        b /= 2;
    }
    return x;
}
 
 
int main(){
 
	
	
	int n ; cin>>n;
	cout<<3*modpow(n,2);
	
	int l ; cin>>l;
	
	
}

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

int main() {
    int x;
    int ans;
    int i=0;
    bool breakFlag = true;
    
    
    cin >> x;
    ans = x;
    
    while(1) {
        for(i=2; i<ans; i++){
            if(ans % i == 0){
                breakFlag = false;
                break;
            }
        }
        if(breakFlag) break;
        ans++;
        breakFlag = true;
    }
    
    cout << ans << endl;
    
    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>

char str[8];
int a,b,c,d;

int main(void){
	register int i,j,k,ans;
	gets(str);
	a=str[0]-'0';b=str[1]-'0';c=str[2]-'0';d=str[3]-'0';
	for(i='+';i<='-';i+=2)
		for(j='+';j<='-';j+=2)
			for(k='+';k<='-';k+=2){
				ans=a;
				if(i=='+')
					ans+=b;
				else
					ans-=b;
				if(j=='+')
					ans+=c;
				else
					ans-=c;
				if(k=='+')
					ans+=d;
				else
					ans-=d;
				if(ans==7)
					return printf("%d%c%d%c%d%c%d=7\n",a,i,b,j,c,k,d),0;
			}
	return 0;
}

Measured memory_bytes: 128
/*
        Author: Prokash
                CSE,JU
*/

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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,train,taxi;
    cin>>n>>train>>taxi;
    cout<<min((n*train),taxi)<<endl;
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

vector<int> G[1000000];
vector<pair<int, int> > bridge;
vector<int> articulation;
int ord[1000000], low[1000000];
bool vis[1000000];

int W[111111];

int al=0;
int sum[111111];
int ans[111111];
void dfs(int v, int p, int &k)
{
	vis[v] = true;
    sum[v]=W[v];
	ord[v] = k++;
	low[v] = ord[v];

	bool isArticulation = false;
	int ct = 0;

	vint g;
	for (int i = 0; i < G[v].size(); i++){
		if (!vis[G[v][i]]){
			ct++;
			g.pb(G[v][i]);
			dfs(G[v][i], v, k);
			sum[v]+=sum[G[v][i]];
			low[v] = min(low[v], low[G[v][i]]);
			if (~p && ord[v] <= low[G[v][i]]) isArticulation = true;
		}
		else if (G[v][i] != p){
			low[v] = min(low[v], ord[G[v][i]]);
		}
	}

	if (p == -1 && ct > 1) isArticulation = true;
    if(isArticulation){
        int s=0;
        for(auto u:g){
            if(low[u]>=ord[v])chmax(ans[v],sum[u]);
            else s+=sum[u];
        }
        chmax(ans[v],al-sum[v]+s);
    }
    else{
        ans[v]=al-W[v];
    }
}



signed main(){
    int N,M;scanf("%lld%lld",&N,&M);
    rep(i,N)scanf("%lld",&W[i]);

    rep(i,M){
        int a,b;
        scanf("%lld%lld",&a,&b);
        a--;b--;
        G[a].pb(b);G[b].pb(a);
    }
    al=accumulate(W,W+N,0ll);
    int k=0;
    dfs(0,-1,k);

    rep(i,N)printf("%lld\n",ans[i]);
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    if (i % 2) {
      b.push_back(a[i]);
    } else {
      b.insert(b.begin(), a[i]);
    }
  }
  if (n % 2) {
    for (int i = 0; i < n; ++i) {
      cout << b[i];
      if (i != n - 1) {
        cout << " ";
      }
    }
  } else {
    for (int i = n - 1; i >= 0; --i) {
      cout << b[i];
      if (i != 0) {
        cout << " ";
      }
    }
  }
}

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

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

    long long N, A, B;
    cin >> N >> A >> B;
    cout << N / (A + B) * A + min(A, N % (A + B)) << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;

void solve(){
  int n; cin >> n;
  vector<vector<int> > v(n, vector<int>(n, -1));
  for(int i = 0; i < n; i++){
    int u, k; cin >> u >> k;
    for(int j = 0; j < k; j++){
      int a, b; cin >> a >> b;
      v[u][a] = b;
    }
  }
  vector<int> t, c(n), d(n, 10000000);
  d[0] = 0;
  while(t.size() != n){
    int mini, mind = 10000000;
    for(int i = 0; i < n; i++){
      if(c[i] == 0){
        if(d[i] < mind){
          mini = i;
          mind = d[i];
        }
      }
    }
    t.push_back(mini);
    c[mini] = 1;
    for(int i = 0; i < n; i++){
      if(v[mini][i] >= 0 && c[i] == 0) d[i] = min(v[mini][i] + d[mini], d[i]);
    }
  }
  for(int i = 0; i < n; i++){
    cout << i << " " << d[i] << endl;
  }
  return;
}

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



Measured memory_bytes: 3216
/*
 * f.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 500;
const int MAX_M = 50000;

/* typedef */

typedef vector<int> vi;

struct UFT {
  int links[MAX_N], ranks[MAX_N], sizes[MAX_N];

  void clear(int n) {
    for (int i = 0; i < n; i++) links[i] = i, ranks[i] = sizes[i] = 1;
  }

  UFT() {}
  UFT(int n) { clear(n); }

  int root(int i) {
    int i0 = i;
    while (links[i0] != i0) i0 = links[i0];
    return (links[i] = i0);
  }

  int rank(int i) { return ranks[root(i)]; }
  int size(int i) { return sizes[root(i)]; }
  bool same(int i, int j) { return root(i) == root(j); }

  int merge(int i0, int i1) {
    int r0 = root(i0), r1 = root(i1), mr;
    if (ranks[r0] == ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      ranks[r0]++;
      mr = r0;
    }
    else if (ranks[r0] > ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      mr = r0;
    }
    else {
      links[r0] = r1;
      sizes[r1] += sizes[r0];
      mr = r1;
    }
    return mr;
  }
};

struct Edge {
  int i, j, c;
  Edge() {}
  bool operator<(const Edge &e) const { return c < e.c; }
};

/* global variables */

Edge es[MAX_M];
UFT uft;
bool igns[MAX_M];

/* subroutines */

/* main */

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

  for (int i = 0; i < m; i++) {
    cin >> es[i].i >> es[i].j >> es[i].c;
    es[i].i--, es[i].j--;
  }
  sort(es, es + m);

  vi ces;
  int csum = 0;
  uft.clear(n);

  for (int i = 0; i < m; i++) {
    int ri = uft.root(es[i].i);
    int rj = uft.root(es[i].j);
    if (ri != rj) {
      uft.merge(ri, rj);
      csum += es[i].c;
      ces.push_back(i);
      if (uft.size(ri) == n) break;
    }
  }

  vi naes;
  for (int i = 0; i < ces.size(); i++) {
    int &ei = ces[i];

    int sum = 0;
    uft.clear(n);
    igns[ei] = true;
    
    for (int j = 0; j < m; j++) {
      if (igns[j]) continue;
      int ri = uft.root(es[j].i);
      int rj = uft.root(es[j].j);
      if (ri != rj) {
	uft.merge(ri, rj);
	sum += es[j].c;
	if (uft.size(ri) == n) break;
      }
    }
    igns[ei] = false;

    if (sum > csum || uft.size(0) != n) naes.push_back(ei);
  }
  //printf("%lu\n", naes.size());

  int nasum = 0;
  for (int i = 0; i < naes.size(); i++) nasum += es[naes[i]].c;

  printf("%lu %d\n", naes.size(), nasum);
  return 0;
}

Measured memory_bytes: 1836
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <map>

using namespace std;

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

	int N;
	cin >> N;

	map<string, int> S;
	for (int i = 0; i < N; i++)
	{
		string Si;
		cin >> Si;

		S[Si]++;
	}

	cout << "AC x " << S["AC"] << "\n";
	cout << "WA x " << S["WA"] << "\n";
	cout << "TLE x " << S["TLE"] << "\n";
	cout << "RE x " << S["RE"] << "\n";
	
	return 0;
}


Measured memory_bytes: 3688
n,k=map(int,input().split())
a=list(map(int,input().split()))

# 二分探索の為のKey関数
def f(m):
  cut=0
  for aa in a:
    cut+=(aa-1)//m
    if cut > k:
      return False
  return True

l,r=0,10**9
while r-l>1:
  m=(l+r)//2
  if f(m):
    r=m
  else:
    l=m

print(r)


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

int main(){
    ll n;
    cin>>n;
    vector<pair<ll,ll>> eve(n);
    rep(i,n){
        ll a,b;
        cin>>a>>b;
        eve[i]=make_pair(b,a);
    }
    sort(eve.begin(),eve.end());
    ll t=0;
    rep(i,n){
        t+=eve[i].second;
        if(t>eve[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = std::vector<int>;
using ll = long long;
using vll = std::vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = std::min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = std::max(a, b); }

int main() {
    int N;
    cin >> N;
    string ans = "";

    if(N == 0) {
        cout << 0 << endl;
        return 0;
    }

    while (N != 0) {
        if (N % -2 == 0) ans += "0";
        else {
            --N;
            ans += "1";
        }
        N /= -2;
    }

    reverse(ans.begin(), ans.end());

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

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

abc = [list(map(int, input().split())) for _ in range(n)]

dp = [[0] * 3 for i in range(n + 1)]
dp[0] = [0, 0, 0]

for i in range(n): # i represents i_th day
    for j in range(3): # j represents j_th activity chosen on the i_th day
        for k in range(3): # k represents k_th activity to be chosen on the day after
            if k != j:
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[i][k])
print(max(dp[n]))

Measured memory_bytes: 105296
# ABC114

N = int(input())
def dfs(num, use):
    if num > N:
        return 0
    cnt = 1 if use == 0b111 else 0
    cnt += dfs(num*10 + 3, use | 0b001)
    cnt += dfs(num*10 + 5, use | 0b010)
    cnt += dfs(num*10 + 7, use | 0b100)
    return cnt
ans = dfs(0, 0)
print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

public class Don
{
    public Don() { }
    private Reader r = new Reader();

    public void Solve()
    {
        var S = r.next();
        var n = S.Count(x => x == 'N');
        var s = S.Count(x => x == 'S');
        var e = S.Count(x => x == 'E');
        var w = S.Count(x => x == 'W');

        if (((n > 0 && s > 0) || (n == 0 && s == 0))&& ((e > 0 && w > 0) || (e == 0 && w == 0)))
        {
            Console.WriteLine("Yes");  
        } else
        {
            Console.WriteLine("No");
        }

        

    }

    public static void Main(string[] args)
    {
        new Don().Solve();
    }

}

class Reader
{
    string[] s;
    int i;
    char[] cs = new char[] { ' ' };

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

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

    public int nextInt()
    {
        return int.Parse(next());
    }

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

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

}

Measured memory_bytes: 2776
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,x;
ll get(ll x,ll y){
	ll a=min(x,y),b=max(x,y);
	if (a==0)return -b;
	return get(a,b%a)+2*a*(b/a);
}
signed main(){
	scanf("%lld%lld",&n,&x);
	printf("%lld\n",get(x,n-x)+n);
} 

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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
// #define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n;
string s;
int32_t main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	cin >> n >> s;
	for(int i=0; i<s.length(); i++){
		if (s[i] + n <= 'Z') s[i] = s[i]+n;
		else {
			s[i] = 'A' + n - ('Z'-s[i]+1);
		}
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
n,m,c = map(int,input().split())
b = list(map(int, input().split()))
a = [list(map(int,input().split())) for i in range(n)]
d = -1000
x = 0
for i in range(n):
    d = 0
    for j in range(m):
        d += a[i][j]*b[j]
    else:
        if d+c>0:
            x+=1
print(x)

Measured memory_bytes: 62336
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;

int t[200005];
int main()
{
	int N, T;
	cin >> N >> T;
	REP(i, N)
	{
		cin >> t[i];
	}

	ll ans = T;
	FOR(i, N, 1)
	{
		ans += min(t[i] - t[i - 1], T);
	}

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

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static readonly int INFTY = int.MaxValue;

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int V = int.Parse(input[0]);
            int E = int.Parse(input[1]);

            int[,] dp = new int[V, V];
            for (int i = 0; i < V; i++)
            {
                for (int j = 0; j < V; j++)
                {
                    dp[i, j] = i == j ? 0 : INFTY;
                }
            }

            int s, t, d;
            for (int i = 0; i < E; i++)
            {
                input = Console.ReadLine().Split(' ');
                s = int.Parse(input[0]);
                t = int.Parse(input[1]);
                d = int.Parse(input[2]);

                dp[s, t] = d;
            }

            WarshallFloyd(dp, V);

            bool isNegative = false;
            for (int i = 0; i < V; i++)
            {
                if (dp[i, i] < 0)
                {
                    isNegative = true;
                    break;
                }
            }

            StringBuilder sb = new StringBuilder();
            if (isNegative) sb.AppendLine("NEGATIVE CYCLE");
            else
            {
                for (int i = 0; i < V; i++)
                {
                    for (int j = 0; j < V; j++)
                    {
                        if (j != 0) sb.Append(" ");
                        sb.Append(dp[i, j] == INFTY ? "INF" : dp[i, j].ToString());
                    }
                    sb.AppendLine();
                }
            }
            Console.Write(sb);
        }

        static void WarshallFloyd(int[,] dp, int V)
        {
            for (int k = 0; k < V; k++)
            {
                for (int i = 0; i < V; i++)
                {
                    if (dp[i, k] == INFTY) continue;

                    for (int j = 0; j < V; j++)
                    {
                        if (dp[k, j] == INFTY) continue;

                        dp[i, j] = Math.Min(dp[i, j], dp[i, k] + dp[k, j]);
                    }
                }
            }
        }
    }
}

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

table = {}
answer = 'YES'
for i in range(0, len(A)):
    Ai = A[i]
    count = table.get(Ai) + 1 if table.get(Ai) else 1
    table[Ai] = count

    if table.get(Ai) >= 2:
        answer = 'NO'
        break

print(answer)


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

int main(){
  int n, t;
  cin >> n >> t;
  int ret=10000;
  for(int i=0; i<n; i++){
    int ci, ti;
    cin >> ci >> ti;
    if(ti<=t)ret=min(ret, ci);
  }
  if(ret==10000)cout << "TLE" << endl;
  else cout << ret << endl;
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>

int main(void) {
	int n, k;
	int head[1000] = { 0 };
	long double ans = 0;
	scanf("%d %d", &n, &k);
	int temp = n;
	for (int i = 0; i < 300; i++) {		
		if (n - k >= 0) {
			head[i] = n - k + 1;
			n = k - 1;
		}
		k = ceil((double)k / 2);
		//printf("k=%d\n", k);
	}
	//for (int i = 0; i < 10; i++)printf("head[%d]=%d\n", i, head[i]);
	for (int i = 0; i < 300; i++) {
		ans += (long double)head[i] / pow(2, i);
	}
	printf("%.10Lf", ans / temp);
	return 0;
}

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

using namespace std;

int main(void){
    unsigned long long n, a, b;
    string s[3];

    cin >> s[0] >> s[1] >> s[2];

    n = stoull(s[0]);
    a = stoull(s[1]);
    b = stoull(s[2]);

    unsigned long long ans = b-a;
    if(ans % 2ull == 0ull){
        ans = ans/2ull;
    }else if(b == n || a == 1ull){
        ans = ans/2ull + 1ull;
    }else{
        unsigned long long near;
        if(n-a > b-1ull){
            ans = b-1ull;
            near = a-1ull;
        }else{
            ans = n-a;
            near = n-b;
        }
        ans = (ans + near + 1)/2;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	PRI(min(b / a, c));
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b,c) for(int i = a;i < b;i++)

void dfs(int s,int e,int & ans,set<int> * adj, bool * visited){
	ans++;
	visited[s] = 1;
	for(auto u : adj[s]){
		if(u == e) continue;
		if(!visited[u]){
			dfs(u,s,ans,adj,visited);
		}
	}
}

int main(){
	int n,m;
	cin >> n >> m;
	set<int> adj[n];
	while(m--){
		int a,b;
		cin >> a >> b;
		a--,b--;
		adj[a].insert(b);
		adj[b].insert(a);
	}
	bool visited[n];
	memset(visited,0,sizeof visited);
	int maxm = INT_MIN;
	for(int i = 0;i < n;i++){
		if(!visited[i]){
			int ans = 0;
			dfs(i,-1,ans,adj,visited);
			maxm = max(maxm,ans);
		}
	}
	cout<<maxm<<"\n";
}

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

using namespace std;

using ll = long long;

int main() {
    ll A, B, Q;
    cin >> A >> B >> Q;

    std::vector<ll> s(A), t(B), x(Q);
    std::for_each(s.begin(), s.end(), [](auto &x) { cin >> x; });
    std::for_each(t.begin(), t.end(), [](auto &x) { cin >> x; });
    std::for_each(x.begin(), x.end(), [](auto &x) { cin >> x; });

    std::pair<ll, ll> s_nearest, t_nearest;
    for (const auto &e : x) {
        const auto si = std::lower_bound(s.cbegin(), s.cend(), e);
        const auto ti = std::lower_bound(t.cbegin(), t.cend(), e);

        if (si == s.begin()) {
            s_nearest = std::make_pair(-1ll << 60, *s.cbegin());
        } else if (si == s.cend()) {
            s_nearest = std::make_pair(*(s.cend() - 1), 1ll << 60);
        } else {
            s_nearest = std::make_pair(*(si - 1), *si);
        }

        if (ti == t.begin()) {
            t_nearest = std::make_pair(-1ll << 60, *t.cbegin());
        } else if (ti == t.cend()) {
            t_nearest = std::make_pair(*(t.cend() - 1), 1ll << 60);
        } else {
            t_nearest = std::make_pair(*(ti - 1), *ti);
        }

        ll ans = std::numeric_limits<ll>::max();
        ans = std::min(ans, std::abs(s_nearest.first - e) + std::abs(t_nearest.first - s_nearest.first));
        ans = std::min(ans, std::abs(s_nearest.first - e) + std::abs(t_nearest.second - s_nearest.first));
        ans = std::min(ans, std::abs(s_nearest.second - e) + std::abs(t_nearest.first - s_nearest.second));
        ans = std::min(ans, std::abs(s_nearest.second - e) + std::abs(t_nearest.second - s_nearest.second));
        ans = std::min(ans, std::abs(t_nearest.first - e) + std::abs(s_nearest.first - t_nearest.first));
        ans = std::min(ans, std::abs(t_nearest.first - e) + std::abs(s_nearest.second - t_nearest.first));
        ans = std::min(ans, std::abs(t_nearest.second - e) + std::abs(s_nearest.first - t_nearest.second));
        ans = std::min(ans, std::abs(t_nearest.second - e) + std::abs(s_nearest.second - t_nearest.second));

        cout << ans << endl;

    }

    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
typedef long long int ll;


int gcd(int x, int y)
{
    return y == 0 ? x : gcd(y, x % y);
}

int main(){
    int n;
    ll x;
    cin>>n>>x;
    ll y[100005];
    for(int i=0;i<n;i++){
        cin>>y[i];
        y[i]-=x;
        y[i]=abs(y[i]);
    }
    ll ans=y[0];
    for(int i=0;i<n;i++){
        ans=gcd(ans,y[i]);
    }
    cout<<ans<<endl;
    return 0;
}



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

int main() {
      int N; cin >> N; 
      int A[N+10]; rep(i,N) cin >> A[i];
      int bkt=0;
      for(int i=1;i<N-1;i++)
      {
            if(A[i-1] < A[i] && A[i] < A[i+1]) bkt++;
            if(A[i-1] > A[i] && A[i] > A[i+1]) bkt++;
      }

      cout << bkt << endl;

      return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
print(*A)
for i in range(1,N):
    v = A[i]
    j=i-1
    while j>=0 and A[j]>v :
        A[j+1] = A[j]
        j-=1
    A[j+1]=v
    print(*A)

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

int main() {
	int a, b;
	cin >> a >> b;
	int sum = 0;

	for (int i = 0; i < 2; i++) {
		if (a < b) {
			sum += b;
			b--;
		} else {
			sum += a;
			a--;
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

using ll = long long int;
using namespace std;

ll MOD = 998244353;

int main(){

  // read problem
  ll N, S, tmp;
  cin >> N >> S;
  vector<ll> A;
  for(ll i = 0; i < N; i++){
    cin >> tmp;
    A.push_back(tmp);
  }

  // solve problem
  vector<vector<ll> > dp(N+1, vector<ll>(S+1));

  // fill dp table
  dp[0][0] = 1;
  for(ll i = 1; i <= N; i++){
    for(ll s = 0; s <= S; s++){
      if(s < A[i-1]){
        dp[i][s] = dp[i-1][s];
      }
      else if(s == A[i-1]){
        dp[i][s] = dp[i-1][s] + i;
      }
      else{
        dp[i][s] = dp[i-1][s] + dp[i-1][s-A[i-1]];
      }
      dp[i][s] = (dp[i][s]+MOD)%MOD;
    }
  }

  // calculate answer
  ll ans = 0;
  for(ll i = 1; i <= N; i++){
    ans = (ans + dp[i][S] + MOD)%MOD;
  }

  cerr << "Answer:" << endl;
  cout << ans << endl;

  return 0;

  
}


Measured memory_bytes: 70784
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5 6
0 1
1 0
1 2
2 4
4 3
3 2
4
0 1
0 3
2 3
3 4

output:
1
0
1
1
"""
import sys

sys.setrecursionlimit(int(1e6))


def generate_adj_table(_v_info):
    for v_detail in _v_info:
        v_from, v_to = map(int, v_detail)
        init_adj_table[v_from].append(v_to)
    return init_adj_table


def graph_dfs(u, low, disc, stack_member, st):
    global Time
    # Initialize discovery time and low value
    disc[u] = Time
    low[u] = Time
    Time += 1
    stack_member[u] = True
    st.append(u)
    scc_set = set()

    # Go through all vertices adjacent to this
    for v in adj_table[u]:

        # If v is not visited yet, then recur for it
        if disc[v] == -1:

            graph_dfs(v, low, disc, stack_member, st)

            # Check if the subtree rooted with v has a connection to
            # one of the ancestors of u
            # Case 1 (per above discussion on Disc and Low value)
            low[u] = min(low[u], low[v])

        elif stack_member[v]:

            '''Update low value of 'u' only if 'v' is still in stack
            (i.e. it's a back edge, not cross edge).
            Case 2 (per above discussion on Disc and Low value) '''
            low[u] = min(low[u], disc[v])

    # head node found, pop the stack and print an SCC
    w = -1  # To store stack extracted vertices
    if low[u] == disc[u]:
        while w != u:
            w = st.pop()
            scc_set.add(w)
            stack_member[w] = False
        ans.append(scc_set)

    return None


def scc():
    # Mark all the vertices as not visited
    # and Initialize parent and visited,
    # and ap(articulation point) arrays
    disc = [-1] * vertices
    low = [-1] * vertices
    stack_member = [False] * vertices
    st = []

    # Call the recursive helper function
    # to find articulation points
    # in DFS tree rooted with vertex 'i'
    for v in range(vertices):
        if disc[v] == -1:
            graph_dfs(v, low, disc, stack_member, st)

    return ans


def solve():
    for question in q_list:
        flag = False
        ele1, ele2 = map(int, question)
        for each in scc_sets:
            if (ele1 in each) and (ele2 in each):
                flag = True
        if flag:
            print('1')
        else:
            print('0')
    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:edges + 1])
    q_num = int(_input[edges + 1])
    q_list = map(lambda x: x.split(), _input[edges + 2:])

    init_adj_table = tuple([] for _ in range(vertices))
    adj_table = generate_adj_table(v_info)

    Time = 0
    ans = []
    scc_sets = scc()
    solve()

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

int main() {
    int N; cin >> N;
    int A[N + 1];
    for (int i = 0; i < N; i++) cin >> A[i];
    long long cnt[200010] = {};
    for (int i = 0; i < N; i++) {
        cnt[A[i]]++;
    }
    long long sum = 0;
    for (int i = 0; i <= 200000; i++) {
        sum += cnt[i] * (cnt[i] - 1) / 2;
    }
    for (int i = 0; i < N; i++) {
        long long ans = sum;
        ans -= cnt[A[i]] - 1;
        cout << ans << endl;
    }
}

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

int main()
{
	int a, b;
	scanf("%d %d",&a,&b);

	if( a <= 0 && 0 <= b )
	{
		printf("Zero\n");
		return 0;
	}

	if( 0 < a )
	{
		printf("Positive\n");
		return 0;
	} 

	int sz = b - a + 1;

	if( sz%2 == 1 ) printf("Negative\n");
	else printf("Positive\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)

/*
bool isprime(int x){
	for(int i = 2;i*i<=x;i++){
		if(x%i == 0)return false;
	}
	return x!=1;
}
int gcd(int a, int b) 
{ 
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    if (a == b) 
        return a; 
   
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 
void dfs(int x,int y){
		if(x == n+1){
			int tmp = 0;
			FOR(i,0,k){
				if(tmp1[mortyy[i]]-tmp1[morty[i]] == mortyyy[i])tmp+=mortyyyy[i];
			}
			rick = max(rick,tmp);
			return ;
		}
		int i;
		for(i = y;i<=n1;i++){
			tmp1[x] = i;
			dfs(x+1,i);
		}
	}
*/


//3111111111111111111111111111111




	void solve(){
		
		ini(k);
		vi morty(50);
		FOR(i,0,50)morty[i] = 49+k/50;
		k%=50;
		while(k--){
			morty[k]+=51;
			FOR(i,0,50)morty[i]-=1;
		}
		out(50);
		FOR(i,0,50){
			cout<<morty[i]<<" ";
		}
		out();



	}









































int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	if(a==b && b==c) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 764
#include "iostream"
#include "vector"
using namespace std;


int main()
{
    int a[5],k; 
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
    bool flg = true;

    for( int i=0 ; i<5 ; i++ )
    {
        for( int j=0 ; j<5 ; j++ )
        {
            if( abs( a[i] - a[j] ) > k ) flg = false;
        }
    }

    if( flg ) cout << "Yay!" << endl;
    else      cout << ":(" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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



int main() {
int n;
cin>>n;
int a[n];
REP(i,n) cin>>a[i];
sort(a,a+n);
int ans=abs(a[0]-a[n-1]);
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
char a[N],b[N],c[N];
int main()
{
    for(int i=1;i<=N;i++)
    {
        if (i%2==1)
        {
            a[i]='1';
            b[i]='0';
        }
        else
        {
            a[i]='0';
            b[i]='1';
        }
     }
    cin>>(c+1);
    int len=strlen(c+1);
    int ans1=0,ans2=0;
    for(int i=1;i<=len;i++)
    {
        if (c[i]!=a[i]) ans1++;
        if (c[i]!=b[i]) ans2++;
    }
   cout<<min(ans1,ans2);
    return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int k = sc.nextInt() - 1;
        char target = s.charAt(k);
        for(int i = 0; i < n; ++i) {
            char c = s.charAt(i);
            System.out.print((c == target) ? c : '*');
        }
        System.out.println();
    }
}


Measured memory_bytes: 22612
#include<stdio.h>

int main(void){

    int Alice_Card,Bob_Card;

    scanf("%d %d",&Alice_Card,&Bob_Card);

    if(Alice_Card == Bob_Card){
        printf("Draw");
    }else{
        if(Alice_Card == 1){
            printf("Alice");
        }else if(Bob_Card == 1){
            printf("Bob");
        }else if(Alice_Card > Bob_Card){
            printf("Alice");
        }else{
            printf("Bob");
        }
    }
    
    return 0;
}


Measured memory_bytes: 128
// #pragma GCC optimize "trapv" Uncomment when dealing with huge numbers
/*<----------PBDS---------->

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
template <typename T>
using order_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

order_set<datatype>oset;
Kth smallest : *oset.find_by_order(k-1); // 0 based index
No of elements less than k : oset.order_of_key(k);
Erase X : oset.erase(x)
<----------PBDS---------->*/
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
	fast;
	int l;
	cin >> l;
	double ans = l*l*l/27.0;
	cout << setprecision(15) << fixed;
	cout << ans;
}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
//	cut here before submit 
//	freopen ("testcase.Ball", "r", stdin );
	int n;
	scanf ("%d", &n );
	rep (i, n ){
		vector<int> ball(10, 0 );
		rep (j, 10 ){
			scanf ("%d", &ball[j] );
		} // end rep
		stack<int> A, B;
		A.push (ball[0] );
		B.push (0 );
		bool ok = true;
		for (int i = 1; i < 10; i++ ){
			if (A.top() < ball[i] ){
				A.push (ball[i] );
			}else
			if (B.top() < ball[i] ){
				B.push (ball[i] );
			}else{
				ok = false;
				break;
			} // end if
		} // end for
		if (ok ){
			printf ("YES\n" );
		}else{
			printf ("NO\n" );
		} // end if
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1172
INF = 10**10
n = int(input())
a = list(map(int, input().split()))

dp_fr = [[INF for _ in range(20)] for _ in range(n)]
dp_ba = [[INF for _ in range(20)] for _ in range(n)]

#dp[i][j]: iまで考えてa_iを4^j倍したときの必要最小コスト
for j in range(20):
	dp_fr[0][j] = 2*j

for i in range(1, n):
	if a[i-1] < a[i]:
		k = 0
		while a[i-1] * pow(4, k) < a[i]:
			k += 1
		for j in range(20):
			if j+k < 20:
				dp_fr[i][j] = 2*j + dp_fr[i-1][j+k]
			else:
				dp_fr[i][j] = 2*j + dp_fr[i-1][19] + 2*(i) * (j+k-19)
	else:
		k = 0
		while a[i-1] >= a[i] * pow(4, k+1):
			k += 1
		for j in range(20):
			dp_fr[i][j] = 2*j + dp_fr[i-1][max(j-k, 0)]

for j in range(20):
	dp_ba[n-1][j] = 2*j

for i in range(n-2, -1, -1):
	if a[i+1] < a[i]:
		k = 0
		while a[i+1] * pow(4, k) < a[i]:
			k += 1
		for j in range(20):
			if j+k < 20:
				dp_ba[i][j] = 2*j + dp_ba[i+1][j+k]
			else:
				dp_ba[i][j] = 2*j + dp_ba[i+1][19] + 2*(n-i-1) * (j+k-19)
	else:
		k = 0
		while a[i+1] >= a[i] * pow(4, k+1):
			k += 1
		for j in range(20):
			dp_ba[i][j] = 2*j + dp_ba[i+1][max(j-k, 0)]

#print(*dp_fr, sep="\n")
#print(*dp_ba, sep="\n")

ans = min(dp_ba[0][0], n + dp_fr[n-1][0])
for i in range(n-1):
	ans = min(ans, dp_ba[i+1][0] + i+1 + dp_fr[i][0])

print(ans)

Measured memory_bytes: 152560
# -*- coding:utf-8 -*-

def zehnpaard():
    from collections import Counter

    n, k = map(int, input().split())
    c = Counter(int(x) for x in input().split())
    print(sum(val for key, val in c.most_common()[k:]))

def main():
    """WA"""
    N, K = list(map(int, input().split()))
    a_list = list(map(int, input().split()))

    import collections
    c_dict = collections.Counter(a_list)
    diff = len(c_dict) - K
    if diff <= 0:
        print(0)
        exit()

    # diff個消す。カウント数が少ないやつを。
    ans = 0
    c_list = sorted(c_dict.items(), key=lambda x: x[1])
    for i in range(diff):
        ans += c_list[i][1]
    print(ans)

def main2():
    N, K = list(map(int, input().split()))
    a_list = list(map(int, input().split()))

    import collections
    c_dict = collections.Counter(a_list)
    print(sum(value for key, value in c_dict.most_common()[K:]))

if __name__ == "__main__":
    main2()


Measured memory_bytes: 40016
#include <bits/stdc++.h>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define EPS (1e-14)
#define _PA(x,N) rep(i,N){cout<<x[i]<<" ";}cout<<endl;
#define _PA2(x,H,W) rep(i,(H)){rep(j,(W)){cout<<x[i][j]<<" ";}cout<<endl;}

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;

int N;
string s, t;
int ans;

void solve() {
	ans = 2 * N;
	for (int i = 0; i < s.size(); i++) {
		string p = s.substr(i);
		string q = t.substr(0, N - i);
		if (p == q) {
			ans = 2 * N - p.size(); 
			break;
		}
	}
	cout << ans << endl;
}

int main() {
	cin >> N;
	cin >> s;
	cin >> t;
	solve();
	return 0;
}




Measured memory_bytes: 256
import java.util.*;

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

        int V = 0;
        for (int i = 0; i < N; i++) {
            int C = sc.nextInt();
            if (v[i] > C) {
                V += v[i] - C;
            }
        }
        System.out.println(V);
    }
}

Measured memory_bytes: 25172
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
unsigned int randxor()
{
    static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
    unsigned int t;
    t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}
int d=365;
vector<int> ans(d);
vector<int> ans1(d);
vector<int> c(26);
vector<vector<int> > s(d);
int score;
void keisan(){
  int cost=0,i,j;
  vector<int> x(26,-1);
  for(i=0;i<d;i++){
    cost+=s[i][ans1[i]];
    x[ans1[i]]=i;
    for(j=0;j<26;j++){
      cost=cost-c[j]*(i-x[j]);
    }
    printf("%d\n",cost);
  }
}
int main(){
  int i,j;
  int ti=clock();
  scanf("%d\n",&d);
  for(i=0;i<26;i++){
    scanf("%d",&c[i]);
  }
  for(i=0;i<d;i++){
    for(j=0;j<26;j++){
      int a;
      scanf("%d",&a);
      s[i].push_back(a);
    }
  }
  for(i=0;i<d;i++){
    scanf("%d\n",&ans1[i]);
    ans1[i]--;
  }
  keisan();
  return 0;
}

Measured memory_bytes: 3912
X,N=map(int,input().split())
if N==0:
  print(X)
  exit()
P=list(map(int,input().split()))
nP=[]
min=10**15
for i in range(-200,200):
  if i not in P:
    nP.append(i)
anlist=[]
for i in nP:
  if min>abs(i-X):
    min=abs(i-X)
    anlist.append(i)
print(anlist[-1])

Measured memory_bytes: 9204
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:String,
    }
    let a=a.chars().collect_vec();
    let mut b=1000;
    let mut c=1000;
    for i in 0..a.len() {
        if a[i]=='C'&&i<b {b=i}
    }
    for i in b..a.len() {
        if a[i]=='F'&&i<c {c=i}
    }
    if c!=1000 {println!("Yes")}
    else {println!("No")}
}

Measured memory_bytes: 2152
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define ld long double
#define zeros(x) x^(x-1)&x
#define pii pair<ll,ll>
#define cd complex<double>
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#define Nmax 200005
#define OFF 100001
using namespace std;

int n,v[Nmax], ans;
pii v2[Nmax];

int main()
{
    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> v[i];
        v2[i] = {v[i], i};
    }
    sort(v2+1,v2+n+1);
    for (int i=1;i<=n;i++){
        if (i % 2 != v2[i].second % 2) ans++;
    }
    cout << ans / 2 << '\n';

    return 0;
}


Measured memory_bytes: 2176