akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)
 
 
//template functions
/////////////////////////
long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}
long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}
long GCM(long A,long B){
            long W,r;
    if(A<B){
 
        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}
 
long upDiv(long a,long b){
  return (a+b-1)/b;
}
 
/////////////////////////
 
 
//Answer
 
 
int main() {
 
long N,K;
long long max,inmax=0,sum=0,j=0,value=0,loops=0;
 
cin>>N>>K;
vector<long> P(N+2);
vector<long> C(N+2);
vector<long> sums(N+3);
for(long i=0;i<N;i++){
cin>>P.at(i+1);
}
for(long i=0;i<N;i++){
cin>>C.at(i+1);
}
long next=0;
for(long i=1;i<N+1;i++){
  value=0;
    for(long k=0;k<N+1;k++){
        sums.at(k)=0;
    }
    next=i;
    sum=0;
    inmax=0;
  	j=0;
    do{      
        j++;
       sum+=C.at(P.at(next));
        sums.at(j)=sum;
       next=P.at(next);
 
    }while(next!=i);
 
    if(j<=K){        
        if(sum>0){
            inmax=0;
            for(long a=0;a<=K%j;a++){
                if(inmax<sums.at(a)){
                inmax=sums.at(a);
                }
            }
          long long inmax2=sums.at(1);
            for(long a=1;a<=j;a++){
                if(inmax2<sums.at(a)){
                inmax2=sums.at(a);
                }
            }
            loops=K/j;
            if(loops*sum+inmax>(loops-1)*sum+inmax2){
            value=loops*sum+inmax;
            }else{
            value=(loops-1)*sum+inmax2;
            }
        }else{
            inmax=sums.at(1);
            for(long a=1;a<=j;a++){
                if(inmax<sums.at(a)){
                inmax=sums.at(a);
                }
            }
            value=inmax;
        }
    }else{
      inmax=sums.at(1);
        for(long a=1;a<=K;a++){
                if(inmax<sums.at(a)){
                inmax=sums.at(a);
                }
            }
      	value=inmax;
 
    }
    if(i==1){
      max=value;
    }
    if(max<value){
        max=value;
    }    
 
}
 
cout<<max<<endl;
 
}



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

using namespace std;

struct pair_hash {
  template <class T1, class T2>
  std::size_t operator()(const std::pair<T1, T2> &p) const {
    auto h1 = std::hash<T1>{}(p.first);
    auto h2 = std::hash<T2>{}(p.second);
    return h1 ^ h2;
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  int px = sx, py = sy;
  unordered_set<pair<int, int>, pair_hash> visited;

  auto to_regist = [&](int x, int y) {
    if ((x == sx && y == ty) || (x == tx && y == ty)) {
      return false;
    } else {
      return true;
    }
  };
  auto xmove = [](int x) {
    if (0 < x) {
      cout << "R";
    } else {
      cout << "L";
    }
  };
  auto ymove = [](int y) {
    if (0 < y) {
      cout << "U";
    } else {
      cout << "D";
    }
  };
  for (int i = 0; i < 4; ++i) {
    // s -> t
    while (px != tx || py != ty) {
      int dx = px == tx ? 0 : (0 < tx - px) * 2 - 1;
      int dy = py == ty ? 0 : (0 < ty - py) * 2 - 1;
      if (dx != 0 && visited.find(make_pair(px + dx, py)) == visited.end()) {
        if (to_regist(px + dx, py)) {
          visited.insert(make_pair(px + dx, py));
        }
        xmove(dx);
        px += dx;
      } else if (dy != 0 &&
                 visited.find(make_pair(px, py + dy)) == visited.end()) {
        if (to_regist(px, py + dy)) {
          visited.insert(make_pair(px, py + dy));
        }
        ymove(dy);
        py += dy;
      } else if (dx != 0) {
        if (visited.find(make_pair(px, py + 1)) == visited.end()) {
          if (to_regist(px, py + 1)) {
            visited.insert(make_pair(px, py + 1));
          }
          ymove(1);
          py += 1;
        } else if (visited.find(make_pair(px, py - 1)) == visited.end()) {
          if (to_regist(px, py - 1)) {
            visited.insert(make_pair(px, py - 1));
          }
          ymove(-1);
          py -= 1;
        } else {
          cout << "why?x\n";
          return 0;
        }
      } else if (dy != 0) {
        if (visited.find(make_pair(px + 1, py)) == visited.end()) {
          if (to_regist(px + 1, py)) {
            visited.insert(make_pair(px + 1, py));
          }
          xmove(1);
          px += 1;
        } else if (visited.find(make_pair(px - 1, py)) == visited.end()) {
          if (to_regist(px - 1, py)) {
            visited.insert(make_pair(px - 1, py));
          }
          xmove(-1);
          px -= 1;
        } else {
          cout << "why?y\n";
          return 0;
        }
      } else {
        cout << "nothing todo\n";
        return 0;
      }
    }
    assert(tx == px && ty == py);
    swap(sx, tx);
    swap(sy, ty);
  }
  cout << "\n";
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	static boolean[][] gragh;
	static boolean[] vis;
	static int n, m;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		int[] a = new int[m];
		int[] b = new int[m];
		for(int i = 0 ; i < m ; i++) {
			a[i] = sc.nextInt() - 1;
			b[i] = sc.nextInt() - 1;
		}
		gragh = new boolean[n][n];
		for(int i = 0 ; i < m ; i++)  gragh[a[i]][b[i]] = gragh[b[i]][a[i]] = true;
		int ans = 0;
		vis = new boolean[n];
		for(int i = 0 ; i < m ; i++) {
			gragh[a[i]][b[i]] = gragh[b[i]][a[i]] = false;
			for(int j = 0 ; j < n ; j++) vis[j] = false;
			dfs(0);
			for(int j = 0 ; j < n ; j++) {
				if(vis[j] == false) {
					ans++;
					break;
				}
			}
			gragh[a[i]][b[i]] = gragh[b[i]][a[i]] = true;
		}
		System.out.println(ans);
	}

	static void dfs(int x) {
		vis[x] = true;
		for(int i = 0 ; i < n ; i++) {
			if(gragh[x][i] == true && vis[i] == false) {
				dfs(i);
			}
		}
	}

}

Measured memory_bytes: 24020
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }


