akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, M;
    cin >> N >> M;
    vector<vector<P>> graph(N);
    rep(i, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        graph[a].push_back({b, -c});
    }

    vector<ll> cost(N, INF);
    bool updated = false;
    cost[0] = 0;
    rep(k, N) {
        for (int i = 0; i < N; ++i) {
            for (P &p : graph[i]) {
                if (cost[p.first] > cost[i] + p.second) {
                    cost[p.first] = cost[i] + p.second;
                    if (k == N - 1 && p.first == N -1) updated = true;
                }
            }
        }
    }
    if (updated) {
        cout << "inf" << '\n';
    } else {
        cout << -cost[N - 1] << '\n';
    }
}

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


Measured memory_bytes: 384
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var e = xArray(1e9,n,n);
  var t = o.m(m);
  for(var i = 0; i < n; i++){
    e[i][i] = 0;
  }
  for(var i = 0; i < m; i++){
    var a = --t[i][0], b = --t[i][1], c = t[i][2];
    e[a][b] = e[b][a] = c;
  }
  for(var k = 0; k < n; k++)
  for(var i = 0; i < n; i++)
  for(var j = 0; j < n; j++){
    if(e[i][j] > e[i][k]+e[k][j]){
      e[i][j] = e[i][k]+e[k][j];
    }
  }
  var ans = 0;
  for(var i = 0; i < m; i++){
    var a = t[i][0], b = t[i][1], c = t[i][2];
    if(e[a][b] < c)ans++;
  }
  return ans;
}

Measured memory_bytes: 11724
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int a,b,k;
  cin >> a >> b >> k;
  int cnt = 0;
  for(int i = max(a,b); i >= 1; i--){
    if(a % i == 0 && b % i == 0){
      cnt++;
      if(cnt == k){
        cout << i << endl;
        return 0;
      }
    }
  }
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a==b&&b==c)
    cout << "No" << endl;
  else if(a==b||b==c||c==a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}

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

#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define pb push_back
#define int long long

const int N = 250010;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int base = 1e6;
const int oo = 1e9;
typedef pair<int, int> ii;

int n, pos = N, curpos[N], bpw[2][N + N];
int has[2][N + N], rev[2][N + N];
string s;

void add(int &x, int val, int mod)  { val = (val % mod + 1ll * mod * mod) % mod;  x = (x + val) % mod;  }
void mul(int &x, int y, int mod) { y = (y + 1ll * mod * mod) % mod; x = x * y % mod; }
int pw(int x, int y, int mod)    {
    int res = 1ll;
    while(y)    {
        if(y % 2 == 1) mul(res, x, mod);
        mul(x, x, mod);
        y /= 2;
    }
    return res;
}

map<ii, int> cnt;

