akhauriyash/Code-Regression huggingface dataset:
n = int(input())
C = input()
cnt_w = 0
cnt_r = C.count('R')
ans = max(cnt_w, cnt_r)
for c in C:
    if c == 'W':
        cnt_w += 1
        temp = max(cnt_w, cnt_r)
        ans = min(ans, temp)
    if c == 'R':
        cnt_r -= 1
        temp = max(cnt_w, cnt_r)
        ans = min(ans, temp)

print(ans)


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

using ll=long long;
#define int ll

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

int N;
vector<int> dist;
vector<int> p;
queue<int> q;

void movesim(int now){
	if(p[now]==0){
		for(int i=1;(i<=6)&&(i+now<N);i++){
			if(dist[now+i]>dist[now]+1){
				dist[now+i]=dist[now]+1;
				q.push(now+i);
			}
		}
	}
	else{
		if(dist[now+p[now]]>dist[now]){
			dist[now+p[now]] = dist[now];
			movesim(now+p[now]);
		}
	}
	while(!q.empty()){
		int jump=q.front();
		q.pop();
		movesim(jump);
	}
}

signed main(){
	N=read();
	p.resize(N);
	dist.resize(N,100050);
	
	dist[0] = 0;
	REP(i,N) p[i]=read();
	movesim(0);
	
	cout<<dist[N-1]<<endl;
}

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

#define pb push_back
#define mp make_pair
#define ft first
#define sc second
#define ull unsigned long long int
#define lli long long int
#define li long int

#define si(n) scanf("%d",&n)
#define sl(n) scanf("%ld",&n)
#define sll(n) scanf("%lld",&n)

#define pi(n) printf("%d",n)
#define pl(n) printf("%ld",n)
#define pll(n) printf("%lld",n)

using namespace std;

const int MAX=1e5+5;

int A[MAX];
vector<pair<int,int> > P;