int solve()
{
    int N, train, taxi;

    cin >> N >> train >> taxi;

    return std::min(N * train, taxi);
}

int main()
{
    std::cout << solve() << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n; cin>>n;
    vl as(n); cin>>as;
    sort(rng(as));
    as.push_back(LINF);

    vl ans;
    unordered_map<ll, bool> used;
    rep(i, n) {
        if (used[as[i]]) continue;
        if (as[i] != as[i + 1]) {
            ans.push_back(as[i]);
        }

        ll temp = as[i];
        while (temp <= 1e6 + 100) {
            used[temp] = true;
            temp += as[i];
        }
    }
    cout<<ans.size()<<endl;
}

Measured memory_bytes: 44228
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define PB push_back
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;
 
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 
	int n; cin >> n;
	vi v(n); FOR(i, n) cin >> v[i];

	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(v[i] == cnt+1)
			cnt++;
	}

	if(cnt == 0) cout << "-1\n";
	else cout << n-cnt << '\n';

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <map>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
int mod = 1e9 + 7;

int main()
{
	ll n;
	cin >> n;
	int ans = 334;
	for (ll i = 1; i*i <= n; i++)
	{
		if (n%i==0)
		{
			ll a = n / i;
			int cand = to_string(a).size();
			ans = min(ans, cand);
		}
	}
	co(ans);
	return 0;
}

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


count = 0
for i in range(len(A) - 2):
    if (A[i] > A[i + 1]) and (A[i + 1] > A[i + 2]):
       count += 1
    elif (A[i + 2] > A[i + 1]) and (A[i + 1] > A[i]):
        count += 1
    else: 
        pass
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>
#include <bitset>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SZ = 2010;

ll n;
bitset<SZ> grid[SZ], msk[SZ];
bitset<SZ> sv[SZ], sv2[SZ];
vector<ll> wn[SZ];
bitset<SZ> cur;