signed main()
{
    //freopen("test.inp", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin >> n >> s;
    bpw[0][0] = bpw[1][0] = 1ll;
    FOR(i, 1, N + N - 1) {
        bpw[0][i] = bpw[0][i - 1] * base % MOD;
        bpw[1][i] = bpw[1][i - 1] * base % MOD2;
        rev[0][i] = pw(bpw[0][i], MOD - 2, MOD);
        rev[1][i] = pw(bpw[1][i], MOD2 - 2, MOD2);
    }
    //cout << pw(base, N + 1, MOD) << '\n';
    //cout << bpw[0][N + 1] << ' ' << bpw[1][N + 1] << '\n';
    // we need to hash all the value of x
    FOR(i, 1, n)    {
        if(s[i - 1] == '+' || s[i - 1] == '-') {
            add(has[0][i], has[0][i - 1] + ((s[i - 1] == '+') ? +1 : -1) * bpw[0][pos], MOD);
            add(has[1][i], has[1][i - 1] + ((s[i - 1] == '-') ? -1 : +1 ) * bpw[1][pos], MOD2);
        } else     {
            pos += ((s[i - 1] == '>') ? +1 : -1);
            has[0][i] = has[0][i - 1];
            has[1][i] = has[1][i - 1];
        }
        //cout << has[0][i] << ' ' << has[1][i] << ' ' << pos << '\n';
        curpos[i] = pos - N;
    } //cout << '\n';

    int s1 = 1ll * has[0][n] % MOD;
    int s2 = 1ll * has[1][n] % MOD2;
    //cout << has[0][3] << ' ' << (bpw[0][curpos[1]] * s1 + has[0][1]) % MOD << '\n';
    cnt[ ii(s1, s2) ] ++;
    int ans = 0ll;
    FOR(i, 1, n)    {
        ans += cnt[ ii(has[0][i], has[1][i]) ];
        //if(cnt[ ii(has[0][i], has[1][i]) ] > 0) cout << i << ' ' << has[0][i] << ' ' << has[1][i] << '\n';
        int pw1 = ((curpos[i] >= 0) ? bpw[0][ curpos[i] ] : rev[0][-curpos[i]]);
        int pw2 = ((curpos[i] >= 0) ? bpw[1][ curpos[i] ] : rev[1][-curpos[i]]);
        int n1 = (s1 * pw1 % MOD + has[0][i] ) % MOD;
        int n2 = (s2 * pw2 % MOD2 + has[1][i] ) % MOD2;
        //cout << n1 << ' ' << n2 << '\n';
        cnt[ ii(n1, n2) ] ++;
    }

    cout << ans;
}
// limit
// negetive number


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N; cin >> N;
    vector<pair<int,pair<int, int>>> T(N);
    for(int i = 0; i < N; i++) cin >> T[i].first >> T[i].second.first >> T[i].second.second;
    sort(T.begin(), T.end());
    int tim = 0;
    int prex = 0, prey = 0;
    string ans = "Yes";
    for(int i = 0; i < N; i++) {
        int nowx = T[i].second.first, nowy = T[i].second.second;
        int dist = abs(nowx - prex) + abs(nowy - prey);
        if((T[i].first - tim - dist) % 2 == 0 && T[i].first - tim - dist >= 0) {
            tim += dist;
            if(tim > T[i].first) {
                ans = "No";
                break;
            }
            prex = nowx, prey = nowy;
        }
        else {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4260
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    s = input()
    month = [i for i in range(1, 13)]
    if int(s[:2]) not in month and int(s[2:]) in month:
        print('YYMM')
    elif int(s[:2]) in month and int(s[2:]) not in month:
        print('MMYY')
    elif int(s[:2]) in month and int(s[2:]) in month:
        print('AMBIGUOUS')
    else:
        print('NA')
    
if __name__ == '__main__':
    main()

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> X(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &X[i]);
  }
  sort(all(X));

  if (N >= M) {
    put(0);
    return 0;
  }

  vector<ll> diffs;
  rep(i, 1, M) { diffs.pb(abs(X[i] - X[i - 1])); }
  sort(all(diffs));

  ll ans = accumulate(begin(diffs), begin(diffs) + M - N, 0);
  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

template <class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 2168
#include <iostream>
#include <vector>
#include <tuple>
#include <deque>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
const ll SIZE = 1e5 * 2 + 10, INF = 1e9;

vector<ll> vec;

int main()
{
    fastInp;

    ll a, b;
    cin >> a >> b;
    if (a <= 0 && b >= 0) {
        cout << "Zero";
        return 0;
    }

    if (a < 0) {
        if ((min(-1ll, b) - a) % 2 == 0) {
            cout << "Negative";
            return 0;
        }
    }
    
    cout << "Positive";
    return 0;
}

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


using namespace std;

typedef complex<double> xy_t;

double dot_product(xy_t a, xy_t b) {
  return (conj(a)*b).real();
}

double cross_product(xy_t a, xy_t b) {
  return (conj(a)*b).imag();
}

double triangle_area(xy_t a, xy_t b) {
  return abs(cross_product(a, b) / 2.0);
}

int main() {
  xy_t P[110];


  int N = 0;
  double x, y;
  while(scanf("%lf,%lf", &x, &y)!= EOF) {
    xy_t entry(x,y);
    P[N++] = entry;
  }

  //center all coordinates based on first element
  

  for (int i = 1; i < N; i++) {
    P[i] -= P[0];
  }

  /*for (int i =0; i < N; i++) {
    cout << " x: " << P[i].real() << " y: " << P[i].imag() << endl;
    }*/
    
  //calculate sum
  double sum = 0.0;
  for (int i = 0; i+2 < N ; i++) {
    xy_t  b = P[i + 1] , c = P[i + 2];
    sum += triangle_area(b, c);
  }

  printf("%.6f\n", sum);
  
}

Measured memory_bytes: 3112
#include<stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d",&n);
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
   for(i = 0; i<VMAX;i++)C[i] = 0;
   
   for(i=0;i<n;i++){
     scanf("%hu",&A[i+1]);
     C[A[i+1]]++;
   }

   for(i=1;i<=VMAX;i++)C[i]=C[i]+C[i-1];

   for(j=1;j<=n;j++){
     B[C[A[j]]]=A[j];
     C[A[j]]--;
   }
  
  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i!=n)printf(" ");
  }
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 9620
use proconio::input;
use std::convert;

