akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>
#include <stack>
#include <math.h>
#include <numeric>
#include <set>

using namespace std;
typedef long long Int;
#define REP(i , x) for(Int i = 0 ; i < x ; ++i)
typedef pair<int, int> P;



int main()
{
	int n;
	while (cin >> n,n){
		int data[10];
		fill(data, data + 10, 0);

		REP(i, n){
			int a;
			cin >> a;
			++data[a];
		}
		REP(i, 10){
			if (data[i]){
				REP(j, data[i]){
					cout << "*";
				}
				cout << endl;
			}
			else{
				cout << "-" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include<iostream> 
#include<vector>
using namespace std;
long double dice_in_line(long long n, long long k, vector<long double> p) {
  vector<long double> a;
  for(long long i=0;i<p.size();i++) {
    long double tmp =  (p[i] + 1)/2;
//    cout << tmp << " tmp" << endl;
    a.push_back((i != 0 ? a[i-1] : 0) + tmp);
  }
  /*
  for(int i=0;i<a.size();i++) {
    cout << a[i] << endl;
  }
  */
  long double answer = 0;
  for(int i= 0;i<n-k+1;i++) {
    if(i==0) {
      answer = a[k-1];
      continue;
    }
    answer = max(answer, (a[i+k-1] - a[i-1]));
  }
  // cout << "ansewer: " << answer << endl;
  return answer;
}
 
int main() {
  long long n, k;
  cin >> n;
  cin >> k;
  vector<long double> p;
  for(long long i = 0;i<n;i++) {
    long double pp;
    cin >> pp;
    p.push_back(pp);
  }
  double a = dice_in_line(n, k, p);
    printf("%.6lf\n", a);
}


Measured memory_bytes: 14572
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,l=map(int,input().split())
a=list(map(int,input().split()))
I,P="Impossible","Possible"

for i in range(n-1):
    if a[i]+a[i+1]>=l:
        print(P)
        for j in range(i):
            print(j+1)
        for j in range(i+1,n)[::-1]:
            print(j)
        break
else:
    print(I)

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

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int k;
	long long tot = 0;
	cin >> k;

	for (int a = 1; a <= k; a++){
		for (int b = 1; b <= k; b++){
			for (int c = 1; c <= k; c++){
				tot += _gcd(a, _gcd(b, c));
			}
		}
	}
	cout << tot << endl;
	return 0;
}

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

int main(){

  char s[5];
  int i;

  scanf("%s", s);

  for(i = 0;i < 3;i++){
    if(s[i] == s[i + 1]){
      printf("Bad\n");
      return 0;
    }
  }

  printf("Good\n");

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#define N 44
int fibonacci(int n);

int main(){
  int i, j, n;
  scanf("%d",&n);
  printf("%d\n",fibonacci(n));

  return 0;
}

int fibonacci(int n)
{
  static int F[N];
  int i;
  if(n == 0 || n == 1){
    return F[n] = 1;
  }
  else if(F[n] > 0){
    return F[n];
  }
  return F[n] = fibonacci(n - 2) + fibonacci(n - 1);
}

Measured memory_bytes: 596
#include <iostream>
#include <complex>
#include <vector>
#include <cstdio>
using namespace std;

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;

bool operator < (const P& a, const P& b) {
  return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
}

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

L caln(P a, P b) {
  return L((a+b)*P(0.5,0), (a+b)*P(0.5,0) + (b-a)*P(0, 1));
}

P intersect(L a, L b) {
  P aa(a[1]-a[0]), bb(b[1]-b[0]);
  return a[0] + aa * cross(bb, b[0]-a[0]) / cross(bb, aa);
}

int main() {
  int n;
  cin >> n;
  while(n--) {
    double x1,y1,x2,y2,x3,y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    P a1(x1,y1), a2(x2,y2), a3(x3,y3);
    P ans = intersect(caln(a1,a2), caln(a2,a3));
    printf("%.3f %.3f %.3f\n", real(ans),imag(ans),abs(a1-ans));
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    ll k, a, b;
    cin >> k >> a >> b;
    rep1 (i, 100000) {
        ll x = k * i;
        if (in(x, a, b + 1)) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main()
{
  int n, a, c = 0;
  
  cin >> n;
  
  for(int i = 0; i < n; i++){
    cin >> a;
    if(a % 2 == 1) c++;
  }
  
  if(c % 2 == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import sys
import math

mod = 998244353

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

N, M, K = map(int, sys.stdin.readline().strip().split())

fact = [1 for i in range(N+1)]
for i in range(1, N):
    fact[i+1] = (fact[i] * (i+1)) % mod

# math.factroialでは速度が足りない
def nCr(n, r, mod=10**9+7):
    if n < 0 or r < 0 or n < r:
        return 0

    if n == 0 or r == 0:
        return 1

    """
    a = math.factorial(n) % mod
    b = math.factorial(r) % mod
    c = math.factorial(n - r) % mod
    """
    a = fact[n]
    b = fact[r]
    c = fact[n-r]

    inv = modinv(b*c, mod)
    ans = a * inv

    return ans % mod


ans = 0
for i in range(K+1):
    ans += nCr(N - 1, i, mod) * (M * pow(M-1, N-1-i, mod))
    # print(ans)
    ans %= mod

print(ans)

Measured memory_bytes: 80964
#include<iostream>
using namespace std;
int main(){
int a=0,b=0,c=0,i,val,tmp_a,tmp_b;
for(i=0;i<10;i++){
cin >> val;
if(val>a){
tmp_a=a;
a=val;
tmp_b = b;
b=tmp_a;
c=tmp_b;
}else if(val>b){
tmp_a = b;
b = val;
c = tmp_a;
}else if(val>c){
c=val;
}
}
cout << a << "\n" << b << "\n" << c << endl;
return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	string S,X;
	cin>>S;
	X="abcdefghijklmnopqrstuvwxyz";
	int n=S.size();
	for(int i=0;i<27;i++){
		for(int j=0;j<n+1;j++){
			if(X[i]==S[j])break;
			if(j==n){
				cout<<X[i];
				return 0;
			}
			if(i==26){
				cout<<"None";
				return 0;
			}
		}
	}
}

Measured memory_bytes: 512
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int N;
  rd(N);
  if(N%2){
    wt_L(2*N);
    wt_L('\n');
  }
  else{
    wt_L(N);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190925-1

// --- original code ---
// {
//   int N;
//   rd(N);
//   wt(if[N%2, 2N, N]);
// }


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int n,a[1001],b[1001],c[1001],i,k=1001;
double x,y,z,d[1001],w=10000;
while(1){
scanf("%d\n",&n);
if(n==0){
break;
}
for(i=0;i<n;i++){
scanf("%d %d %d\n",&a[i],&b[i],&c[i]);
x=b[i],y=c[i];
x=x/100;
z=y/(x*x);
if(z>22){
z=z-22;
}
else{
z=22-z;
}
d[i]=z;
if((z<w) || (z==w && k>a[i])){
w=z;
k=a[i];
}
}
for(i=0;i<n;i++){
if(w==d[i]){
printf("%d\n",a[i]);
break;
}
}
w=10000,k=1001;
}
return 0;
}


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

int main(){
  int n,h,w;
  cin >>n >>h >>w;
  int cnt = 0;
  rep(i,n){
    int a,b;
    cin >>a >>b;
    if(h<=a && w<=b) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N);
  if (N % 2 == 0) {
    cout << N << endl;
  } else {
    cout << 2 * N << endl;
      }

  return 0;
}



Measured memory_bytes: 256
K,S = map(int,input().split())

def F(K,S):
  # x+y = S, <=K
  if S < 0:
    return 0
  if S <= K:
    return (S+1)
  if S > K+K:
    return 0
  return (K+K-S+1)

answer = 0

for x in range(K+1):
  answer += F(K,S-x)

print(answer)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int N;
char S[300001];
int  A[300001];
int  B[300001];

int main()
{
	cin >> N >> S;
	int t = 0;
	for (int i = 0; i < N; i++) {
		A[i] = t;
		if (S[i] == 'W') t++;
	}
	t = 0;
	for (int i = N - 1; i >= 0; i--) {
		B[i] = t;
		if (S[i] == 'E') t++;
	}
	t = N;
	for (int i = 0; i < N; i++) {
		int tmp = A[i] + B[i];
		t = t < tmp ? t : tmp;
	}
	cout << t << endl;
	return 0;
}

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

using Weight = long long;
struct Edge {
	int src, dst;
	Weight weight;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;


void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}

std::vector<Weight> dijkstra(const Graph &g, int s) {
	const Weight INF = std::numeric_limits<Weight>::max() / 8;
	using state = std::tuple<Weight, int>;
	std::priority_queue<state> q;
	std::vector<Weight> dist(g.size(), INF);
	dist[s] = 0;
	q.emplace(0, s);
	while (q.size()) {
		Weight d;
		int v;
		std::tie(d, v) = q.top();
		q.pop();
		d *= -1;
		/* if(v == t) return d; */
		if (dist[v] < d) continue;
		for (auto &e : g[v]) {
			if (dist[e.dst] > dist[v] + e.weight) {
				dist[e.dst] = dist[v] + e.weight;
				q.emplace(-dist[e.dst], e.dst);
			}
		}
	}
	return dist;
}

int main() {
	int N;
	std::cin >> N;
	Graph g(N + 1);
	for (int i = 0; i < N - 1; i++) {
		int a, b, c;
		std::cin >> a >> b >> c;
		add_edge(g, a, b, c);
	}
	int Q, K;
	std::cin >> Q >> K;
	std::vector<long long> ans(Q);
	std::vector<long long> k_dist = dijkstra(g, K);
	for (int i = 0; i < Q; i++) {
		int x, y;
		std::cin >> x >> y;
		ans[i] = k_dist[x] + k_dist[y];
	}

	for (auto& p : ans)
		std::cout << p << std::endl;

	return 0;
}

Measured memory_bytes: 11888
#include <stdio.h>
    int main(){
      int a[2]={0,0,0};
      int flag_A=0;
      int flag_B=0;
      //in
      scanf("%d %d %d",&a[0],&a[1],&a[2]);
      //read
      for(int n=0;n<3;n++){
        if(a[n]==5) flag_A++;
        else if(a[n]==7) flag_B++;
      }
      //out
      if(flag_A==2&&flag_B==1) printf("YES\n");
      else printf("NO\n");
    }

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

const int N = 2e5+100;
int a[N], d[N];

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, K;
    cin >> n >> K;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for(int j = 1; j <= K; j++) {
        memset(d, 0, sizeof d);
        for(int i = 1; i <= n; i++) {
            int l = i-a[i], r = i+a[i];
            l = max(l, 1), r = min(r, n);
            d[l]++, d[r+1]--;
        }
        bool changed = false;
        for(int i = 1; i <= n; i++) {
            d[i] += d[i-1];
            if(d[i] != a[i]) changed = true;
            a[i] = d[i];
        }
        if(!changed) {
            break;
        }
    }
    for(int i = 1; i<= n; i++) cout << a[i] << " ";
    return 0;
}


Measured memory_bytes: 5200
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 3e3+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;


vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	vi m(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}
lli PROD(lli a, lli b, lli mod=MOD){
	a%=mod; b%=mod;
	return a*b % mod;
}
int dx[4]={-1,0,0,1}, dy[4]={0,1,-1,0};

// ---- コーディングはここから！ ('-')7


typedef vvl Matrix;
Matrix ones(int n) {
	Matrix r(n,vl(n));
	fore(i,0,n)r[i][i]=1;
	return r;
}
Matrix operator*(Matrix &a, Matrix &b) {
	int n=sz(a),m=sz(b[0]),z=sz(a[0]);
	Matrix r(n,vl(m));
	fore(i,0,n)fore(j,0,m)fore(k,0,z)
		r[i][j]+=a[i][k]*b[k][j],r[i][j]%=MOD;
	return r;
}
Matrix be(Matrix b, lli e) {
	Matrix r=ones(sz(b));
	while(e){if(e&1LL)r=r*b;b=b*b;e/=2;}
	return r;
}


void solve(){
	lli n,k; cin>>n>>k;
	Matrix v(n,vl(n));
	fore(i,0,n)fore(j,0,n)cin>>v[i][j];
	auto res = be(v,k);
	lli rr = 0;
	fore(i,0,n)fore(j,0,n)rr=SUM(rr,res[i][j]);
	cout<<rr<<ENDL;
}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 3680
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
 	LL a,b,c;
	cin>>a;
	cout<<a*(a-1)/2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n;cin>>n;
    ll a[n];
    set<ll>s;
    f(i,0,n){cin>>a[i];s.insert(a[i]);}
    if(s.size()==n)cout<<"YES";
    else cout<<"NO";
    return 0;  
} 

Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int SZ = 60;
ll myx[SZ];
ll calc(ll a){
	if(a==0LL) return 0LL;
	ll ans = 0LL;
	for(ll i=SZ-1;i>=0LL;i--){
		ll tmp = (1LL<<i);
		if(a>=tmp){
			ans ^= (((a-tmp)%2ll==0LL ? tmp : 0LL));
			if(i==1LL) ans^=1LL;
			ans^=calc(a-tmp);
			break;
		}
	}
	return ans;
}
int main(void){
	ll n,m; scanf("%lld %lld",&n,&m);
	if(n==0LL){
		printf("%lld",m);
		return 0;
	}
	n--;
	ll ans = 0LL;
	ans^=calc(m);
	ans^=calc(n);
	printf("%lld",ans);
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  bool a=true;
  char C='a';
  vector<string> W(N);
  for(int i=0;i<N;i++){
    cin >> W.at(i);
    if(i!=0){
      if(W.at(i).at(0)!=C){
        a=false;
      }  
    }
   C=W.at(i).at(W.at(i).size()-1);
  }
  sort(W.begin(),W.end());
  for(int i=0;i<N-1;i++){
    if(W.at(i)==W.at(i+1)){
      a=false;
    }
  }
  if(a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
    
    

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

const int MAXN = 1e5+2;
int A[MAXN];

int main(void)
{
	ios_base::sync_with_stdio(false);
	int N;
	cin >> N;
	for (int i(1); i <= N; ++i)
		cin >> A[i];

	int total_cost(0);
	A[0] = A[N+1] = 0;
	for (int i(1); i <= N+1; ++i)
		total_cost += abs(A[i] - A[i-1]);
	
	for (int i(1); i <= N; ++i)
		cout << total_cost - abs(A[i-1] - A[i]) - abs(A[i+1]-A[i]) + abs(A[i-1]-A[i+1]) << '\n';
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

using namespace std;

//------------------------------------------------------------------------------
ll power(ll a,ll n)
{
          ll result=1;
          while(n>0)
          {
               if(n&1)
                    result=result*a;
               a=a*a;
               n=n>>1;
          }
          return result;
}
ll lcm(ll a,ll b)
{
          return ((a*b)/__gcd(a,b));
}
bool ispow2(ll n)
{
          return (ceil(log2(n))==floor(log2(n)));
}
bool isprime(ll n)
{
          if(n==1)
               return false;
          else if(n==2)
               return true;
          else
          {
               for(ll i=2;i*i<=n;++i)
               {
                    if(n%i==0)
                         return false;
               }
               return true;
          }
}

ll ncr(ll n,ll r)
{
    if(r > n - r)
          r = n - r;
    ll ans = 1;
    ll i;

    for(i = 1; i <= r; i++)
     {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
void sieve(int n)
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
     prime[1]=false;
     prime[0]=false;
    for (int p=2; p*p<=n; p++)
    {
        // If prime[p] is not changed, then it is a prime
        if (prime[p] == true)
        {
            // Update all multiples of p greater than or
            // equal to the square of it
            // numbers which are multiple of p and are
            // less than p^2 are already been marked.
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

    // Print all prime numbers
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout<<p<<" ";
}
//------------------------------------------------------------------------------


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

          int t=1;
          //cin>>t;
          while(t--)
          {
                    int n;
                    cin>>n;
                    int cnt=0;
                    for(int i=1;i<=n;++i)
                    {
                         for(int j=1;j<=n/i;++j)
                         {
                              int a = i;
                              int b = j;
                              int c = n - i*j;
                              if(a>0 && b>0 && c>0)
                              {
                                   //cout<<a<<" "<<b<<" "<<c<<"\n";
                                   ++cnt;
                              }
                         }
                    }
                    cout<<cnt;
          }
          return 0;
}


Measured memory_bytes: 3696
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define N 100005
#define mod 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define debug(x) cout<<(#x)<<" is "<<(x)<<endl
#define lb(arr,n,x) lower_bound(arr,arr+n,x)-arr
#define ub(arr,n,x) upper_bound(arr,arr+n,x)-arr
#define endl "\n"
#define PI 3.14159265358979323846  /* pi */
#define sqr(x) (x)*(x)
#define sign(x) (x>0)-(x<0)
#define is_poweroftwo(n) (n&& !(n&(n-1)))
#define all(v)  ((v).begin()),((v).end())
#define degreesToRadians(angleDegrees) (angleDegrees * PI / 180.0) // Converts degrees to radians.
#define radiansToDegrees(angleRadians) (angleRadians * 180.0 / PI) // Converts radians to degrees.
#define int long long
#define debug(x) cout<<(#x)<<" is "<<(x)<<endl
#define AagLgaDe ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;
typedef long double ld;
 
//Calculation of (x^y)%mm
ll mod_exp(ll x,ll y,ll mm)
{
    if(y==0)
        return(1);
    else if(y%2==0)
        return(mod_exp((x*x)%mm,y/2,mm));
    else
        return((x*mod_exp((x*x)%mm,(y-1)/2,mm))%mm);
}
bool isPowerOfTwo(int n) 
{ 
   if(n==0) 
   return false;
   return (ceil(log2(n)) == floor(log2(n))); 
}
 
//int x1[]={+1,-1,+0,+0};
//int y1[]={+0,+0,+1,-1};
//int x2[]={+0,+0,+1,-1,-1,+1,-1,+1};
//int y2[]={-1,+1,+0,+0,+1,+1,-1,-1};
//int x3[]={-2,-2,-1,-1,+1,+1,+2,+2};
//int y3[]={-1,+1,-2,+2,-2,+2,-1,+1};
 
int solve()
{
	int n, W;
	cin>>n>>W;
	vector<vector<int>> items(n, vector<int>(2));
	for(int i=0;i<n;i++){
		cin>>items[i][0]>>items[i][1];
	}
	sort(items.begin(), items.end());
	vector<vector<int>> dp(n+1, vector<int>(W+1, 0));
	for(int j=1;j<=W;j++)
	{
		if(j>=items[0][0])
			dp[1][j]=items[0][1];
	}
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=W;j++)
		{
			if(j>=items[i-1][0])
			{
				dp[i][j]=max(dp[i-1][j-items[i-1][0]]+items[i-1][1], dp[i-1][j]);
			}
			else
				dp[i][j]=dp[i-1][j];
		}
	}
	return dp[n][W];
 
}
 
signed main() {
  	AagLgaDe
    //int t;cin>>t;while(t--)
	    cout<<solve()<<endl;
 
 
return 0;
}

Measured memory_bytes: 83056
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define sz(x)  ((ll)x.size())
#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif
void tokenize(string str,const char delim,vector<string> & res){
	stringstream p(str);
	string token;
	while(getline(p,token,delim)){
		res.push_back(token);
	}
	return;
}

// Your workSpace ...


ll n;
ll x,q,b,c;
void test_case(){
	cin>>n;
	map<ll,ll> m;
	ll sum = 0;
	for(int i = 0;i<n;++i){
		cin>>x;
		sum += x;
		m[x]++;
	}
	cin>>q;
	while(q--){
		cin>>b>>c;
		
		ll freq = m[b];
		//debug() << owo(m) << owo(freq) << owo;
		sum += freq*(c-b);
		cout<<sum<<endl;
		m.erase(b);
		m[c] = freq + m[c];
		
	}
	
}







int main(){
	FAST_IO;
	int tt;
	//cin>>tt;
	tt = 1;
	while(tt--){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 7572
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,ans = 0;
  cin >> N;
  for(int i = 1;i<=N;i++){
    if(i == 105 || i == 135 || i == 189 || i == 165 || i == 195){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
money = 1000
kabu = 0
todo = [0]*n
for i in range(n):
    if(i == 0):
        if(a[n-2-i] < a[n-1-i]):
            state = 1
            todo[n-1] = 1#uri
        elif(a[n-2-i] > a[n-1-i]):
            state = -1
            todo[n-1] = 0
        else:
            state = 0
            todo[n-1] = 0
    elif(i == n-1):
        if(state == 1):
            todo[n-1-i] = -1
    else:
        if(a[n-2-i] < a[n-1-i]):
            temp = 1
            if(state != temp):
                todo[n-1-i] = 1
            state = 1
        elif(a[n-2-i] > a[n-1-i]):
            temp = -1
            if(state != temp):
                todo[n-1-i] = -1#kai
            state = -1

for i in range(n):
    if(todo[i] == -1):
        if(money > 0):
            kazu = money//a[i]
            money = money - kazu * a[i]
            kabu = kazu                
    elif(todo[i] == 1):
        money = money + kabu * a[i]
        kabu = 0
    
print(money)

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

#define mp make_pair
#define pb push_back

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int MAX_N = 200000;
int n;
int a[MAX_N];
int l[MAX_N];
//int r[MAX_N];

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

  int b = 0;
  int j = 0;
  for (int i = 0; i < n; i++) {
    while (b & a[i]) {
      b &= ~a[j++];
    }
    l[i] = j;
    b |= a[i];
  }

  i64 c = 0;
  for (int i = 0; i < n; i++) {
    c += i - l[i] + 1;
  }

  cout << c << endl;

  return 0;
}


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

arr = [0] * (10**5 + 2)
for i in range(n):
    arr[a[i]] += 1
ans = []
for x in range(1,10**5):
    ans.append(arr[x-1] + arr[x] + arr[x+1])

print(max(ans))


Measured memory_bytes: 13964
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
 
using namespace std;
 
#define eb emplace_back
#define pb push_back
#define MP make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define rep(i,j,n) for (int i = j; i < n; ++i)
#define repn(i,j,n) for (int i = j; i <= n; ++i)
#define revn(i,j,n) for (int i = j; i >= n; --i)
#define sz(i) i.size()
#define mem(i,v) memset(i,v,sizeof(i))
#define all(v) v.begin(), v.end()
#define endl '\n'
#define int long long
#define INF 1e18
#define ss second
#define ff first

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
//const int mod=1e9+7;
const int mod=998244353;
const int up=1e5+10;
const int MAXN=1e6+10;

// int n,m,x,y,res=0,sz[2*up],par[2*up],ans[2*up];

// int get(int x)
// {
//     return x*(x-1)/2;
// }

// int find(int x)
// {
//     if(par[x]==x)
//         return x;
//     else
//         return par[x]=find(par[x]);
// }

// void merge(int u,int v)
// {
//     x=find(u);
//     y=find(v);
//     if(sz[x]<sz[y])
//         swap(x,y);
//     res-=get(sz[x]);
//     res-=get(sz[y]);
//     sz[x]+=sz[y];
//     res+=get(sz[x]);
//     par[v]=u;
// }

// void solve()
// {
//     cin>>n>>m;
//     vector<pii>q(m+1);
//     vector<pair<int,pii>>e(n);
//     repn(i,1,n)
//     {
//         sz[i]=1;
//         par[i]=i;
//     }
//     repn(i,1,n-1)
//     {
//         cin>>e[i].ss.ff>>e[i].ss.ss>>e[i].ff;
//     }
//     repn(i,1,m)
//     {
//         cin>>q[i].ff;
//         q[i].ss=i;
//     }
//     sort(all(e));
//     sort(all(q));
//     int pos=1;
//     repn(i,1,m)
//     {
//         while(pos<n && e[pos].ff<=q[i].ff)
//         {
//             x=e[pos].ss.ff;
//             y=e[pos].ss.ss;
//             merge(x,y);
//             ++pos;
//         }
//         ans[q[i].ss]=res;
//     }
//     repn(i,1,m)
//     {
//         cout<<ans[i]<<" ";
//     }
//     cout<<endl;
// }


int dep[2*up],a[2*up];
void solve()
{
    int n;
    cin>>n;
    repn(i,0,n)
    {
        cin>>a[i];
    }
    revn(i,n,0)
    {
        if(i==n)
            dep[i]=a[i];
        else
            dep[i]=dep[i+1]+a[i];
    }
    int cur=1,ans=0;
    repn(i,0,n)
    {
        
        if(cur<0)
        {
            cout<<-1<<endl;
            return;
        }
        //cout<<cur<<" "<<dep[i+1]<<endl;
        ans+=min(cur,dep[i]);
        cur-=a[i];
        cur=cur*2;
        cur=min(cur,((int)1e15));
        if(cur<0)
        {
            cout<<-1<<endl;
            return;
        }
    }
    cout<<ans<<endl;
}

int32_t main()
{
    int t;
    // memset(prime, true, sizeof(prime)); 
    // sieve();
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
}



Measured memory_bytes: 5180
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll k,x,i;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>k>>x;
    for(i = max(-1000000LL, x - k + 1);i <= min(1000000LL, x + k - 1);i += 1) cout<<i<<" ";
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<string> s(N);
  
  for (int i = 0; i < N; ++i) cin >> s.at(i);
  
  int M;
  cin >> M;
  
  vector<string> t(M);
  
  for (int i = 0; i < M; ++i) cin >> t.at(i);
  
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int tmp = 1;
    for (int j = 0; j < N; ++j) {
      if (i == j) continue;
      if (s.at(i) == s.at(j)) tmp++;
    }
    for (int j = 0; j < M; ++j) {
      if (s.at(i) == t.at(j)) tmp--;
    }
    if (tmp > ans) ans = tmp;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};

int n,k;
int a[100000];
int gcd;

int main(){
  cin>>n>>k;
  rep(i,n){
    cin>>a[i];
    gcd = __gcd(a[i],gcd);
  }
  rep(i,n)
    if(a[i]>=k&&(a[i]-k)%gcd==0){
      cout<<"POSSIBLE"<<endl;
      return 0;
    }


  cout<<"IMPOSSIBLE"<<endl;

  return 0;
}



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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 300 + 5;

int d[MAX_V][MAX_V]; //d[v][u]は辺e=(v,u)のコスト(default: d[i][j] = INF && d[i][i] = 0)
int V;

void warshall_floyd() {
    for (int k = 0; k < V; k++)
        for (int i = 0; i < V; i++)
            for (int j = 0; j < V; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

// kruskal の使い方
#define MAX_E 10000

struct edge {
    int u;
    int v;
    int cost;
};

vector<edge> es;

// Union Find
struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unionSet(int x, int y) {
        x = root(x);
        y = root(y);

        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool same(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
};

bool comp(const edge &e1, const edge &e2) {
    return e1.cost < e2.cost;
}

int kruskal() {
    sort(es.begin(), es.end(), comp);
    UnionFind uf = UnionFind(V);
    int res = 0;
    for (auto &e : es) {
        if (!uf.same(e.u, e.v)) {
            uf.unionSet(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main() {
    int n, m, r;
    cin >> n >> m >> r;
    V = n;
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) {
            d[i][j] = INF;
            if (i == j) d[i][j] = 0;
        }
    }
    vector<int> path;
    for (int i = 0; i < r; i++) {
        int temp;
        cin >> temp;
        temp--;
        path.push_back(temp);
    }
    for (int i = 0; i < m; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        x--;
        y--;
        d[x][y] = c;
        d[y][x] = c;
    }
    warshall_floyd();
    sort(path.begin(), path.end());
    int res = INF;
    do {
        int sum = 0;
        for (int i = 0; i < path.size() - 1; i++) {
            sum += d[path[i]][path[i + 1]];
        }
        if (sum < res) res = sum;
    } while (next_permutation(path.begin(), path.end()));
    cout << res << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N;
  cin >> N;
  string S;
  cin >> S;

  vi dp_cur(16,0);
  vi dp_nxt(16,0);
  dp_cur[0] = 1;
  
  rep(i,N){
    dp_nxt[0]= dp_cur[0];
    if(S[i]=='R'){
      dp_nxt[1] = dp_cur[1] + dp_cur[0];
      dp_nxt[6] = dp_cur[6] + dp_cur[2];
      dp_nxt[8] = dp_cur[8] + dp_cur[3];
      dp_nxt[13] = dp_cur[13] + dp_cur[7];
      dp_nxt[15] = dp_cur[15] + dp_cur[9];
    }
    else{
      dp_nxt[1] = dp_cur[1];
      dp_nxt[6] = dp_cur[6];
      dp_nxt[8] = dp_cur[8];
      dp_nxt[13] = dp_cur[13];
      dp_nxt[15] = dp_cur[15];
    }
    if(S[i]=='G'){
      dp_nxt[2] = dp_cur[2] + dp_cur[0];
      dp_nxt[4] = dp_cur[4] + dp_cur[1];
      dp_nxt[9] = dp_cur[9] + dp_cur[3];
      dp_nxt[11] = dp_cur[11] + dp_cur[5];
      dp_nxt[14] = dp_cur[14] + dp_cur[8];
    }
    else{
      dp_nxt[2] = dp_cur[2];
      dp_nxt[4] = dp_cur[4];
      dp_nxt[9] = dp_cur[9];
      dp_nxt[11] = dp_cur[11];
      dp_nxt[14] = dp_cur[14];
    }
    if(S[i]=='B'){
      dp_nxt[3] = dp_cur[3] + dp_cur[0];
      dp_nxt[5] = dp_cur[5] + dp_cur[1];
      dp_nxt[7] = dp_cur[7] + dp_cur[2];
      dp_nxt[10] = dp_cur[10] + dp_cur[4];
      dp_nxt[12] = dp_cur[12] + dp_cur[6];
    }
    else{
      dp_nxt[3] = dp_cur[3];
      dp_nxt[5] = dp_cur[5];
      dp_nxt[7] = dp_cur[7];
      dp_nxt[10] = dp_cur[10];
      dp_nxt[12] = dp_cur[12];
    }
    rep(j,16){
      dp_cur[j] = dp_nxt[j];
    }
  }
  i64 ans = dp_cur[10] + dp_cur[11] + dp_cur[12] + dp_cur[13] + dp_cur[14] + dp_cur[15];

  rep(i,N){
    for(int j=1;i+j+j<N;j++){
      if(S[i]!=S[i+j] and S[i]!=S[i+j+j] and S[i+j]!=S[i+j+j]){
        ans--;
      }
    }
  }


  cout << ans << endl;
}

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

Measured memory_bytes: 3652
#include<iostream>
#include<string>
using namespace std;
int main () {
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i < S.size(); i ++) {
    for (int j = i; j < S.size(); j ++) {
      bool ok = true;
      for (int k = i; k <= j; k ++) {
        if (S[k] != 'A' && S[k] != 'T' && S[k] != 'G' && S[k] != 'C') {
          ok = false;
        }
      }
      if (ok && ans < j - i + 1) ans = j - i + 1;
    }
  }
  cout << ans << endl;
}
  



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

int main()
{
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if (a*b == c*d)
	{
		cout << a*b << endl;
	}
	else
	{
		cout << max(a*b, c*d) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	cout << x * x * x << endl;

}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(void){
	double w;
	while(scanf("%lf",&w) != EOF){
		if(w <= 48){
			printf("light fly\n");
		}else if(w <= 51){
			printf("fly\n");
		}else if(w <= 54){
			printf("bantam\n");
		}else if(w <= 57){
			printf("feather\n");
		}else if(w <= 60){
			printf("light\n");
		}else if(w <= 64){
			printf("light welter\n");
		}else if(w <= 69){
			printf("welter\n");
		}else if(w <= 75){
			printf("light middle\n");
		}else if(w <= 81){
			printf("middle\n");
		}else if(w <= 91){
			printf("light heavy\n");
		}else{
			printf("heavy\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1036
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define int long long
#define gcd __gcd
const int inf = 0x3f3f3f3f;
const int maxn = 2001110;
const int M = 1e9+7;
int n,m;

int sum[maxn];
int inv[maxn];
int sinv[maxn];

int solve(int x,int y)
{   
    int ans = 0;
    for(int i = 0; i <= x; i++) 
    {   
        ans = (ans + (sum[i+y+1] * sinv[i+1])%M)%M;
    }
    return ans*sinv[y]%M;
}


signed main()
{
    sum[0] = sum[1] = 1;
    inv[0] = inv[1] = 1;
    sinv[0] = sinv[1] = 1;
    for(int i = 2; i < maxn; i++) 
    {
        sum[i] = sum[i-1]*i%M;
        inv[i] = (M-M/i)*inv[M%i]%M;
        sinv[i] = (inv[i]*sinv[i-1])%M;
    }
    int r1,c1,r2,c2;
    cin>>r1>>c1>>r2>>c2;
    int ans = solve(r2,c2);
    int a = 0,b = 0, c = 0;
    if(r1) a = solve(r1-1,c2);
    if(c1) b = solve(r2,c1-1);
    if(r1 && c1) c = solve(r1-1,c1-1);
    //cout<<ans<<' '<<a<<' '<<b<<' '<<c<<endl;
    ans = ((ans - a - b + c)%M + M )%M;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    map<ll,ll> mp;
    rep(i,N){
        cin >> A[i];
        mp[A[i]]++;
    }
    ll cnt = 0;
    for(auto& e:mp){
        if(e.first < e.second){
            cnt += e.second - e.first;
        }else if(e.first > e.second){
            cnt += e.second;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 7040
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int U = int.Parse(str[1]);
		int V = int.Parse(str[2]);
		int[,]A = new int[N-1,2];
		var list = new List<int>[N];
		var list2 = new List<int>[N];
		var list22 = new List<int>[N];
		for(var i=0;i<N;i++){
			list[i] = new List<int>();
			list2[i] = new List<int>();
			list22[i] = new List<int>();
		}
		for(var i=0;i<N-1;i++){
			string[] str2 = Console.ReadLine().Split();
			A[i,0] = int.Parse(str2[0]);
			A[i,1] = int.Parse(str2[1]);
			list[A[i,0]-1].Add(A[i,1]-1);
			list[A[i,1]-1].Add(A[i,0]-1);
		}
		var listh = new List<int>();
		int[]F = new int[N];
		for(var i=0;i<N;i++){
			F[i] = -1;
		}
		listh.Add(V-1);
		int ht = 0;
		while(listh.Count>0){
			ht++;
			var listh2 = new List<int>(listh);
			listh.Clear();
			for(var i=0;i<listh2.Count;i++){
				int h2 = listh2[i];
				F[h2]=ht;
				for(var j=0;j<list[h2].Count;j++){
					int h3 = list[h2][j];
					if(F[h3]==-1){
						list2[h2].Add(h3);
						list22[h3].Add(h2);
						listh.Add(h3);
					}
				}
			}
		}
		//for(var i=0;i<N;i++){
       	//	Console.Error.Write(F[i]+" ");
        //}
		var listi = new List<int>();
		for(var i=0;i<N;i++){
			if(list2[i].Count==0){
				listi.Add(i);
			}
		}
		int[]G = new int[N];
		for(var i=0;i<listi.Count;i++){
			G[listi[i]]=F[listi[i]];
		}
		int[]CT = new int[N];
		while(listi.Count>0){
			var listi2 = new List<int>(listi);
			listi.Clear();
			for(var i=0;i<listi2.Count;i++){
				int i2 = listi2[i];
				if(list22[i2].Count>0){
					int i3 = list22[i2][0];
					G[i3]=Math.Max(G[i3],G[i2]);
					CT[i3]++;
					if(CT[i3]==list2[i3].Count){
						listi.Add(list22[i2][0]);
					}
				}
			}
		}
		int ua = 1;
		int a = V-1;
		int ut = F[U-1];
		int t = U-1;
		int ans = 0;
		int uct = ut-ua-1;
		for(var i=0;i<=uct/2;i++){
          	//Console.Error.WriteLine(ua+" "+a+" "+ut+" "+t);
			int ct1 = i+G[t]-ut;
			int c1 = i+1+G[t]-ut;
			int g1 = G[t];
          	int ct2 = ct1+(g1-c1)-1;
			//Console.Error.WriteLine(ct1+" "+ct2+" "+c1+" "+g1);
			//if((g1-c1)==1){
			//	ct1 += 0;
			//} else if((g1-c1)%2==0){
			//	ct1 += (g1-c1)-1;
			//} else {
			//	ct1 += (g1-c1)-2;
			//}
			ans = Math.Max(ans,ct2);
			ua++;
			ut--;
			t = list22[t][0];
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 45524
import math

def kochCurve(p1, p2, n):
  if n == 0:
    print(p2[0], p2[1])
    return

  v = [(p2[0]-p1[0])/3, (p2[1]-p1[1])/3]
  s = [p1[0]+v[0], p1[1]+v[1]]
  t = [s[0]+v[0], s[1]+v[1]]

  theta = math.atan2(v[1], v[0]) + math.pi/2

  a = math.sqrt((t[0]-s[0])**2+(t[1]-s[1])**2)
  h = 3**(1/2)*a/2
  u = [s[0]+(t[0]-s[0])/2+h*math.cos(theta), s[1]+(t[1]-s[1])/2+h*math.sin(theta)]

  n -= 1
  kochCurve(p1, s, n)
  kochCurve(s, u, n)
  kochCurve(u, t, n)
  kochCurve(t, p2, n)

if __name__ == "__main__":
  n = int(input())
  print(0, 0)
  kochCurve([0, 0], [100, 0], n)

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

int main() {
    int d, g;
    cin >> d >> g;
    vector<pair<int, int>> pc(d);
    for(int i = 0; i < d; ++i)
        cin >> pc.at(i).first >> pc.at(i).second;
    int ans = 0x40000000;
    for(int i = 0, tmp, tn,rest_max; i < (1 << d); ++i) {
        tmp = 0, tn = 0,rest_max=-1;
        for(int j = 0; j < d; ++j) {
            if(i & (1 << j)) {
                tn += pc.at(j).first;
                tmp += pc.at(j).first * 100 * (j + 1) + pc.at(j).second;
            }else{
				rest_max=j;
			}
        }
        if(tmp < g) {
            int s1=100*(rest_max+1);
			int need=(g-tmp+s1-1)/s1;
			if(need>=pc.at(rest_max).first)
				continue;
			tn+=need;
		}
        ans = min(ans, tn);
    }
    cout << ans << "\n"s;
}

Measured memory_bytes: 256