akhauriyash/Code-Regression huggingface dataset:
#pragma once
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s, t;
    cin >> s >> t;
    int res = 0;
    for(int i=0; i<3; i++){
        if(s.at(i) == t.at(i)){
            res++;
        }
    }
    cout << res << endl;
}


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

using namespace std;

int main(int argc, char *argv[]) {
	int A, B, X;
	cin >> A >> B >> X;

	bool is_ok(false);
	if (A > X) {
		is_ok = false;
	} else if (A == X) {
		is_ok = true;
	} else {  // X > A
		if (X - A <= B) {
			is_ok = true;
		}	
	}

	cout << ((is_ok) ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, i, j, t=0, b=0, sum=0;
  cin >> N;
  vector<int> card(N, 0), check(N, 0);
  
  for(i=0; i<N; i++){
    cin >> card[i];
  }
  while(1){
    b=0;
    for(i=0; i<N; i++){
      if(card[i] < card[i+1] && i != N-1){
        t= card[i+1];
        card[i+1] = card[i];
        card[i] = t;
        b++;
      }
    }
    if(b==0)
      break;
  }
  for(i=0; i<N; i++){
    if(i%2 == 0){
      sum += card[i];
    }
    else if (i%2 == 1){
      sum -= card[i];
    }
    else{
      cout << "error" << endl;
    }
  }
  cout << sum << endl;
}
  

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



int main() {
    int n;
    cin >> n;
    vector<char> s(n);
    rep(i,n) cin >> s[i];
    set<char> t;
    rep(i,n) t.insert(s[i]);
    if(t.size()==3) cout <<"Three" << endl;
    else cout << "Four" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;

#define INF 1010001000
#define EPS 1e-10
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef pair<int, int> i_i;
typedef long long int llong;
typedef pair<llong, llong> ll_ll;
typedef struct edge {int f, t;}Edge;


int main()
{
    string a;
    cin >> a;
    rep(i, 19) {
        if (i == 5 || i == 13) {
            cout << " ";
        } else {
            cout << a[i];
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    ll x = 0;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
        x ^= a[i];
    }
    rep(i, n) {
        ll ans = x ^ a[i];
        cout << ans << endl;
    }
    return 0;
}


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

//B OddString
int main() {
	string S;
	cin >> S;
	for (int i = 1; i < S.size(); i++) {
		S.erase(S.begin() + i);
	}
	cout << S << endl;
}

Measured memory_bytes: 512
/*
				C++
				encoding: UTF-8
				Modified: <28/Sep/2019 05:34:31 PM>

				✪ H4WK3yE乡
				Mohd. Farhan Tahir
				Indian Institute Of Information Technology (IIIT), Gwalior
*/

#include <bits/stdc++.h>
#ifdef LOCAL_PROJECT
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define         ll                     long long
#define         ve                     vector
#define         pb                     push_back
#define         endl                   "\n"
#define         ff                     first
#define         ss                     second
#define         pii                    pair<int, int>
#define         len(v)                 int(v.size())
#define         all(v)                 v.begin(), v.end()
#define         reset(a, b)            memset(a, b, sizeof(a));
#define         fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define         dfr(i, s, n)           for (int i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on

signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	int n, k;
	cin >> n >> k;
	ve< int > arr (n);
	fr (i, 0, n) cin >> arr[i];
	sort (all (arr));
	int i = lower_bound (all (arr), k) - arr.begin ();
	pr (n - i);
	return 0;
}


Measured memory_bytes: 640
n, m = map(int, input().split())
f = {}
s = {}


for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        f[b] = 1
        if b in s:
            print("POSSIBLE")
            exit()
    if b == n:
        s[a] = 1
        if a in f:
            print("POSSIBLE")
            exit()
print("IMPOSSIBLE")

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

int main(){

  int n; cin >> n;

  int H[n];
  for(int i = 0; i < n; i++){
    cin >> H[i];
  }

  int ans = 0;
  int max = H[0];

  for(int i = 0; i < n; i++){
    if(H[i] >= max){
      max = H[i];
    //  cout << max << endl;
    //  cout << ans << endl;
      ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int bitlength{3};

class AllBitSearch
{//bitパターンを生成し，各パターンで処理
	vector<int> T;
	void values_set( ) {
		T.resize(4);
		vector<char> C(4);
		for (int i = 0; i < 4; ++i) { cin >> C[i]; }
		for (int i = 0; i < 4; ++i) { T[i] = int(C[i] - '0'); }
	}
	inline int check(bitset<bitlength> &Bit) {
		int x{T[0]};
		for (int b = 0; b < bitlength; ++b) {
			x = x + T[b + 1] * ((Bit.test(2 - b) << 1) - 1);
		}
		return x;
	}
	int patternDo( ) {
		string os = to_string(T[0]);
		for (int i = 0; i < (1 << 3); ++i) {
			bitset<bitlength> Bit(i);
			//cout << "pattern " << Bit << " ";
			int value = check(Bit); //cout << value << endl;
			if (value == 7) {
				for (int b = 0; b < bitlength; ++b) {
					if (Bit.test(2 - b) == 1) {
						os = os + "+" + to_string(T[b + 1]);
					} else {
						os = os + "-" + to_string(T[b + 1]);
					}
				}
				cout << os << "=7" << endl;
				return 0;
			}
		}
		return -1;
	}
public:
	void procedures( ) {
		values_set( );
		patternDo( );
	}
};

int main( ) {
	cin.tie(0); ios::sync_with_stdio(false);
	AllBitSearch niku;
	niku.procedures( );
}

Measured memory_bytes: 256
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        Dim dic As New HashSet(Of String)
        Dim pre As Char = " "c
        Dim flg As Boolean

        For i As Integer = 0 To N - 1
            Dim W As String = ReadLine()

            If i <> 0 AndAlso pre <> W(0) Then flg = True
            If dic.Contains(W) Then flg = True

            dic.Add(W)
            pre = W(W.Length - 1)
        Next

        WriteLine(New String() {"Yes", "No"}(B2I(flg)))
    End Sub

    Function B2I(ok As Boolean) As Integer
        If ok Then Return 1
        Return 0
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 22096
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x; cin>>x;
  if(400<=x&&x<=599) cout<<8;
  else if(600<=x&&x<=799) cout<<7;
  else if(800<=x&&x<=999) cout<<6;
  else if(1000<=x&&x<=1199) cout<<5;
  else if(1200<=x&&x<=1399) cout<<4;
  else if(1400<=x&&x<=1599) cout<<3;
  else if(1600<=x&&x<=1799) cout<<2;
  else if(1800<=x&&x<=1999) cout<<1;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define N 200005
#define ll long long
#define P 998244353
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define CM cerr<<(&MOP1-&MOP2)/1024.0/1024.0<<endl
using namespace std;
template <class T> inline T Min(T x, T y){
    return x<y?x:y;
}
template <class T> inline T Max(T x, T y){
    return x>y?x:y;
}
bool MOP1;
int li[N],n;
struct node{
	int x,y;
	void read(int i){
		scanf("%d%d",&x,&y);
		li[i]=y;
	}
}A[N];
struct bit{
	int C[N];
	void clear(){
		for(int i=0;i<N;i++)C[i]=0;
	}
	void add(int x){
		while(x)C[x]++,x-=x&-x;
	}
	ll query(int x){
		ll res=0;
		while(x<=n)res+=C[x],x+=x&-x;
		return res;
	}
}BIT;
bool cmp(node a,node b){
	return a.x<b.x;
}
void jia(ll &a,ll b){
	a+=b;
	if(a<0)a+=P;
	if(a>=P)a-=P;
}
ll ans;
ll js[N];
bool MOP2;
int main(){
	scanf("%d",&n);
	js[0]=1;
	for(int i=1;i<=N-5;i++)js[i]=(js[i-1]<<1)%P;
	for(int i=1;i<=n;i++)A[i].read(i);
	sort(li+1,li+1+n);
	for(int i=1;i<=n;i++)A[i].y=lower_bound(li+1,li+1+n,A[i].y)-li;
	ans=1LL*n*(js[n]-1)%P;
	for(int i=1;i<=n;i++){
		jia(ans,2LL-js[i]);
		jia(ans,2LL-js[n-i+1]);
	}
	BIT.clear();
	sort(A+1,A+1+n,cmp);
	for(int i=1;i<=n;i++){
		ll tmp=BIT.query(A[i].y+1);
		jia(ans,js[tmp]-1LL);
		jia(ans,js[i-1-tmp]-1LL);
		BIT.add(A[i].y);
	}
	BIT.clear();
	for(int i=n;i;i--){
		ll tmp=BIT.query(A[i].y+1);
		jia(ans,js[tmp]-1LL);
		jia(ans,js[n-i-tmp]-1LL);
		BIT.add(A[i].y);
	}
	printf("%lld\n",ans);
	return 0;
}






Measured memory_bytes: 4992
#include <iostream>
using namespace std;
int main ()
{
    int a,b;
    cin>>a>>b;
    
    if(a<b){cout<<"a < b"<<endl;}
    else if(a>b){cout<<"a > b"<<endl;}
    else{cout<<"a == b"<<endl;}
    
    return 0;
}


Measured memory_bytes: 3092
N = int(input())
A = list(map(int, input().split()))
X = [None] * N
X[0] = sum(A) - 2 * sum(A[1::2])
for n in range(1, N):
  X[n] = 2 * A[n - 1] - X[n - 1]
print(' '.join(map(str, X)))

Measured memory_bytes: 19096
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>

bool table[102][102] = {};
int color[102] = {}; //0:?????¢?´¢???1:?¨??????????, 2:??¢?´¢??????
int n, counter = 0;
int t_visit[102] = {};
int t_finish[102] = {};

void DFS(int y) {
	
	for (int j = 0; j <= n - 1;j++) {

		//?¨????or??¢?´¢???????????£???????????????
		if ((table[y][j] == 1)&&(color[j] == 0)) {
			color[y] = 1; //?¨???????????????????
			if (t_visit[y] == 0) t_visit[y] = ++counter;
			DFS(j);
		}

	}

	color[y] = 2; //??¢?´¢???????????????
	if (t_visit[y] == 0) t_visit[y] = ++counter;
	if (t_finish[y] == 0) t_finish[y] = ++counter;
	
}

int main(void) {
	int u, k, s;

	scanf("%d", &n);

	for (int i = 0;i <= n - 1;i++) {
		scanf("%d %d", &u, &k);
		for (int j = 0;j <= k - 1;j++) {
			scanf("%d", &s);
			table[u - 1][s - 1] = 1;
		}
	}


	for (int i = 0;i <= n - 1;i++) {
		if (color[i] == 0) {
			DFS(i);
		}
	}


	for (int i = 0; i <= n - 1;i++) {
		printf("%d %d %d\n", i + 1, t_visit[i], t_finish[i]);
	}

	return 0;
}

Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define PI       3.1415926535897932384626433832795028841971
#define INF      100000000
#define EPS      1e-10
#define MOD      1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string str;
int n;

int main(){
    cin >> str >> n;
    rep(i,str.size()){
        while(str[i] != 'a'){
            if('z'-str[i]+1 <= n){
                n -= 'z'-str[i]+1;
                str[i] = 'a';
            }
            break;
        }
    }
    if(n > 0){
        int x = str[str.size()-1]-'a';
        x = (x+n)%26;
        str[str.size()-1] = 'a'+x;
    }
    cout << str << endl;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) p[i] = i + 1;
  do
  {
    rep(i, n) cout << p[i] << (i == n - 1 ? "\n" : " ");
  } while (NP(p));
  return 0;
}



Measured memory_bytes: 3220
#include <stdio.h>

int main(){
	
	int h,m,s;
	int input;
	
	scanf("%d",&input);
	h = (input / 60) /60;
	m = (input%3600)/60;
	s = input%60;
	printf("%d:%d:%d\n",h,m,s);
	
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
int main(){

long long  a,b,c,d,e,f,i=0,j;
cin >> a >> b;
vector<int>vec[100];
//int i=0;
e=a;
f=b;
while(a--)
{

    b=f;
    while(b--)
    {
        cin >> c;
        vec[i].push_back(c);
    }
    i++;

}
long long l=0,k,p,sum=0,co=0;
for(i=0;i<e-1;i++)
{
    sum=0;
    for(j=i+1;j<e;j++)
    {
        sum=0;
      for(k=0;k<f;k++)
      {
          p=abs(vec[i][k]-vec[j][k])*abs(vec[i][k]-vec[j][k]);
          sum+=p;


      }
      //cout << "sum " << sum << endl;
      //cout <<sqrt((double)sum) << " " <<(long long)sqrt((double)sum) << endl;
      if(sqrt((double)sum)==(long long)sqrt((double)sum))
      {
         co++;
      }




    }






}
cout << co << endl;



}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define N 100005
int n, m, v, p;
int A[N];
ll S[N];
bool cmp(int a, int b){return a > b;}
int main()
{
	scanf("%d%d%d%d", &n, &m, &v, &p);
	for (int i = 1; i <= n; i++)
		scanf("%d", &A[i]);
	sort(A + 1, A + n + 1, cmp);
	for (int i = 1; i <= n; i++)
		S[i] = S[i - 1] + A[i];
	for (int i = p + 1; i <= n; i++)
	{
		int now = m + A[i];
		if (now < A[p])
		{
			printf("%d\n", i - 1);
			return 0;
		}
		ll lst = (ll)(v - p - (n - i)) * m;
		if (lst > (ll)(i - p) * now - (S[i - 1] - S[p - 1]))
		{
			printf("%d\n", i - 1);
			return 0;
		}
	}
	printf("%d\n", n);
}


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

int main(){
    // int n[4];
    vector <int> v(4,0);

    rep(i,4){
        cin >> v[i];
    }

    sort(v.begin(), v.end());
    if(v[0] == 1 && v[1] == 4 && v[2] == 7 && v[3] == 9){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main()
{
	long long int x, y;
	cin >> x >> y;
	if (abs(x - y) <= 1){
		cout << "Brown" << endl;
	}else{
		cout << "Alice" << endl;
	}

	return 0;
}

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

int hako[1000];
int N, C[1000], Q;
int t[100000], x[100000], d[100000];

int main() {
	
	for (int i = 0; i < 1000; i++) {
		hako[i] = 0;
	}

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> C[i];

	}
	cin >> Q;

	for (int i = 0; i < Q; i++) {
		cin >> t[i] >> x[i] >> d[i];
	}

	for (int i = 0; i < Q; i++) {
		if (t[i] == 1) {
			hako[x[i] - 1] += d[i];
			if (hako[x[i] - 1] > C[x[i] - 1]) {
				cout << x[i] << endl;
				return 0;
			}
		}
		if (t[i] == 2) {
			hako[x[i] - 1] -= d[i];
			if (hako[x[i] - 1] < 0) {
				cout << x[i] << endl;
	
			
				return 0;
			}
		}
	}
	cout << 0 << endl;


	return 0;
}


Measured memory_bytes: 4280
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(M)]
ans_kouho = [min(a)+min(b)] + [a[x-1]+b[y-1]-c for x, y, c in xyc]
print(min(ans_kouho))



Measured memory_bytes: 106948
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int div = 0;
  for (int i=0; i<=a; i++) {
    for (int j=0; j<=b; j++) {
      for (int k=0; k<=c; k++) {
        if (i*500 + j*100 + k*50 == x) {
          div++;
        }
      }
    }
  }
  cout << div << endl; 
}

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

//昇順
int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

//二分してできる限り左の挿入点を返す
int bisect_left(int x,int a[],int left,int right){
    int mid;
    right++;
    while (left < right) {
        mid = (left + right) / 2;
        if (a[mid] < x) {
            left = mid + 1;
        } else {
            right = mid;
        }
    }
    return left;
}



int main(void){
    int N;
    scanf("%d", &N);
    int *array = (int *)malloc(N * sizeof(int));
    for (int i = 0; i < N; i++) 
        scanf("%d", &array[i]);

    //入力ソート
    qsort(array,N,sizeof (int), asc);   

    //ふるいのフラグ
    bool flag[1000000+10] = {0};

    //エラトステネスのふるい実行
    for (int i = 0; i < N; i++) {
        int now = 2;
        //array[N - 1] は ソートしてるので max(array)
        while(now * array[i] <= array[N-1]){
            //ダメ
            flag[now * array[i]] = 1;
            //次の倍数へ
            now += 1;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (flag[array[i]] == 0) {
            //array[i] と同じ数の個数を log(N) で返す
            //定数で返したいならbinソートみたいなのやればいい
            int counter = bisect_left(array[i]+1,array,0,N-1) - 
                        bisect_left(array[i],array,0,N-1);
            // array[i] と同じ数の個数が1の時
            if (counter == 1) 
                ans++;
        }
    }
    printf("%d\n",ans);
}



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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,ans,A[15], x[15][15], y[15][15];

signed main() {
    cin >> n;
    rep(i,n) {
        cin >> A[i];
        rep(j,A[i]) cin >> x[i][j] >> y[i][j], x[i][j]--;
    }
    int b = pow(2,n);
    rep(i,b) {
        bool a[15]={};
        int hoge = i, tmpans=0;
        rep(j,n) {
            if (hoge%2) a[j] = true, tmpans++;
            hoge/=2;
        }
        rep(j,n) {
            rep(k,A[j]) {
                if (a[j]) {
                    if (y[j][k] && !a[x[j][k]]) tmpans = 0;
                    if (!y[j][k] && a[x[j][k]]) tmpans = 0;
                }
            }
        }
        ans = max(ans, tmpans);
    }
    cout << ans << endl;
}



Measured memory_bytes: 384
import java.io.InputStream;
import java.util.Scanner;
import java.util.stream.*;

public class Main {
  public static void main(String[] args){
    System.out.println(new Main().excute(System.in)); 
  }
  public String excute(InputStream f) {
    Scanner scan = new Scanner(f);
    String s =  scan.next();

    String[] w = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

    return "" + (7 - IntStream.range(0, w.length)
                .filter(i ->  w[i].equals(s))
                .sum());
  }
}


Measured memory_bytes: 28628
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
    long long int n;
    scanf("%lld", &n);
    long long int c[5];
    for(int i = 0; i < 5; i++){
        scanf("%lld", &c[i]);
    }

    long long int min_c = c[0];
    for(int i = 0; i < 5; i++){
        min_c = min(min_c, c[i]);
    }
    printf("%lld\n", (n + min_c - 1) / min_c + 4);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define int ll 
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <ll, ll> pi;
typedef tuple<ll,ll,ll> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
const int MAXN = -1;
#ifndef LOCAL
#define cerr if(0)cout
#endif
 
int32_t main() 
{
	IAMSPEED
	string s,t; cin >> s >> t;
	int ans = 0;
	FOR(i,0,s.size()-1) {
		if(s[i]!=t[i])++ans;
	}
	cout << ans;
}


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

int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	int n,a,b;
	scanf("%d %d %d",&n,&a,&b);
	if(n*a>b)printf("%d\n",b);
	else printf("%d\n",n*a);
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;

class C
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var n = int.Parse(Console.ReadLine());
		var rs = new int[n].Select(_ => read()).OrderBy(p => p[0]).ToArray();
		var bs = new int[n].Select(_ => read()).OrderBy(p => p[1]).ToArray();

		var map = new int[n].Select(_ => new int[0].ToList()).ToArray();
		for (int i = 0; i < n; i++)
		{
			var p = rs[i];
			for (int j = 0; j < n; j++)
			{
				var q = bs[j];
				if (p[0] < q[0] && p[1] < q[1]) map[i].Add(j + 1);
			}
		}

		var c = 0;
		var u = new bool[n + 1];
		for (int b, i = n - 1; i >= 0; i--)
			if ((b = map[i].FirstOrDefault(j => !u[j])) > 0)
			{
				c++;
				u[b] = true;
			}
		Console.WriteLine(c);
	}
}


Measured memory_bytes: 28460
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int long long
#define endl "\n"
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr(a,b,c) for(int a=b; a<c; a++)
#define frr(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define pii pair<int,int>
#define R(a) ll a; cin >> a;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

#define RA(a, n) ll a[(n) + 1] = {}; fr(i, 1, (n)+1) {cin >> a[i];}
#define RM(a, n, m) int a[n + 1][m + 1] = {}; fr(i, 1, n+1) {fr(j, 1, m+1) cin >> a[i][j];}
#define reset(X) memset(X, 0, sizeof(X))
using vi=vector<int>;
const int inf = 1e18;
const int mod=1e9+7;
unsigned int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isPrime(int n)
{   if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
int modInverse(int n, int p)
{
    return power(n, p-2, p);
}
int f[200005];
int dp[2010];
ll go(ll x,ll y) {
	assert(x>=0&&y>=0);
	return f[x+y]*modInverse(f[x]*f[y],mod)%mod;
}
signed main()
{
    fastio;
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}


Measured memory_bytes: 3660
import sys
N = int(input())
acc = [[0]*19 for _ in range(19)]
a = []

for num in (sys.stdin.readline() for _ in range(N)):
    num = num.rstrip()
    idx = num.find(".")
    mul = 10**(9 if idx == -1 else 9 - (len(num) - idx - 1))
    n = int(num.replace(".", "")) * mul

    cnt2, cnt5 = 0, 0
    while n & 1 == 0:
        cnt2 += 1
        n >>= 1
    while n % 5 == 0:
        cnt5 += 1
        n /= 5

    acc[min(18, cnt2)][min(18, cnt5)] += 1
    a.append((min(18, cnt2), min(18, cnt5)))

for i in range(18, -1, -1):
    for j in range(17, -1, -1):
        acc[i][j] += acc[i][j+1]
for j in range(18, -1, -1):
    for i in range(17, -1, -1):
        acc[i][j] += acc[i+1][j]

ans = 0
for i, j in a:
    ans += acc[18-i][18-j] - (1 if i >= 9 and j >= 9 else 0)

print(ans // 2)


Measured memory_bytes: 85620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
 
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(n);i++)
#define fori(a,b,i) for(int i=(a);i<=(b);i++)
#define ford(a,b,i) for(int i=(a);i>=(b);i--)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);


#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
typedef long long int llint;


int main(){
	llint n;
	cin>>n;
	llint a[n], b[n], c[n];
	loop(i, n) { cin>>a[i]; cin>>b[i]; cin>>c[i]; }
	llint dp[n][3];
	memset(dp, 0, sizeof(dp));
	loop(i, n){
		loop(j, 3){
			if(i == 0){
				if(j == 0) dp[i][j] = max(dp[i][j], a[i]);
				else if(j == 1) dp[i][j] = max(dp[i][j], b[i]);
				else dp[i][j] = max(dp[i][j], c[i]);
			}
			else{
				loop(k, 3){
					if(j == k) continue;
					if(j == 0) dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i]);
					if(j == 1) dp[i][j] = max(dp[i][j], dp[i-1][k] + b[i]);
					if(j == 2) dp[i][j] = max(dp[i][j], dp[i-1][k] + c[i]);
				}
			}
		}
	}
	cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
	return 0;
}



Measured memory_bytes: 4992
/*starting with the name of almighty ALLAH*/
/*solved by RAKIB JOY*/
// Practice is the only shortcut to improve
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define vc vector
#define vi vc<int>
#define vl vc<ll>
#define dbg(x) cout<<x<<endl;
#define mp(x,y) make_pair(x,y)
#define yes dbg("YES")
#define no dbg("NO")
#define tst int t;cin>>t;while(t--)
#define srt(v) sort(v.begin(),v.end());
#define rsrt(v) sort(v.begin(),v.end(),greater<int>());
#define rj ios::sync_with_stdio(false);cin.tie(0);
#define rvs(v) reverse(v.begin(),v.end());
#define F first
#define S second
#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define PI 2*acos(0.0)
#define pii pair<int,int>
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define coutv(v) for(auto it:v)cout<<it<<' ';cout<<endl;
#define cinv(v) for(auto &it:v)cin>>it;
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using ordered_set =tree<T, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;
*/
//sieve bool b[1000005];void primenire(){int i, j;b[0]=true;b[1]=true;for(i=4; i<=1000000; i+=2){b[i]=true;}for(i=3; i<=1001; i+=2){if(!b[i]){for(j=i*i; j<=1000001; j+=2*i){b[j]=true;}}}}
//power ll power(ll a,ll b){if(b==0) return 1LL;if(b&1) return a*power(a,b-1);else return power(a,b/2)*power(a,b/2);}
//bigmod long long int m(long long int a,long long int b,long long int c){if(b==0)return 1;if(b%2==0){long long int  tmp=m(a,b/2,c);return ((tmp%c)*(tmp%c))%c;}elsereturn ((a%c)*(m(a,b-1,c)%c))%c;}
//MaxSubarraySum ll mss(vector<ll>v){ll mx=v[0];ll sz=v.size();for(int i=1;i<=sz;i++){ll t=v[i]+v[i-1];if(t>=v[i]) v[i]=t;mx=max(mx,v[i]*1LL);}return mx;}
//combination ll com[1001][1001];void combination(){com[1][1]=1;com[1][0]=1;for(ll i=2; i<=1000; i++){com[i][0]=1;for(ll j=1; j<=i; j++){com[i][j]=com[i-1][j]+com[i-1][j-1];}}}
///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

void solve()
{
   string s;
   cin>>s;
   ll cnt=0;
   ll sz=s.size()-1;
   fr(i,0,sz) cnt+=(s[i]-'0');
   if(cnt%9) cout<<"No"<<endl;
   else cout<<"Yes"<<endl;
}
int main()
{
    rj
    solve();



    return 0;
}



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

#define print(s) cout << (s) << endl;
#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n) 
#define all(a) (a).begin(), (a).end()
#define inf 10000000
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int ans = inf;
    REP(i,s.length()-2){
        int n = stoi(s.substr(i,3));
        int tem=abs(753-n);
        if (ans>tem){
            ans = tem;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main()
{
	int N, K;

	cin >> N >> K;

	int X, Y;

	for (int i = 1; i <= K; i++)
	{
		cin >> X >> Y;

		cout << min({ X - 1, Y - 1, N - X, N - Y }) % 3 + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vll vector<ll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
ll mod1 = 1e9 + 7;
ll mod2 = 998244353;

ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=(z*x);x =(x*x) ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}







int main(){
	string s;
	cin>>s;
	if(s[3]==s[2] && s[4]==s[5]){
		cout<<"Yes"<<endl;

	}
	else cout<<"No"<<endl;
    
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string t = "abcdefghijklmnopqrstuvwxyz" ;
  string s ;
  cin >> s ;
  sort(s.begin(), s.end());
  int n = s.size();
  int flag = 0;
  for(int i = 0 ;i < 26 ;i++){
    for( int j= 0 ; j < n ; j++){
      if ( t.at(i) == s.at(j)){
        break;
      }
      if( j == n - 1){
        cout << t.at(i) << endl;
        flag = 1;    
      }    
    }
    if( flag == 1){
      break;
    }
  }
  if ( flag != 1 ){
    cout << "None" << endl;
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

const int inf = 1e9;
const ll linf = 1e18;

// 最大公約数
template <typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) { return (b != 0) ? gcd(b, a % b) : abs(a); }
template <typename ForwardIt>
constexpr typename iterator_traits<ForwardIt>::value_type
gcd(ForwardIt first, ForwardIt last)
{
    using val_t = typename iterator_traits<ForwardIt>::value_type;
    if (first == last) return static_cast<val_t>(0);
    val_t res = *first;
    while (++first != last) res = gcd(res, *first);
    return res;
}
template <typename T>
constexpr T gcd(initializer_list<T> t) { return gcd(t.begin(), t.end()); }

// 最小公倍数
template <typename M, typename N>
constexpr common_type_t<M, N> lcm(M a, N b) { return (a != 0 && b != 0) ? a / gcd(a, b) * b : 0; }
template <typename ForwardIt>
constexpr typename iterator_traits<ForwardIt>::value_type
lcm(ForwardIt first, ForwardIt last)
{
    using val_t = typename iterator_traits<ForwardIt>::value_type;
    if (first == last) return static_cast<val_t>(0);
    val_t res = *first;
    while (++first != last) res = lcm(res, *first);
    return res;
}
template <typename T>
constexpr T lcm(initializer_list<T> t) { return lcm(t.begin(), t.end()); }

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

    int n; cin >> n;
    ll m; cin >> m;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i]; a[i] >>= 1;
    }
    bool flag = true;
    for (int i = 1; i < n; i++) {
        static int bin = __builtin_ffsll(a[0]);
        int nbin = __builtin_ffsll(a[i]);
        if (bin != nbin) { flag = false; break; }
        bin = nbin;
    }
    ll x = lcm(a.begin(), a.end());
    cout << (flag ? (m / x + 1) / 2 : 0) << endl;
    return 0;
}

Measured memory_bytes: 1024
import re
n, a, b, c, d = map(int, input().split())
s = input()
for i in range(a-1, c-1):
  if s[i] + s[i+1] == "##":
    print("No")
    exit()
for i in range(b-1, d-1):
  if s[i] + s[i+1] == "##":
    print("No")
    exit()
if c < d:
  print("Yes")
else:
  f = False
  for i in range(b-2, min(d-1, n-2)):
    if s[i] + s[i+1] + s[i+2] == "...":
      f = True
  if f:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3700
//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 = 1e9+10;

int dp[5010][5010];
int exist[5010][5010];
int main(){
  int N, M;
  scanf("%d %d", &N, &M);
  vector<PII> ps(N);
  VI xs(N), ys(N);
  // x??§?¨???¨y??§?¨??????\??????????????????
  REP(i,N){
	scanf("%d %d", &ps[i].first, &ps[i].second);
	xs[i] = ps[i].first, ys[i] = ps[i].second;
  }
  xs.PB(-INF), xs.PB(INF);
  ys.PB(-INF), ys.PB(INF);
  SORT(xs); SORT(ys);

  // x -> x', 0 <= x' < N+2
  map<int,int> compX, compY;
  int MX = 0;
  REP(i,N+2)
	if(!compX.count(xs[i])){
	  compX[xs[i]] = MX++;
	}
  int MY = 0;
  REP(i,N+2)
	if(!compY.count(ys[i])){
	  compY[ys[i]] = MY++;
	}

  REP(i,N){
	++exist[compY[ps[i].second]][compX[ps[i].first]];
  }
  for(int y=0;y<MY;++y)
	for(int x=0;x<MX;++x)
	  dp[y][x] = (y>0? dp[y-1][x]:0) + (x>0?dp[y][x-1]:0) - (y>0&&x>0? dp[y-1][x-1]:0) + exist[y][x];

  while(M--){
	int sx, sy, ex, ey;
	scanf("%d %d %d %d", &sx, &sy, &ex, &ey);
	int sxi = compX.lower_bound(sx)->second;
	int syi = compY.lower_bound(sy)->second;
	auto it = compX.upper_bound(ex); --it;
	int exi = it->second;
	it = compY.upper_bound(ey); --it;
	int eyi = it->second;

	int ans = dp[eyi][exi] - (sxi>0?dp[eyi][sxi-1]:0) - (syi>0?dp[syi-1][exi]:0) + (syi>0&&sxi>0? dp[syi-1][sxi-1]:0);
	printf("%d\n", ans);
  }
  
  return 0;
}

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

# if 0 in a
if 0 in a or len([i for i in a if i < 0]) % 2 == 0:
    print(sum(map(abs,a)))
else :
    tmp = sorted(map(abs,a))
    print(sum(tmp[1:])-tmp[0])

Measured memory_bytes: 14412
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i++)
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
#define all(a) a.begin(),a.end()
#define MOD 1000000007
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}
ll lcm(ll n, ll m) { return m / gcd(n, m) * n; }

int main(void) {
	int s;
	cin >> s;
	cout << s / 3600 << ":" << (s%3600)/60 << ":" << (s%3600) % 60 << endl;
	return 0;
}


Measured memory_bytes: 3096
n = int(input())
txy = [list(map(int, input().split())) for _ in range(n)]

T=X=Y=0
ok = True
for t,x,y in txy:
  if abs(X-x)+abs(Y-y) <= t-T:
    if (t-T)%2 == 0:
      if (abs(X-x)+abs(Y-y))%2!=0:
        ok = False
        break
    else:
      if (abs(X-x)+abs(Y-y))%2==0:
        ok = False
        break
  else:
    ok = False
    break
  T,X,Y = t,x,y
print("Yes" if ok else "No")

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


int main() {
    long long int a,b,x;cin >> a >> b >> x;
    long long int l,r;
    r = (b/x);
    l = ((a+x-1)/x);
    cout << r-l+1 << endl;
    

}       

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 10, N = 5e2 + 10;
int a[N], n;
int mark[MAXN];
vector<pair<int, int> > v;
deque<int> rm;
bool isval() {
	int ls = 0, mx = n * (n - 1) / 2;
	for (auto p : v) {
		int plc = p.first, num = p.second;
		ls += num;
		if (!(plc >= ls && plc <= mx)) 
			return false;
		mx += n - num;
		ls++;
	}
	return true;
}
int main() {
	ios_base::sync_with_stdio (false), cin.tie(0), cout.tie(0);
	memset(mark, -1, sizeof(mark));
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
		if (mark[a[i]] != -1) {
			cout << "No\n";
			return 0;
		}
		mark[a[i]] = i;
		v.push_back({a[i], i});
	}
	sort(v.begin(), v.end());
	if (!isval()) {
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
	for (auto p : v) {
		int num = p.second;
		for (int i = 0; i < num; i++)
			rm.push_back(num);
	}
	for (int i = 0; i < n * n; i++) {
		if (mark[i] != -1) {
			int add = n - mark[i] - 1;
			for (int j = 0; j < add; j++)
				rm.push_back(mark[i]);
		}
		else {
			mark[i] = rm[0];
			rm.pop_front();
		}
	}
	for (int i = 0; i < n * n; i++)
		cout << mark[i] + 1 << " ";
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

char s[1005][1005];
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H,W;
	cin >> H >> W;
	for(int i=0;i<H;i++)cin >> s[i];
	queue<pair<int,int>> q,q2,emptyq;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(s[i][j]=='#')q2.push(pair<int,int>(i,j));
		}
	}
	int dx[4] = {-1,0,0,1};
	int dy[4] = {0,-1,1,0};
	int ans = 0;
	bool f = 1;
	while(f){
		f = 0;
		q = q2;
		q2 = emptyq;
		while(!q.empty()){
			pair<int,int> p = q.front();q.pop();
			for(int i=0;i<4;i++){
				int nx = p.first + dx[i];
				int ny = p.second+ dy[i];
				if(nx>=0&&ny>=0&&nx<H&&ny<W){
					if(s[nx][ny]=='.'){
						f = 1;
						s[nx][ny] = '#';
						q2.push(pair<int,int>(nx,ny));
					}
				}
			}
		}
		if(f)ans++;
	}
	cout << ans << endl;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

