akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var st = Reads();

            string ans = "";
            for (int i = 0; i < n; i++)
            {
                ans += st[0][i];
                ans += st[1][i];
            }
            WriteLine(ans);
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <array>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

#include <atcoder/lazysegtree>
#include <atcoder/modint>

using namespace std;
using namespace atcoder;
#define rep(i,l,r) for(int i = l; i < r; ++i)
#define fir first
#define sec second

using mint = modint998244353;
using S = pair<mint, int>;
using F = pair<mint, mint>;

S op(S s1, S s2)
    {return {s1.fir + s2.fir, s1.sec + s2.sec};}
S e() {return {0, 0};}

S mapping(F f, S s)
    {return {s.fir * f.fir + s.sec * f.sec, s.sec};}
F composition(F f1, F f2)
    {return {f2.fir * f1.fir, f2.sec * f1.fir + f1.sec};}
F id() {return {1, 0};}

int main() {
    int n, q, x, t, l, r, b, c;
    cin >> n >> q;

    vector<S> a(n);
    rep(i, 0, n) {
        cin >> x;
        a[i] = {x, 1};
    }

    lazy_segtree<S, op, e, F, mapping, composition, id> lseg(a);

    rep(i, 0, q) {
        cin >> t >> l >> r;
        if (t == 0) {
            cin >> b >> c;
            lseg.apply(l, r, {b, c});
        } else {
            cout << lseg.prod(l, r).fir.val() << endl;
        }
    }
}


Measured memory_bytes: 19112
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    set<int> st;
    int q,a,b,c;
    cin >> q;
    for (int i=0;i<q;i++) {
        cin >> a;
        if ( a==0 ) {
            cin >> b;
            st.insert(b);
            cout << st.size() << endl;
        } else if ( a==1 ) {
            cin >> b;
            auto itr = st.find(b);
            if (itr!=st.end()) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        } else if ( a==2 ) {
            cin >> b;
            st.erase(b);
        } else if ( a==3 ) {
            cin >> b >> c;
            auto itr1 = st.lower_bound(b);
            auto itr2 = st.upper_bound(c);
            for (itr1;itr1!=itr2;++itr1) {
                cout << *itr1 << endl;
            }
        }
    }
}



Measured memory_bytes: 12384
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

char b[1024][1024];
int memo[1024][1024];
bool win[1024][1024];

int main(){
  const int h = getInt();
  const int w = getInt();
  const int k = getInt();

  REP(i,h) scanf("%s", b[i]);

  REP(i,h) REP(j,w){
    int d = 0;
    if(i) d = max(d, memo[i - 1][j] - 1);
    if(j) d = max(d, memo[i][j - 1] - 1);
    if(d == 0){
      win[i][j] = false;
      if(b[i][j] == '.') memo[i][j] = k + 1;
      else memo[i][j] = 0;
    }else{
      win[i][j] = (b[i][j] == '.');
      memo[i][j] = d;
    }
  }
  // REP(i,h){ REP(j,w) printf("%d", win[i][j]); puts(""); }
  puts(win[h - 1][w - 1] ? "Chieno" : "Cacao");
  // pyon pyon surunja^~
  return 0;
}


Measured memory_bytes: 7136
n = int(input())
s = [input() for _ in range(n)]

cnt = 0
cnt1 = 0
cnt2 = 0
cnt3 = 0
for x in s:
    cnt += x.count("AB")
    if x[0] == "B":
        cnt1 += 1
    if x[-1] == "A":
        cnt2 += 1
    if x[0] == "B" and x[-1] == "A":
        cnt3 += 1

cnt1 -= cnt3
cnt2 -= cnt3

if cnt1+cnt2 > 0 or cnt3 == 0:
    print(cnt + cnt3 + min(cnt1, cnt2))
else:
    print(cnt + cnt3 + min(cnt1, cnt2) - 1)

Measured memory_bytes: 44376
#include <stdio.h>

