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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
    
  int n, k;
  cin >> n >> k;
  
  int a[n];
  
  for (int i = 0; i < k; i++)
    cin >> a[i];
  
  for (int i = k; i < n; i++)
  {
    cin >> a[i];
    if (a[i-k] < a[i])
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef long long ll;
typedef long double ld;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second

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

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

    int n;
    cin >> n;
    map<int, int> mp[2];
    for(int i = 0, num; i < n; ++i)
    {
        cin >> num;
        ++mp[i&1][num];
    }

    vpii temp[2];

    for(int i = 0; i < 2; ++i)
    {
        for(auto &z : mp[i])
        {
            temp[i].pb({z.se, z.fi});
        }

        sort(rall(temp[i]));

        if(sz(temp[i]) == 1)
        {
            temp[i].pb({0, -1});
        }
    }

    int ans = 0;

    for(int i = 0; i < 2; ++i)
    {
        for(int j = 0; j < 2; ++j)
        {
            if(temp[0][i].se != temp[1][j].se)
            {
                ckmax(ans, temp[0][i].fi + temp[1][j].fi);
            }
        }
    }

    cout << n - ans << "\n";
}


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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

int main() {
    ll h, w;
    cin >> h >> w;

    ll ans = 0;

    if (h == 1 || w == 1) {
        ans = 1;
    } else if (h % 2 == 0 || w % 2 == 0) {
        ans = (h * w) / 2;
    } else {
        ans += ((h + 1) / 2) * ((w + 1) / 2);
        ans += (h / 2) * (w / 2);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		String ans = "Good";
		for (int i = 0; i < s.length() - 1; i++) {
			if (s.charAt(i) == s.charAt(i + 1)) {
				ans = "Bad";
				break;
			}
		}

		System.out.println(ans);
		sc.close();
	}
}


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



int cd=20000;

int d,c[26],s[366][26];
int t[366];
ll r;

void init(){
    cin>>d;
    REP(i,26)cin>>c[i];
    REP(i,d)REP(j,26)cin>>s[i][j];
}

void greedy(){
    REP(i,d)REP(j,26)t[i]=s[i][j]>s[i][t[i]]?j:t[i];
}

ll score(int *t){
    ll ans=0;vector<int>cnt(26,0);
    REP(i,d){
        cnt[t[i]]=-1;
        ans+=s[i][t[i]];
        REP(j,26)cnt[j]++,ans-=cnt[j]*c[j];
    }
    return ans;
}

void crt_new(){
    int idx=rand()%d;
    int q=rand()%26;
    while(q==t[idx])q=rand()%26;
    int tmp=t[idx];
    t[idx]=q;
    ll res=score(t);
    if(res>r)r=res;
    else t[idx]=tmp;
}

void solve()
{

    init();
    // ll begin_t=clock();
    greedy();
    r=score(t);
    while(cd--)crt_new();
    // REP(i,d)cout<<t[i]<<" ";cout<<endl;
    REP(i,d)cout<<t[i]+1<<endl;
    // cout<<r<<endl;

    // ll end_t=clock();cout<<end_t-begin_t<<"ms"<<endl;
}

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

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=2e6+40,MAXM=5e5+10,hrdg=1000000007;
const ll llINF=0x7fffffff;
const int INF=0x7fffffff;
int a[2005][2005];
char b[2005][2005];

int main()
{
    int i,j,n,m;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
        scanf("%s",b[i]);
    int cnt=0;
    for(i=1;i<=n;i++)
        {for(j=0;j<m;j++)
        if(b[i][j]=='.')
        a[i][j]+=++cnt;
    else
        cnt=0;
        cnt=0;
        }

    for(i=1;i<=n;i++)
        {for(j=m-1;j>=0;j--)
        if(b[i][j]=='.')
        a[i][j]+=++cnt;
    else
        cnt=0;
        cnt=0;
        }
    for(i=0;i<m;i++)
        {for(j=1;j<=n;j++)
        if(b[j][i]=='.')
        a[j][i]+=++cnt;
    else
        cnt=0;
    cnt=0;}
    for(i=0;i<m;i++)
        {for(j=n;j>0;j--)
        if(b[j][i]=='.')
        a[j][i]+=++cnt;
    else
        cnt=0;
    cnt=0;}
    for(i=1;i<=n;i++)
        for(j=0;j<m;j++)
            cnt=max(cnt,a[i][j]);
    printf("%d",cnt-3);
    return 0;
}