pub fn mpow<O, N, M>(n: N, m: M, md: O) -> O
where
    O: num::Integer + Copy + convert::From<N> + convert::From<M>,
    N: num::Integer + Copy,
    M: num::Integer + Copy,
{
    let mut result: O = O::one();
    let two: O = From::from(M::one() + M::one());
    let mut mm: O = From::from(m);
    let mut nn: O = From::from(n);

    while !mm.is_zero() {
        if mm.is_odd() {
            result = (result * nn) % From::from(md);
        }
        nn = (nn * nn) % From::from(md);
        mm = mm / two;
    }

    result
}

#[proconio::fastout]
fn main() {
    input! {
        n: i32
    }

    let m: i64 = 1000000007;
    let ans10: i64 = mpow(10, n, m);
    let ans9: i64 = mpow(9, n, m);
    let ans8: i64 = mpow(8, n, m);
    let ans = (ans10 - ans9 + m - ans9 + m + ans8) % m;
    println!("{}", ans);
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n)
  vll A(n);
  vll B(n);
  FOR(i,0,n){
    ci(A[i])
    B[i]=A[i];
  }
  SORT(A);
  ll m=A[n-1];
  bl b;
  if(m==A[n-2]){
    b=true;
  }
  else{
    b=false;
  }
  
  if(b){
  FOR(i,0,n){
    co(m)
  }
  }
    else{
      FOR(i,0,n){
        if(B[i]==m){
          co(A[n-2])
        }
        else{
          co(m)
        }
      }
    }
}

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

const int mod = 1e9+7;

ll res(int x, int y){
	ll ans = 1;
  	rep(i, y){
    	ans = ans * x % mod;
    }
  	return ans;
}

int main(){
	int n;
  	cin >> n;
  
  	ll ans = res(10, n) - res(9, n) - res(9, n) + res(8, n);
  	ans %= mod;
  	ans = (ans+mod)%mod;
  	cout << ans << endl;
}

Measured memory_bytes: 3640
N, Q = list(map(int, input().split()))
S = input()
T = [list(map(int, input().split())) for _ in range(Q)]

total_list = []
total = 0
for i in range(N-1):
  if S[i] == 'A' and S[i+1] == 'C':
    total += 1
  total_list.append(total)

for i in range(Q):
  l, r = T[i][0], T[i][1]
  if l != 1:
    print(total_list[r-2]-total_list[l-2])
  else:
    print(total_list[r-2])

Measured memory_bytes: 30604
#include <algorithm>
    #include <bits/stdc++.h>
    #include <cctype>
    #include <cmath>
    #include <cstdio>
    #include <iomanip>
    #include <iostream>
    #include <list>

    #include <stack>
    #include <string>
    #include <vector>
    #include <bits/stdc++.h>
    #define INFINI (1000 * 1000 * 1000)

    using namespace std;
    //#define s(T) scanf("%d", &T)
    #define sl(T) scanf("%lld", &T)
    #define fill(a, val) memset(a, val, sizeof(a))
    #define mp make_pair
    #define pb push_back
    #define all(x) x.begin(), x.end()
    #define DREP(x) sort(all(x)); x.erase(unique(all(x)), x.end())
    #define INDEX(a, val) (lower_bound(all(a), val) - a.begin())
    #define mod ll(1e9+7)
    typedef long long ll;


    bool compare_first(pair<ll,ll >a,pair<ll,ll >b)
    {
        return a.first<b.first;
    }

     bool compare_second(pair<int,pair<int , int> > a,pair<int,pair<int , int> > b)
    {
        return a.second.first<b.second.first;
    }


    ll min(ll a,ll b)
    {
        if(a>b)return b;
        return a;
    }


    int main() {
      ios::sync_with_stdio(false);

string s;
cin>>s;

vector<char> ans;
for(int index=0;index<s.size();index++)
{
    if(s[index]!='B')
        ans.push_back(s[index]);
    else if(!ans.empty())
    {
        ans.pop_back();
    }
}

for(int index=0;index<ans.size();index++)
    cout<<ans[index];
cout<<endl;


return 0;
    }


/*

 }
 */


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

#define ipr pair<int, int>
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define rf(i, j, k) for (int i = j; i >= k; i--)
#define ll unsigned long long
#define int long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
#define cnt_ones(x) __builtin_popcountll(x)

#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

const int Maxn = (int)1e6;
const ld pi = acos(-1);
const int mod = (int)1e9 + 7;
const int inf = (int)1e18;

