akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007

int main(){
    string s;
    cin >> s;
    bool flag=true;
    int l=s.length();
    int count=0;
    if(s.front()!='A') flag=false;
    for(int i=0;i<l;i++){
        if(s[i]=='C') count++;
        if(i<2||i==l-1){
            if(s[i]=='C') flag=false;
        }
        if('A'<=s[i]&&s[i]<='Z'){
            if(!(s[i]=='A'||s[i]=='C')) flag=false;
        }
    }
    if(count!=1) flag=false;
    if(flag) cout <<"AC" <<endl;
    else cout <<"WA"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <utility>

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,a,b) for(ll i=(a); i < (b); i++)
#define RFOR(i,a,b) for(ll i=(b)-1; i >= (a); i--)
#define rep(i,n) FOR(i,0,(n))
#define rrep(i,n) RFOR(i,0,(n))

int main() {
	int N;
	cin >> N;
	vector<string> S(N);
	rep(i,N) cin >> S[i];
	int res = 0;
	rep(A,N) {
		bool flg = true;
		vector<string> s(S);
		for(int i = 0; i < N; i++)
			s[i] = S[(i+A)%N];

		for(int i = 0; i < N && flg; i++) {
			for(int j  = 0; j < N && flg; j++) {
				if(s[i][j] != s[j][i]) {
					flg = false;
				}
			}
		}
		if(flg) res += N;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 512
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
di = {}
for i in a:
    if i in di:
        di[i] += 1
    else:
        di[i] = 1
ans = 0
for i in di.values():
    ans += i%2
print(ans)

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

int main()
{
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3852
#include<stdio.h>
#include<stdlib.h>

int main()
{
    int n,q,cnt =0;
    scanf("%d",&n);
    int *S = malloc(sizeof(int)*n);
    for(int i=0;i<n;i++) scanf("%d",&S[i]);
    scanf("%d",&q);
    int *T = malloc(sizeof(int)*q);
    for(int i=0;i<q;i++) scanf("%d",&T[i]);
    int r,l,s;
    for(int i=0;i<q;i++)
    {
        r = n;
        l = 0;
        while(l<r)
        {
            s = (r+l)/2;
            if(T[i]==S[s])
            {
                cnt++;
                break;
            }
            else
            {
                if(S[s]<T[i])
                {
                    l = s+1;
                }
                else
                {
                    r = s;
                }
            }
        }
    }
    printf("%d\n",cnt);
    free(T);
    free(S);
}


Measured memory_bytes: 2120
D, G = [int(_) for _ in input().split()]

p = [[i*100] + [int(_) for _ in input().split()] for i in range(1, D+1)]
p.sort(reverse=True)

def dfs(pos, total, maxpos, count, ans):
    if total >= G:
        if count < ans:
            return count
    if pos >= D:
        if maxpos < D:
            for i in range(1, p[maxpos][1]+1):
                if total + i * p[maxpos][0] >= G:
                    if count + i < ans:
                        return count + i
        return ans

    ans1 = dfs(pos+1, total, maxpos, count, ans)
    ans2 = dfs(pos+1, total+p[pos][0]*p[pos][1]+p[pos][2],
            maxpos+1 if pos==maxpos else maxpos, count+p[pos][1], ans)

    return min(ans, ans1, ans2)

print(dfs(0,0,0,0,10000))


Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	s := getString()
	ans := len(s)
	for i := 0; i < 2; i++ {
		cur := i
		cnt := 0
		for j := 0; j < len(s); j++ {
			if s[j] != '0'+byte(cur) {
				cnt++
			}
			cur = (cur + 1) % 2
		}
		ans = min(ans, cnt)
	}
	out(ans)
}


Measured memory_bytes: 2104
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  //
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<vector<ll> > data(N + 1, vector<ll>(500, 0));
  vector<vector<ll> > sum(N + 1, vector<ll>(500, 0));
  rep(i, M) {
    int l, r;
    cin >> l >> r;
    data[l][r]++;
  }
  REP(i, 0, N) {
    REP(j, 0, N) {
      sum[i + 1][j + 1] =
          sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + data[i + 1][j + 1];
    }
  }
  rep(i, Q) {
    int p, q;
    cin >> p >> q;
    cout << sum[q][q] - sum[p - 1][q] - sum[q][p - 1] + sum[p - 1][p - 1]
         << endl;
  }
  return 0;
}


Measured memory_bytes: 4864
import sys
n,d,a=map(int,input().split())
xh=[]
xx=[]
for i in range(n):
    x,h=map(int,input().split())
    xx.append(x)
    xh.append((x,h//a+(h%a>0)))
xh.sort()
xx.sort()
dp=[0]*n
import bisect
buf=0
count=0
if d==0:
    for i in range(n):
        count+=xh[i][1]
    print(count)
    sys.exit()
for i in range(n):
    #print(buf)
    buf+=dp[i]
    y=max(xh[i][1]-buf,0)
    count+=y
    buf+=y
    idx=bisect.bisect_left(xx,xx[i]+2*d+1)
    if idx>=n:
        continue
    dp[idx]-=y
    #print(dp,y,buf)
print(count)

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; cin >> N >> K;
    double ans = 0.0;
    for(int i = 1; i <= N; i++){
        int cnt = 0;
        int val = i;
        while(val < K){
            val *= 2;
            cnt++;
        }
        double res = 1;
        ans += res / (1 << cnt);
    }
    printf("%.10f\n", ans/N);
    return 0;
}

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

int main()
{
	int N,Y;
	int x;
	
	cin >> N >> Y;
	Y/=1000;
	
	for(int i=0;i<=N;i++)
	{
		for(int j=0;j<=N;j++)
		{
			x=N-i-j;
			if(x<0)break;
			
			if(10*i+5*j+x==Y)
			{
				cout << i << " " << j << " " << x << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

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

int main() {
  /* 入力受け取り */
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  /* しゃくとり法 */
  ll res = 0;
  int right = 0;
  int sum = 0;  // AND 和
  rep(left, n) {
    while (right < n && (sum ^ a[right]) == (sum + a[right])) {
      sum += a[right];
      ++right;
    }
    res += right - left;
    if (left == right)
      ++right;
    else {
      sum -= a[left];  // a[left] を削除 (sum ^= a[left] でも OK)
    }
  }

  cout << res << endl;
}

Measured memory_bytes: 4016
N=int(input())
H=input()
word=[]
word.append(H)
for i in range(N-1):
  S=input()
  if S in word:
    print('No')
    exit()
  else:
    if H[-1]==S[0]:
      H=S
      word.append(H)
    else:
      print('No')
      exit()
print('Yes')

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

int main (){
  int N;
  string S,T;
  cin >>N;
  cin >>S>>T;
  string U;
  for(int i = 0;i<N;i++){
    U +=S.at(i);
    U +=T.at(i);
  }
  cout << U <<endl;
}
    

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

using namespace std;

// いま見ている頂点をiとすると左の子は2*i、右の子は2*i+1となる

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

  vector<int> v(H + 1);
  for (int i = 1; i <= H; i++)
  {
    cin >> v[i];
  }

  for (int i = 1; i <= H; i++)
  {
    int val = v[i];
    int pa = -INT_MAX;
    int left = -INT_MAX, right = -INT_MAX;

    if (i * 2 <= H)
    {
      left = v[i * 2];
    }
    if (i * 2 + 1 <= H)
    {
      right = v[i * 2 + 1];
    }
    if (i / 2 > 0)
      pa = v[i / 2];

    cout << "node " << i << ": key = " << val << ", ";
    if (pa != -INT_MAX)
      cout << "parent key = " << pa << ", ";
    if (left != -INT_MAX)
      cout << "left key = " << left << ", ";
    if (right != -INT_MAX)
      cout << "right key = " << right << ", ";

    cout << endl;
  }
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int n, k;
	cin >> n >> k;
 
	int a[n];
	rep(i, n) cin >> a[i];
 
	bool dp[k+1];
	// dp[i]:石が残りi個のとき、先手が勝てるか
	rep(i, k+1) dp[i] = false;
 
	for(int i = 1; i <= k; i++){
		for(int j = 0; j < n; j++){
			if(i >= a[j]){
				dp[i] |= !dp[i-a[j]];
			}
		}
	}
 
	cout << (dp[k] ? "First" : "Second") << endl;
}

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

int main(){
  int n;
  string s, t;
  cin >> n >> s >> t;
  for(int i = n; i > 0; i--){
    int count = 0;
    for(int j = 0; j < i; j++){
      if(s.at(n - i + j) == t.at(j)) count++;
    }
    if(count == i){
      cout << 2 * n - i;
      return 0;
    }
  }
  cout << 2 * n;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
int main(){
  string S , T;
  cin >> S >> T;
  for (int i = 0; i < T.size() - 1; i++){
    if( S[i] != T[i] ){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout <<"Yes"<<endl;
}

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

int main(){
  string s;
  cin >> s;
  int m=0,n=s.size()-1;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='A')
      break;
    m++;
  }
  for(int i=0;i<s.size();i++){
    if(s.at(n)=='Z')
      break;
    n--;
  }
  cout << n-m+1 << endl;
}

Measured memory_bytes: 3716
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=101000;
int n,f[N],dp[N];
VI r[N],s[N];
void dfs(int u) {
	r[u].clear();
	for (auto v:s[u]) {
		dfs(v);
		r[u].pb(dp[v]);
	}
	sort(all(r[u]));
	reverse(all(r[u]));
	rep(i,0,SZ(r[u])) {
		dp[u]=max(dp[u],r[u][i]+i+1);
	}
}
int main() {
	scanf("%d",&n);
	rep(i,2,n+1) {
		scanf("%d",f+i);
		s[f[i]].pb(i);
	}
	dfs(1);
	printf("%d\n",dp[1]);
}


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

void dfs(int num, vector<ll>& w, map<int, set<pair<int, ll>>>& mp, vector<bool>& bmp)
{
    if(bmp[num]) return;
    bmp[num] = true;
    set<pair<int, ll>> now = mp[num];
    for(auto itr = now.begin(); itr != now.end(); itr++)
    {
        if(bmp[itr->first]) continue;
        w[itr->first] += w[num] + itr->second;
        dfs(itr->first, w, mp, bmp);
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    map<int, set<pair<int, ll>>> mp;
    for(int i=0; i<N-1; i++)
    {
        int u, v;
        ll w;
        cin >> u >> v >> w;
        u--; v--;
        mp[u].emplace(v, w);
        mp[v].emplace(u, w);
    }

    vector<ll> w(N, 0);
    vector<bool> bmp(N, false);
    for(int i=0; i<N; i++)
    {
        dfs(i, w, mp, bmp);
    }

    for(int i=0; i<N; i++)
    {
        // cout << i+1 << ' ' << w[i] << endl;
        if(w[i]%2) cout << "1\n";
        else cout << "0\n";
    }

    return 0;
}


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

#define ten(n) ((int)1e##n)
#define uni(x) x.erase(unique(all(x)),x.end())
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// dump macro{{{
// http://www.creativ.xyz/dump-cpp-652
#define DUMPOUT cerr // 変数ダンプ先。coutかcerr

#ifdef PCM
// 引数はいくつでもどんな型でも可（ストリーム出力演算子があればOK）
#define dump(...) DUMPOUT<<"  "; \
  DUMPOUT<<#__VA_ARGS__; \
  DUMPOUT<<":=> "; \
  dump_func(__VA_ARGS__); DUMPOUT<<"in ["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl;
#define dump_1d(x,n) DUMPOUT <<"  " \
  <<#x<<"["<<#n<<"]"<<":=> {"; \
  rep(i,n){ DUMPOUT << x[i] << (((i)==(n-1))?"}":", "); } DUMPOUT <<" in [" << __LINE__ << "]" << endl;

#define dump_2d(x,n,m) DUMPOUT <<"  " \
    <<#x<<"["<<#n<<"]"<<"["<<#m<<"]"<<":=> \n"; \
    rep(i,n)rep(j,m){ DUMPOUT << ((j==0)?"     |":" ") << x[i][j] << (((j)==(m-1))?"|\n":" "); } \
    DUMPOUT <<"  in [" << __LINE__ << "]" << endl;
#else
#define dump(...) 42
#define dump_1d(...) 42
#define dump_2d(...) 42
#endif

// デバッグ用変数ダンプ関数
void dump_func() {
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail)
{
    DUMPOUT << head;
    if (sizeof...(Tail) == 0) {
        DUMPOUT << " ";
    }
    else {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i<vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}/*}}}*/

#define rep(i, x) for(int i = 0; i < (int)(x); i++)/*{{{*/
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define foreach(x,a) for(auto& (x) : (a) )
#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define INF 2147483647
#define INFLL 1000000000000000000LL
#define MOD 1000000007/*}}}*/

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;/*{{{*/
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<pii,vii,greater<pii> > spq;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*}}}*/

//--------------------------------------------------------------------------

int main() {
  int n;cin>>n;
  cout << (n%2 ? 2*n: n) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t,u;
    cin>>s;
    cin>>t;
    int a,b;
    cin>>a>>b;
    cin>>u;
    if(u==s){a--;}
    else b--;
    cout<<a<<" "<<b;
    return 0;

}

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

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

using namespace std;

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

	int ans=0;
	rep(i,n) if(i==n-1 || s[i]!=s[i+1]) ans++;
	cout<<ans<<endl;

	return 0;
}


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

int main(){

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

    // f(x)     = floor( A * x / B ) - A * floor( x / B )
    // f(x+B)   = floor( A * (x+B) / B) - A * floor( (x+B) / B )
    //          = floor( A * x / B + A * B / B) - A * floor( x / B + B / B )
    //          = floor( A * x / B + A ) - A * floor( x / B + 1 )
    //          = floor( A * x / B ) + A - A * floor( x / B ) - A * 1       // Aや1 は整数なので floor の外に出せる
    //          = floor( A * x / B ) - A * floor( x / B )                   // したがって f(x+B) = f(x) で周期的

    // 定義域 0 <= x <= B-1 で f(x) を調べる
    // f(x)     = floor( A * x / B ) - A * floor( x / B )
    // x < B のとき x/B < 1 なので floor( x/B ) = 0
    // したがって、 f(x) = floor( A * x / B )

    // A * x / B は単調増加なので
    // f(x) = floor( A * x / B ) は 広義単調増加。
    // x最大となる値 x = B-1 で求めれば良い。ただし x <= N という条件があるので
    // x = min( B-1, N ) となる

    cout << min(B-1,N)*A/B << endl;

    return 0;
}


Measured memory_bytes: 3624
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int[] A = new int[N];
		ArrayList<Integer> exsist = new ArrayList<Integer>();
		boolean exis[] = new boolean[N];
		for (int i = 0; i < N; i++) {
			A[i] = scn.nextInt();
		}
		for (int i = N; i > 0; i--) {
			int sum = 0;
			for (int j = i * 2; j <= N; j += i) {
				if (exis[j - 1])
					sum++;
			}
			if (sum % 2 != A[i - 1]) {
				exsist.add(i);
				exis[i - 1] = true;
			}
		}
		System.out.println(exsist.size());
		for (int i = exsist.size(); i > 0; i--) {
			System.out.print(exsist.get(i - 1) + ((i == 1) ? "" : " "));
		}
	}

}

Measured memory_bytes: 95404
import java.util.*;
import java.io.*;
import static java.lang.System.*;

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int ans = 0;
    int cnt = 1;
    while(cnt < B){
      cnt += A - 1;
      ans++;
    }
    out.println(ans);
  }
}

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