int root[SIZE];
int sz[SIZE];

void init() {
    for(int i = 0; i < SIZE; ++i) {
        root[i] = i;
        sz[i] = 1;
    }
}

int Root(int x) {
    if(x == root[x]) return x;

    int rt = Root(root[x]);
    sz[x] = sz[rt];
    return rt;
}

bool Unite(int x, int y) {
    int rx, ry;
    rx = Root(x);
    ry = Root(y);

    if(rx == ry) return false;
    if(sz[rx] > sz[ry]) {
        root[ry] = rx;
    } else {
        root[rx] = ry;
    }

    sz[rx] += sz[ry];
    sz[ry] = sz[rx];
    return true;
}

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

    int N, Q;
    cin >> N >> Q;

    init();
    while(Q--) {
        int t, u, v;
        cin >> t >> u >> v;

        if(t == 0) {
            Unite(u, v);
        } else {
            if(Root(u) == Root(v)) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 5204
let s' = read_line ()
let t = read_line ()
let n, m = String.(length s', length t)
let _ = String.(for i = n - m downto 0 do let b = ref true in iteri (fun j c -> match s'.[i + j] with '?' -> () | c' -> if c' <> c then b := false) t;
  if !b then (print_endline @@ map (function '?' -> 'a' | c -> c) @@ (sub s' 0 i) ^ t ^ (sub s' (i + m) @@ n - i - m); exit 0) done); print_endline "UNRESTORABLE"

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

using namespace std;

int ans=0,n,m,x,y,fri[510],sfri[510][510];
int frin[510];
int main(){

while(1){
fill(fri,fri+510,0);
fill(sfri[0],sfri[510]+510,0);
fill(frin,frin+510,0);
ans=0;
cin >> n >> m;
if(n==0&&m==0)break;
for(int i=0;i<m;i++){
    cin >> x >> y;
      sfri[x][y]=1;
    if(x==1){
        if(fri[y]==0){
        ans+=1;
        fri[y]=1;
        frin[y]=2;
        //cout << 'p' << endl;
    }
    }
}
for(int u=2;u<=500;u++){
    for(int t=2;t<=500;t++){
        if(sfri[u][t]==1&&frin[u]==2&&fri[t]==0){
            ans+=1;
            fri[t]=1;
           // cout << t << endl;
        }
         if(sfri[u][t]==1&&frin[t]==2&&fri[u]==0){
            ans+=1;
            fri[u]=1;
           // cout << u << endl;
        }
    }
}
cout << ans << endl;
}
return 0;
}

Measured memory_bytes: 2180
//package atcoder;
 
import java.util.*;
import java.math.BigDecimal;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int A = sc.nextInt();
		int count = 0;
		while(H>0) {
			H = H-A;
			count ++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23124
import copy

n = int(input())
l = list(map(int,input().split()))
p1 = n//2
p2 = n//2-1
ans = copy.copy(l)
ans.sort()

for i in l:
    if i >= ans[p1]:
        print(ans[p2])
    else:
        print(ans[p1])


Measured memory_bytes: 32472
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine();
            var split = line.Split(' ');
            int a = int.Parse(split[0]);
            int b = int.Parse(split[1]);
            int c = int.Parse(split[2]);

            if(a < b)
            {
                if (a < c && c < b)
                    Console.WriteLine("Yes");
                else
                    Console.WriteLine("No");
            }
            else
            {
                if (b < c && c < a)
                    Console.Write("Yes");
                else
                    Console.WriteLine("No");
            }

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>

using namespace std;

// int search_xyz(int e);
int tree[10000];

int root(int a);
bool is_same_set(int p, int q);

int main()
{
    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n; i++)
    {
        tree[i] = i;
    }
    // int com[q],p[q], y[q];
    int com, x, y;
    for (int i = 0; i < q; i++)
    {
        cin >> com >> x >> y;
        if (com == 0)
        {
            tree[root(x)] = root(y);
        }
        else
        {
            if (is_same_set(x, y) == true)
            {
                cout << 1 << endl;
            }
            else
            {
                cout << 0 << endl;
            }
        }
    }
    return 0;
}

int root(int a)
{
    if (tree[a] == a)
    {
        return a;
    }
    else
    {
        tree[a] = root(tree[a]);
        return tree[a];
    }
}

bool is_same_set(int p, int q)
{
    return root(p) == root(q);
}



Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxi=10e18;
ll dp[1000][1000];
ll a[200005];
ll sum(ll i,ll j){
    ll sum=0;
    for(ll k=i;k<=j;k++)sum+=a[k];

    return sum;
}

int main(){
    ll n;cin>>n;
    
    for(ll i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            dp[i][j]=maxi;
        }
    }
    for(ll i=0;i<n;i++)dp[i][i]=0;
    for(ll i=n-2;i>=0;i--){
        for(ll j=i+1;j<n;j++){
            for(ll k=i+1;k<=j;k++){
                ll sum1=sum(k,j);
                ll sum2=sum(i,k-1);
                dp[i][j]=min(dp[i][j],sum1+sum2+dp[i][k-1]+dp[k][j]);
            }
        }
    }
  /* for(ll i=0;i<n;i++){
        for(ll j=0;j<n;j++){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<dp[0][n-1];
}

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

using namespace std;
int main (){

    string s;
    cin >> s ;
    int ans;
    if      (s == "SUN") ans=7;
    else if (s == "MON") ans=6;
    else if (s == "TUE") ans=5;
    else if (s == "WED") ans=4;
    else if (s == "THU") ans=3;
    else if (s == "FRI") ans=2;
    else if (s == "SAT") ans=1;
    cout << ans ;

}

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

bool BinarySearch(int A[], int n,int key) {
	int left = 0, right = n;
	int mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (A[mid] > key) {
			right = mid;
		}
		else if (A[mid] < key) {
			left = mid+1;
		}
		else {
			return key == A[mid];
		}
	}
	return false;
}

int main() 
{
	int sum = 0;
	int a, b,c[1000000],d[1000000];
	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> c[i];
	}
	sort(c, c + a);
	cin >> b;
	for (int i = 0; i < b; i++) {
		cin >> d[i];
		if (BinarySearch(c, a, d[i])) {
			sum++;
		}
	}
	cout << sum<<endl;
	
}


Measured memory_bytes: 3744