int main(void){

    int A1, A2, A3;

    scanf("%d %d %d", &A1, &A2, &A3);

    if((A1 + A2 + A3) >= 22){
        printf("bust\n");
    } else if ((A1 + A2 + A3) <= 21){
        printf("win\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n, u[2], m;
    scanf("%d%d%d%d", &n, &u[0], &u[1], &m);
    int a[2][n][n];
    map<int, pii> pos[2];
    rep(k, 2)rep(i, n)rep(j, n){
        scanf("%d", &a[k][i][j]);
        pos[k][a[k][i][j]] = {i, j};
    }
    int row[2][n], col[2][n], diag[2][2], cnt[2];
    rep(k, 2){
        rep(i, n) row[k][i] = col[k][i] = 0;
        rep(i, 2) diag[k][i] = 0;
        cnt[k] = 0;
    }

    rep(t, m){
        int x;
        scanf("%d", &x);
        rep(k, 2){
            if(pos[k].find(x) != pos[k].end()){
                int i, j;
                tie(i, j) = pos[k][x];
                cnt[k] += (++row[k][i] == n);
                cnt[k] += (++col[k][j] == n);
                if(i == j) cnt[k] += (++diag[k][0] == n);
                if(i == n-1-j) cnt[k] += (++diag[k][1] == n);
                if(n == 1) chmin(cnt[k], 1);
            }
        }
        if(cnt[0] >= u[0]){
            if(cnt[1] >= u[1]) puts("DRAW");
            else puts("USAGI");
            return 0;
        }
        else if(cnt[1] >= u[1]){
            puts("NEKO");
            return 0;
        }
    }
    puts("DRAW");
}


Measured memory_bytes: 22200
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int a,b,k;
cin >> a >> b >> k;
int i=100;
int ans;
while(1){
  if(a%i==0&&b%i==0) {
    k--;
  }
  if(k==0) break;
  i--;
}
cout << i << endl;
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <math.h>
#include <iomanip>
#include <vector>

typedef long long ll;

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

using namespace std;

int main()
{
    // vector<int> a, b;
    int as, bs;
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n+1);
    vector<int> room(n+1, -1);

    rep(i, m) {
        cin >> as >> bs;
        a.at(as).push_back(bs);
        a.at(bs).push_back(as);
    }
    vector<int> next;
    room.at(1) = 0;
    next.push_back(1);
    while (0 < next.size()) {
        vector<int> nextt;
        for(int ni: next) {
            for (int r: a.at(ni)) {
                if (room.at(r) != -1) { continue; }
                room.at(r) = ni;
                nextt.push_back(r);
            }
        }
        next = nextt;
    }
    cout << "Yes" << endl;
    int s = 0;
    for ( int m: room) {
        s++;
        if (s < 3) continue;
        cout << m << endl;
    }
}


Measured memory_bytes: 10532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll m = 0, z = 0;
  REP(i, n) {
    cin >> a[i];
    m += a[i] < 0;
    z += a[i] == 0;
    a[i] = abs(a[i]);
  }
  sort(ALL(a));
  ll ans = 0;
  FOR(i, 1, n) { ans += a[i]; }
  if (m % 2 == 1) {
    ans -= a[0];
  } else {
    ans += a[0];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
  int h, m, s, S;
  cin >> S;
  h = S / 3600;
  m = (S % 3600) / 60;
  s = (S % 3600) % 60;

  cout << h << ":" << m << ":" << s << endl;
  return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int N; cin >> N;
    string S; cin >> S;
    
    int lcnt = 0;
    for (int i = N - 1; i >= 0; --i) {
        if (S[i] == ')') lcnt++;
        else if (lcnt > 0) lcnt--;
    }
    
    int rcnt = 0;
    for (int i = 0; i < N; ++i) {
        if (S[i] == '(') rcnt++;
        else if (rcnt > 0) rcnt--;
    }
    
    for (int i = 0; i < lcnt; ++i) cout << '(';
    cout << S;
    for (int i = 0; i < rcnt; ++i) cout << ')';
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll d, n;
    cin >> d >> n;
    if(n == 100)
        n++;
    ll ans = n * pow(100, d);
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

#define MAX_N 100000
ll inv[MAX_N], fac[MAX_N], finv[MAX_N];
void make() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2; i<MAX_N; i++) {
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    fac[i] = fac[i-1] * (ll)i % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}
ll perm(ll n, ll r) {
  if(n < 0)       return 0;
  else if(n < r)  return 0;
  else            return (fac[n] * finv[n-r]) % mod;
}
ll comb(ll n, ll r) {
  ll ans = 1;
  ans = perm(n, r); // n * (n-1) * ... * (n-r+1)
  ans = (ans * finv[r]) % mod; // フェルマーの小定理
  return ans;
}

int main() {
  make();
  int N;
  cin >> N;
  vector<int> A(N+1);
  map<int, int> mp;
  // unordered_map<int, int> mp;
  int idx, idx2;
  rep(i, N+1) {
    cin >> A[i];
    if(mp.find(A[i]) != mp.end())
      idx = mp[A[i]], idx2 = i;
    else
      mp.insert(make_pair(A[i], i));
  }
  int l = idx;
  int m = idx2 - idx - 1;
  int r = N - idx2;
  REP(i, 1, N+2) {
    if(i == 1)
      cout << N << endl;
    else {
      ll zero = comb(N-1, i);
      ll one = ((comb(N-1, i-1) * 2) % mod + mod - comb(l+r, i-1)) % mod;
      ll two = comb(N-1, i-2);
      cout << (zero + one + two) % mod << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 8576
N=int(input())
if N%2==1: #Nが奇数ならどうやっても2を因数に持たない
    print(0)
else: #偶数ならば、10の倍数ごとに5を因数に持つ
    ans=0
    i=1
    ans+=N//10
    while N>=10*5**i:
        ans+=N//(10*5**i)
        i+=1
    print(ans)

Measured memory_bytes: 2940
#include <cstdio>
#include <cmath>
#include <iostream>

using namespace std;

inline double rad(int C) {
  return C * M_PI / 180.0;
}

static double calc_area(int a, int b, double radc) {
  return static_cast<double>(a) * static_cast<double>(b) * sin(radc) / 2.0;
}

static double calc_c(int a, int b, double radc) {
  return sqrt(a * a + b * b - 2 * a * b * cos(radc));
}

static double calc_height(int b, double radc) {
  return b * sin(radc);
}

int main() {
  int a, b, C;
  cin >> a >> b >> C;
  const double radc = rad(C);
  printf("%f\n", calc_area(a, b, radc));
  printf("%f\n", static_cast<double>(a) + static_cast<double>(b) + calc_c(a, b, radc));
  printf("%f\n", calc_height(b, radc));
  return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
long long n,k,a[200005],p[200005],m,d;
bool vis[200005];
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;++i)
	 	cin>>a[i];
	int i=a[1];
	p[0]=1;
	vis[1]=1;
	while(!vis[i])
	{
		vis[i]=1;
		++d;
		p[d]=i;
		i=a[i];
	}
	++d;
	for(int j=0;j<=d;++j)
	{
		if(p[j]==i)
		{
			m=j;
			break;
		}
	}
	if(k<=m)
	{
		cout<<p[k];
		return 0;
	}
	d-=m;
	k=(k-m)%d;
	cout<<p[k+m];
	return 0;
}

Measured memory_bytes: 6788
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline void InputV(vector<T>& A, int N) {rep(i,N) cin >> A.at(i);}
//C++14 (GCC 5.4.1)
int main() {
    int N,K;
    cin >>N >>K;

    vector<int> h(N);
    InputV(h,N);
    
    bool is=false;
    //-----------------------------------
    int Ans=0;
    vector<int> c_min(N,INT_MAX);
    c_min.at(0)=0;
    c_min.at(1)=std::abs(h.at(1)-h.at(0));
    repd(i,2,N){
        repd(j,max(0,i-K),i){
            //cout << i<<" "<<j<<endl;
            chmin(c_min.at(i),c_min.at(j)+std::abs(h.at(i)-h.at(j)));
        }
    };

    cout << c_min.at(N-1) <<endl;
    //cout << ((is) ? "YES" : "NO") <<endl;
}

Measured memory_bytes: 1024
#C - Day dream
S_input = input()
S = S_input
for i in range(len(S_input)):
    S = S[:i]+S_input[len(S_input)-1-i]+S[i+1:]
#print(S)
#S_input = input()
    
#S = S_input[::-1]
end_flg = 1
while end_flg:
    if S.startswith('maerd'):
        S = S.replace('maerd', '', 1)
    elif S.startswith('remaerd'):
        S = S.replace('remaerd','',1)
    elif S.startswith('esare'):
        S = S.replace('esare','',1)
    elif S.startswith('resare'):
        S = S.replace('resare', '', 1)
    else:
        end_flg = 0
if len(S) == 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3536
#include <stdio.h>

int main(void){
    int r,c,i,j;
    scanf("%d %d",&r,&c);
    int data[r][c];
    int ans[r+1][c+1];
    for(i = 0;i<r+1;i++){
        for(j = 0;j<c+1;j++){
            ans[i][j] = 0;
        }
    }
    for(i = 0;i<r;i++){
        for(j = 0;j<c;j++){
            scanf("%d",&data[i][j]);
            ans[i][j] = data[i][j];
        }
    }
    for(i = 0;i<r;i++){
        for(j = 0;j<c;j++){
            ans[i][c] += data[i][j];
        }
    }
    for(j=0;j<c+1;j++){
        for(i = 0;i<r;i++){
            ans[r][j] += ans[i][j];
        }
    }
    for(i=0;i<r+1;i++){
        for(j=0;j<c+1;j++){
            if(j != 0)printf(" ");
            printf("%d",ans[i][j]);
        }
        printf("\n");
    }
    return 0;
}

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

int main()
{
  	int n,m,c;
  	cin>>n>>m>>c;
  	vector<int> b(m);
  	int ai;
  	for(int i=0 ; i<m ; ++i)
    cin>>b[i];
  	int ans=0;
  	for(int i=0 ; i<n ; ++i)
    {
    	int curr=0;
      	for(int j=0 ; j<m ; ++j)
        {
          	cin>>ai;
        	curr+=(b[j]*ai);
        }
      	curr+=c;
      	ans+=curr>0;
    }
  	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bfs(nodes, src):
    from collections import deque

    N = len(nodes)
    que = deque([src])
    res = [-1] * N
    res[src] = 0
    while que:
        u = que.popleft()
        for v in nodes[u]:
            if res[v] != -1:
                continue
            res[v] = u
            que.append((v))
    return res

N, M = MAP()
nodes = [[] for i in range(N)]
for i in range(M):
    a, b = MAP()
    a -= 1; b -= 1
    nodes[a].append(b)
    nodes[b].append(a)

res = bfs(nodes, 0)
Yes()
for a in res[1:]:
    print(a+1)


Measured memory_bytes: 91820
#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 fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

template <typename T>
struct twodim_fenwick_tree {
    int h, w;
    vector<vector<T>> data;
    twodim_fenwick_tree(int h, int w) : h(h), w(w), data(h+1, vector<T>(w+1)) {}
    void add(int r, int c, T x=1) {
        for (int i = r+1; i <= h; i += i&-i)
            for (int j = c+1; j <= w; j += j&-j) data[i][j] += x;
    }
    T sum(int r, int c) {
        T res = 0;
        for (int i = r; i; i -= i&-i)
            for (int j = c; j; j -= j&-j) res += data[i][j];
        return res;
    }
    T sum(int r1, int c1, int r2, int c2) {
        return sum(r2, c2) - sum(r1, c2) - sum(r2, c1) + sum(r1, c1);
    }
};

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

    int n, m, q;
    cin >> n >> m >> q;
    twodim_fenwick_tree<int> ft(n, n);
    rep(i, m) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        ft.add(l, r);
    }
    while (q--) {
        int p, q;
        cin >> p >> q;
        p--; q--;
        cout << ft.sum(p, 0, n, q+1) << endl;
    }
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll diff = b - a;
    if (diff%2 == 0) {
        cout << diff / 2 << endl;
    } else {
        cout << min(a-1, n-b) + (diff-1) / 2 + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
	string s;
	int cnt[3] = {};
	cin >> s;
	for(int i = 0; i < s.size(); i++) {
		cnt[s[i]-'a']++;
	}
	if(max(cnt[0],max(cnt[1],cnt[2])) - min(cnt[0],min(cnt[1],cnt[2])) <= 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 512
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

int A, B, K;
set <int> S;

int main()
{
	scanf("%d %d %d", &A, &B, &K);
	for(int i = 0; i < K; i++) {
		if(A + i >= A && A + i <= B) {
			S.insert(A + i);
		}
		if(B - i >= A && B - i <= B) {
			S.insert(B - i);
		}
	}
	set <int> :: iterator i;
	for(i = S.begin(); i != S.end(); i++) {
		cout << *i << "\n";
	}

	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int c[101];
int main()
{
	int a,b;
	cin>>a>>b;
	c[a]++;
	c[b]++;
	for(int i=1;i<=3;i++)
	{
		if(!c[i])
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

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

int main(){
  long long n,m;
  cin>>n>>m;
  vector<pair<long long,long long>>mise(n);
  for(long long i=0;i<n;i++){
    cin>>mise[i].first>>mise[i].second;
  }
  sort(mise.begin(),mise.end());
  long long sum=0;
  long long kazu=0;
  for(int i=0;i<n;i++){
    if(kazu<m){
      if(m-kazu>=mise[i].second){
        sum+=mise[i].second*mise[i].first;
        kazu+=mise[i].second;
      }else{
        sum+=(m-kazu)*mise[i].first;
        kazu+=m-kazu;
      } 
    }
    if(kazu==m)break;
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 1792
function main()
  K,N=map(x->parse(Int,x),split(readline()))
  A=map(x->parse(Int,x),split(readline()))
  t=0
  for i=1:N-1
    t=max(t,A[i+1]-A[i])
  end
  t=max(t,K+A[1]-A[N])
  println(K-t)
end
main()

Measured memory_bytes: 207956
S = list(input())

N = len(S)
M = N // 2
A = S[:M]
B = S[M + 1:]

flag = True
for i in range(M):
  if A[i] != B[-1 - i]:
    flag = False
  if A[i] != A[-1 - i]:
    flag = False

if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

vi to[100005];
// abc148 f

vi dist;
int n;

void dfs(int v, int d=0, int p=-1) {
  dist[v] = d;
  for (int u: to[v]) {
    if (u == p) continue;
    dfs(u,d+1,v);
  }
}

vi getDist(int v) {
  dist = vi(n);
  dfs(v);
  return dist;
}
int main() {
  int t, a; cin >> n >> t >> a;
  t--; a--;
  rep(i,n-1) {
    int a,b; cin >> a >> b; a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  vi distA = getDist(a); 
  vi distT = getDist(t);

  int ans=0;
  rep(i,n) {
    if (distA[i] > distT[i]) {
      chmax(ans, distA[i]);
    }
  }
  ans--;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 13576
N = int(input())
SP = [0]*N
for n in range(N):
    SP[n] = list(input().split())+ [n+1]

for sp in SP:
    sp[1] = int(sp[1])

SP.sort(key = lambda x: x[1], reverse=True)
SP.sort(key = lambda x: x[0])

for sp in SP:
    print(sp[2])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int a[10];
int main() {
	for(int i = 0; i < 10; i++) scanf("%d", &a[i]);
	sort(a, a + 10, greater<int>());
	for(int i = 0; i < 3; i++) printf("%d\n", a[i]);
	return 0;
}

Measured memory_bytes: 3284
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        int[] n = Read.Ints();
        int now = 0;
        bool flag = true;
        for (int i = 0; i < n[0]; i++)
        {
            string a = Read.Str();
            for (int k = 0; k < n[1]; k++)
            {
                if (a[k] == '#')
                {
                    if (k < now) { flag = false; break; }
                    else { now = k; }
                }
            }
        }Console.WriteLine(flag?"Possible":"Impossible");
    }
    public static Boolean uso() { return false; }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (int i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] Ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define MAX (2000000)
#define INFINITY (1<<30)
int H,A[MAX+1];

void MaxHeap(int i){
    int l,r,max;
    l=2*i;
    r=2*i+1;
    if(l<=H&&A[l]>A[i])max=l;
    else max=i;
    if(r<=H&&A[r]>A[max])max=r;
    
    if(max!=i){
        swap(A[i],A[max]);
        MaxHeap(max);
    }
}

int extract(){
    int max;
    if(H<1)return -INFINITY;
    max=A[1];
    A[1]=A[H];
    H--;
    MaxHeap(1);
    return max;
}

void IncreaseKey(int i,int key){
    if(key<A[i])return;
    A[i]=key;
    while(i>1&&A[i/2]<A[i]){
        swap(A[i],A[i/2]);
        i=i/2;
    }
}

void Insert(int key){
    H++;
    A[H]=-INFINITY;
    IncreaseKey(H,key);
}

int main(void){
    int key;
    char command[10];
    while(1){
        scanf("%s",command);
        if(command[0]=='e'&&command[1]=='n')break;
        if(command[0]=='i'){
            scanf("%d",&key);
            Insert(key);
        }
        else{
            printf("%d\n",extract());
        }
    }
    return 0;
}



Measured memory_bytes: 7072
s=input()
ans=0
cnt=1
res=[]
s+="X"
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        cnt+=1
    elif s[0]==">" and ans==0:
        ans+=cnt*(cnt+1)//2
        cnt=1
    else:
        res.append(cnt)
        cnt=1
for i in range(len(res)//2):
    r1=max(res[2*i],res[2*i+1])
    r2=min(res[2*i],res[2*i+1])
    ans+=(r1*(r1+1)+r2*(r2-1))//2
if len(res)%2==1:
    ans+=res[-1]*(res[-1]+1)//2
print(ans)

Measured memory_bytes: 6300
//	created : 16/05/02
// 	author   : Rp7rf
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define INF 1e9


int main(void){
  string s;
  int ret = 0;
  cin>>s;
  rep(i,s.size()/2){
    if((s[i] == ')' && s[s.size()-i-1] == '('))continue;
    if((s[i] == '(' && s[s.size()-i-1] == ')'))continue;
    if(s[i] != s[s.size()-i-1]){ret++;continue;}
    if((s[i] == '(' && s[s.size()-i-1] == '('))ret++;
    if((s[i] == ')' && s[s.size()-i-1] == ')'))ret++;
  }
  if(s.size()%2){
    int center = s.size()/2;
  //  cout<<s[center]<<endl;
    if(s[center]=='(' || s[center]==')')ret++;
  }
  cout<<ret<<endl;
}

Measured memory_bytes: 1180
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
mod = 10**9+7
ans = 0 ;count = 0 ;pro = 1
n=20
class UnionFind:
    __slots__ = ['id','sz']

    def __init__(self, n):
        self.id = [-1] * n
        self.sz = n

    def root(self, x):
        if self.id[x] < 0:
            return x
        else:
            self.id[x] = self.root(self.id[x])
            return self.id[x]

    def find(self, x, y):
        return self.root(x) == self.root(y)

    def union(self, x, y):
        s1, s2 = self.root(x), self.root(y)
        if s1 != s2:
            if self.id[s1] <= self.id[s2]:
                self.id[s1] += self.id[s2]
                self.id[s2] = s1
            else:
                self.id[s2] += self.id[s1]
                self.id[s1] = s2
            self.sz-=1
            return True
        return False

uf=UnionFind(13)
uf.union(1,3)
uf.union(1,5)
uf.union(1,7)
uf.union(1,8)
uf.union(1,10)
uf.union(1,12)
uf.union(4,6)
uf.union(4,9)
uf.union(4,11)
x,y=map(int,input().split())
if uf.find(x,y):
    print("Yes")
else:
    print("No")

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define ld long double
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';              

typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

const ll mod = 1e9 + 7;

int main(){

	// IOS

	ll n,m,i,v;
	cin >> n >> m;
	vl a(n + 1, 0);
	forn(0,m,i){
		cin >> v;
		a[v] = 1;
	}

	cerr << "Hmm\n";

	ll dp[n + 1];

	cerr << "Hmmmn\n";

	fill(dp,dp + n + 1, 0);

	dp[0] = 1;

	cerr << "Hmmmn\n";

	forn(1,n + 1,i){
		if(i > 1){
			if(a[i - 1] == 0){
				dp[i] = (dp[i - 1] + dp[i]) % mod;
			}
			if(a[i - 2] == 0){
				dp[i] = (dp[i - 2] + dp[i]) % mod;				
			}
		}else{
			if(a[i - 1] == 0){
				dp[i] = (dp[i - 1] + dp[i]) % mod;
			}
		}
	}
	cout << dp[n] % mod << '\n';
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{

    int N;
    cin >> N;

    int64_t sum = 0;
    vector<int> A(N);
    for (int i=0;i<N;++i) {
        cin >> A[i];
        if (i == 0) {
            sum += abs(A[i]);
        } else {
            sum += abs(A[i] - A[i-1]);
        }
    }
    sum += abs(A.back());

    for (int i=0;i<N;++i) {
        int prev = i==0?0:A[i-1];
        int cur = A[i];
        int next = i==N-1?0:A[i+1];
        cout << (sum - abs(cur-prev) - abs(next-cur) + abs(next-prev)) << endl;
    }


    return 0;
}

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

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


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,f=1; scanf("%d",&n);
  char s[n]; scanf("%s",s);
  if (n%2==0){
    for (int i=0; i<n/2; i++){
      if (s[i]!=s[n/2+i]){ f=0; break;}
      if (i==n/2-1) f=1;
    }
  }else{ f=0;}
  if(f==1) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	long long a, b, k;

	scanf("%lld %lld %lld", &a, &b, &k);

	if (a >= k)
	{
		printf("%lld %lld\n", a - k, b);
		return 0;
	}

	if (a + b >= k)
	{
		printf("0 %lld\n", b + a - k);
		return 0;
	}

	printf("0 0\n");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define P pair<int,int>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define re(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    int ans=0;
    rep(i,n-1){
       if(a[i]==a[i+1]){
           ans++;
       } 
    }
    cout<<n-ans<<endl;
}


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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T> inline bool changeMinimum(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T> inline bool changeMaximum(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */

int main() {


    int  N;
    cin >> N;
    double  PI=3.14159265358979323846;
    cout << N * 2 * PI << endl;
}

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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

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(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

//ARC055D
int gcd(int a,int b){return b?gcd(b,a%b):a;}
/*int gcd(int a,int b){
	if(a==0)return b;
	if(b==0)return a;
	if(a<0)a=-a;
	if(b<0)b=-b;
	int s=botbit(a|b);
	a>>=botbit(a);
	do{
		b>>=botbit(b);
		if(a>b)swap(a,b);
		b-=a;
	}while(b);
	return a<<s;
	
}*/
int lcm(int a,int b){return a/gcd(a,b)*b;}

const int B=500;

vi snuke(int n){
	const int Vmax=1000;
	vi u(B+1);
	vi res{B};
	u[B]=1;
	while(int(res.size())<n){
		int a=res.back();
		bool z=0;
		gnr(b,1,B+1)if(!u[b]&&lcm(a,b)<=Vmax){
			res.pb(b);
			u[b]=1;
			z=1;
			break;
		}
		if(!z){
			cout<<u.size()<<endl;
		}
		assert(z);
	}
	return res;
}

bool isprime(int p){
	for(int i=2;i*i<=p;i++)
		if(p%i==0)return false;
	return true;
}

vi pris(int n){
	vi res;
	int cur=B+1;
	while(int(res.size())<n){
		if(isprime(cur))res.pb(cur);
		cur++;
	}
	return res;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	//int n;cin>>n;
	//cout<<snuke((n+1)/2)<<endl;
	//cout<<pris(n/2*2).back()<<endl;
	
	int n;cin>>n;
	vvc<int> a(n,vi(n,-1));
	set<int> s;
	auto waf=[&](int v,int off){
		int d=v+off;
		while(s.count(d))d+=v;
		s.insert(d);
		return d;
	};
	vi c=snuke((n+1)/2);
	vi ps=pris(n);
	rep(i,n){
		for(int j=(i+1)%2;j<n;j+=2){
			a[i][j]=ps[i]*c[j/2];
		}
	}
	int mx=0;
	rep(i,n)rep(j,n)chmax(mx,a[i][j]);
	cerr<<mx<<endl;
	using T=tuple<int,int,int>;
	vc<T> z;
	rep(i,n)rep(j,n){
		if((i+j)%2==0){
			int w=1;
			const int dyx[]{-1,0,1,0,-1};
			rep(k,4){
				int y=i+dyx[k],x=j+dyx[k+1];
				if(0<=y&&y<n&&0<=x&&x<n)
					w=lcm(w,a[y][x]);
			}
			chmax(mx,w);
			z.eb(w,i,j);
		}
	}
	cerr<<mx<<endl;
	sort(all(z),greater<T>());
	for(auto p:z){
		int v,i,j;tie(v,i,j)=p;
		int d=waf(v,1);
		a[i][j]=d;
		chmax(mx,d);
	}
	cerr<<mx<<endl;
	assert(mx<=1000000000000000LL);
	rep(i,n)
		rep(j,n){
			cout<<a[i][j];
			if(j<n-1)cout<<" ";
			else cout<<endl;
		}
}


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000003ll;

// ? https://en.wikipedia.org/wiki/Arithmetic_progression#Product

ll fact[MOD];
ll ifact[MOD];
ll modpow(ll a,ll b){
    ll r=1;
    while(b){
        if(b&1)r=r*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return r;
}
ll modinv(ll a){
    return modpow(a,MOD-2);
}

int main(){
    int q;
    scanf("%d",&q);
    // precalc
    fact[0] = 1;
    FOR(i,1,MOD)fact[i]=fact[i-1]*i%MOD;
    ifact[MOD-1] = modinv(fact[MOD-1]);
    FORR(i,1,MOD)ifact[i-1]=ifact[i]*i%MOD;
    // query
    while(q--){
        ll n,a,d;
        scanf("%lld%lld%lld",&a,&d,&n);
        ll iv = a*modinv(d)%MOD;
        if(d==0){
            printf("%lld\n",modpow(a,n));
            continue;
        }else if(a==0 || iv+n-1>=MOD){
            puts("0");
            continue;
        }
        // calc
        ll ans = modpow(d,n) * fact[iv+n-1] % MOD * ifact[iv-1] % MOD;
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 16512
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <ll,ll>
#define N 100005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

struct node
{
	int wt, str,  val;
}s[1005];

bool cmp(node x, node y)
{
	return (x.wt + x.str < y.wt + y.str);
}
ll dp[N], ans = 0;
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> s[i].wt >> s[i].str >> s[i].val;
	}
	sort(s, s + n, cmp);
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i < n; ++i)
	{
		for (int w = (s[i].str + s[i].wt); w >= 1; --w)
		{
			if(s[i].wt <= w)
				dp[w] = max(dp[w], dp[w - s[i].wt] + s[i].val);
		}
	}
	for (int i = 0; i < N; ++i)
	{
		ans = max(ans, dp[i]);
	}
	cout << ans;
}


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

int main(){
  int a, b, c, ans;
  cin >> a >> b >> c;
  if (a+b < b+c && a+b < c+a) {
    ans = a+b;
  } else if (b+c < c+a) {
    ans = b+c;
  } else {
    ans = c+a;
  }
  cout << ans << endl;
  return 0;
}

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

int const MAXN = 2e5;
int a[MAXN];
bool b[MAXN];

int main() {
  int N; std::cin >> N;
  for(int i = 0; i < N; ++i) std::cin >> a[i];
  std::fill_n(b, N, false);
  int ans = 0;
  for(int i = N; i > 0; --i) {
    int cnt = a[i-1];
    for(int j = i*2; j <= N; j += i) if(b[j-1] > 0) ++cnt;
    if(cnt%2==1) { b[i-1] = true; ++ans; }
  }
  std::cout << ans << "\n";
  for(int i = 0; i < N; ++i) if(b[i]) {
    --ans;
    if(ans > 0) std::cout << (i+1) << " ";
    else        std::cout << (i+1) << "\n";
  }
  return 0;
}


Measured memory_bytes: 1920
n = gets.to_i
a = gets.split.map(&:to_f)
b = gets.split.map(&:to_f)
d = a.zip(b)
(1..3).each do |k|
  p d.map {|x, y| (x - y).abs ** k }.inject(:+) ** (1.0 / k)
end
p d.map {|x, y| (x - y).abs }.max


Measured memory_bytes: 6956
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	if(n>m)swap(n,m);
	if((n==1)&&(m==1)) puts("1");
	else
	if(n==1)printf("%d\n",m-2);
	else
	{
	  ll ans=1ll*n*m;
	  ans-=1ll*2*(n+m-2);
	  printf("%lld\n",ans);
	}
	return 0;
}

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

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 13;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

double x[N], y[N];

ld dis(int i, int j){
    return sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
}

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    double f = 1;
    vector<int> v;
    for (int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
        f *= (i+1);
        v.pb(i);
    }
    ld s = 0;
    do{
        for (int i = 0; i < n-1; i++){
            s += dis(v[i], v[i+1]);
        }
    }while(next_permutation(all(v)));
    cout << fixed << setprecision(22) << s / f;
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    int sum_a = 1, sum_b = 1;
    cin >> N;
    vector<int> P(N), Q(N);
    for (int i = 0; i < N; i++)
    {
        cin >> P[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> Q[i];
    }
    vector<int> base(N);
    vector<int> base2(N);
    iota(base.begin(), base.end(), 1);
    base2 = base;
    while (P != base)
    {
        next_permutation(base.begin(), base.end());
        sum_a++;
    }
    while (Q != base2)
    {
        next_permutation(base2.begin(), base2.end());
        sum_b++;
    }
    int sum = (sum_a > sum_b) ? sum_a - sum_b : sum_b - sum_a;
    cout << sum << endl;
}

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

const int S=(1<<20)+5;
char buf[S],*H,*T;
inline char Get() {
	if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
	if(H==T) return -1;
	return *H++;
}
inline int read() {
	int x=0;
	char c=Get();
	while(!isdigit(c)) c=Get();
	while(isdigit(c)) x=x*10+c-'0',c=Get();
	return x;
}

const int N=200010;
struct Edge {
	int to,capa,next;
} e[N];
int h[N],sum=0,n,m;
bool vis[N];
int cmt,cnt,col[N],c[3];
bool falun;

inline int color(const int &x) {
	if(x>=3) return x-3;
	if(x<0) return x+3;
	return x;
}

void add_edge(int u,int v,int w) {
	e[++sum].to=v;
	e[sum].capa=w;
	e[sum].next=h[u];
	h[u]=sum;
}

void dfs(int u) {
	c[col[u]]++;
	vis[u]=1;
	cnt++;
	for(int tmp=h[u]; tmp; tmp=e[tmp].next) {
		cmt+=(e[tmp].capa==1);
		int v=e[tmp].to;
		if(!vis[v]) col[v]=color(col[u]+e[tmp].capa),dfs(v);
		else if(col[v]!=color(col[u]+e[tmp].capa)) falun=0;
	}
}

int main() {
	int u,v;
	n=read();
	m=read();
	for(int i=1; i<=m; i++) {
		u=read();
		v=read();
		add_edge(u,v,1);
		add_edge(v,u,-1);
	}
	long long ans=0;
	for(int i=1; i<=n; i++) {
		if(vis[i]) continue;
		memset(c,0,sizeof(c));
		cmt=cnt=0;
		falun=1;
		dfs(i);
		if(!falun) ans+=1ll*cnt*cnt;
		else if(c[0]&&c[1]&&c[2]) ans+=1ll*c[0]*c[1]+1ll*c[1]*c[2]+1ll*c[2]*c[0];
		else ans+=cmt;
	}
	printf("%lld\n",ans);
	return 0;
}

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

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


    vector<int> dp(n+1);
    dp[0] = 0;
    dp[1] = dp[0] + abs(v[1]-v[0]);
    for (int i = 2; i < n; ++i)
    {
        dp[i] = min(dp[i-1]+abs(v[i]-v[i-1]), dp[i-2] + abs(v[i]-v[i-2]));
    }

    cout << dp[n-1] << "\n";

    // for (int i = 0; i < n; ++i) {
    //     cout << dp[i] << " " ;
    // }

    return 0;
}

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

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

int main(){
  // 入力
  int K;
  cin >> K;

  int result=0;
  for (int i=1; i<=K; i++) {
    for (int j=1; j<=K; j++) {
      for (int k=1; k<=K; k++) {
        result += gcd( gcd(i,j), k);
      }
    }
  }

  // cout << gcd( gcd(1,1), 1) << endl;

  cout << result << endl;
  return 0;
}

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

int main()
{
  int K ;
  cin>>K ;
  vector<int64_t>Lun_num{1,2,3,4,5,6,7,8,9} ;
  if(K<=9){
    cout<<Lun_num.at(K-1) ;
    return 0 ;
  }
  
  for(int i=0;9+i<K;i++){
    int64_t X=Lun_num.at(i) ;
    if(X%10!=0) Lun_num.push_back(10*X+(X%10)-1) ;
    Lun_num.push_back(10*X+(X%10)) ;
    if(X%10!=9) Lun_num.push_back(10*X+(X%10)+1) ;
  }
  cout<<Lun_num.at(K-1)<<endl ;
  
  return 0 ;
}

Measured memory_bytes: 3700
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N = nextInt();

		int ans = 1;
		while(ans <=N){
			ans=ans*2;
		}

		System.out.println(ans/2);

	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21076
function main()
    N, M, X, Y = parse.(split(readline()))
    a = parse.(split(readline()))
    b = parse.(split(readline()))
    append!(a, [X])
    append!(b, [Y])
    if maximum(a) < minimum(b)
        print("No War")
    else
        print("War")
    end
end
main()

Measured memory_bytes: 119812
package main

import (
	"fmt"
)

func main() {
	var A, B, K, cnt, ans int
	fmt.Scan(&A, &B, &K)
	gcd := gcdof2numbers(A, B)
	for i := gcd; ; i-- {
		if A%i == 0 && B%i == 0 {
			cnt++
		}
		if cnt == K {
			ans = i
			break
		}
	}
	fmt.Println(ans)
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}


Measured memory_bytes: 512
import sys
input = lambda:sys.stdin.readline().strip()
n,m = map(int,input().split())
h = list(map(int,input().split()))
adj = [set() for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a-=1;b-=1;
    adj[a].add(b)
    adj[b].add(a)
ans = 0
for i in range(n):
    val = h[i]
    ok = True
    for j in adj[i]:
        if h[j]>=val:
            ok = False
            break 
    if ok:
        ans+=1
print(ans)

Measured memory_bytes: 45208