template<typename G>
void print(vector<G> v) {
    rep(i, v.size()) {
        if (i != 0) cout << " ";
        cout << v[i];
    }
    cout << endl;
}

template<typename T>
void print(vector<vector<T>> v) {
    rep(i, v.size()) {
        print(v[i]);
    }
}


void solve() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> g(h, vector<char>(w));
    vector<vector<int>> field(h, vector<int>(w, -1));

    int cnt = 1;
    rep(i, h) {
        rep(j, w) {
            cin >> g[i][j];
            if (g[i][j] == '#') field[i][j] = cnt++;
        }
    }

    // print(g);
    // cout << endl;
    // print(field);

    rep(i, h) {
        rep(j, w-1) {
            if (field[i][j+1] < 0) field[i][j+1] = field[i][j];
        }
        for (int j = w-1; j > 0; j--) {
            if (field[i][j-1] < 0) field[i][j-1] = field[i][j];
        }
    }

    rep(j, w) {
        rep(i, h-1)
            if (field[i+1][j] < 0) field[i+1][j] = field[i][j];
        for (int i = h-1; i > 0; i--) {
            if (field[i-1][j] < 0) field[i-1][j] = field[i][j];
        }
    }

    // cout << endl;
    print(field);
}

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


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;


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

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

typedef long long ll;
typedef pair<ll, ll> P;
const int mod = 1e9 + 7;
ll N;

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};