int main() {
    // freopen("a.in","r",stdin);
    // freopen("a.out","w",stdout);
    int N, M;
    cin >> N >> M;

    int a,b;
    for(int i=0; i<M; i++) {
        cin >> a >> b;
        A[a] += 1; A[b+1] -= 1; P.pb(mp(a,b));
    }

    sort(P.begin(),P.end());
    for(int i=1; i<=N; i++) {
        A[i] += A[i-1];
    }

    int last = 0, ans = 1, mn = P[0].sc;

    for(int i=0; i<M; i++) {
        if(P[i].ft >= mn) {
            last = i; mn = P[i].sc; ans += 1;
        }
        else {
            mn = min(mn, P[i].sc);
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 1784
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



ll cnt[26];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N , M ;
    cin >> N >> M ;
    
    ll two = 0;
    ll one = 0;
    
    
    rep(i,N){
        string inp;
        cin >> inp;
        rep(j, M){
            cnt[inp[j] - 'a'] ++;
        }
    }
    
    rep(i,26){
        ll num = cnt[i];
        num %= 4;
        two += num/2;
        num %= 2;
        one += num;
    }
    
    ll aimtow, aimone;
    
    if( (N%2==0) && (M%2==0)){
        aimtow = 0, aimone = 0;
    }
    else if((N%2 == 1) && (M%2 == 1)){
        aimtow = (N+M -2) /2;
        aimone = 1;
    }
    else{
        aimone = 0;
        if(N%2 == 1){
            aimtow = M/2;
        }
        else aimtow = N/2;
    }
    
    
    if((aimone == one) && (aimtow >= two)) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 

int main() {
    ll n, m;
    cin >> n >> m;
    if (n > m) swap(n, m);
    ll ret = 0;
    if (n==1) {
        if (m==1) ret=1;
        else if(m==2) ret=0;
        else ret = m-2;
    }  
    if (n > 2) ret = (n-2)*(m-2); 
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
input = sys.stdin.readline

n=int(input())
a = list(map(int,input().split()))

new=sorted(a)
new=np.array(new)
a=np.array(a)
ans=a-new
if len([i for i in ans if i == 0])==len(a) or len([i for i in ans if i == 0])==(len(a)-2):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 21532
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  map<ll, int> mp;
  mp[0]++;
  ll sum = 0;
  rep(i, n){
    int in;
    cin >> in;
    sum += in;
    mp[sum]++;
  }
  ll ans = 0;
  for(auto p : mp){
    ans += (ll)p.second * (p.second-1) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 16072
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, Y; cin >> X >> Y;
    if (X % Y == 0) {
        cout << -1 << endl;
    } else {
        cout << X << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int N = 10;
int ch[N][N];

void warshall_floyd(){
  int i,j,k;
  rep(k,N)rep(i,N)rep(j,N) ch[i][j] = min(ch[i][j],ch[i][k]+ch[k][j]);
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int H,W;cin >> H >> W;
  vector<vector<int> > v(W,vector<int>(H));
  rep(i,N)rep(j,N) cin >> ch[i][j];
  rep(y,H)rep(x,W) cin >> v[x][y];
  warshall_floyd();
  int sum = 0;
  rep(y,H)rep(x,W) if(v[x][y] != -1) sum += ch[v[x][y]][1];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
int W;
int H;
int x;
int y;
int r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

if(x>=r&&y>=r&&x<=W-r&&y<=H-r)
{
  printf("Yes\n");
}
else
{
 printf("No\n");
}

return 0;
 
}

Measured memory_bytes: 584
#include <cstdio>
#include <cctype>
#include <array>
#include <unordered_set>
#include <queue>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int n = 0, c = gcu();
	// bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	return n; }
	// return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	//if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
//template <typename T>
//svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
//svo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}
#undef svo
#undef si

struct board {
	enum {size = 3};
	struct pos {int r, c;};
	typedef array<array<int, size>, size> arr;

	arr b;
	pos p;
	int f, g, h;

	void read() {
		for (int i = 0; i < size; i++)
			for (int j = 0; j < size; j++) {
				b[i][j] = in();
				if (!b[i][j])
					p.r = i, p.c = j;
			}
		g = 0;
		f = h = hn(b);
	}

	void print() {
		for (auto &r: b) {
			for (int &c: r)
				out(&c == &r[0]?"":" ", c);
			out('\n');
		}
		out('\n');
	}

	static int hn(const arr &a) {
		int l = 0;
		for (int i = 0; i < size; i++)
			for (int j = 0; j < size; j++) {
				if (!a[i][j])
					continue;
				int k = a[i][j] - 1;
				l += abs(i - k / size) + abs(j - k % size);
			}
		return l;
	}

	static int key(const arr &a) {
		int k = 0;
		for (auto &r: a)
			for (int c: r)
				k = (k * 10) + c;
		return k;
	}

	int solver() {
		static const pos to[] = {-1, 0, 0, -1, 1, 0, 0, 1};
		unordered_set<int> m;
		priority_queue<board> q;
		q.push(*this);
		while (!q.empty()) {
			board a = q.top();
			q.pop();
			int k = key(a.b);
			if (m.count(k))
				continue;
			m.insert(k);
			if (!a.h)
				return a.g;
			for (pos o: to) {
				o.r += a.p.r, o.c += a.p.c;
				if (0 <= o.r && o.r < size && 0 <= o.c && o.c < size) {
					board c = a;
					swap(c.b[a.p.r][a.p.c], c.b[o.r][o.c]);
					c.g += 1;
					c.h = hn(c.b);
					c.f = c.g + c.h;
					c.p = o;
					q.push(c);
				}
			}
		}
		return -1;
	}
};

bool operator < (const board &a, const board &b) {
	return a.f > b.f;
}

int main() {
	board b;
	b.read();
	out(b.solver(), '\n');
}



Measured memory_bytes: 3360
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>

using namespace std;
using uint = uint32_t;
using LL = int64_t;
using ULL = uint64_t;
using PP = pair<LL, LL>;
template <typename T> using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
#define REP(i, a, n) for(LL i = (a), i##_max_ = (n); i < i##_max_; ++i)
#define REM(i, a, n) for(LL i = (LL)(n) - 1, i##_min_ = (a); i >= i##_min_; --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP { cin.tie(NULL); ios::sync_with_stdio(false); }
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U> istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U> ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N> void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N> void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template <class T> T Next() { T buf; cin >> buf; return buf; }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Algebraic.h"
#include "BinaryMatrix.h"
#include "BinaryTree.h"
#include "Bipartite.h"
#include "BIT.h"
#include "DynamicMod.h"
#include "Factorization.h"
#include "FFT.h"
#include "FlowSolver.h"
#include "Graph.h"
#include "LazySegmentTree.h"
#include "Math.h"
#include "Matrix.h"
#include "MinCostFlowSolver.h"
#include "MinMax.h"
#include "Numbers.h"
#include "Polynomial.h"
#include "Position.h"
#include "Range.h"
#include "Rational.h"
#include "SegmentTree.h"
#include "SegmentTree2D.h"
#include "SuffixArray.h"
#include "Tree.h"
#include "UnionFind.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp; ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

int main() {
	int N;
	cin >> N;

	int sum = 0;
	REP(i, 1, N + 1) {
		int j = N - i;
		if (j > i) ++sum;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
i = 0
l = 0
num = 0
a = []
n = int(input())

while i<n:
    a.append(list(map(int, input().split())))
    i += 1

for i in range(4):
    for j in range(3):
        for k in range(10):
            result = False
            l = 0
            num = 0
            while l < n:
                if i + 1 == a[l][0] and j + 1 == a[l][1] and k + 1 == a[l][2]:
                    num += a[l][3]
                l += 1
            
            print(" %s" % num, end="")
            # if result == True:
            #     print(" %s" % a[l][3], end="")
            # else:
            #     print(" 0", end="")
            
            if k == 9:
                print("")

    if i != 3:
        print("####################")
                


Measured memory_bytes: 5616
import sys

def InputToInt():
    A = input().split()
    for i in range(len(A)):
        A[i] = int(A[i])
    return A
    
if __name__ == '__main__':
    N = int(input())
    H = InputToInt()

    state = 1
    for i in range(N-1):
        if H[i+1] < H[i]-1:
            print('No')
            sys.exit()
        elif H[i+1] > H[i]:
            state = 1
        elif H[i+1] == H[i]-1 and state == -1:
            print('No')
            sys.exit()
        elif H[i+1] == H[i]-1:
            state = -1
        elif H[i+1] == H[i] and state == -1:
            pass
        elif H[i+1] == H[i] and state == 0:
            pass
        elif H[i+1] == H[i] and state == 1:
            state = 0
                    
    print('Yes')



Measured memory_bytes: 11868
#include<stdio.h>
#include<string.h>
int main(void){
  int i,p=0;
  char s[100001];
  scanf("%s",s);
  for(i=0;s[i]!='\0';i++)if(s[i]=='p')p++;
  printf("%d",strlen(s)/2-p);
  return 0;
}

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

int main() {
	
	char S[3];
	char T[3];
	int ans = 0;

	scanf("%s", S);
	scanf("%s", T);

	for (int i = 0; i < 3; i++) {
		if (S[i] == T[i]) {
			ans += 1;
		}
	}

	printf("%d", ans);
	
	return 0;
}



Measured memory_bytes: 128
A,B = map(int, input().split())
a=[]
q=1
while True:
    if  int(q*0.08)==A:
        a.append(q)
    if int(q*0.08)>A:
        break
    q+=1
b=[]
w=1
while True:
    if  int(w*0.1)==B:
        b.append(w)
    if int(w*0.1)>B:
        break
    w+=1
    
#print(a)
#print(b)
#
#print(max(a[0],b[0]))
e=max(a[0],b[0])

if e in a and e in b:
    print(e)
else:
    print('-1')

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int x;
    cin >> x;
    if(x == 3 or x == 7 or x == 5){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

#define MAX_N 100'000

using namespace std;

int A[MAX_N];

int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    int a;
    cin >> a;
    A[a - 1] = i;
  }
  for (int i = 0; i < N; ++i) {
    printf("%d ", A[i]);
  }
  printf("\n");
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.readline

def cmin(a, b, i):
  if a > b:
    dp[i] = b
    return True
  return False

N = int(input())
cost_arr = list(map(int, input().split()))

dp = [sys.maxsize]*N
dp[0] = 0

for i in range(1, N):
  cmin(dp[i], dp[i-1] + abs(cost_arr[i] - cost_arr[i-1]), i)
  if i > 1:
    cmin(dp[i], dp[i-2] + abs(cost_arr[i] - cost_arr[i-2]), i)
print(dp[N-1])    

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

#define PI 3.14159265359
#define INF 1000000009
#define LINF 10000000000000000009
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

int dx[4] = {1, 0, -1, 0};
int dy[5] = {0, 1, 0, -1};
using namespace std; 

map<ll, ll> PrimeFactorial(ll n) 
{
    map<ll,ll> ret;
    
    for(ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while (n % i == 0) {
                ret[i]++;
                n /= i;
            }
        }
    }

    if(n > 1) { ret[n]++; }

    return ret;
}

int main(void)
{
    ll n;
    cin >> n;
    
    map<ll, ll> p = PrimeFactorial(n);
    ll ans = 0;
    for(auto prime : p) {
        //cout << prime.first << "," << prime.second << endl;
        int k = prime.second;
        int cnt = 0;
        int i = 0;
        while(cnt + i< k) {
            i++;
            ans++;
            cnt += i;
            //printf("cnt,%d\n",cnt );
        }
    }
    cout << ans << endl;
    return 0;
}
/** atcoder **/


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
typedef long long ll;
using namespace std;

int main () {
    ll N, K;
    string S;
    cin >> N >> S >> K;
    char c = S[K-1];
    for(int i = 0; i < N; i++)
    {
        if(S[i] == c) {
            cout << S[i];
        }else {
            cout << '*';
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int time[3], timeaf[3];
	int ans[3][3];

	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 3; j++){
			cin >> time[j];
		}
		for (int k = 0; k < 3; k++){
			cin >> timeaf[k];
		}

		timeaf[0] -= time[0];
		for (int j = 2; j >= 1; j--){
			if (timeaf[j] < time[j]){
				timeaf[j - 1] -= 1;
				timeaf[j] += 60;
				timeaf[j] -= time[j];
			}
			else {
				timeaf[j] -= time[j];
			}
		}

		for (int j = 0; j < 3; j++){
			ans[i][j] = timeaf[j];
		}
	}

	for (int i = 0; i < 3; i++){
		cout << ans[i][0];
		for (int j = 1; j <= 2; j++){
			if (j == 1){
				cout << " " << ans[i][j];
			}
			else {
				cout << " " << ans[i][j] << endl;
			}
		}
	}
}

Measured memory_bytes: 3108
# B - Contiguous Repainting
N,K = map(int,input().split())
a = [0] + list(map(int,input().split()))
ans = 0
tmp = [0,0]
for i in range(1,K+1):
    ans += max(0,a[i])
    tmp[a[i]>=0] += abs(a[i])
loss = min(tmp)
for i in range(K+1,N+1):
    ans += max(0,a[i])
    tmp[a[i-K]>=0] -= abs(a[i-K])
    tmp[a[i]>=0] += abs(a[i])
    loss = min(loss,min(tmp))
print(ans-loss)

Measured memory_bytes: 14384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    #ifdef TarekHasan
        freopen("input.txt","r",stdin);
    #endif // TarekHasan
    int a,b,c; cin >> a >> b >> c;
    if(b*c>=a)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  int N,ans=0;
  string S;
  cin >> N >> S;
  rep(i,N){
    int count=0;
    for(int j=0;j<N-i;j++){
      if(S[j]==S[j+i]) count++;
      else count=0;
      ans=max(ans,min(i,count));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
W,H,N = STDIN.gets.split.map{|v| v.to_i}

left=0;
right=W;
bottom=0;
top=H;

for times in 1..N do
  x,y,a = STDIN.gets.split.map{|v| v.to_i}
  case a
  when 1 then
    left=[left, x].max
  when 2 then
    right=[right, x].min
  when 3 then
    bottom=[bottom, y].max
  when 4 then
    top=[top, y].min
  end 
end

width=right > left ? right - left : 0
height=top > bottom ? top - bottom : 0
print width*height

Measured memory_bytes: 1788
#include <bits/stdc++.h>
typedef long long       ll;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define fore(i, b, e)      for(int i = b; i < e; i++)
#define forr(i, b, e)      for(int i = b; i < e; i++)
#define forg(i, b, e, m)  for(int i = b; i < e; i+=m)
#define fi first
#define se second
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef pair<ll, int>  ii;
typedef pair<int, ii>  iii;
typedef vector<int>     vi;

typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const double PI = acos(-1);
const double EPS = 1e-9;

int main()
{    
    ios::sync_with_stdio(false);cin.tie(0);
    ll a,b,c;
    cin>>a>>b>>c;
    ll y=c-a-b;
    if (y<0)
    {
        cout<<"No\n";
        return 0;
    }
    if (y*y>4*a*b)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
}
// PLUS ULTRA!
    


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int[] v=new int[n];
        int[] c=new int[n];
        for(int i=0; i<n; i++){
            v[i]=sc.nextInt();
        }
        for(int i=0; i<n; i++){
            c[i]=sc.nextInt();
        }

        int profit=0;
        for(int i=0; i<n; i++){
            int temp=v[i]-c[i];
            if(temp>0){
                profit+=temp;
            }
        }
        System.out.println(profit);
    }
}


Measured memory_bytes: 23252
#include <iostream>

int main(int argc, char** argv)
{
    int A, B;
    std::cin >> A >> B;

    int K = A+B;
    if (K%2==1) {
        std::cout << "IMPOSSIBLE" << std::endl;
    }
    else {
        std::cout << (K / 2) << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	string s;
	cin>>s;
	int n = s.size();
	for(int i=0;i<n-1;i++){
		if( s[i] == s[i+1] ){
			cout<<i+1<<" "<<i+2<<endl;
			return 0;
		}
	}
	for(int i=0;i<n-2;i++){
		if( s[i] == s[i+2] ){
			cout<<i+1<<" "<<i+3<<endl;
			return 0;
		}
	}
	cout<<-1<<" "<<-1<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <unordered_map>

const int MOD = pow(10,9)+7;
typedef long long ll;

using namespace std;
int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}




int main() {

    int X = in();

    
    int n = (int)sqrt(2*X);
    
    if ( n*(n+1)/2 < X  ){
        n++;
    }
    
    
    cout << n  << endl;
    return 0;
    
    
}





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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = InputNum();
            var a = n;
            var sum = 0;
            while (n > 0)
            {
                sum += n % 10;
                n /= 10;
            }
            WriteLine(a % sum == 0 ? "Yes" : "No");
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> a( N );
	for( int i = 0; i < N; i++ ) {
		cin >> a[i];
	}

	vector<long long> acc( N + 1 );
	vector<long long> accp( N + 1 );
	for( int i = 0; i < N; i++ ) {
		acc[i + 1] = acc[i] + a[i];
		accp[i + 1] = accp[i] + max( a[i], 0 );
	}
	long long ans = 0;
	for( int i = 0; i < N - K + 1; i++ ) {
		long long b = acc[i + K] - acc[i];
		if( i > 0 ) b += accp[i] - accp[0];
		if( i + K < N ) b += accp[N] - accp[i + K];
		long long w = 0;
		if( i > 0 ) w += accp[i] - accp[0];
		if( i + K < N ) w += accp[N] - accp[i + K];
		ans = max( { ans, b, w } );
	}

	cout << ans << endl;
}


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

public class Main {
	static int mod = (int) 1e9 + 7;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int a[] = fs.nextIntArray(n);
//		int n = (int)1e5;
//		int a[] = new int[n];
//		Random random = new Random();
//		for(int i=0;i<n;i++) {
//			//a[i]=(int)1e9;
//			a[i] = random.nextInt((int)1e9);
//		}

		//iを取ろうとした時に、jが取られる確率
		
		int sum[] = new int[n];
		for(int i=1;i<n;i++) sum[i] = (int)plus(sum[i-1], div(1,i+1));
		
		long ans = 0;
		for(int i=0;i<n;i++) {
			int l = i;
			int r = n-1-i;
			long now = plus(sum[l], sum[r]);//i番目の箱が足される回数の期待値
			now = plus(now,1); //自分を取るときは確率1で取られる 
			ans = plus(ans, mul(now, a[i]));
		}
		for(int i=1;i<=n;i++) {
			ans = mul(ans, i);
		}
		System.out.println(ans);
	}
	
	//MOD culculations
	static long plus(long x, long y) {
		x %= mod;
		y %= mod;
		long res = (x + y) % mod;
		return res;
	}

	static long suv(long x, long y) {
		x %= mod;
		y %= mod;
		long res = (x - y + mod) % mod;
		return res;
	}

	static long mul(long x, long y) {
		x %= mod;
		y %= mod;
		long res = x * y % mod;
		return res;
	}

	static long div(long x, long y) {
		x %= mod;
		y %= mod;
		long res = x * modpow(y, mod - 2) % mod;
		return res;
	}

	//modの元での高速pow()
	static long modpow(long a, long p) {
		if (p == 0)
			return 1;
		if (p % 2 == 0) {
			long halfP = p / 2;
			long root = modpow(a, halfP);
			return root * root % mod;
		} else
			return a * modpow(a, p - 1) % mod;
	}

}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

int main(){
  int n,m;
  string s,a,b;
  cin >> n;
  cin >> s;
  m = s.size();
  a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  rep(i,m){
    rep(j,26){
       if(s[i] == a[j]){
         s[i] = a[(j+n)%26];
         break;
       }
    }
  }
  rep(i,m) b += s[i];
  cout << b << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int n;
	ll k;
	cin >> n >> k;
	
	vector<pair<int,int> > v;
	
	REP(i,n)
	{
		int a,b;
		cin >> a >> b;
		v.PB(MP(a,b));
	}
	
	sort(ALL(v));
	
	REP(i,n)
	{
		if(k > v[i].SE)
		{
			k -= v[i].SE;
		}
		else
		{
			cout << v[i].FI << endl;
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1400
<?php
/**
 * ABC127
 * A - Ferris Wheel
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d %d", $a, $b);

if ($a <= 5) {
    $result = 0;
} elseif ($a <= 12) {
    $result = $b / 2;
} else {
    $result = $b;
}

echo $result, PHP_EOL;


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

int manhattan_2(vector<int> a,vector<int> b){
  return abs(a[0]-b[0])+abs(a[1]-b[1]);
}

int main(){
  int N,M;
  cin >> N >>M;
  int stu[N][2],pos[M][2];
  for(int i=0;i<N;i++) cin >> stu[i][0] >>stu[i][1];
  for(int i=0;i<M;i++) cin >> pos[i][0] >>pos[i][1];
  for(int i=0;i<N;i++){
    int t = manhattan_2( {stu[i][0],stu[i][1]} , {pos[0][0],pos[0][1]} );
    int ans=1;
    for(int j=0;j<M;j++){
      if(manhattan_2({stu[i][0],stu[i][1]} , {pos[j][0],pos[j][1]})<t){
        t = manhattan_2({stu[i][0],stu[i][1]} , {pos[j][0],pos[j][1]});
        ans = j+1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
s=[] #全kについて、スイッチの状態を格納する。s[][]で呼び出し
for i in range(m):
	switch=[] #各kについて、スイッチの状態を一旦格納する
	k,*switch=map(int,input().split())
	#switch[i]はswitchの番号であり[1,n]なので、インデックスを1つずつ減らす
	for i in range(k):
		switch[i]-=1
	s.append(switch)
p=list(map(int,input().split()))

ans=0
#スイッチの2**n通りの状態に対して
for state in range(2**n):
	state=list(map(int,format(state,'b').zfill(n)))
	allon=1
	for i in range(m):
		count=0
		for j in range(len(s[i])):
			count+=state[s[i][j]]
		if count%2!=p[i]:
			allon=0
			break
	if allon==1:
		ans+=1
print(ans)
			

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	char a,b;
	scanf("%c %c",&a,&b);
	if(a=='H'&&b=='H')
		printf("H\n");
	else if(a=='H'&&b=='D')
		printf("D\n");
	else if(a=='D'&&b=='H')
		printf("D\n");
	else if(a=='D'&&b=='D')
		printf("H\n");
	return 0;
}

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

int main(void)
{
    char s[10];
    int i;
    int min=999;
    int box;
    /*for(i=0;i<10;i++){
        scanf("%s",&s[i]);
    }*/gets(s);
    int l=strlen(s);
    for(i=0;i<l-2;i++){
        box=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
        if(abs(753-box)<min){
            min=abs(753-box);
        }
    }

    printf("%d\n",min);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>

using namespace std;
int main(void){
    
   double r, s, are, circ;
    
    cin >> r;
    
    s = 3.141592653589;
    are = r * r * s;
    circ = 2 * r * s;
    
    cout << fixed << setprecision(6) << are << " " << circ << endl;
    
    return 0;
}



Measured memory_bytes: 3284
#include <iostream>
using namespace std;
int main(){
    string s;
    int i,j,l=0,r=0,pos;
    cin >> s;
    int a[s.size()];
    for (i=0;i<s.size();i++){
        if (s[i]=='R'){
            r++;
            a[i]=0;
        }
        else{
            j=i;
            while (s[j]=='L'&&j<s.size()){
                l++;
                a[j]=0;
                pos=j;
                j++;
            }
            if (r>l&&(r-l)%2==1){
                if (l%2==0){
                    a[i-1]=(l+r)/2+1;
                    a[i]=(l+r)/2;
                }
                else{
                    a[i-1]=(l+r)/2;
                    a[i]=(l+r)/2+1;
                }
            }
            else if (r<l&&(l-r)%2==1){
                if (r%2==0){
                    a[i-1]=(l+r)/2;
                    a[i]=(l+r)/2+1;
                }
                else{
                    a[i-1]=(l+r)/2+1;
                    a[i]=(l+r)/2;
                }
            }
            else{
                a[i-1]=(l+r)/2;
                a[i]=(l+r)/2;
            }
            i=pos;
            l=0;
            r=0;
        }
    }
    for (i=0;i<s.size()-1;i++)
        cout << a[i] << " ";
    cout << a[s.size()-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    int n, a, ans=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        while(a%2==0)
        {
            ans++;
            a/=2;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
h, w = [int(i) for i in input().split()]
h3 = int(h/3)
w3 = int (w/3)
ret = sys.maxsize
# ||| Split
if(h % 3 == 0 or w % 3 == 0):
    ret = 0
a1 = h3 * w
a2 = (h3+1) * w
if(ret > a2 - a1):
    ret = a2 - a1
a1 = w3 * h
a2 = (w3+1) * h
if(ret > a2 - a1):
    ret = a2 - a1
# print("|||:", a2 - a1)
 
# T Split
a1 = h3 * w
a2 = (h-h3) * int(w/2)
if(w % 2 == 1):
    a2 += (h-h3)
a3 = (h-h3) * int(w/2)
amin = a1
if(a1 > a3):
    amin = a3
amax = a2
if(a1 > a2):
    amax = a1
if(ret > (amax - amin)):
    ret = amax - amin
 
# print("T1: ", amax - amin)
 
h31 = h3 + 1
a1 = (h31) * w      # 10
a2 = (h-h31) * int(w/2)  # 6
if(w % 2 == 1):
    a2 += (h-h31) # 9
a3 = (h-h31) * int(w/2)
amin = a1
if(a1 > a3):
    amin = a3
amax = a2
if(a1 > a2):
    amax = a1
if(ret > (amax - amin)):
    ret = amax - amin
 
# print("T2: ", amax - amin, amax, amin)
 
h, w = w, h
h3 = int(h/3)
w3 = int (w/3)
a1 = h3 * w
a2 = (h-h3) * int(w/2)
if(w % 2 == 1):
    a2 += (h-h3)
a3 = (h-h3) * int(w/2)
amin = a1
if(a1 > a3):
    amin = a3
amax = a2
if(a1 > a2):
    amax = a1
if(ret > (amax - amin)):
    ret = amax - amin
 
# print("T3: ", amax - amin)
 
h31 = h3 + 1
a1 = (h31) * w
a2 = (h-h31) * int(w/2)
if(w % 2 == 1):
    a2 += (h-h31)
a3 = (h-h31) * int(w/2)
amin = a1
if(a1 > a3):
    amin = a3
amax = a2
if(a1 > a2):
    amax = a1
if(ret > (amax - amin)):
    ret = amax - amin
 
# print("T4: ", amax - amin)
 
print(int(ret))

Measured memory_bytes: 3192
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int h[] = new int[N];
		for(int i = 0; i < N; i++) {
			h[i] = sc.nextInt();
		}
		
		int cost[] = new int[N];
		cost[0] = 0;
		cost[1] = Math.abs(h[1] - h[0]);
		for(int i = 2; i < N; i++) {
			cost[i] = Math.min(cost[i - 2] + Math.abs(h[i] - h[i - 2]), cost[i - 1] + Math.abs(h[i] - h[i - 1]));
		}
		System.out.println(cost[N - 1]);
	}
}


Measured memory_bytes: 52124
#include<iostream>
using namespace std;
int main(){
	int N;
	string S;
	cin>>N>>S;
	if(N%2==1){
		cout<<"No";
		return 0;
	}else{
		for(int i=0;i<N/2;i++){
			if(S[i]!=S[i+N/2]){
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 384
/* ****mittal21**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define endl        '\n'
#define pii         pair<long long int,long long int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
#define N  100005
void solve()
{
   
   string s;
   cin>>s;
   if(s.back()=='s')
    cout<<s+"es";
  else
    cout<<s+"s";
   return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll testcase=1;
    //cin>>testcase;
    while(testcase--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

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

int main() {
  int h, w;
  cin >> h >> w;
  V<string> g(h);
  rep(i, h) cin >> g[i];

  using S = tuple<int, int, int>;
  priority_queue<S, V<S>, greater<S>> q;

  V<V<int>> c(h + 1, V<int>(w + 1, INF));

  q.push({0, 0, 0});
  while (!q.empty()) {
    auto e = q.top();
    q.pop();
    auto d = get<0>(e) + 1;
    rep(i, 4) {
      int x = get<1>(e) + dx[i];
      int y = get<2>(e) + dy[i];
      if (x < 0 || x >= w) continue;
      if (y < 0 || y >= h) continue;
      if (g[y][x] == '#') continue;
      if (d < c[y][x]) {
        c[y][x] = d;
        q.push({d, x, y});
      }
    }
  }
  if (c[h - 1][w - 1] == INF) {
    cout << -1 << endl;
    return 0;
  }
  int cnt = 0;
  rep(i, h) rep(j, w) if (g[i][j] == '.') cnt++;
  int ans = cnt - (c[h - 1][w - 1] + 1);
  cout << ans << endl;
}


Measured memory_bytes: 3616
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = myconv(next(),4);
  var N = one[0];
  var C = one[1];
  var K = one[2];
  var list = new Array(N);
  for(var i = 0; i < N; i ++){
    list[i] = myconv(next(),1);
  }
  list.sort(function(a,b){
  	return a - b;
  });
  myerr(list);
  var first = null;
  var jokyaku = 0;
  var output = 0;
  for(var i = 0; i < N; i++){
      if(first == null){
         first = list[i];
        myerr("最初更新?");
        output++;
      }
      if(first + K >= list[i]){
        myerr("時間セーフ");
         jokyaku++;
         if(jokyaku == C){
           myerr("定員MAX" + i);
           jokyaku = 0;
           first = null;
         }
      }else{
        myerr("時間オーバー");
        output++;
        jokyaku = 1;
        first = list[i];
      }
  }
  myout(output);
}

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

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

int dp[(int)1e6+10];
const int INF = 2e18;

main()
{
	int N,M;
	cin >> N >> M;
	int sum=0;
	memset(dp, 127, sizeof(dp));
	dp[0] = 0;
	for(int i=1; i<=N; i++) {
		int w,v;
		cin >> w >> v;
		sum += v;
		for(int i=sum; i>=v; i--)
			dp[i]=min(dp[i],dp[i-v]+w);
	}
	int ans = -(2e18);
	for(int i=1; i<=1e6+5; i++)
		if(dp[i]<=M)
			ans=max(ans,i);
	cout << ans;
	return 0;
}


Measured memory_bytes: 8064
# A equals to B, A not equals to C
# A not equals to B, A equals to C
# A not equals to B and C, B equals to C
def kawaiso(A,B,C):
  YES_CODE = "Yes"
  NO_CODE = "No"

  if A == B and A != C:
      return YES_CODE 
  
  if A != B and A == C:
      return YES_CODE 
  
  if B == C and A != C:
      return YES_CODE 
  
  return NO_CODE 

A, B, C = map(int ,input().split())
result = kawaiso(A,B,C)
print(result)

Measured memory_bytes: 3060
n = int(input())
a = sorted(list(map(int, input().split())))
MA = (max(a) + 1)
ans = [0] * MA

for i in range(n):
    for j in range(a[i],MA,a[i]):
        ans[j] += 1
print(sum(ans[i]==1 for i in a))

Measured memory_bytes: 32336
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

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

    bool f = true;
    ll maxi = 0;
    ll lcmAll = 1;

    set<ll> div;


    for(int i = 0; i < n; i++){
        maxi = max(maxi, a[i]);
        lcmAll = lcm(lcmAll, a[i] / 2);
        if((a[i] / 2) % 2 == 0){
            ll cnt = 0;
            ll tmp = a[i];
            while(true){
                if(tmp % 2 == 0){
                    tmp /= 2;
                    cnt++;
                } else {
                    break;
                }
            }
            div.insert(cnt);
        } else {
            div.insert(1);
        }
    }

    if(div.size() > 1){
        f = false;
    }

    if(!f){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;


    ans = (m / lcmAll) - m / (lcmAll * 2);


    cout << ans << endl;


}

Measured memory_bytes: 1152
def main():
    N, K, *A = map(int, open(0).read().split())
    A = [0] + A
    cur = 1
    visited = [-1] * (N + 1)
    visited[cur] = 0
    for i in range(1, K + 1):
        next = A[cur]
        if cur == next:
            print(next)
            return
        elif (j := visited[next]) != -1:
            print(visited.index((K - j) % (i - j) + j))
            break
        else:
            visited[next] = visited[cur] + 1
            cur = next
    else:
        print(next)
        return


if __name__ == "__main__":
    main()


Measured memory_bytes: 32560
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define per(i,n) for ((i)=n;(i)>=(1);(i)--)
using namespace std;
int n,m,a[200005],c[200005];
struct nd
{
	int mi,s;
}s[800005];
nd operator +(nd x,nd y)
{
	nd ans;ans.mi=min(x.mi,y.mi);
	ans.s=0;
	if(x.mi==ans.mi) ans.s+=x.s;
	if(y.mi==ans.mi) ans.s+=y.s;
	return ans;
}
void pushup(int x)
{
	s[x]=s[x+x]+s[x+x+1];
}
void build(int x,int l,int r)
{
	if(l==r){s[x]=(nd){0,1};return;}
	int mid=(l+r)/2;
	build(x+x,l,mid);
	build(x+x+1,mid+1,r);
	pushup(x);
}
void update(int x,int l,int r,int y,int c)
{
	if(l==r){s[x].mi+=c;return;}
	int mid=(l+r)/2;
	if(y<=mid)update(x+x,l,mid,y,c); else update(x+x+1,mid+1,r,y,c);
	pushup(x);
}
void del(int x)
{
	if(x-c[x]+1>=1) update(1,1,n,x-c[x]+1,-1);
	c[x]--;
}
void add(int x)
{
	c[x]++;
	if(x-c[x]+1>=1) update(1,1,n,x-c[x]+1,1);
}
int main()
{
	int i,j;
	cin>>n>>m;
	rep(i,n){cin>>a[i];c[a[i]]++;}
	build(1,1,n);
	rep(i,n)
	{
		int t=i;
		rep(j,c[i])
		{
			if(t<1) break;
			update(1,1,n,t,1);
			t--;
		}
	}
	while(m--)
	{
		int x,y;
		cin>>x>>y;
		del(a[x]);
		add(a[x]=y);
		cout<<(s[1].mi==0?s[1].s:0)<<endl;
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  long f0,f1;
  f0 = 2; f1 = 1;
  for(int i=2; i<=N; i++){
    long tmp;
    tmp = f1;
    f1 = f0+f1;
    f0 = tmp;
  }
  cout << f1 << endl;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  ll n, a, b;
  cin >> n >> a >> b;
  if (a > b) swap(a, b);
  ll ret = min(b - 1, n - a);  // 1で会う, n で会う
  if (a % 2 == b % 2) {
    ret = min(ret, (b - a) / 2);
  }
  ret = min(ret, (n - b) + (b - a + 1) / 2);
  ret = min(ret, (a - 1) + (b - a + 2) / 2);
  cout << ret << endl;
}


Measured memory_bytes: 256