Measured memory_bytes: 19840
// "bits/stdc++.h" {{{
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <limits>
#include <typeinfo>
#include <initializer_list>
#include <bitset>
#include <chrono>
#include <functional>
#include <tuple>
#include <typeindex>
#include <utility>
#include <string>
#include <regex>
// }}}

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  VAR(int, n, h, w);
  OUTL((n - h + 1) * (n - w + 1));
  return 0;
}

Measured memory_bytes: 256
s = input()
s2 = s.replace("A","")
s4 = set(s) - set(list("KIHBRA"))

if s2 == "KIHBR" and s4 == set() and s.index("H")-s.index("K") == 2 and s.count("AA") == 0:
    print("YES")
else:
    print("NO")

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	string s;
	cin >> s;
	if(s=="ABC") cout << "ARC\n";
	else cout << "ABC\n";
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main(){
    int x;
    int y;
    cin >> x >> y;
    if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12){
        x = 1;
    }else if(x == 4 || x == 6 || x == 9 || x == 11){
        x = 2;
    }else{
        x = 3;
    }
    if(y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12){
        y = 1;
    }else if(y == 4 || y == 6 || y == 9 || y == 11){
        y = 2;
    }else{
        y = 3;
    }
    if(x == y){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import numpy as np

N,M,Q = [int(i) for i in input().split()]
T = [[0]*(N+1)]*(N+1)
T=np.array(T)

for _ in range(M):
    l, r = map(int, input().split())
    T[l][r] += 1

np.cumsum(T, axis=0, out=T)
np.cumsum(T, axis=1, out=T)
data = T.tolist()

for _ in range(Q):
    ql, qr = [int(i) for i in input().split()]
    answer = data[qr][qr] - data[qr][ql-1] +  data[ql-1][ql-1] - data[ql-1][qr]
    print(answer)

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

int main() {

  string S;
  long long K;
  cin >> S >> K;

  int answer = 0;

  for (int i = 0; i < S.size(); i++) {
    if ((S[i] - '0') != 1) {
      answer = S[i] - '0';
      break;
    } else {
      if ((long long) i + 1 == K) {
        answer = 1;
        break;
      }
    }
  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int dz=12,INF=0x7f7f7f7f;
int min(int x,int y){return(x<y)?x:y;}
int main(void)
{
  int N,M,X,check,cost,C[dz],A[dz][dz],skill[dz],total=INF;
  check=scanf("%d %d %d",&N,&M,&X);
  rep(i,N){check=scanf("%d",&C[i]);rep(j,M)check=scanf("%d",&A[i][j]);}
  rep(bit,pow(2,N))
  {
    cost=0;rep(i,M)skill[i]=0;
    rep(i,N)if(bit&(int)pow(2,i)){cost+=C[i];rep(j,M)skill[j]+=A[i][j];}
    check=1;rep(i,M)if(skill[i]<X){check=0;break;}
    if(check)total=min(total,cost);
  }
  return printf("%d\n",total==INF?-1:total),0;
}

Measured memory_bytes: 2540
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint comb[52][52];

lint N, A, B;
lint val[50];
map<lint, lint> cnt;
int main() {
	cin >> N >> A >> B;
	REP(i, N) {
		cin >> val[i];
		cnt[val[i]]++;
	}
	sort(val, val + N, greater<lint>());
	bool flag = true;
	REP(i, A) {
		if (val[0] != val[i]) flag = false;
	}
	comb[0][0] = 1;
	REP(i, N + 1) {
		REP(j, N + 1) {
			comb[i + 1][j] += comb[i][j];
			comb[i][j + 1] += comb[i][j];
		}
	}
	if (flag) {
		lint ans = 0;
		FOR(i, A, min(cnt[val[0]], B) + 1) {
			ans += comb[cnt[val[0]] - i][i];
		}
		cout << setprecision(20) << (double)(val[0]) << endl;
		cout << ans << endl;
	}
	else {
		lint ch = 0;
		double sum = 0;
		REP(i, A) {
			if (val[A - 1] == val[i]) ch++;
			sum += (double)(val[i]) / A;
		}
		cout << setprecision(20) << sum << endl;
		cout << comb[cnt[val[A - 1]] - ch][ch] << endl;
	}
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,A[10];
int main()
{
  cin>>A[1]>>A[2]>>A[3]>>A[4];
  sort(A+1,A+1+4);
    if(A[1]==1 && A[2]==4 && A[3]==7 && A[4]==9) cout<<"YES";
      else cout<<"NO";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1e9+7;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
typedef pair<ll, ll> pll;;


int main() {
  int n; cin >> n;
  vector<ll> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a[i]; 
  for (int i = 0; i < n; i++) cin >> b[i]; 

  long long cnt_a = 0, cnt_b = 0;

  for (int i=0; i<n; i++){
    if(a[i] > b[i]) cnt_a += (a[i] - b[i]);
    if(b[i] > a[i]) cnt_b += (b[i] - a[i]) / 2;
  }

  if(cnt_b >= cnt_a) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int abs(int a) {
    if (a < 0) {
        return -a;
    } else {
        return a;
    }
}

int main(void){
    int n, h;
    bool flag = true;
    cin >> n;
    int arr[n][3];
    
    for (int i=0; i<n; i++) {
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    }
    
    int cx, cy;
    for (cx=0; cx<=100; cx++) {
        for (cy=0; cy<=100; cy++) {
            flag = true;
            for (int i=0; i<n; i++) {
                if (arr[i][2] != 0) {
                    h = abs(arr[i][0] - cx) + abs(arr[i][1] - cy) + arr[i][2];
                    break;
                }
            }
            for (int i=0; i<n; i++) {
                if (max((h - abs(arr[i][0] - cx) - abs(arr[i][1] - cy)), 0) != arr[i][2]) {
                    flag = false;
                    break;
                }
            }
            if (flag == true) {
                cout << cx << " " << cy << " " << h << endl;
                return 0;
            }
        }
    }
    return 0;
}



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

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

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int S[100010];

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

	int N;
	cin >> N;
	rep(i, 0, N)
	{
		cin >> S[i];
	}

	int ans = 0;
	rep(i, 1, N)
	{
		int l = 0, r = N - 1;
		int res = 0;
		if ((N - 1) % i == 0)
		{
			while (l < r)
			{
				res += S[l] + S[r];
				chmax(ans, res);
				l += i;
				r -= i;
			}
		}
		else
		{
			while (l + i < N - 1)
			{
				res += S[l] + S[r];
				chmax(ans, res);
				l += i;
				r -= i;
			}

		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int H,W,K;
    cin >> H >> W >> K;
    vector<vector<char>>S(H,vector<char>(W));
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> S[i][j];
        }
    }
    int ans = INF;
    for(int bit = 0; bit < (1 << (H-1)); bit++) {
        vector<int>cnt(W);
        vector<vector<int>>cnt2(W);
        int sum = 0;
        bool flag = true;
        for(int i = 0; i < H; i++) {
            if(i) {
                if(1 & (bit >> (i-1))) {
                    for(int j = 0; j < W; j++) {
                        cnt2[j].push_back(cnt[j]);
                        if(cnt[j] > K) {
                            flag = false;
                        }
                        cnt[j] = 0;
                    }
                }
            }
            for(int j = 0; j < W; j++) {
                cnt[j]+=(int)(S[i][j]-'0');
            }
        }
        for(int j = 0; j < W; j++) {
            cnt2[j].push_back(cnt[j]);
            if(cnt[j] > K) {
                flag = false;
            }
        }
        vector<vector<int>>s(W+1,vector<int>(cnt2[0].size()));
        for(int i = 0; i < W; i++) {
            bool ok = false;
            for(int j = 0; j < cnt2[i].size(); j++) {
                s[i][j] += cnt2[i][j];
                if(s[i][j] > K) {
                    ok = true;
                }
            }
            if(ok) {
                sum++;
            }
            for(int j = 0; j < cnt2[i].size(); j++) {
                if(ok) {
                    s[i][j] = cnt2[i][j];
                }
                s[i+1][j] = s[i][j];
            }
        }
        if(!flag) {
            continue;
        }
        int bt = bit;
        while(bt) {
            sum += bt%2;
            bt /= 2;
        }
        ans = min(ans,sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>  // ver1.9.5
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(8);
  int n,l;
  cin >> n >> l;
  Vi a(n);
  rep(i,0,n) cin >> a[i];
  
  int memo;
  rep(i,0,n-1){
    if(a[i]+a[i+1] >= l){
      memo = i+1;
      break;
    }
    if(i==n-2) {cout<<"Impossible"<<endl;return 0;}
  }
  cout << "Possible" << endl;
  rep(i,1,memo) cout << i << endl;
  repreq(i,n-1,memo) cout << i << endl;
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int inf=1000001000;
ll INF=1e18;
ll mod=1000000007;
ll MOD=1000000007;


int main() {
    int n;
    cin >> n;
    ll c=-INF,cc=INF,f=-INF,ff=INF;
    rep(i,n){
        ll a,b;
        cin >> a >> b;
        c=max(c,a+b);
        cc=min(cc,a+b);
        f=max(f,a-b);
        ff=min(ff,a-b);
    }
    cout << max(c-cc,f-ff) << endl;
}


Measured memory_bytes: 3628
#pragma GCC Optimize("Ofast")
#pragma GCC Optimize "trapv"
#define _GLIBCXX_DEBUG

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

#define FAST ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define TC int t; cin >> t; while(t--)
#define li long int
#define ll long long
#define ull unsigned long long 
#define Vec(x) vector <x>
#define Pai(x,y) pair <x,y>
#define Map(x,y) map <x,y>
#define UMap(x,y) unordered_map <x,y>
#define Set(x) set <x>
#define Sta(x) stack <x>
#define Qu(x) queue <x>
#define DQ(x) deque(x)
#define PriorQ(x)	priority_queue <x>
#define bg begin()
#define ed end()
#define sz size()
#define ct(x) count(x)
#define len length()
#define F first
#define S second
#define Makep make_pair
#define ins(x) insert(x)
#define ers(x) erase(x)
#define endl "\n";
#define MOD 1000000007
#define PI 2*acos(0.0)
#define clr() clear()
#define fori0(n) for(int i=0;i<n;i++)
#define foriab(a,b) for(int i=a;i<b;i++)
#define mem0(x) memset(x,0,sizeof(x))
#define mem1(x) memset(x,1,sizeof(x))
#define autoit(x) for(auto it=x.beg;it!=x.ed;it++)
#define count0(x) __builtin_popcount(x)
#define ret return 
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

const ll Inf=1e9+5;

ll a[100005],dp[100005],n,k;

ll ans(ll i){	
	if(i==n-1)
		return 0;
	if(i>=n)
		return Inf;
	ll ostep=Inf, tstep=Inf;
	if(dp[i]!=-1)	return dp[i];
	if(i+1<n){
		ostep=abs(a[i]-a[i+1])+ans(i+1);
	}
    if(i+2 < n){
		tstep=abs(a[i]-a[i+2])+ ans(i+2);
	}
	return dp[i]=min(ostep,tstep);
}

void solve(){
	memset(dp,-1,sizeof(dp));
	cin >> n;
	for(ll i=0;i<n;i++)
		cin >> a[i];
	cout << ans(0) << endl;
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	
	FAST
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	solve();
	ret 0;
}

Measured memory_bytes: 9852
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[])
{
    vector<int> intvec;

    int n;

    cin >> n;

    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        intvec.push_back(tmp);
    }
    reverse(intvec.begin(), intvec.end());
    for (vector<int>::iterator it = intvec.begin(); it != intvec.end(); it++)
    {
        cout << *it;
        if(it!=intvec.end()-1) cout << " ";

    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 3100
import sys

def main():
  input = sys.stdin.readline
  N, M, Q  = map(int, input().split())
  
  Pos = [[0 for _ in range(N+1)] for _ in range(N+1)] 
  for _ in range(M):
    l, r = map(int, input().split())
    Pos[l][r] += 1

  cum = [[0 for _ in range(N+1)] for _ in range(N+1)]
  for i in range(1, N+1):
    for j in range(1, N+1):
      cum[i][j] = Pos[i][j] + cum[i-1][j] + cum[i][j-1] - cum[i-1][j-1]

  for _ in range(Q):
    p, q = map(int, input().split())
    print(cum[q][q] - cum[p-1][q] - cum[q][p-1] + cum[p-1][p-1])


if __name__ == '__main__':
  main()

Measured memory_bytes: 15852
#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;

// 4 方向への移動 (下、右、上、左)
vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; ++i) cin >> S[i];

    // dist[x][y] = マス (x, y) への最短距離
    // キューの各要素は、マス (x, y) を表すペアとする
    vector<vector<int>> dist(H, vector<int>(W, -1));
    queue<pair<int,int>> que;

    // 初期条件
    dist[0][0] = 0;
    que.push({0, 0});

    // 幅優先探索
    while (!que.empty()) {
        pair<int,int> v = que.front();
        que.pop();
        int x = v.first, y = v.second;
        for (int dir = 0; dir < 4; ++dir) {
            int x2 = x + dx[dir], y2 = y + dy[dir];

            // 配列外参照はダメ、黒マスには行けない
            if (x2 < 0 || x2 >= H || y2 < 0 || y2 >= W || S[x2][y2] == '#') 
                continue;

            if (dist[x2][y2] != -1) continue;
            dist[x2][y2] = dist[x][y] + 1;
            que.push({x2, y2});
        }
    }

    // 残り白マス数をカウント
    int white = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (S[i][j] == '.') ++white;
        }
    }
    
    // 最短路に使う白マス数は dist[H-1][W-1] + 1
    if (dist[H-1][W-1] == -1) cout << -1 << endl;
    else cout << white - (dist[H-1][W-1] + 1) << endl;
}

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

typedef struct dish_t {
    int a;
    int b;
    int c;
} DISH;

int qsort_dish(const void *a, const void *b)
{
    //降順
    return ((*(DISH *)b).c) - ((*(DISH *)a).c);
}

int main(int argc, char *argv[])
{
    int n;
    DISH dish[100000];
    int i;
    long long point_tkhs, point_aoki;
    long long ans;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%d %d", &dish[i].a, &dish[i].b);
        dish[i].c = dish[i].a + dish[i].b;
    }

    qsort(dish, n, sizeof(DISH), qsort_dish);

    point_tkhs = 0;
    point_aoki = 0;
    for (i = 0; i < n; i++) {
        if (i % 2 == 0) {
            point_tkhs += (long long) dish[i].a;
        } else {
            point_aoki += (long long) dish[i].b;
        }
    }

    ans = point_tkhs - point_aoki;

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 2556
#93B
a,b,k = map(int,input().split())

if a+k <= b-k:
	for i in range(a, a+k):
		print(i)
	for i in range(b-k+1, b+1):
		print(i)
else:
	for i in range(a,b+1):
		print(i)

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
#define ll long long
#define pb push_back

int main()
{
    int n, a;
    vector<int> x;
    while (1)
    {        
        cin >> a;
        if (a == 0)
        {
            break;
        }
        vector<bool> nums(2*a,true);
        nums[0] = false; // 1は素数ではないため
        for (int i = 0; i <= a; i++)
        {
            if(nums[i]){
                for(int j=1; j<2*a/(i+1); j++){
                    nums[(i+1)*(j+1)-1] = false;   
                }
            }
        }
        int cnt=0;
        for(int i = a; i < 2*a; i++){
            if(nums[i]) cnt++;
        }
        
        x.push_back(cnt);
    }
    for (int i = 0; i < x.size(); i++)
    {
        cout << x[i] << endl;
    }
}



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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;






int main() {

	int n;
	cin >> n;
	string s;
	cin >> s;
	REP(i, s.size()) {
		int a = s[i] - 'A';
		a += n;
		a %= 26;
		s[i] = 'A' + a;
	}

	cout << s << endl;
	
}

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

int main() {
    long long a, b, c;
    cin >> a >> b >> c;
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        cout << 0 << endl;
        return 0;
    }
    long long mx = max({a, b, c});
    if (mx == a) {
        cout << (b * c) << endl;
    } else if (mx == b) {
        cout << (a * c) << endl;
    } else {
        cout << (a * b) << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int gcd(int a, int b) {
    if(a % b == 0) {
        return b;
    }
    else {
        return(gcd(b, a % b));
    }
}


int main() {
    ll n, ans = 1;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        ans *= i;
        if (ans > 1000000007) {
            ans %= 1000000007;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<queue>
int main(){
 int n;
 scanf("%d",&n);
  
 if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
  puts("hon");
  
  else if(n%10==0||n%10==1||n%10==6||n%10==8)
   puts("pon");
  
  else if(n%10==3)
   puts("bon");
  
return 0;}

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define mp(i,j) make_pair(i,j)
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

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

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

void Main()
{
	string S; cin >> S;
	vector<vector<int>> vec;
	int current_l = 0;
	int current_r = 0;
	for (int i = 0; i < S.size(); i++) {
		if (i != S.size() - 1 && S[i] == 'R' && S[i + 1] == 'L') {
			if (vec.size() != 0) {
				vec.back().push_back(current_r);
				current_r = 0;
			}
			vector<int> _v;
			_v.push_back(i);
			_v.push_back(current_l);
			vec.push_back(_v);
			++i;
			current_l = 0;
		} else if (S[i] == 'R') {
			++current_l;
		} else if (S[i] == 'L') {
			++current_r;
		}
	}
	vec.back().push_back(current_r);
	// rep(i,vec.size()) {
	// 	rep(j,3) {
	// 		cout << vec[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	int res[100010];
	memset(res, 0, sizeof(res));
	rep(i,vec.size()) {
		int left_div = vec[i][1] / 2;
		int left_diff = vec[i][1] - left_div;
		int right_div = vec[i][2] / 2;
		int right_diff= vec[i][2] - right_div;
		res[vec[i][0]] = 1 + left_div + right_diff;
		res[vec[i][0] + 1] = 1 + right_div + left_diff;
	}
	rep(i,S.size()) {
		cout << res[i];
		if (i != S.size() - 1) {
			cout << " ";
		}
	}
	cout << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3716
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main{

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		for (char c : line.toCharArray()) {
			if (Character.isLowerCase(c)) {
				System.out.print(Character.toUpperCase(c));
			} else {
				System.out.print(Character.toLowerCase(c));
			}
		}
		System.out.println();
	}

}

Measured memory_bytes: 25020
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

int main() {
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << fixed << setprecision(10);
  cout << W * H / 2.0 << " ";
  if(W / 2 == x && H / 2 == y) cout << 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s; cin >> s;
    int ln = s.size(), i;
    bool ans = true;
    for(i=0; i<ln; ++i)
    {
        if(s[i] == '7'){ans = true; break;}
        else ans = false;
    }
    cout << ((ans) ? "Yes" : "No") <<endl;
    return 0;
}

Measured memory_bytes: 3652
use proconio::input;
use rand::Rng;
use std::collections::BTreeSet;

fn main() {
   input! {
      dn: usize,
      c: [i64; 26],
      s: [[i64;26]; dn],
   }

   let mut t = vec![];
   let mut last = vec![BTreeSet::new(); 26];
   for i in 0..26 {
      last[i].insert(0);
      last[i].insert(dn + 1);
   }
   for d in 0..dn {
      let mut mx = std::i64::MIN;
      let mut tn = 0;
      for t in 0..26 {
         let mut score = 0i64;
         score += s[d][t];
         for j in 0..26 {
            if j != t {
               score -= c[j] * (d + 1 - last[j].range(..=d).rev().next().unwrap()) as i64;
            }
         }
         if score > mx {
            mx = score;
            tn = t;
         }
      }
      last[tn].insert(d + 1);
      t.push(tn);
   }

   let mut rng = rand::thread_rng();
   for i in 0..100000 {
      let d = rng.gen_range(0, dn);
      let q = rng.gen_range(0, 26);
      if t[d] == q {
         continue;
      }
      let p = t[d];
      let mut score = 0;
      score -= s[d][p];
      score += s[d][q];
      let f1 = last[p].range(..=d).rev().next().unwrap();
      let b1 = last[p].range(d + 2..).next().unwrap();
      let f2 = last[q].range(..=d).rev().next().unwrap();
      let b2 = last[q].range(d + 2..).next().unwrap();
      score -= c[p] * (d + 1 - f1) as i64 * (b1 - (d + 1)) as i64;
      score += c[q] * (d + 1 - f2) as i64 * (b2 - (d + 1)) as i64;
      if score > 0
         || rng.gen_range(0.0, 1.00) < ((100000 * score) as f64 / ((100000 - i) as f64)).exp()
      {
         t[d] = q;
         last[p].remove(&(d + 1));
         last[q].insert(d + 1);
      }
   }
   for &t in t.iter() {
      println!("{}", t + 1);
   }
}


Measured memory_bytes: 3340
#include <bits/stdc++.h> 
using namespace std; 
typedef long long LL; 
const int MAX_N = 2e6 + 5; 
int N; 
string s[MAX_N]; 
int ch[MAX_N][26]; 
int ed[MAX_N], tot = 1; 
void ins(string s) {
    int o = 1; 
    for (int i = 0; i < (int)s.length(); i++) { 
        int c = s[i] - 'a'; 
        if (!ch[o][c]) ch[o][c] = ++tot; 
        o = ch[o][c]; 
    } 
    ed[o]++; 
} 
int main () {
    ios::sync_with_stdio(0); 
    cin >> N; 
    for (int i = 1; i <= N; i++) cin >> s[i]; 
    for (int i = 1; i <= N; i++) reverse(s[i].begin(), s[i].end()), ins(s[i]);
    LL ans = 0; 
    for (int i = 1; i <= N; i++) { 
        int o = 1, cnt = 0, buc[30];
        memset(buc, 0, sizeof(buc)); 
        for (int j = 0; j < (int)s[i].length(); j++) ++buc[s[i][j] - 'a']; 
        for (int j = 0; j < (int)s[i].length(); j++) { 
            for (int k = 0; k < 26; k++) 
                if (buc[k] && k != s[i][j] - 'a') cnt += ed[ch[o][k]]; 
            o = ch[o][s[i][j] - 'a'], buc[s[i][j] - 'a']--, cnt += ed[o]; 
        } 
        ans += cnt; 
    } 
    cout << ans - N << '\n'; 
    return 0; 
} 

Measured memory_bytes: 171632
#!/usr/bin/env python3
# from typing import *
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def solve(X, K, D):

    X = abs(X)
    if X/K > D or X/D > K or X > K*D :
        print(X-K*D)
        return
    cnt = X//D
    X %= D
    ans1 = X
    ans2 = D-X
    K -= cnt
    if K % 2 == 1:
        print(ans2)
    else:
        print(ans1)




def main():
    X, K, D = map(int, input().split())
    solve(X, K, D)

if __name__ == '__main__':
    main()


'''
cd ~/Desktop/Programming/AtCoder/contest/abc175/abc175_c && sh shellscripts/test_py.sh
cd ~/Desktop/Programming/AtCoder/contest/abc175/abc175_c && sh shellscripts/etest_py.sh
cd ~/Desktop/Programming/AtCoder/contest/abc175/abc175_c && sh shellscripts/submit_py.sh
'''


Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
    string S; cin >> S;
    int N = 4;
    for(int bit=0;bit<(1<<N); bit++){
        int result = S[0]-'0';
        for(int j=0;j<3;j++){
            if(bit & (1<<j)){
                result += S[j+1]-'0';
            }else{
                result -= S[j+1]-'0';
            }
        }
        if(result == 7){
            string ans="";
            ans += S[0];
            for(int j=0;j<3;j++){
                if(bit & (1<<j)){
                    ans += '+';
                }else{
                    ans += '-';
                }
                ans += S[j+1];
            }
            ans += "=7";
            cout << ans << endl;
            break;
        }
    }
}

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

using namespace::std;

long long int N, A[100000],B[100000],ans,h,w,v,tmp,b,a;
char S[6];

int min(int x, int y) {
	if (x > y)return y;
	return x;
}


int main() {
		cin >> N;

		for (int i = 1; i <= 3500; i++) {
			for (int j = 1; j <= 3500; j++) {
				a = 4 * i*j - N*i - N*j;
				b = N*i*j;
				if (a != 0) {
					if (b%a == 0) {
						w = b / a;
						if (w > 0) {
							cout << i << " " << j << " " << w << endl;
							return 0;
						}
					}
				}
			}
		}

		return 0;
	}


	


Measured memory_bytes: 256
arr = gets.split.map(&:to_i)
sunuke = []
arr[0].times do |i|
	sunuke << i+1
end
arr[1].times do |i|
	num = gets.to_i
	arr2 = gets.split.map(&:to_i)
	num.times do |i|
		sunuke.delete(arr2[i])
	end
end

p sunuke.length

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

constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int a[200010];
int cnt[200010];

void solve() {
  memset(cnt,0,sizeof(cnt));
  int n;
  cin >> n;
  int mx1 = 0;
  int mx2 = 0;
  REP(i,n) {
    int tmp;
    cin >> tmp;
    cnt[tmp]++;
    a[i] = tmp;
    if (tmp >= mx1) {
      mx2 = mx1;
      mx1 = tmp;
    } else if (tmp > mx2) {
      mx2 = tmp;
    }
  }
  REP(i,n) {
    if (a[i] != mx1) {
      cout << mx1 << endl;
    } else {
      if (cnt[mx1] > 1) {
        cout << mx1 << endl;
      } else {
        cout << mx2 << endl;
      }
    }
  }
}

int main(int argc, char *argv[]){

  /* Regular */
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }
  
  // /* AOJ */
  // solve();
  return 0;
}

Measured memory_bytes: 3200
#include <iostream>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x < r || (w - x) < r || y < r || (h - y) < r){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}



Measured memory_bytes: 3084
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int x, a, b; cin >> x >> a >> b;
    string ans = "dangerous";
    if(a >= b) ans = "delicious";
    else if(b - a <= x) ans = "safe";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using i64 = long long;



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

  int a,b;
  cin>>a>>b;
  if (a<=8 && b<=8) {
    cout<<"Yay!\n";
  } else {
    cout<<":(\n";
  }
}


Measured memory_bytes: 256
def miller_rabin(n):
    """ primality Test
        if n < 3,825,123,056,546,413,051, it is enough to test 
        a = 2, 3, 5, 7, 11, 13, 17, 19, and 23.
        Complexity: O(log^3 n)
    """
    if n == 2: return True
    if n <= 1 or not n&1: return False

    primes = [2, 3, 5, 7, 11, 13, 17, 19, 23]

    d = n - 1
    s = 0
    while not d&1:
        d >>= 1
        s += 1

    for prime in primes:
        if prime >= n: break
        x = pow(prime, d, n)
        if x == 1: break
        for r in range(s):
            if x == n - 1: break
            if r + 1 == s: return False
            x = x * x % n
    return True

N = int(input())
print(sum(1 for _ in range(N) if miller_rabin(input())))

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

A=[[] for _ in range(N-1)]
B=[0]*N
C=[0]*N
D=[0]*N

for i in range(N-1):
    a,b=map(int,input().split())
    A[a-1].append(b)
    C[b-1]=i+1

for i in range(N-1): 
    c=0
    for j in A[i]:
        while True:
            c+=1
            if c!=B[i]:
                B[j-1]=c
                break

print(max(B))            

for i in range(1,N):
    D[C[i]]=B[i]

for i in range(1,N):
    print(D[i])




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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M, K;

int cnt[int(1e5+5)], ans[int(1e5+5)];

int Group[int(1e5+5)];
bool visited[int(1e5+5)];
int DFS(int num){
  if (visited[num]) return Group[num];
  
  visited[num] = true;
  return Group[num] = DFS(Group[num]);
}

int main(){
  cin >> N >> M >> K;
  for (int i = 1; i <= N; i++) Group[i] = i;

  for (int i = 0; i < M; i++){
    int A, B; cin >> A >> B;
    ans[A]--; ans[B]--;
    int GA = Group[A], GB = Group[B];
    while (GA != Group[GA]) GA = Group[GA];
    while (GB != Group[GB]) GB = Group[GB];

    Group[A] = min(GA, GB);
    Group[B] = min(GA, GB);
    Group[max(GA, GB)] = min(GA, GB);
  }

  for (int i = 1; i <= N; i++){
    cnt[DFS(i)]++;
  }

  for (int i = 1; i <= N; i++){
    ans[i] += cnt[Group[i]] - 1;
  }

  for (int i = 0; i < K; i++){
    int C, D; cin >> C >> D;
    if (Group[C] != Group[D]) continue;
    ans[C]--; ans[D]--;
  }

  cout << ans[1];
  for (int i = 2; i <= N; i++) cout << " " << ans[i];
  cout << endl;

  return 0;
}


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

int main()
{
	int n;
	string s;
	cin>>n>>s;
	string a = s.substr(0,n/2);
	string b = s.substr(n/2);
	if(a==b) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import numpy as np
S = np.array(list(map(str, input().rstrip())))

S[np.where(S=="W")] = 1
S[np.where(S=="B")] = 0
S = S.astype(int)
now = np.where(S==1)[0]
goal = np.arange(now.shape[0])

print((now - goal).sum())

Measured memory_bytes: 18796
import sys
input = sys.stdin.readline
def main():
    A, B, C, X, Y =map(int, input().split())
    ans = min(min(2*X*C + max((Y-X)*B, 0), 2*Y*C + max((X-Y)*A, 0)), A*X + B*Y)
    print(ans)    

if __name__ == '__main__':
    main()

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

vector<vector<pair<int,int>>> edge(110);
vin d(110);

void dijkstra(int s){
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
    fill(all(d),inf);
    d[s]=0;
    q.push(mp(0,s));
    while(q.size()){
        auto p=q.top();q.pop();
        auto v=p.second;
        if(d[v]<p.first)continue;
        for(auto e:edge[v]){
            if(d[e.first]>d[v]+e.second){
                d[e.first]=d[v]+e.second;
                q.push(mp(d[e.first],e.first));
            }
        }
    }
}

int main(){
    int n,m;cin>>n>>m;
    int a,b,c;
    rep(i,m){
        cin>>a>>b>>c;
        edge[a].push_back(mp(b,c));
        edge[b].push_back(mp(a,c));
    }
    int ans=0;
    rep2(i,1,n+1){
        dijkstra(i);
        for(auto e:edge[i]){
            if(d[e.first]!=e.second)ans++;
        }
    }
    cout<<ans/2<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#include <cstdio>
#include <map>


using namespace std;


using ll = long long;


int main()
{
    map<ll, ll> cnt;
    ll N;

    scanf("%lld", &N);
    for (ll i = 0; i < N; i++) {
        ll tmp;
        scanf("%lld", &tmp);
        if (cnt.find(tmp) == cnt.end())
            cnt[tmp] = 1;
        else
            cnt[tmp]++;
    }

    vector<pair<ll, ll>> A;
    for (auto e : cnt) {
        A.push_back(make_pair(e.first, e.second));
    }

    sort(A.begin(), A.end(), [](auto &l, auto &r) { return l.first < r.first; });

    ll ans = 0;
    for (auto it = A.begin(); it != A.end(); ++it) {
        ll tmp = it->second;
        if (it != A.begin() && (it - 1)->first >= it->first - 1)
            tmp += (it - 1)->second;
        if (it + 1 < A.end() && (it + 1)->first <= it->first + 1)
            tmp += (it + 1)->second;
        ans = max(ans, tmp);
    }

    cout << ans << endl;
}


Measured memory_bytes: 5368