int main() {
    cin >> N;
    Sieve s(10000);

    int cnt = 0;
    vector<ll> ans;
    for (int i = 11; i < 10000; i += 10) {
        if (s.isPrime(i)) {
            ans.push_back(i);
            cnt++;
        }

        if (cnt == N) break;
    }

    rep(i, N) {
        printf("%d%c", ans[i], (i == N - 1 ? '\n' : ' '));
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M = 1e9+7;

ll bd[10000][100], d;
string s;

int main() {
	getline(cin, s);
	cin >> d;
	memset(bd, 0, sizeof(bd));
	bd[0][0] = 1;
	for (int i=1; i<s.length(); i++) {
		for (int j=0; j<10; j++) {
			bd[i][0] += bd[i-1][(10*d-j)%d];
			bd[i][0] %= M;
		}
		for (int j=1; j<d; j++) {
			bd[i][j] = bd[i][j-1]+bd[i-1][j]-bd[i-1][(j-10+10*d)%d]+M;
			bd[i][j] %= M;
		}
	}
	ll cnt = 0;
	ll sum = 0;
	for (int i=0; i<s.length(); i++) {
		for (int j=0; j<s[i]-'0'; j++) {
			cnt += bd[s.length()-1-i][((-sum-j)%d+d)%d];
			cnt %= M;
		}
		sum += s[i]-'0';
	}
	cnt += bd[0][sum%d];
	cout << (cnt-1+M)%M << "\n";
}

Measured memory_bytes: 8064
immutable long mod=998244353;
immutable int M=1_000_00*4;

void main(){
  import std.stdio, std.algorithm;
  
  long n, a, b, k; rd(n, a, b, k);

  auto fact=genFact(M, mod);
  auto invFact=genInv(fact, mod);

  long comb(long nn, long rr){
    if(nn<rr) return 0;
    long ret=fact[nn]%mod;
    (ret*=invFact[rr])%=mod;
    (ret*=invFact[nn-rr])%=mod;
    return ret;
  }

  long tot=0;
  for(long x=0; x<=n; x++)if(k-a*x>=0){
    if((k-a*x)%b==0){
      long y=(k-a*x)/b;
      if(y>n) continue;
      (tot+=comb(n, x)*comb(n, y)%mod)%=mod;
    }
  }
  writeln(tot);
}

long[] genFact(int n, long mod){
  auto fact=new long[](n);
  fact[0]=fact[1]=1;
  foreach(i; 2..n) fact[i]=i*fact[i-1]%mod;
  return fact;
}

long[] genInv(long[] arr, long mod){
  auto inv=new long[](arr.length);
  inv[0]=inv[1]=1;
  foreach(i, elem; arr[1..$]) inv[i]=powmod(arr[i], mod-2, mod);
  return inv;
}

long powmod(long a, long x, long mod){
  if(x==0) return 1;
  else if(x==1) return a;
  else if(x&1) return a*powmod(a, x-1, mod)%mod;
  else return powmod(a*a%mod, x/2, mod);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 9468
let (n1, n2, n_limit) = (4, 16, 45)

let area =
  [| [1; 4]; [0; 2; 5]; [1; 3; 6]; [2; 7]
   ; [0; 5; 8]; [1; 4; 6; 9]; [2; 5; 7; 10]; [3; 6; 11]
   ; [4; 9; 12]; [5; 8; 10; 13]; [6; 9; 11; 14]; [7; 10; 15]
   ; [8; 13]; [9; 12; 14]; [10; 13; 15]; [11; 14] |]

let goal = Array.init n2 (fun i -> (i + 1) mod n2)

let md = Array.make_matrix n2 n2 0

let initialize_md () =
  for i = 0 to n2 - 2 do
    for j = 0 to n2 - 1 do
      md.(i+1).(j) <- abs (i / n1 - j / n1) + abs (i mod n1 - j mod n1)
    done
  done

let idastar a limit space lower =
  let rec doit i space moved lower =
    if i = limit then
      if a <> goal then ()
      else begin
        List.length moved |> Printf.printf "%d\n";
        exit 0;
      end
    else
      List.iter (fun j ->
        let x = a.(j) in
        match moved with
        | y :: _ when y = x -> ()
        | moved ->
          let lower = lower - md.(x).(j) + md.(x).(space) in
          if lower + i > limit then ()
          else begin
            a.(j) <- 0;
            a.(space) <- x;
            doit (i + 1) j (x :: moved) lower;
            a.(j) <- x;
            a.(space) <- 0;
          end)
      area.(space) in
  doit 0 space [] lower

let findi a x =
  let n = Array.length a in
  let rec doit i =
    if i = n then assert false
    else if a.(i) = x then i
    else doit (i + 1) in
  doit 0

let () =
  initialize_md ();
  let a = Array.init n2 (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let space = findi a 0 in
  let lower =
    Array.fold_left (fun (i, sum) e -> (i + 1, sum + md.(e).(i))) (0, 0) a |> snd in
  for limit = lower to n_limit do
    idastar a limit space lower
  done

Measured memory_bytes: 4500
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long L;

int main()
{
	//ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> L;
	long long tmp = L * L;
	tmp *= L;
	double ans = (double)tmp / 27.0;
	printf("%.10f\n", ans);
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
x1,y1,x2,y2 = map(int,input().split())

xy = [[x1,y1],[x2,y2]]

vec = [x2-x1,y2-y1]

A = [[0,-1],[1,0]]

for i in range(2):
    vec[0],vec[1] = A[0][0]*vec[0]+A[0][1]*vec[1],A[1][0]*vec[0]+A[1][1]*vec[1]
    xy.append([xy[-1][0]+vec[0],xy[-1][1]+vec[1]])

ans = ""
for i in range(2,4):
    ans += " ".join(map(str,xy[i]))
    ans += " "

print(ans[:-1])


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } else return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } else return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;

int N;
int A[3000];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", A + i);
	ll ans = 0;
	REP(i, N) ans += A[i] - 1;
	
	cout << ans << endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int h, n;

vector<i64> dp(20005,giant);

//inputします
void input() {
	cin >> h >> n;
	dp[0] = 0;
	ff(i, 0, n) {
		int a, b;
		cin >> a >> b;
		ff(j, 0, h) {
			int s = min(h, j + a);
			dp[s] = min(dp[j] + b, dp[s]);
		}
	}
	cout << dp[h] << endl;
}

//ライブラリ置き場



//main
int main() {
	input();
	
	return 0;
}

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

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

    int res = 1;
    for(int i = 0; i < n; i++){
        if(i == 0) res = res * k;
        else res = res * (k-1);
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
 
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
 
int main() {
  int n,m;
  map<int,int>cntd,cntt;
 
  cin >> n;
  vector<int>d(n);
  rep(i, 0, n)cin >> d[i],cntd[d[i]]++;
  cin >> m;
  vector<int>t(m);
  rep(i, 0, m)cin >> t[i],cntt[t[i]]++;
 
  rep(i, 0, m){
      int p = t[i];
      if(cntd[p]<cntt[p]){
          cout << "NO" << endl;
          return 0;
      }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};


//0-indexed
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n = 0) : n(n), d(n + 1) {}
  void add(int i, T x) {
    for (i++; i <= n; i += i & -i){
      d[i] += x;
    }
  }
  T sum(int i) {
    T num = 0;
    for (i++; i; i -= i & -i){
      num += d[i];
    }
    return num;
  }
  T sum(int l, int r) {
    return sum(r - 1) - sum(l - 1);
  }
};


int main() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> pi(n + 1, -1);
  vector<vector<int>> ps(n);
  rep(i, n){
    int l = pi[a[i]];
    if(l != -1) ps[l].emplace_back(i);
    pi[a[i]] = i;
  }
  vector<vector<P>> qs(n);
  rep(qi, q){
    int l, r;
    cin >> l >> r;
    l--, r--;
    qs[l].emplace_back(r, qi);
  }
  vector<int> ans(q);
  BIT<int> d(n);
  for (int x = n - 1; x >= 0; x--){
    for(int y : ps[x]) d.add(y, 1);
    for(P query: qs[x]){
      int r = query.first,  i = query.second;
      ans[i] = (r - x + 1) - d.sum(r);
    }
  }
  rep(i, q){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 59988
n = int(input())
v = list(map(int, input().split())) 
res = 0
a = sorted(v)
for i in range(n-1):
    if i == 0:
        res = (a[i] + a[i+1])/2
    else:
        res = (res+a[i+1])/2
print(res)

Measured memory_bytes: 3060
def solve():
    n = int(input())
    a = 97
    tmp = 0
    index = 0
    ans = []
    for i in range(1, 12):
        pre = tmp
        tmp += 26 ** i
        if n <= tmp:
            index = i
            n = n - pre
            break
    n = n - 1
    for _ in range(0, index)[::-1]:
        ans.append(chr((n % 26) + a))
        n = n // 26
    print(''.join(ans[::-1]))








if __name__ == '__main__':
    solve()


Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define pb push_back
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(type,arr,n)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//=======================
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
//=======================
const int MOD = 1000000007;
const int N = 300005, M = N;
//=======================
vi g[N],adj[N];
int n, m, s, w, W, S, k, i, l, j, p, q, pr, fi, md;


void abhinay()
{
   
    #ifndef ONLINE_JUDGE   
        freopen("input.txt", "r", stdin);   
        freopen("output.txt", "w", stdout);   
    #endif   
    
}

int main(){
    abhinay();
    cin>>n;
    int dp[n+1][3];
    vi A(n+1),B(n+1),C(n+1); 
    fo(i,n) cin>>A[i]>>B[i]>>C[i];
    dp[0][0]=A[0],dp[0][1]=B[0],dp[0][2]=C[0];
    for (int i = 1; i < n; i++)
    {
        dp[i][0] = A[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = B[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = C[i]+max(dp[i-1][1],dp[i-1][0]);
    }
    int ret = 0;
    ret = max(ret,dp[n-1][0]);
    ret = max(ret,dp[n-1][1]);
    ret = max(ret,dp[n-1][2]);

    cout << ret;
    return 0;
}
	

Measured memory_bytes: 19624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()

int main(){
	ll d10[18];d10[0] = 1;
	for (int i = 1;i < 18;i++)d10[i] = d10[i - 1] * 10;
	ll N;
	cin >> N;
	ll d = -1, n = N;
	while (n) {
		n /= 10;
		d++;
	}
	if ((N + 1) % d10[d] == 0)cout << N / d10[d] + 9 * d << endl;
	else cout << N / d10[d] - 1 + 9 * d << endl;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

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

    vector<pi> s;
    //c?????????d?????????????????¨??????
    rep(i,m)
    {
        int c,d;
        scanf(" %d %d",&c,&d);
        if(c<d) s.pb(pi(c,d));
    }

    sort(all(s));

    int ans=n+1;
    int back=s[0].fi;
    int now=s[0].se;

    if(m>0)
    {
        rep(i,m-1)
        {
            if(now<s[i+1].fi)
            {
                ans+=2*(now-back);

                back=s[i+1].fi;
                now=s[i+1].se;
            }
            else now=max(now,s[i+1].se);
        }
        ans+=2*(now-back);
    }

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

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  bool flag = false;
  set<ll> st;
  REP(i,N){
    ll A;
    IN(A);
    if(st.find(A)==st.end()){
      st.emplace(A);
    }else{
      flag = true;
    }
  }

  if(flag){
    OUT("NO");
  }else{
    OUT("YES");
  }

  return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; 
	cin >> N; 
	long long int A[100010] = {}; 
	long long int B[100010] = {}; 
	long long int P[100010] = {}; 
	for(int i = 0; i < N; i++){
		cin >> A[i]; 
	}
	for(int i = 0; i < N; i++){
		cin >> B[i]; 
		P[i] = A[i] - B[i]; 
	}
	sort(P, P+N); 
	int m = lower_bound(P, P+N, 0) - P; 
	if(m == N) cout << -1 << endl; 
	if(m == 0) cout << 0 << endl; 
	else{
		long long int deficit = 0, surplus = 0; 
		for(int i = 0; i < N; i++){
			if(P[i] < 0) deficit += abs(P[i]); 
			if(P[i] > 0) surplus += P[i]; 
		}
		if(deficit > surplus) cout << -1 << endl; 
		else{
			int count = 0; 
			long long int dokomade = 0; 
			for(int i = 0; i < N; i++){
				dokomade += P[N - 1 - i]; 
				if(dokomade >= deficit){
					count = i + 1; 
					break; 
				}
			}
		cout << m + count << endl; 
		}
	}
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ll long long
#define INF 999999999

const ll mod = 1e9+7;

int main(){
	ll n;
	cin >> n;
	if (n%2==0) {cout << n << endl;}
	else {cout << n*2 << endl;}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (int i = 0; i < (ll)(n); ++i)
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	int n; cin >> n;
	for(int i=1;i<1000000;i++) {
		if(i*100<=n&&n<=i*105) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000, mod = 998244353;
char s[maxn + 10];
int f[maxn * 2 + 10][maxn * 2 + 10], n, now;

inline void addto(int &x, int y) {
	x += y; if (x >= mod) x -= mod;
}

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	f[0][0] = 1;
	for (int i = 1; i <= n * 2; ++i) {
		if (i <= n) {
			if (s[i] == '0') now += 2;
			else if (s[i] == '1') ++now;
		}
		for (int j = 0; j <= i; ++j)
			if (j <= now && i - j <= min(i, n) * 2 - now) {
				f[i][j] = f[i - 1][j];
				if (j) addto(f[i][j], f[i - 1][j - 1]);
			}
	}
	printf("%d", f[n * 2][now]);
}

Measured memory_bytes: 60544
#include <bits/stdc++.h>
 
using namespace std;
 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
using llong = long long;
using ld = long double;
using ii = pair<int, int>;
using ull = unsigned long long;
using pll = pair<llong, llong>;
using vi = vector<int>;
 
 
#define endl "\n"
#define fi first
#define se second
#define left LEVO
#define right PRAVO
#define time CHAS
#define all(a) (a).begin(), (a).end()
#define prev PAPEREDNIKXD
#define next NASTUPNIKXD
#define pb push_back
#define deb cout<<"CHECK\n";
#define last(a) (a)[(a).size()-1]
 
#define elif else if
#define cclear cout<<flush;
#define fclear fflush(stdout);
#define x_files freopen("exam.in","r",stdin);freopen("exam.out","w",stdout);
#define kchay ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
const llong over999 = 1e14;
const ld eps = 1e-9;
const int base = 1000*1000;
const ld Pi = acos(-1);
const llong md = 1e9+7;
const llong ya = 0;
 
/*.st*/
 
 
int n, m, q, a[10100], c[200][200];
 
void dfs(int x, int y, int it)
{
    if(!a[it])it++;
    a[it]--;
    c[x][y] = it;
    if(x+1 <= n && !c[x+1][y])dfs(x+1, y, it);
        elif(y+1 <= m && !c[x][y+1])dfs(x, y+1, it);
            elif(x-1 >= 1 && !c[x-1][y])dfs(x-1, y, it);
                elif(y-1 >=1 && !c[x][y-1])dfs(x, y-1, it);
    return;
}
 
int main() {
    kchay;   
    //x_files;
    
    cin >> n >> m;
    
    cin >> q;
    
    for(int i = 1; i <= q; i++)
    {
        cin >> a[i];
    }
    
    dfs(1, 1, 1);
    
    
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 384
import collections,sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
a = LI()
ans = 0
num_count = collections.defaultdict(int)
for x in a:
    num_count[x-1] += 1
    num_count[x] += 1
    num_count[x+1] += 1
print(max(num_count.values()))


Measured memory_bytes: 20004
#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define ull unsigned long long
#define si short int
#define ll long long
#define piii pair<pair<int, int>, int>
#define piiii pair<pair<int, int>, pair<int, int>>

/*-----------------------------------------------------MATH------------------------------------------------*/
inline ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

inline int pwm(ll xx, ll pow, int MD) {
    if (pow < 0) { pow = pow % (MD - 1) + MD - 1; }
    ll mlt = 1;
    while (pow) {
        if (pow & 1) {
            mlt *= xx;
            mlt %= MD;
        }
        xx *= xx;
        pow >>= 1;
        xx %= MD;
    }
    return (int) mlt;
}

inline ll gcdex(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll xx, yy;
    ll gc = gcdex(b, a % b, yy, xx);
    x = xx;
    y = yy - (a / b) * xx;
    return gc;
}

inline int inv(ll r, int _mod) { return pwm(r % _mod, _mod - 2, _mod); }

inline int64_t hilbertOrder(int x, int y, int pow, int rotate) {
    if (pow == 0) {
        return 0;
    }
    int hpow = 1 << (pow - 1);
    int seg = (x < hpow) ? (
            (y < hpow) ? 0 : 3
    ) : (
                      (y < hpow) ? 1 : 2
              );
    seg = (seg + rotate) & 3;
    const int rotateDelta[4] = {3, 0, 0, 1};
    int nx = x & (x ^ hpow), ny = y & (y ^ hpow);
    int nrot = (rotate + rotateDelta[seg]) & 3;
    int64_t subSquareSize = int64_t(1) << (2 * pow - 2);
    int64_t ans = seg * subSquareSize;
    int64_t add = hilbertOrder(nx, ny, pow - 1, nrot);
    ans += (seg == 1 || seg == 2) ? add : (subSquareSize - add - 1);
    return ans;
}

/*-----------------------------------------------------MATH------------------------------------------------*/
vector<int> arr(1e6 + 1, 0);
vector<int> now(1e4 + 1, 0);
ll mod = 1e9 + 7;
int dp[10][10];
void solve() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int left=i;
        int last=-1;
        while(left>0){
            last=left%10;
            left/=10;
        }
        int right=i%10;
        dp[last][right]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        int left=i;
        int last=-1;
        while(left>0){
            last=left%10;
            left/=10;
        }
        int right=i%10;
       // cout<<last<<" "<<right<<" "<<i<<endl;
        ans+=dp[right][last];
    }
    cout<<ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);
    unsigned int beg_time = clock();

    int n = 1;
    for (int i = 0; i < n; i++) solve();


    unsigned int end_time = clock();
    //cout<<endl<<endl<<end_time-beg_time;

    return 0;
}

Measured memory_bytes: 4224
#include<stdio.h>

void mergeSort(int *,int,int);
void merge(int *,int,int,int);

int A[500000],count=0;

int main()
{

  int i,n;

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

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

  return 0;
}

void mergeSort(int A[500000], int left, int right)
{
  int mid;
  if (left+1 < right)
    {
      mid = (left + right)/2;
      mergeSort(A, left, mid);
      mergeSort(A, mid, right);
      merge(A, left, mid, right);
    }

}

void merge(int A[500000], int left, int mid, int right)
{
  int n1,n2,i,j,k;
  n1 = mid - left;
  n2 = right - mid;
  int L[n1+1],R[n2+1];
  for (i = 0;i<n1;i++)
    {
      L[i] = A[left + i];
    }
  for (i = 0;i<n2;i++)
    {
      R[i] = A[mid + i];
    }
  L[n1] = 2000000000;
  R[n2] = 2000000000;
  i = 0;
  j = 0;
  for (k = left;k<right;k++)
    {
      if (L[i] <= R[j])
	{
	  A[k] = L[i];
	  i = i + 1;
	  count++;
	}
      else
	{
	  A[k] = R[j];
	  j = j + 1;
	  count++;
	}
    }
}

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

int main()
{
        int a, b;
        cin >> a >> b;
        double avr = (a + b) / 2.0;
        int ans = avr;
        if ((a+b) % 2) {
                ans += 1;
        }
        cout << ans << endl;


}


Measured memory_bytes: 256