int main()
{
	fastInp;

	cin >> n;

	for (int i = 1; i <= n + 1; i++) {
		sv[i - 1][i] = 1;
		sv2[i][i - 1] = 1;
	}
	for (int i = 1; i < n; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < s.size(); j++) {
			if (s[j] == '1') {
				grid[i + 1][j + 1] = 1;
			}
			else {
				grid[j + 1][i + 1] = 1;
			}
		}
	}

	for (int i = 0; i <= n + 3; i++) {
		cur = 0;
		for (int j = 0; j < i; j++) cur[j] = 1;
		msk[i] = cur;
	}
	for (int i = 2; i <= n + 1; i++) {
		for (int j = 0; j <= n + 1; j++) {
			ll lft = j, rt = j + i;
			if (lft == 2 && rt == 4) {
				cout << "";
			}
			if (rt <= n + 1) {
				if ((((sv[lft] & grid[lft] & sv2[rt]) >> lft) & msk[i + 1]) != 0 || (((sv2[rt] & grid[rt] & sv[lft]) >> lft) & msk[i + 1]) != 0) {
					sv[lft][rt] = 1;
					sv2[rt][lft] = 1;
				}
			}
		}
	}

	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		if (sv[0][i] && sv[i][n + 1]) {
			ans++;
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 5672
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define INF (int)1e9
int main() {
     
    fio;
    int n,k;
    cin>>n>>k;

    unordered_map<int,bool> mp;

    while(k--)
    {
	    int size;
	    cin>>size;
	    for(int i=0;i<size;i++)
	    {
		    int x;
		    cin>>x;
		    mp[x]=true;
	    }
    }

    ll count=0;
    for(int i=1;i<=n;i++)
    {
	    if(!mp[i])
		    count++;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3668
n,k=map(int,input().split())
v=[int(i) for i in input().split()]
ans=0
chk=[0,0]
c=[]
for x in range(min(n,k)+1):
    if x>0:
        chk[0]+=v[x-1]
        if v[x-1]<0:
            c.append(v[x-1])
    ans=max(ans,chk[0])
    d=[]
    chk[1]=0
    for y in range(min(n,k)+1):
        if x+y>=k or x+y>=n:
            break
        if y>0:
            chk[1]+=v[-y]
            if v[-y]<0:
                d.append(v[-y])
        ans=max(ans,chk[0]+chk[1])
        e=c+d
        e.sort(reverse=True)
        t=0
        for z in range(k):
            if x+y+z>k or len(e)==0:
                break
            if z>0:
                t+=-(e[-1])
                e.pop()
                ans=max(ans,chk[0]+chk[1]+t)
print(ans)


Measured memory_bytes: 40048
n, m, x, y = map(int, input().split())
xn = list(map(int,input().split()))
ym = list(map(int,input().split()))
max_xn = max(xn)
min_ym = min(ym)
a = range(max_xn, min_ym+1)
ac = False
for i in a:
  if max_xn < i <= min_ym and x < i < y:
    ac = True
    break
if ac:
  print("No War")
else:
  print("War")
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
typedef vector<ll> vll;
typedef pair<ll, ll> Pll;

const int MAXN = 100000 + 10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll N, K;
    cin >> N >> K;
    unordered_map<ll, ll> hashMap;
    ll x;
    for (int i = 0; i < N; ++i) {
        cin >> x;
        ++hashMap[x];
    }
    ll capacity = hashMap.size() - K;
    if (capacity <= 0) {
        cout << 0 << endl;
        return 0;
    }
    priority_queue<pair<ll, ll>> que;
    for (auto p = hashMap.begin(); p != hashMap.end(); ++p) {
        if (que.size() == capacity) {
            if (que.top().first <= p->second) continue;
            que.pop();
        }
        que.push(pair<ll, ll>(p->second, p->first));
    }
    ll ans = 0;
    while (!que.empty()) {
        ans += que.top().first;
        que.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14020
def main():
    import sys
    input = sys.stdin.readline

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

    AA = [0] * (N+1)
    for i in range(N):
        AA[i+1] = AA[i] + A[i]

    ans = 10**15
    for i in range(1, N-2):
        L = AA[i+1]
        ok = i
        ng = -1
        mid = (ok+ng)//2
        while ok-ng > 1:
            if AA[mid+1] >= (L+1)//2:
                ok = mid
            else:
                ng = mid
            mid = (ok+ng)//2
        L_list = []
        if ok != 0:
            L_list.append((AA[ok], L - AA[ok]))
        if ok != i:
            L_list.append((AA[ok+1], L - AA[ok+1]))

        R = AA[-1] - L
        ok = N-1
        ng = i
        mid = (ok + ng) // 2
        while ok - ng > 1:
            if AA[mid+1] - AA[i+1] >= (R + 1) // 2:
                ok = mid
            else:
                ng = mid
            mid = (ok + ng) // 2
        R_list = []
        if ok != i+1:
            R_list.append((AA[ok] - AA[i+1], R - AA[ok] + AA[i+1]))
        if ok != N-1:
            R_list.append((AA[ok+1] - AA[i+1], R - AA[ok+1] + AA[i+1]))

        for p, q in L_list:
            for r, s in R_list:
                ans = min(ans, max(p, q, r, s) - min(p, q, r, s))
                #print(p,q,r,s)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 78980
#include <iostream>
#include <vector>
#include <string>
#define NIL (-1)
using namespace std;

/// LeftMost-Child Right-Sibling Tree
struct LCRSTreeNode {
	int p;// the parent
	int l;// the leftmost child
	int r;// the immediate right sibling 
	int d;// the depth of this node
	string type;// the type of this node; root, leaf, internal node
};

void print(vector<LCRSTreeNode> &T) {
	for (int i=0; i<T.size(); ++i) {
		// set type
		if (T[i].p == NIL) {
			T[i].type = "root";
		} else if (T[i].l == NIL) {
			T[i].type = "leaf";
		} else {
			T[i].type = "internal node";
		}	
		// node id: parent = p , depth = d, type, [c1...ck] 
		cout << "node " << i << ": parent = ";
		cout << T[i].p << ", depth = ";
		cout << T[i].d << ", ";
		cout << T[i].type << ", [";
	  int c = T[i].l;
		while (c != NIL) {
			cout << c;
			c = T[c].r;
			if (c != NIL) {
				cout << ", ";
			}
		}	
		cout << "]" << endl;
	}
}

void set_depth(int id, int depth, vector<LCRSTreeNode> &T) {
	if (id == NIL) return;
	T[id].d = depth;
	set_depth(T[id].r, depth,   T); 
	set_depth(T[id].l, depth+1, T);
}

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

	vector<LCRSTreeNode> T(n);
	for (int i=0; i<n; ++i) {
		T[i].p = T[i].l = T[i].r = NIL;
		T[i].d = NIL;
		T[i].type = "";
	}

	for (int i=0; i<n; ++i) {
		int id, k, child_id; 
		cin >> id >> k;
		if (k==0) continue;
		for (int j=0;j<k;++j) {
			cin >> child_id;
			T[child_id].p = id;
			int immediate_left_child_id;
			/// leftmost child
			if (j==0) {
				T[id].l = child_id;
			} else {
				/// immediate right siblings
				T[immediate_left_child_id].r = child_id;
			}
			immediate_left_child_id = child_id;
		}
	}

	/// find the root 
	int root_id = NIL;
	for (int i=0; i<n; ++i) {
		if (T[i].p == NIL) {
			root_id = i;
			break;
		}
	}

	/// set depths
	set_depth(root_id, 0, T);

	/// print
	print(T);
	return 0;
}





Measured memory_bytes: 12876
#include <bits/stdc++.h>
using namespace std;
#define rep(i, ns, ne) for (int i = ns; i < ne; ++i)
#define rep2(i, ns, ne) for (int i = ns; i <= ne; ++i)

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> v(N);
  rep(i, 0, N) { cin >> v[i]; }
  sort(v.begin(), v.end());
  for (auto s : v) {
    cout << s;
  }
  cout << endl;

  getchar();
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int cnt = 0;
  
  for(int i=0;i<N-1;i++){
    if(S.at(i)==S.at(i+1)) cnt++;
  }
  
  cout << N-cnt << endl;
}


Measured memory_bytes: 512
lst = [int(input()) for i in range(5)]
dit=[]
time=0
for i in range(5):
    x = lst[i]
    if lst[i]%10==0:
        y=0
    else:
        y=10-lst[i]%10
    dit.append([x,y])
dit_sorted=sorted(dit,key=lambda x:x[1])
for i in range(4):
    if dit_sorted[i][1]==0:
        time += dit_sorted[i][0]
    else:
        time += (dit_sorted[i][0]//10+1)*10
time += dit_sorted[4][0]
print(time)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define var long long int
#define make_pair mp
#define second  s
#define first f
using namespace std;
var n,k,a[1000005];
var dp[1000005];

var min_frog(var i){
	if(i == (n))	return 0;
	
	if(dp[i] != -1) return dp[i];
	
	var min_jump = INT_MAX;	
	for(int in=i+1;in<=min(n,i+k);in++){
		min_jump = min(min_jump , abs(a[i]-a[in]) + min_frog(in));
	}
	
	return dp[i] = min_jump;
}

signed main() {
	memset(dp,-1,sizeof(dp));
	cin >> n >> k;
	for(int i=1;i<=n;i++){
		cin >> a[i];
	}
	cout << min_frog(1) << endl;
	return 0;
}

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

int main(void){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    int count = 1;
    for(int i = 0; i< N; i++){
        if(a.at(i) == count){
            count++;
        }
    }
    if(count != 1){
        printf("%d\n", N - count + 1);
    }
    else{
        printf("-1\n");
    }
}

Measured memory_bytes: 1024
N = int(input())
S = input()

r = 0
g = 0
b = 0

for i in range(N):
    if S[i] == 'R':
        r += 1
    if S[i] == 'G':
        g += 1
    if S[i] == 'B':
        b += 1

rgb_tot = r*g*b
#print(rgb_tot)

for i in range(N):
    first = S[i]
    for j in range(i,N):
        if 2*j - i < N:
            if first != S[j] and first != S[2*j-i] and S[j] != S[2*j-i]:
                #print("%d %d %d" % (i,j,2*j-i))
                #print(rgb_tot)
                rgb_tot -= 1

print(rgb_tot)


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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  int a = N;
  int b = 10;
  for (int i;; i++) {
    int c = a % b;
    sum += c/(b/10);
    a = a - c;
    b *= 10;
    if (a < b/10) {
      break;
    }
  }
  if (N % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct node{
  unsigned int key;
  struct node *prev;
  struct node *next;
} Node;

void firstdelete(void);
void lastdelete(void);

Node *firstnode, *lastnode, *thisnode, *newnode;

void printlist(){
  thisnode = firstnode;
  while(1){
    if (thisnode == NULL) break;
    printf("%d", thisnode->key);
    if (thisnode->next != NULL) printf(" ");
    thisnode = thisnode->next;
  }
  printf("\n");
}

void insert(unsigned int key){
 Node  *newnode = (Node*)malloc(sizeof(Node));
   newnode->key = key;
   newnode->prev = NULL;
   if(firstnode != NULL){
     firstnode->prev = newnode;
     newnode->next = firstnode;
     firstnode = newnode;
   } else {
     firstnode = lastnode = newnode;
     newnode-> next  = NULL;
   }
   return;
}

void delete(unsigned int key){
  thisnode = firstnode;
  if(thisnode == NULL) return;

  while(thisnode->key != key){
    thisnode = thisnode->next;
    if(thisnode == NULL) return;
  }

  /*
  if(thisnode == firstnode && thisnode == lastnode){
    free(thisnode);
    firstnode = NULL;
    lastnode = NULL;
  }  
  else
  */
  if(thisnode == firstnode) firstdelete();
  else if (thisnode == lastnode) lastdelete();
  else{
    thisnode->prev->next = thisnode->next;
    thisnode->next->prev = thisnode->prev;
    free(thisnode);
  }
  return;
}

void firstdelete(void){
  thisnode = firstnode;
  if(thisnode == NULL) return;

  if(thisnode == firstnode && thisnode == lastnode){
    free(thisnode);
    firstnode = NULL;
    lastnode = NULL;
  } else {   
    firstnode = firstnode->next;
    firstnode->prev = NULL;
    free(thisnode);
  }
}

void lastdelete(void){
  thisnode = lastnode;
  if(thisnode == NULL) return;

  if(thisnode == firstnode && thisnode == lastnode){
    free(thisnode);
    firstnode = NULL;
    lastnode = NULL;
  }  else {
    lastnode = lastnode->prev;
    lastnode->next = NULL;
    free(thisnode);
  }
}

int main(void){
  int n, key, i;
  char com[20];
  scanf("%d",&n);

  
  for (i = 0; i<n; i++){
    scanf("%s", com);
    if(com[0] == 'i'){
      scanf("%d", &key);
      insert(key);
    }
    else if(com[0] == 'd')
      if(strlen(com) > 6){
	if(com[6] == 'F') firstdelete();
	else lastdelete();
      } else {
	scanf("%d", &key);
	delete(key);
      }
  }
  printlist();
  return 0;
}
  
    
       
  

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

int main(){
    string str1;
    string str2;
    cin>>str1;
    cin>>str2;
    int flag=0;
    for(int i=0;i<str1.size();i++){
        if (str1.at(i)!=str2.at(i)){
            flag=1;
        }
    }
    if (flag==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3628
#include <stdio.h>
#define N 200000
int main(){

  int n,i,j,minv,maxv,R[N];
  
  scanf("%d",&n);

  
  for(i=0;i<n;i++){
    scanf("%d",&R[i]);
  }

  maxv=R[1]-R[0];
  minv=R[0];
  for(j=1;j<n;j++){
    if(maxv<(R[j]-minv)) maxv=R[j]-minv;
    if(minv>R[j]) minv=R[j];
  }

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

    
}



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

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

vector<bool> ERA(long long n) {
    vector<bool> B(n + 1, true);
    B[0] = false;
    B[1] = false;
    for (long long i = 2; i <= n; i++) {
        if (B[i]) {
            for (long long j = i * 2; j <= n; j += i) B[j] = false;
        }
    }
    return B;
}

int main() {

    auto res = ERA(100010);
    vector<long long> primes;
    for (int i = 0; i < res.size(); i++) if (res[i]) primes.push_back(i);

    while (true) {

        long long N, A, B;
        cin >> N >> A >> B;

        if (!(N | A | B)) break;

        long long P = 2, Q = 2;
        for (int i = 0; i < primes.size(); i++) {
            for (int j = i; j < primes.size(); j++) {
                if (primes[i] * primes[j] > N) break;
                if (A * primes[j] > B * primes[i]) break;
                if (P * Q < primes[i] * primes[j]) P = primes[i], Q = primes[j];
            }
        }


        cout << P << " " << Q << endl;

    }

    return 0;
}






























































Measured memory_bytes: 3276
#include "bits/stdc++.h"
using namespace std;
int main()
{
	long long x, total;
	scanf("%lld", &x);
	total = x / 11;
	x -= 11 * total;
	if(x)
	{
		if(x <= 6)
		{
			(total *= 2) += 1;
		}
		else
		{
			(total += 1) *= 2;
		}
	}
	else
	{
		total *= 2;
	}
	printf("%lld\n", total);
}

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

import heapq

x, y, z, k = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

yam = []
for l in range(x):
    for m in range(y):
        for n in range(z):
            if k < len(yam) and a[l]+b[m]+c[n] <= yam[0]:
                break
            elif k < len(yam):
                heapq.heappushpop(yam, a[l]+b[m]+c[n])
            else:
                heapq.heappush(yam, a[l]+b[m]+c[n])
yam.sort(reverse=True)
#print(yam)

for l in range(k):
        print(yam[l])

Measured memory_bytes: 3700
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int x, y;
	cin>>x>>y;
	for(int i=0; i<=x; i++){
		if(y==2*i+4*(x-i)){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	int x;
	cin >> x;
	if (x == 0) cout << 1 << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 3568
#include <iostream>

using namespace std;

int
main()
{
  int n,k,s;
  
  cin >> n >> k >> s;
 
  if ( s < 1e9 ) {
    for ( int i = 0 ; i < k ; i++ ) {
      cout << s << ' ';
    }
    for ( int i = 0 ; i < n - k ; i++ ) {
      cout << 1000000000 << ' ';
    }
    cout << endl;
  } else {
    for ( int i = 0 ; i < k ; i++ ) {
      cout << s << ' ';
    }
    for ( int i = 0 ; i < n - k ; i++ ) {
      cout << 1 << ' ';
    }
    cout << endl;
  }
}




Measured memory_bytes: 1280
#include <iostream>
#include <cmath>

#define RADIUS 6378.1

double ground_dist(double a, double b, double c, double d)
{
	a *= M_PI / 180.0; b *= M_PI / 180.0; c *= M_PI / 180.0; d *= M_PI / 180.0;
	return RADIUS * std::acos(std::sin(a)*std::sin(c) + std::cos(a)*std::cos(c)*std::cos(d-b));
}

int main()
{
	double a, b, c, d;
	while (true) {
		std::cin >> a >> b >> c >> d;
		if (a==-1 && b==-1 && c==-1 && d==-1) break;
		//if (b>d && b-d > 180) b = 360 - b;
		//else if (d>b && d-b > 180) d = 360 - d;
		std::cout << std::round(ground_dist(a, b, c, d)) << std::endl;
	}
	return 0;
}



Measured memory_bytes: 3564
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  int n, m;
  cin >> n >> m;
  VI p(m), y(m);
  vector<vector<PI> > tr(n + 1);
  REP(i, 0, m) {
    cin >> p[i] >> y[i];
    tr[p[i]].push_back(PI(y[i], i));
  }
  vector<PI> ans(m);
  REP(i, 1, n + 1) {
    sort(tr[i].begin(), tr[i].end());
    REP(j, 0, tr[i].size()) {
      ans[tr[i][j].second] = PI(i, j + 1);
    }
  }
  REP(i, 0, m) {
    printf("%06d%06d\n", ans[i].first, ans[i].second);
  }
}


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


typedef long long ll;

int N,M,H,W,K,A,B,S,T;

using namespace std;

int main() {
  cin >> N;
  vector<int> c(N,0),v(N,0),m(N,0);
  for(int i = 0; i < N; i++)  cin >> v.at(i);
  for(int i = 0; i < N; i++)  cin >> c.at(i);
  for(int i = 0; i < N; i++)  m.at(i) = v.at(i) - c.at(i);
  sort(m.begin(),m.end());
  reverse(m.begin(),m.end());
  int i = 0,ans = 0;
  while(m.at(i) > 0){
    ans += m.at(i);
    i++;
    if(i == N) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
L = list(map(int, input().split()))

L.sort()
import bisect
ans = 0
for i in range(n-2):
    b = L[i]
    for j in range(i+1, n-1):
        c = L[j]
        p = bisect.bisect_left(L, b+c)
        #print(b, c, j, p, p-j-1)
        ans += max(p-j-1, 0)
print(ans)

Measured memory_bytes: 43884
N = int ( input().strip() ) ;
arr = list ( map ( int , input().strip().split(" ") ) ) ;

c0 = 0 ;
for v in arr :
	c0 = c0 ^ v ;

arr2 = list ( map ( lambda x:c0^x , arr ) ) ;
print ( " ".join(  map( str , arr2 ) ) ) ;

Measured memory_bytes: 41632
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    W, H = map(int, readline().split())
    if W == H == 0:
        return False
    S = [readline().strip() for i in range(H)]

    dd = ((-1, 0), (0, -1), (1, 0), (0, 1))

    sx = sy = gx = gy = 0
    for i in range(H):
        Si = S[i]
        for j in range(W):
            if Si[j] == "K":
                sy = i; sx = j
            elif Si[j] == "M":
                gy = i; gx = j
    ks = kg = 0
    for k in range(4):
        dx, dy = dd[k]
        if S[sy+dy][sx+dx] != "#":
            ks = k
        if S[gy+dy][gx+dx] != "#":
            kg = k

    dx, dy = dd[ks]
    sx1 = sx; sy1 = sy
    while S[sy1+dy][sx1+dx] != "#":
        sx1 += dx; sy1 += dy
    dx, dy = dd[kg]
    gx1 = gx; gy1 = gy
    while S[gy1+dy][gx1+dx] != "#":
        gx1 += dx; gy1 += dy

    N = W*H*4
    G0 = [[[] for i in range(2)] for j in range(N)]
    G1 = [[[] for i in range(2)] for j in range(N)]
    for i in range(H):
        for j in range(W):
            if S[i][j] == "#":
                continue
            for k in range(4):
                dx, dy = dd[k]
                x = j; y = i
                while S[y+dy][x+dx] != "#":
                    x += dx; y += dy
                dx1, dy1 = dd[k-1]
                if S[i+dy1][j+dx1] == "#":
                    p0 = (i*W + j)*4 + (k-1)%4
                    p1 = (y*W + x)*4 + k
                    G0[p0][1].append(p1)
                    G1[p1][1].append(p0)
                dx2, dy2 = dd[k-3]
                if S[i+dy2][j+dx2] == "#":
                    p0 = (i*W + j)*4 + (k+1)%4
                    p1 = (y*W + x)*4 + k
                    G0[p0][0].append(p1)
                    G1[p1][0].append(p0)
    used = set()
    que = deque()
    for k in range(4):
        if k != ks:
            s = ((sy1*W + sx1)*4 + ks, (sy*W + sx)*4 + k)
            que.append(s)
            used.add(s)
    while que:
        v1, v2 = que.popleft()
        for k in range(2):
            for w1 in G0[v1][k]:
                for w2 in G1[v2][k^1]:
                    s = (w1, w2)
                    if s in used:
                        continue
                    que.append(s)
                    used.add(s)
    ok = 0
    for k in range(4):
        if k != kg:
            s = ((gy*W + gx)*4 + k, (gy1*W + gx1)*4 + kg)
            if s in used:
                ok = 1
    if ok:
        write("He can accomplish his mission.\n")
        return True

    que = deque([(sy1*W + sx1)*4 + ks])
    used = [0]*N
    used[(sy1*W + sx1)*4 + ks] = 1
    while que:
        v = que.popleft()
        for w in G0[v][0]:
            if used[w]:
                continue
            used[w] = 1
            que.append(w)
        for w in G0[v][1]:
            if used[w]:
                continue
            used[w] = 1
            que.append(w)
    for k in range(4):
        if used[(gy*W + gx)*4 + k]:
            ok = 1
    if ok:
        write("He cannot return to the kitchen.\n")
    else:
        write("He cannot bring tea to his master.\n")
    return True
while solve():
    ...


Measured memory_bytes: 21916
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;


long long mod = 1000000007;
long long N;
int main()
{
    cin >> N;

    vector<long long> A(N);
    vector<long long> ones(60, 0);
    for (int i = 0; i < N;i++){
        cin >> A[i];
        for (int j = 0; j < 60; j++)
        {
            if (A[i] & (1ll << j))
                ones[j]++;
        }
    }
    long long ans = 0;

    for (int i = 0; i < 60;i++){
        ans += (((ones[i] % mod) * ((N - ones[i])%mod)%mod) * ((1ll << i)%mod)%mod);
    }
    ans = ans % mod;

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

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define mp make_pair
#define pb push_back
using namespace std;

//***********************************************************************

// // hash struct for unordered_map
// struct hash_pair { 
//     template <class T1, class T2> 
//     size_t operator()(const pair<T1, T2>& p) const
//     { 
//         auto hash1 = hash<T1>{}(p.first); 
//         auto hash2 = hash<T2>{}(p.second); 
//         return hash1 ^ hash2; 
//     } 
// };

// int MAXNUM = 5e3+5;
// vector <int>vis(MAXNUM);
// vector<int> pr;
// void sieve() {
// 	pr.push_back(2);
// 	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
// 		pr.push_back(i);
// 		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
// 	}
// }
// //************************************************************************

void solve()
{
    ll n,k;
    cin >> n >> k;
    vector<ll> v(n);
    for(int i=0;i<n;i++)
    cin >> v[i];

    for(int i=k;i<n;i++)
    {
        if(v[i]>v[i-k])
        cout << "Yes" << endl;
        else
        cout << "No" << endl;
    }
}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

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

int main(){

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

    int A;
    vector<int> player(N, K-Q);
    rep(i, Q){
        cin >> A;
        player[A-1] += 1;
    }

    for(int porson : player){
        if(porson > 0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll H, A, ans;
    scanf("%lld %lld", &H, &A);
    ans = H/A;
    if ( H % A != 0 ) ans++;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
# B - Shiritori
N = int(input())
W = [str(input()) for _ in range(N)]

ans = "Yes"
for i in range(N-1):
    if W.count(W[i]) > 1:
        ans = "No"
        break
    if W[i][-1] != W[i+1][0]:
        ans = "No"
        break

print(ans)


Measured memory_bytes: 9092
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }

map <char, ll> po;
char name[5] = { 'M', 'A', 'R', 'C', 'H' };
ll N;
ll dfs(ll i, ll count) {
	if (i == 5) return count == 3 ? 1 : 0;
	return po[name[i]] * dfs(i + 1, count + 1) + dfs(i + 1, count);
}

int main() {
	cin >> N;
	rep(i, N) {
		string s;
		cin >> s;
		++po[s[0]];
	}

	cout << dfs(0, 0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

#define MAX 1000001

vector<int> vprimes;
bool *isPrime = new bool[MAX];

/* ツ素ツ青板青カツ青ャ O(n^2) */
void MakePrime(){
  isPrime[0]=false;
  isPrime[1]=false;
  isPrime[2]=true;
  for(int i = 2; i < MAX; ++i){
    isPrime[i] = true;
  }
  for(long long int i = 2; i < MAX; ++i){
    if( isPrime[i] ){
      for(long long int j = 2; i * j < MAX; ++j) {
	isPrime[i*j] = false;
      }
    }
  }
  for(int i = 0; i < MAX; ++i){
    if( isPrime[i] ){
      vprimes.push_back( i );
    }
  }
}

int main(){
  MakePrime();
  while(true){
    int n;
    int cnt = 0;
    bool same=false;
    cin >> n;
    if( n == 0 ) break;
    for(int i = 1; i < vprimes.size() && vprimes[i] < n - 2; ++i){
      if( isPrime[ n - vprimes[i] ] ){
	cnt++;
	if( n - vprimes[i] == vprimes[i] ){--cnt;same=true;}
      }
    }
    cnt/=2;
    cout << cnt+same << endl;
  }
  return 0;
}

Measured memory_bytes: 2324
def main():
    n, m = (int(i) for i in input().split())
    graph = { i: [] for i in range(1, n+1) }

    for i in range(m):
        src, dst = (int(i) for i in input().split())
        graph[src].append(dst)
        graph[dst].append(src)

    def bfs():
        st = [1] 
        pptr = { 1: 0 }

        while st:
            room = st.pop(0)
            for dest_room in graph[room]:
                if dest_room in pptr:
                    continue
                st.append(dest_room)
                pptr[dest_room] = room

        return pptr

    pptr = bfs()
    if len(pptr) != n:
        print('No')

    else:
        print('Yes')
        for i in sorted(pptr.keys()):
            if i == 1:
                continue
            print(pptr[i])

main()


Measured memory_bytes: 50324
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
#define N 200010
typedef long long ll;
inline ll read(){
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,l[N],r[N];
ll a[N],b[N],c[N];
double ans;
void init(){
	int k=max_element(a+1,a+n+1)-a;
	rotate(a+1,a+k,a+n+1);
	rotate(b+1,b+k,b+n+1);
	a[n+1]=a[1];
	c[1]=c[2]=0;
	for(int i=3;i<=n+1;++i){
		c[i]=2*(b[i-1]+c[i-1])-c[i-2];
		a[i]-=c[i];
	}
}
struct Point{
	ll x,y;
	Point(ll _x=0,ll _y=0){x=_x,y=_y;}
	inline Point operator + (const Point b){
		return Point(x+b.x,y+b.y);
	} 
	inline Point operator - (const Point b){
		return Point(x-b.x,y-b.y);
	}
	inline ll operator % (const Point b){
		return x*b.y-y*b.x;
	}
	inline bool operator < (const Point b){
		return y==b.y?x<b.x:y<b.y;
	}
	inline __int128 len2(){
		return x*x+(__int128)y*y;
	}
}p[N];
typedef vector<Point> Poly;
inline bool Para(Point a,Point b){
	return b%a==0;
}
inline bool Left(Point a,Point b){
	return b%a>0;
}
Poly A,B;
Poly Convex(Poly &a){
	Point LTL=(*min_element(a.begin(),a.end()));
	sort(a.begin(),a.end(),[&](Point a,Point b){
		a=a-LTL,b=b-LTL;
		return Para(a,b)?a.len2()<b.len2():Left(b,a);
	});
	static Point st[N];
	static int top;
	top=0;
	for(int i=0;i<(int)a.size();++i){
		while(top>1&&!Left(a[i]-st[top-1],st[top]-st[top-1]))--top;
		st[++top]=a[i];
	}
	Poly ans;
	st[top+1]=st[1];
	for(int i=1;i<=top;++i){
		if((st[i+1]-st[i]).x<=0)ans.push_back(st[i]);
	}
	return ans;
}
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
	}
	for(int i=1;i<=n;++i){
		b[i]=read();
	}
	init();
	A.emplace_back(0,0);
	for(int i=1;i<=n+1;++i){
		A.emplace_back(i,a[i]);
	}
	B=Convex(A);
	l[0]=0,r[n+1]=n+1;
	for(auto p:B)l[p.x]=r[p.x]=p.x;
	for(int i=1;i<=n;++i)if(!l[i])l[i]=l[i-1];
	for(int i=n;i>=1;--i)if(!r[i])r[i]=r[i+1];
	for(int i=1;i<=n;++i){
		ans+=c[i];
		if(l[i]==r[i])ans+=a[i];
		else{
			int len=r[i]-l[i];
			ans+=((i-l[i])*a[r[i]]+(r[i]-i)*a[l[i]])*1.0/len;
		}
	}
	printf("%.12lf\n",ans/n);
	return 0;
}



Measured memory_bytes: 22592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
string f (ll n) {
    if(n == 0) return "";
    //-1
    n--;
    return f(n/26) + string(1,'a'+n%26);
}
 
int main() {
    ll n;
    cin>>n;
 
    cout<< f(n)<<endl;
    return 0;
}

Measured memory_bytes: 3600
# abc 154
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N = int(readline().strip())
A = list(map(int, readline().split()))

if len(A) == len(set(A)):
  print('YES')
else:
  print('NO')

Measured memory_bytes: 24084
#include<iostream>
#include<ctype.h>
#include <stdio.h>
#define _CRT_SECURE_NO_WARNINGS

using namespace std;

int main()
{
	int a, b;
	char s[60];

	cin >> a >> b;

	for (int i = 0; i < a;i++) {

		cin >> s[i];
	}

	s[b - 1] = tolower(s[b - 1]);

	
	for (int i = 0; i < a;i++) {
		cout << s[i];
	}

	cout << endl;

		return 0;
}

Measured memory_bytes: 1016
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define hashset unordered_set
#define hashmap unordered_map
#define getbit(x, i) (((x) >> (i)) & 1)
using namespace std;
typedef pair<int, int> pii; 
template <typename T>
inline vector<T> readvector(size_t size) {
    vector<T> res(size);
    for (size_t i = 0; i < size; ++i) {
        cin >> res[i];
    }
    return res;
}
template <typename T>
inline void printvector(vector<T>& arr, string sep = " ", string ends = "\n") {
    for (size_t i = 0; i < arr.size(); ++i) {
        cout << arr.at(i) << sep;
    }
    cout << ends;
}
inline int binPow(int x, int deg, int mod) {
    int ans = 1;
    for (int i = sizeof(x) * CHAR_BIT - 1; i >= 0; i--) {
        ans *= ans;
        ans %= mod;
        if (getbit(deg, i)) ans *= x;
        ans %= mod;
    }
    return ans;
}
// ====================== END ======================
const int MAXN = 1e5 + 10;
const int MOD = 1e9 + 7;


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

    int n;
    cin >> n;
    auto arr = readvector<int>(n);
    int mn = 1e9;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cnt += arr[i] < mn;
        mn = min(arr[i], mn);
    }
    cout << cnt << endl;

    return 0;
}   

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
 
typedef long long ll;

#define rep(i,n) for(ll i = 0; i < n; i++)
 
using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

int main(){
  int n, ans=0;
  cin >> n;
  for(int i=1; i<=n; i++){
    if(i%2==0) continue;
    int num=0;
    for(int k=1; k<=i; k++){
      if(i%k == 0) num++;
    }
    if(num==8) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <cstdlib>
#include <random>
#include <chrono>
#include<iterator>
#include <locale>
 
/*,---.   ,--.                          ,--.
'   .-'  |  ,---.  ,--.,--. ,--.  ,--. `--'
`.  `-.  |  .-.  | |  ||  |  \  `'  /  ,--.
.-'    | |  | |  | '  ''  '   \    /   |  |
`-----'  `--' `--'  `----'     `--'    `--'*/
 
using namespace std;   
int n;
long long f(int pos, vector<long long> vals){
    if(pos == -1){
        return 0;
    }
    int zero = 0;
    int one = 0;
    vector<long long> zeroVal;
    vector<long long> oneVal;
    for(int i = 0;i<vals.size();i++){
        if(((vals[i])&(1<<pos)) != 0){
            oneVal.push_back(vals[i]);
        }else{
            zeroVal.push_back(vals[i]);
        }
    }
    if(zeroVal.size() == 0 || oneVal.size() == 0){
        return f(pos - 1, vals);
    }else{
        return min(f(pos - 1, zeroVal), f(pos - 1, oneVal)) + (1<<pos);
    }

}
int dp[200047];
int main(){
    cin >> n;
    vector<long long> value(n);
    for(int i = 0;i<n;i++){
        cin >> value[i];
    }
    dp[1] = abs(value[0] - value[1]);
    for(int i = 2;i<n;i++){
        dp[i] = min(dp[i-1] + abs(value[i] - value[i-1]), dp[i-2] + abs(value[i] - value[i-2]));
    }
    cout<<dp[n-1];
    
    

}

Measured memory_bytes: 1408
#include <cstdio>
#include <vector>

using namespace std;

int max(int a, int b)
{
	return (a > b ? a : b);
}

int max(int a, int b, int c)
{
	return max(max(a, b), c);
}

int min(int a, int b)
{
	return (a < b ? a : b);
}

int min(int a, int b, int c)
{
	return min(min(a, b), c);
}

int main()
{
	int H, W, max_ = 0;

	scanf("%d", &H);
	scanf("%d", &W);

	vector<vector<int> > c(H, vector<int>(W));

	vector<vector<int> > dp(H, vector<int>(W, 0));

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			scanf("%d", &c[i][j]);

			if (c[i][j] == 0)
			{
				if (i == 0 || j == 0)
				{
					dp[i][j] = 1;
				}

				max_ = 1;
			}
		}
	}

	for (int i = 1; i < H; i++)
	{
		for (int j = 1; j < W; j++)
		{
			if (c[i][j] == 0)
			{
				dp[i][j] = min(dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]) + 1;

				max_ = max(dp[i][j], max_);
			}
		}
	}

	printf("%d\n", max_ * max_);

	return 0;
}

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a,b;
	cin>>a>>b;
	if (b>=a){
		cout<<a;
	}
	else {
		cout<<a-1;
	}
	return 0;
}

Measured memory_bytes: 256