template <class T>
ostream &operator<<(ostream &out, vector<T> &A) {
    fr(i, 0, (int)A.size()) out << A[i] << " ";
    return out;
}


int32_t main() {IOS
    int n;  cin>>n;
    string s;
    while(n > 0){
        int temp = n%26;
        if(temp == 0){
            s += 'z';
            n = n/26 - 1;
        }
        else{
            s += ('a' + temp - 1);
            n /= 26;    
        }
    }
    reverse(all(s));
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 132
	// https://atcoder.jp/contests/abc132/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		String str = sc.next();
		char[] c = str.toCharArray();
		Arrays.sort(c);

		if (c[0] == c[1] && c[2] == c[3] && c[0] != c[3]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

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

ll lcm(ll x, ll y) {
    return x / gcd(x,y) * y;
}

int main(void)
{
    IOS
    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    cin >> v[0];
    int g = v[0];
    int mx = v[0];
    REP(i,N-1) {
        cin >> v[i+1];
        g = gcd(g,v[i+1]);
        mx = max(mx,v[i+1]);
    }
    bool ans = false;
    REP(i,N) {
        if (v[i] < K) continue;
        if ((K-v[i]) % g == 0) {
            ans = true;
            break;
        }
    }

    if (ans) OUT("POSSIBLE")
    else OUT("IMPOSSIBLE")

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

int arr[502];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int a, b; cin >> a >> b;

    for(int i = 0; ; ++i){
        if(a * i - i + 1 >= b){
            cout << i;
            return 0;
        }
    }
    
    assert(false);

    cout << a;

    return 0;
}


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

#ifdef __LOCAL_DEBUG__
# define _debug(fmt, ...) fprintf(stderr, "\033[94m%s: " fmt "\n\033[0m", \
    __func__, ##__VA_ARGS__)
#else 
# define _debug(...) ((void) 0)
#endif
#define rep(i, n) for (int i=0; i<(n); i++)
#define Rep(i, n) for (int i=1; i<=(n); i++)
#define range(x) (x).begin(), (x).end()
typedef long long LL;
typedef unsigned long long ULL;

int k, n;


int main() {
  cin >> n >> k; k--;
  cout << (n - 1 + k - 1) / k << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;
 
int main(){

	string s;
	getline(cin, s);
	rep(i, s.size()){
		if('A' <= s[i] && s[i] <= 'Z') s[i] += 32;
		else if('a' <= s[i] && s[i] <= 'z') s[i] -= 32;
	}
	cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <set>

using namespace std;

const set<string> MM = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"};

int main() {
  string S;
  cin >> S;
  if (MM.count(S.substr(0, 2)) != 0) {
    if (MM.count(S.substr(2, 2)) != 0) {
      cout << "AMBIGUOUS" << endl;
    } else {
      cout << "MMYY" << endl;
    }
  } else if (MM.count(S.substr(2, 2)) != 0) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3576
/** coder Mohammad Al-Hussein *_^ */
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define mp make_pair
#define All(v) v.begin(),v.end()
#define mod  1000000007
#define write freopen("output.txt","w",stdout)
#define read freopen("test (1).txt","r",stdin)
#define FIO std::ios_base::sync_with_stdio(false);
using namespace std;
/// ggppgggpgg
/// gpgpgpgpgp
/// 0100011112



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

    int R = 0,P = 0,res = 0;

    for(int i=0; i<s.length(); i++)
    {
        if(s[i] == 'g')
        {
            if(P < R) res++,P++;
            else R++;
        }
        else
        {
            if(P < R) P++;
            else res--,R++;
        }
    }

    cout << res << endl;









    return 0;
}


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

int main()
{
    int sum, result;
    int n, m,  i, a;
    vector <int> v;

    cin >> n >> m;

    sum = 0;
    for (i = 0; i < m; i++)
    {
        cin >> a;
        sum = sum + a;
    }

    result = n - sum;

    if (result < 0)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << result << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	ans := 0
	for i := range a {
		for a[i]%2 == 0 {
			ans++
			a[i] /= 2
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int a[200005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  REP(i, n) cin >> a[i];

  vector<int> ans;
  REP(i, n) {
    if(n % 2 == 0) {
      if((i + 1) % 2 == 0) ans.insert(ans.begin(), a[i]);
      else ans.push_back(a[i]);
    } else {
      if((i + 1) % 2 != 0) ans.insert(ans.begin(), a[i]);
      else ans.push_back(a[i]);
    }
  }

  REP(i, n) cout << ans[i] << endl;
}


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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("F.in", "r", stdin);
	freopen ("F.out", "w", stdout);
#endif
}

const int Mod = 1e9 + 7, N = 4010;

int fpm(int x, int power) {
    int res = 1;
    for (; power; power >>= 1, x = 1ll * x * x % Mod)
        if (power & 1) res = 1ll * res * x % Mod;
    return res;
}

int fac[N], ifac[N];

void Fac_Init(int maxn) {
    fac[0] = ifac[0] = 1;
    For (i, 1, maxn)
        fac[i] = 1ll * fac[i - 1] * i % Mod;
    ifac[maxn] = fpm(fac[maxn], Mod - 2);
    Fordown (i, maxn - 1, 1)
        ifac[i] = 1ll * ifac[i + 1] * (i + 1) % Mod;
}

inline int Comb(int n, int m) {
	if (n < 0 || m < 0 || n < m) return 0;
	return 1ll * fac[n] * ifac[n - m] % Mod * ifac[m] % Mod;
}

inline int f(int n, int m) {
	if (m > n) return 0;
	return (Comb(n + m, m) - Comb(n + m, m - 1) + Mod) % Mod;
}

int main () {

	File();

	int n = read(), k = read();

	Fac_Init(n << 1);

	printf ("%lld\n", 1ll * (f(n, k - 1) - f(n, k - 2) + Mod) % Mod * fpm(2, max(n - k - 1, 0)) % Mod);

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
int main(){
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  rep(i,n){
    cin >> c.at(i);
    rep(j,m){
      cin >> a.at(i).at(j);
    }
  }
  int sum =10000000;
  rep(i, 1 << n){
    vector<int> l(m);
    int cost=0;
    bool s = true;
    rep(j, n){
      if((i >>j) &1){
        rep(k,m){
          l.at(k) += a.at(j).at(k);
          
        }
        cost += c.at(j);
      }
      
    }
    rep(k,m){
      if(l.at(k) < x){
            s =false;
          }
      }
      if(s){
        sum = min(sum, cost);
      }
    }
    if(sum == 10000000){
      cout << -1 << endl;
    }
  else{  
    cout << sum << endl;
  }
}
      

Measured memory_bytes: 3644
#include<stdio.h>
#define SIZE 100000

int isOK(int n,int k,int p,int w[]){
	int i,j,sum=0;
	for(i=0;i<n;i++){
		sum+=w[i];
		if(sum>p){
			k--;i--;
			sum=0;
			if(k<=0)return -1;
		}
	}
	
	return 1;
}

int solve(int l,int r,int n,int k,int w[]){
	int mid=(l+r)/2;
	if(isOK(n,k,mid,w)==-1)return solve(mid+1,r,n,k,w);
	if(mid==l)return mid;
	return solve(l,mid,n,k,w);


}

int main(void){
	int n,k;
	int w[SIZE];
	int i;
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++)scanf("%d",&w[i]);
	printf("%d\n",solve(0,1<<30,n,k,w));
	return 0;
}

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

#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )

void swap(int* x, int *y)
{
	int t;

	t = *x;
	*x = *y;
	*y = t;
}

void insertSort(int p[], int n)
{
	int i, j,k;

	for (i = 1; i < n; i++)
	{
		j = i;
		while (j >= 1 && (p[j] < p[j - 1]))
		{
			swap(&p[j], &p[j - 1]);
			j--;
		}

		for (k = 0; k < n-1; k++)
			printf("%d ", p[k]);

		printf("%d\n",p[n-1]);
	}
}

int GCD(int x, int y)
{
	if (x < y)
		swap(&x, &y);

	if (y == 0)
		return x;

	return GCD(y, x % y);
}

int not_prime_count(int p[], int n)
{
	int count = 0;
	int i, j;
	int num;

	for (i = 0; i < n; i++)
	{
		for (j = 2; j < (int)(sqrt(p[i])+1); j++)
		{
			if (p[i] % j == 0)
			{
				count++;
				break;
			}
		}
	}
	return count;
}

typedef struct T
{
	char mark;
	int num;
}T;

int bubble_sort(T p[], int n)
{
	int i, j;
	int count = 0;
	char temp;

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n - 1 - i; j++)
		{
			if (p[j].num > p[j + 1].num)
			{
				swap(&p[j].num, &p[j + 1].num);
				temp = p[j].mark;
				p[j].mark = p[j + 1].mark;
				p[j + 1].mark = temp;

				count++;
			}
		}
	}
	for (i = 0; i < n - 1; i++)
		printf("%c%d ", p[i].mark,p[i].num);
	printf("%c%d\n", p[n-1].mark,p[n - 1].num);

	return count;
}

int selection_sort(T p[],int n)
{
	int i, j, min;
	int count = 0;
	char temp;

	for (i = 0; i < n; i++)
	{
		min = i;
		for (j = i; j < n; j++)
		{
			if (p[j].num < p[min].num)
				min = j;
		}

		if (i != min)
		{
			swap(&p[i].num, &p[min].num);
			temp = p[i].mark;
			p[i].mark = p[min].mark;
			p[min].mark = temp;
			count++;
		}
	}

	for (i = 0; i < n - 1; i++)
		printf("%c%d ", p[i].mark, p[i].num);
	printf("%c%d\n", p[n - 1].mark, p[n - 1].num);

	return count;
}

T card[100];
T card2[100];

int main()
{
	int N;
	int h[100000];
	int table[100000] = { 0 };

	scanf("%d", &N);

	int i;
	for (i = 0; i < N; i++)
		scanf("%d", &h[i]);

	table[0];
	table[1] = ABS(h[1] - h[0]);

	for (i = 2; i < N; i++)
		table[i] = MIN(table[i - 2] + ABS(h[i - 2] - h[i]), table[i - 1] + ABS(h[i - 1] - h[i]));

	printf("%d\n", table[N - 1]);

}

Measured memory_bytes: 896
from heapq import heappush, heappop

def main():
  INF = 10 ** 7
  h, w = map(int, input().split())
  mp = [[INF] + list(map(int, input().split())) + [INF] for _ in range(h)]
  mp.insert(0, [INF] * (w + 2))
  mp.append([INF] * (w + 2))
  ridge = [[None] * (w + 2) for _ in range(h + 2)]
  vec = ((1, 0), (0, -1), (-1, 0), (0, 1))
  
  def is_ridge(x, y):
    to_set = set()
    for dx, dy in vec:
      nx, ny = x + dx, y + dy
      temp = ridge[ny][nx]
      if temp != None:
        if temp is True:
          ridge[y][x] = True
          return True
        else:
          to_set.add(temp)
    
    if not to_set:
      ridge[y][x] = (x, y)
    elif len(to_set) == 1:
      ridge[y][x] = list(to_set)[0]
    else:
      ridge[y][x] = True
    return ridge[y][x]
  
  que = []
  for y in range(1, h + 1):
    for x in range(1, w + 1):
      h = mp[y][x]
      heappush(que, (h, x, y))
  
  ans = 0
  while que:
    _, x, y = heappop(que)
    if is_ridge(x, y) is True:
      ans += 1
  print(ans)

main()



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

int main() {
	int N;
	cin >> N;
	vector<long int> vec (N);
	for(int i = 0;i < N;i++){
		cin >> vec.at(i);
	}
	int count = 0;
	for(int i = 0;i < N;i++){
		while(vec.at(i) % 2 == 0){
			count++;
			vec.at(i) /= 2;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;
class Main{
    public static void main(String[] args){
      Scanner scanner = new Scanner(System.in);
      int a,b;
      a = scanner.nextInt();
      b = scanner.nextInt();
      if(a>b)System.out.println("a > b");
      else if(a<b)System.out.println("a < b");
      else System.out.println("a == b");
    }
}


Measured memory_bytes: 26356
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printde(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x; cin >> x;
    int k; cin >> k;
    unordered_set<int> rs;
    set<int> times;
    for(int i = 0; i < k; i++){
        int r; cin >> r;
        times.insert(r);
        rs.insert(r);
    }
    int q; cin >> q;
    vector<int> as(q);
    vector<pair<int, int>> as2(q);
    unordered_map<int, vector<int>> ts;
    for(int i = 0; i < q; i++){
        int t, a;
        cin >> t >> a;
        as2[i] = {as[i] = a, i};
        times.insert(t);
        ts[t].push_back(i);
    }
    sort(as2.begin(), as2.end());
    int sign = -1, acc = 0, bidx = 0, lidx = q - 1, prev = 0;
    unordered_set<int> lows, highs;
    vector<ll> anss(q);
    ll low = 0, high = x;
    for(int time : times){
        int diff = time - prev;
        prev = time;
        acc += sign * diff;
        low = max(0ll, min(x, low + sign * diff));
        high = max(0ll, min(x, high + sign * diff));
        while(bidx <= lidx && as2[bidx].first + acc <= 0){
            lows.insert(as2[bidx].second);
            printd(lows);
            bidx++;
        }
        while(bidx <= lidx && as2[lidx].first + acc >= x){
            highs.insert(as2[lidx].second);
            lidx--;
        }
        if(ts.count(time)){
            for(int i : ts[time]){
                if(lows.count(i)){
                    anss[i] = low;
                }else if(highs.count(i)){
                    anss[i] = high;
                }else{
                    anss[i] = acc + as[i];
                }
            }
        }
        if(rs.count(time)){
            sign *= -1;
        }
    }
    for(int i = 0; i < q; i++){
        cout << anss[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 30496
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")


#include<bits/stdc++.h>
using namespace std;

const int MX=500005;

int bit[MX],last[MX],a[MX],ans[MX];
vector <int> qr[MX],ord[MX];

void upd(int i,int n,int x)
{
    while(i<=n){
        bit[i]+=x;
        i+=i & -i;
    }
}

int qry(int i)
{
    int s=0;
    while(i>0){
        s+=bit[i];
        i-=i & -i;
    }
    return s;
}

int main()
{
    int n,q,l,r;
    scanf("%d %d",&n,&q);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=0;i<q;i++){
        scanf("%d %d",&l,&r);
        qr[r].push_back(l);
        ord[r].push_back(i); //ord[i][j] has the index of qr[i][j]
    }
    for(int i=1;i<=n;i++){
        int p=last[a[i]];
        if(p) upd(p,n,-1);
        upd(i,n,1),last[a[i]]=i;
        int m=qr[i].size();
        for(int j=0;j<m;j++){
            int l=qr[i][j],r=i;
            ans[ord[i][j]]=qry(r)-qry(l-1);
            //printf("%d %d %d",l,r,ans[ord[i][j]]);
        }
    }
    for(int i=0;i<q;i++) printf("%d\n",ans[i]);
    return 0;
}



Measured memory_bytes: 52932
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll n=s.size();
    V<ll> a(26,0);
    rep(i,n){
        a[s[i]-'a']++;
    }
    ll ans=n*(n-1)/2;
    rep(i,26) ans-=a[i]*(a[i]-1)/2;
    out(ans+1);
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    int ans = 1e9;

    for(int i = 1; i <= N; i++) {
        int S1 = 0;
        int S2 = 0;
        for(int j = 0; j < N; j++) {
            if(j <= i) {
                S1 += v[j];
            } else {
                S2 += v[j];
            }
        }
        if(abs(S1 - S2) < ans) {
            ans = abs(S1 - S2);
        }
    }

    cout << ans << endl;
}


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

using namespace std;
using namespace __gnu_pbds;

template <class T> bool MIN(T &a, T b)                 { return a > b ? (a = b, true) : false; }
template <class T> bool MAX(T &a, T b)                 { return a < b ? (a = b, true) : false; }

template <class Node_CItr, class Node_Itr, class Cmp_Fn, class _Alloc>
struct my_update_policy {
      virtual Node_CItr node_begin() const = 0;
      virtual Node_CItr node_end() const = 0;
      typedef int metadata_type;

      int prefix_max(int x) { // sum of indices <= x
            int ans = 0;
            auto it = node_begin();
            while (it != node_end()) {
                  auto l = it.get_l_child();
                  auto r = it.get_r_child();
                  if (Cmp_Fn()(x, (*it)->first)) {
                        it = l;
                  }
                  else {
                        MAX(ans, (*it)->second);
                        if (l != node_end()) {
                              MAX(ans, l.get_metadata());
                        }
                        it = r;
                  }
            }
            return ans;
      }
      void operator()(Node_Itr it, Node_CItr end_it) {
            auto l = it.get_l_child();
            auto r = it.get_r_child();
            int lft = 0;
            int rgt = 0;
            if (l != node_end()) lft = l.get_metadata();
            if (r != node_end()) rgt = r.get_metadata();
            const_cast <int&> (it.get_metadata()) = max({lft, rgt, (*it)->second});
      }
};

template <class T> using ordermap = tree <T, T, less <T>, rb_tree_tag, my_update_policy>;

const int maxn = 2e5 + 5;

int n;
vector < vector <int> > graph;
int arr[maxn];
int bad[maxn];
int dp[maxn];

ordermap <int> om;

void dfs(int u = 1, int p = 0) {
      int val = arr[u];
      int maxi = om.prefix_max(val - 1);
      int val_lis = maxi + 1;
      auto it = om.find(val);
      if (it == om.end()) {
            bad[u] = -1;
            om.insert(make_pair(val, val_lis));
      }
      else {
            bad[u] = om[val];
            om.erase(val);
            om.insert(make_pair(val, val_lis));
      }
      int lis = om.prefix_max(1000000000);
      dp[u] = lis;
      for (int v : graph[u]) {
            if (v == p) {
                  continue;
            }
            dfs(v, u);
      }
      om.erase(val);
      if (bad[u] != -1) {
            om.insert(make_pair(val, bad[u]));
      }
}

signed main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr); cout.tie(nullptr);
      cout.precision(12);

      bool FILEIO = 0;
      if (FILEIO and fopen("in.txt", "r")) {
            freopen("in.txt", "r", stdin);
      }

      cin >> n;
      for (int i = 1; i <= n; i++) {
            cin >> arr[i];
      }
      graph.resize(n + 1);
      for (int e = 1; e < n; e++) {
            int u, v;
            cin >> u >> v;
            graph[u].push_back(v);
            graph[v].push_back(u);
      }
      dfs();
      for (int i = 1; i <= n; i++) {
            cout << dp[i] << endl;
      }
}


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

double dp[3001][3001]={0};

double go(double arr[],int n,int x){
    if(x==0)return 1;
    if(n==0)return 0;
    if(dp[n][x]>-0.9)return dp[n][x];
    
    dp[n][x]=arr[n-1]*go(arr,n-1,x-1) + (1-arr[n-1])*go(arr,n-1,x);
    return dp[n][x];
}

int main() {
	int n;
	cin>>n;
	double arr[n];
	for(int i=0;i<n;i++){
	    cin>>arr[i];
	}
	for(int i=0;i<3001;i++){
	    for(int j=0;j<3001;j++){
	        dp[i][j]=-1;
	    }
	}
	double f=go(arr,n,(n+1)/2);
	cout<<fixed<<setprecision(10)<<f<<endl;
	return 0;
}

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

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

    long long sum = 0;

    for (long long i = 1; i < (long long)sqrt(n) * 2; i++)
    {
        if (n % i == 0)
        {
            if (n / i - 1 <= i)
                break;
            // cout << i << " ";
            sum += n / i - 1;
            // cout << n / i - 1 << " ";
        }
    }
    // cout << endl;
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std; 
int qpow(long long m,long long  n)
{
    int b = 1;
    while (n > 0)
    {
          if (n & 1)
             b = (b*m);
          n = n >> 1 ;
          m = (m*m);
    }
    return b;
} 

int main()
{
    long long n=0,m=0;
    scanf("%lld%lld",&n,&m);
    long long ans=1;
    ans = m*qpow(m-1,n-1);
    printf("%lld",ans);
 return 0;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n, c;
  cin >> n >> c;
  vvi d(c, vi(c));
  vvi e(n, vi(n));
  rep(i, c) rep(j, c) cin >> d[i][j];
  rep(i, n) rep(j, n) {
    int x;
    cin >> x;
    e[i][j] = --x;
  }
  dumpv(d, c, c);
  dumpv(e, n, n);
  vvi co(3, vi(c));
  rep(i, n) rep(j, n) {
    int r = (i + j) % 3;
    dump(r);
    rep(k, c) {
      int cur_c = e[i][j];
      int nxt_c = k;
      dump(i, j, cur_c, nxt_c, d[cur_c][nxt_c]);
      co[r][k] += d[cur_c][nxt_c];
    }
    dump(co);
  }
  dump(co);
  int min_co = INF;
  rep(c1, c) rep(c2, c) rep(c3, c) {
    if (c1 == c2 || c2 == c3 || c1 == c3) continue;
    mins(min_co, co[0][c1] + co[1][c2] + co[2][c3]);
  }
  cout << min_co << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

int main() {
  int x,n,temp,pointer=1;
  cin>>x>>n;
  set<int> main;
  if(n){
  for(int i=0;i<n;i++){
    cin>>temp;
    main.insert(temp);
  }
  for(int i=0;i<n;i++){
  
  if(main.count(x)==0){
    cout<<x<<'\n';break;
  }else{
  if(main.count(x-pointer)==0){ cout<<x-pointer<<'\n';break;

  }else if(main.count(x+pointer)==0){ cout<<x+pointer<<'\n';break;

  }else pointer++;
  
  }
  }
  
  }else cout<<x<<'\n';

}


Measured memory_bytes: 3596
#include<stdio.h>
#include<string.h>
int main()
{
    int i,j=0;
    char ara1[104],ara2[107];
    scanf("%s%s",ara1,ara2);

//    strcat(ara2,ara1);
    printf("%s%s\n",ara2,ara1);

    return 0;
}


Measured memory_bytes: 128