akhauriyash/Code-Regression huggingface dataset:
//     自己选择的路，跪着也要走完。朋友们，虽然这个世界日益浮躁起来，只
// 要能够为了当时纯粹的梦想和感动坚持努力下去，不管其它人怎么样，我们也
// 能够保持自己的本色走下去。                               ——陈立杰
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

typedef signed char          int8;
typedef unsigned char       uint8;
typedef short                int16;
typedef unsigned short      uint16;
typedef int                  int32;
typedef unsigned            uint32;
typedef long long            int64;
typedef unsigned long long  uint64;
typedef __int128             int128;

template <typename Int>
inline Int read()       
{
    Int flag = 1;
    char c = getchar();
    while ((!isdigit(c)) && c != '-') c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
	return init * flag;
}

template <typename Int>
inline Int read(char &c)       
{
    Int flag = 1;
    c = getchar();
    while ((!isdigit(c)) && c != '-') c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
	return init * flag;
}

template <typename Int>
inline void write(Int x)
{
    if (x < 0) putchar('-'), x = ~x + 1;
    if (x > 9) write(x / 10);
    putchar((x % 10) | 48);
}  

template <typename Int>
inline void write(Int x, char nextch)
{
    write(x);
    putchar(nextch);
}

int t;
int128 n, a, b, c, d;

map<int128, int128> g;

int128 get(int128 goal) {
    // printf("get(%lld)\n", goal);
    if (!goal) return 0;
    if (g.find(goal) != g.end()) return g[goal];
    int128 ans = d * goal, x = goal / 2;
    ans = min(ans, get(x) + a + goal % 2 * d);
    if (goal % 2) ans = min(ans, get(x + 1) + a + (2 - goal % 2) * d);
    x = goal / 3;
    ans = min(ans, get(x) + b + goal % 3 * d);
    if (goal % 3) ans = min(ans, get(x + 1) + b + (3 - goal % 3) * d);
    x = goal / 5;
    ans = min(ans, get(x) + c + goal % 5 * d);
    if (goal % 5) ans = min(ans, get(x + 1) + c + (5 - goal % 5) * d);
    // if (goal == 4) printf("%d + %d + %d\n", (int)get(x + 1), (int)c, (int)(5 - goal % 5) * (int)d);
    // printf("g[%lld] = ", goal); write(ans, 10);
    // if (ans < 0) { printf("when goal = %lld, ans begin equal to ", goal); write(ans, 10); }
    return g[goal] = ans;
}

int main()
{
    t = read<int>();
    while (t--) {
        n = read<int128>();
        a = read<int128>();
        b = read<int128>();
        c = read<int128>();
        d = read<int128>();
        g.clear();
        g[1] = d;
        g[2] = g[1] + min(d, a);
        g[3] = d + min(g[2], b);
        write(get(n), 10);
        // for (int i = 1; i <= n; i++) {
        //     printf("num %d cost ", i);
        //     write(g[i], 32);
        //     printf("coins\n");
        // }
    }
    return 0;
}

Measured memory_bytes: 4572
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define fr first
#define sc second
#define pb push_back
const ll mod = 1e9+7;
const int N = 2e5+205;
void solve(){
	string s; 
	cin>>s; 
	int n = s.size();
	if(s[n-1]=='s')s+="es";
	else s+="s";
	cout<<s<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, -1)
#define RREP(i, n, k) for(auto i = n; i != k; i--)

#define debug(x) cerr << #x << " " << x << endl
#define print(x) cout << x;
#define println(x) cout << x << endl;
#define spc << " " <<

#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define eb emplace_back
#define np next_permutation

using ll = long long;
using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;
template<class T>using VV = vector<vector<T>>;
using Vi = vector<int>;
using VVi = vector<vector<int>>;

int main() {
   string S; cin >> S;
   stack<int> stk;
   Vi imos = Vi(S.length(), 0);

   rep(i, S.length()) {
      switch (S[i]) {
         case '\\':
            stk.push(i);
            break;
         case '_':
            break;
         case '/':
            if (!stk.empty()) {
               int left_i = stk.top();
               stk.pop();
               int area = i - left_i;
               imos[left_i] = area;
               imos[i] = -area;
            }
            break;
      }
   }

   Vi lakes;
   int total = 0;

   Vi ruiseki = Vi(imos);
   int sub_total = ruiseki[0];
   REP(i, 1, ruiseki.size()) {
      if (ruiseki[i] > 0) sub_total += ruiseki[i];
      ruiseki[i] += ruiseki[i-1];
      if (ruiseki[i] == 0 && sub_total != 0) {
         lakes.pb(sub_total);
         total += sub_total;
         sub_total = 0;
      }
   }

//   rep(i, ruiseki.size()) cout << ruiseki[i] << " "; cout << endl;

   cout << total << endl;
   cout << lakes.size();
   for (int x: lakes) cout << " " << x;
   cout << endl;
   return 0;
}



Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll maxsum(ll N,ll W,ll wts[],ll val[])
{
    ll dp[N+1][W+1],i,j;
    for(j=0;j<=W;j++)
    {
        dp[1][j]=0;
    }
    dp[1][wts[1]]=val[1];

    for(i=2;i<=N;i++)
    {
     for(j=0;j<=W;j++)
     {
         dp[i][j]=dp[i-1][j];
         if(wts[i]>j)
         continue;
         dp[i][j]=max(dp[i][j],val[i]+dp[i-1][j-wts[i]]);
     }
    }
    sort(dp[N],dp[N]+W+1);
    return dp[N][W];

}
int main()
{
  ll N,W;
  cin>>N>>W;

  ll w[N+1],i;
  ll val[N+1];

  for(i=1;i<=N;i++)
  {
      cin>>w[i]>>val[i];
  }
  cout<<maxsum(N,W,w,val)<<endl;
}

Measured memory_bytes: 78336
let explode s =
  let rec exp i l =
    if i < 0 then l else exp (i - 1) (s.[i] :: l) in
  exp (String.length s - 1) []

let rec print_int_list = function
    [] -> ()
  | [x] -> print_int x
  | (x :: xs) -> print_int x;
                 print_char ' ';
                 print_int_list xs
let left_less l =
  let (sum, ans) = List.fold_left (fun (sum,li)  c ->
            if c = '<' then (sum+1, (sum+1)::li)
            else (0, 0 :: li) ) (0,[0]) l
  in
  List.rev ans

let right_gtr l =
  let (sum, ans) = List.fold_right (fun c (sum,li) ->
            if c = '>' then (sum+1, (sum+1)::li)
            else (0, 0 :: li) ) l (0,[0])
  in
  ans
                 
let () =
  let s = Scanf.sscanf (input_line stdin) "%s" (fun a -> a) in
  let l = explode s in
  let left = left_less l in
  let right = right_gtr l in
  let ans =
    List.fold_left (+) 0
      (List.map2 (fun a b -> max a b) left right)
  in
  print_int ans;
  print_newline ()


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

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

    int n;
    cin >> n;

    map<string, int> mp;
    rep(i, n){
        string s;
        cin >> s;

        sort(s.begin(), s.end());
        ++mp[s];
    }
    
    ll res = 0;
    for(auto i = mp.begin(); i != mp.end(); ++i){
        ll v = i->second;
        res += v * (v-1) / 2;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 11264
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;

int main(void) {
	int N , i, cnt = 0, flag = 1;
	ll tmp;
	vector<ll> A;

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%lld", &tmp);
		A.push_back(tmp);
	}
	while (true) {
		rep(i,N) {
			if ((A.at(i) & 1) == 1) {
				flag = 0;
				break;
			}
		}

		if (flag == 0) {
			break;
		}
		else {
			cnt++;
		}

		rep(i, N) {
			A.at(i) = A.at(i) / 2;
		}
	}
	printf("%d\n", cnt);

	return 0;
}

Measured memory_bytes: 256
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
n = 0

if x > sum(a):
    print(N-1)
    exit()

for i in a:
    if x >= i:
        x -= i
        n += 1
    else:
        break
print(n)

Measured memory_bytes: 3060
while True:
    m,f,r =map(int,input().split())
    if m==f==r==-1:
        break
    x = m + f
    if m==-1 or f==-1:
        print("F")
    elif x >= 80:
        print("A")
    elif x >= 65 and x < 80:
        print("B")
    elif x >= 50 and x < 65:
        print("C")
    elif x >= 30 and x < 50:
        if r >= 50:
            print("C")
        else:
            print("D")
    elif x < 30:
        print("F")


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

using namespace std;
int main() {
	string n; cin >> n;
	cout << "ABC" << n << endl;
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    mx = (N - 1) * (N - 2) // 2
    if mx < K:
        print(-1)
        exit()
    ans = []

    for i in range(2,N+1):
        ans.append((1,i))

    cnt = mx - K
    for j in range(2, N+1):
        for k in range(j,N+1):
            if cnt == 0:
                break
            if j == k:
                continue
            ans.append((j,k))
            cnt -= 1

    print(len(ans))
    for a,b in ans:
        print(a,b)
    



    



if __name__ == "__main__":
    main()

Measured memory_bytes: 42864
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n){
        scanf("%d",&a[i]);
    }
    sort(a.begin(),a.end());
    cout << a[n-1] << " ";
    int k = a[n-1];
    int temp = 1000000000+10;
    int t = k/2;
    int kouho;
    rep(i,n-1){
        if(temp >= abs(t-a[i])){
            kouho = a[i];
            temp = abs(t-a[i]);
        }
    }
    cout << kouho << endl;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename x>
using ordered_set = tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>;
#define sorta(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n,greater<__typeof(a[0])>())
#define all(x) (x).begin(),(x).end()
#define ms0(x) memset((x),0,sizeof((x)))
#define ms1(x) memset((x),-1,sizeof((x)))
typedef pair<int,int> pi;
#define inarr(arr,n) for(int i=0;i<n;i++)cin>>arr[i];
#define prinarr(arr) {for(int x:arr)cout<<x<<" ";} cout<<"\n";
#define cout1(a) cout<<a<<"\n";
#define cout2(a,b) cout<<a<<" "<<b<<"\n";
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define setpre(n) cout<<fixed<<setprecision(8)<<n<<"\n";
#define filldp(arr,n,m,k) for(int i=0;i<n;i++){for(int j=0;j<m;j++) arr[i][j]=k;}

#define mod 1000000007
#define mod1 998244353


vector<vector<int>> adj;
vector<int> dis;
vector<int> parent;
vector<bool> visited;

void newgr(int n){
    n+=10;
    adj=vector<vector<int>>(n);
    dis=vector<int>(n,0);
    //parent=vector<int>(n,-1);
    visited=vector<bool>(n,false);
}

void dfs(int s){
    visited[s]=true;
    for(auto u:adj[s]){
        if(!visited[u]){
            //parent[u]=s;
            dis[u]=dis[s]+1;
            dfs(u);
        }
    }
}

void bfs(int s){
    queue<int> q;
    q.push(s);
    visited[s]=true;
    dis[s]=0;
    while(!q.empty()){
        auto u=q.front();
        q.pop();
        for(auto x:adj[u]){
            if(!visited[x]){
                //parent[x]=u;
                visited[x]=true;
                dis[x]=dis[u]+1;
                q.push(x);
            }
        }
    }
}

long long power(long long x,long long y){  
    long long ans=1;
    x%=mod;
    while(y>0){
        if(y&1) ans=(ans*x)%mod;
        y>>=1;
        x=(x*x)%mod;
    }
    return ans;
}

long long modinv(long long b){ 
    return power(b,mod-2);
}



int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
	cin>>n;
	int ans=(1000-(n%1000))%1000;
	cout1(ans);
    return 0;
}

Measured memory_bytes: 3640
from collections import deque
try:
    while 1:
        V, d = map(int, input().split())
        F = [0]*V
        a = b = 1
        for v in range(V):
            a, b = (a+b) % 1001, a
            F[v] = a
        G = [[] for i in range(V)]
        for i in range(V):
            for j in range(i+1, V):
                if abs(F[i] - F[j]) < d:
                    G[i].append(j)
                    G[j].append(i)
        L = [0]*V
        ans = 0
        for i in range(V):
            if L[i]:
                continue
            ans += 1
            que = deque([i])
            L[i] = 1
            while que:
                v = que.popleft()
                for w in G[v]:
                    if L[w]:
                        continue
                    que.append(w)
                    L[w] = 1
        print(ans)
except:
    ...


Measured memory_bytes: 12880
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    string s;cin >> s;
    int n = s.length();
    for (int i = 0; i < n; i++) {
      	if(s[i] == '?'){
        	s[i] = 'D';
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3672
from collections import defaultdict
import numpy as np
S = input()

d = defaultdict(list)
for i, s in enumerate(S):
    d[s].append(i + 1)


ans = (-1, -1)
for k, v in d.items():
    dif = np.diff(v).tolist()
    if 1 in dif:
        i = dif.index(1)
        ans = (v[i], v[i + 1])
        break
    elif 2 in dif:
        i = dif.index(2)
        ans = (v[i], v[i + 1])
        break

print(*ans, sep=" ")


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



int main(){
    int a,b,ss;
    char s[4];
    scanf("%s",s);
    ss=atoi(s);
    a=ss/100;
    b=ss-a*100;
    if((a>12 && b >12) || (a==0 && b==0))printf("NA\n");
    else if((a>12 && b==0) || (a==0 && b>12))printf("NA\n");
    else if(a>12 || a==0)printf("YYMM\n");
    else if(b>12 || b==0)printf("MMYY\n");
    else printf("AMBIGUOUS\n");

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<cstring>
using namespace std;
 
int main(){

  int n, c[500], s[500], f[500], ans[500]={0};
  cin >> n;
  for(int i=0; i<n-1; i++){
    cin >> c[i] >> s[i] >> f[i];
  }

  for(int i=0; i<n; i++){
    for(int j=i; j<n-1; j++){
      if(ans[i]<s[j]){
        ans[i]=s[j];
      } else if(ans[i]%f[j]==0){
        ;
      } else {
        ans[i]+=f[j]-ans[i]%f[j];
      }
        ans[i]+=c[j];
    }
  }

  for(int i=0; i<n; i++){
    cout << ans[i] << endl;
  }

  return 0;
}


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

constexpr int MOD = 998244353;
constexpr int MAX = 200200;

template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(long long e){
        long long a = 1, p = x;
        while(e > 0) {
            if (e & 1) {a = (a * p) % mod; e--;}
            else {p = (p * p) % mod; e /= 2;}
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

template<int mod> struct Combination {
    vector<ModInt<mod>> fact, ifact;
    Combination(int n) : fact(n+1), ifact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= n; i++) fact[i] = (fact[i - 1] * i);
        ifact[n] = fact[n].inverse();
        for (int i = n; i > 0; i--) ifact[i - 1] = ifact[i] * i;
    }
    ModInt<mod> operator() (int n, int r) {
        if (r < 0 or r > n) return 0;
        return fact[n] * ifact[n-r] * ifact[r];
    }
    const ModInt<mod> &operator[] (int i) const {
        return fact[i];
    }
};

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

    Combination<MOD> binom(MAX);
    ModInt<MOD> ans = 0, val = m - 1;
    for (int i = 0; i <= k; i++) {
        ans += val.pow(n - i - 1) * m * binom(n - 1, n - i - 1);
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 4852
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]


def enclose_field(field, outline="#"):
    """
    迷路等の外周をoutlineで埋めることで、IndexErrorを回避できます。
    [0, 0] → [1, 1]、[H-1, W-1] → [H, W]となります。
    """
    for i in range(len(field)):
        field[i] = [outline] + field[i] + [outline]
    field.append([outline] * (len(field[0])))
    field.insert(0, [outline] * (len(field[0])))
    return field


S = enclose_field(S, outline="a")

for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            adj = [S[i+1][j], S[i-1][j], S[i][j+1], S[i][j-1]]
            if "#" not in adj:
                print("No")
                exit()
else:
    print("Yes")


Measured memory_bytes: 3064
//gauravsinghh
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#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;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 1000000000
#define lim 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int main(){
    IOS
    //io_set();
    string s;
    cin >> s;
    ll c = 0;
    rep(i, sz(s)/2){
      if(s[i] != s[sz(s) - 1 - i]){
        c++;
      }
    }
    cout << c << endl;
    return 0;
} 




































































































 

Measured memory_bytes: 256
use strict;
use warnings;

my @a;
{
  for (my $i=0; $i<3; $i++) {
    my $in = <STDIN>;
    my @b = split(" ", $in);
    $a[$i] = \@b;
  }
}
my $n = <STDIN>;
chomp $n;
my @b;
{
  for (my $i=0; $i<$n; $i++) {
    my $in = <STDIN>;
    chomp $in;
    $b[$i] = $in;
  }
}
for (my $i=0; $i<3; $i++) {
  for (my $j=0; $j<3; $j++) {
      for (my $k=0; $k<$n; $k++) {
        if ($a[$i][$j] == $b[$k]) {
          $a[$i][$j] = 0;
        }
      }
  }
}
my $ans = "No";
for (my $i=0; $i<3; $i++) {
  if ($a[$i][0]==0 && $a[$i][1]==0 && $a[$i][2]==0) {
    $ans = "Yes";
    last;
  }
  if ($a[0][$i]==0 && $a[1][$i]==0 && $a[2][$i]==0) {
    $ans = "Yes";
    last;
  }
}
if ($a[0][0]==0 && $a[1][1]==0 && $a[2][2]==0) {
    $ans = "Yes";
}
if ($a[0][2]==0 && $a[1][1]==0 && $a[2][0]==0) {
    $ans = "Yes";
}
print "$ans\n";

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

int main(){
	ll N,W;
	cin >> N >> W;
	vector<ll> weights(N), val(N);
	vector<ll> ans(100005);
	fill(ans.begin(), ans.end(), 100000000000);
	ans[0] = 0;

	for(int i=0;i<N;i++){
		cin >> weights[i] >> val[i];
	}

	for(int i=0;i<N;i++){
		for(int j=100004;j>=val[i];j--){
			ans[j] = min(ans[j], ans[j-val[i]] + weights[i]);
		}
	}

	ll ans_w = INT64_MAX, ans_v = INT64_MIN;
	for(int i=0;i<100005;i++){
		if(ans[i] <= W && ans_v < i){
			ans_v = i;
		}
	}

	cout << ans_v;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++)
#define per(i,j,k) for(int i=(int)j;i>=(int)k;i--)
using namespace std;
typedef long long LL;
const int N=110000;
int a[N];
LL f[N][3];
int ct[3];
int n;
int main(){
    ct[0]=ct[2]=1;
    ct[1]=-1;
    scanf("%d",&n);
    rep(i,1,n){
        if(i!=1){
            char opt[3];scanf("%s",opt);
            scanf("%d",&a[i]);if(opt[0]=='-')a[i]=-a[i];
        }
        else scanf("%d",&a[i]);
    }
    rep(i,0,n)rep(j,0,2)f[i][j]=-(1ll<<60);
    f[0][0]=0;
    rep(i,0,n){
        if(i){
            rep(j,0,2)rep(k,j,2)f[i][j]=max(f[i][j],f[i][k]);
            if(a[i]<0){
                per(j,1,0)f[i][j+1]=max(f[i][j+1],f[i][j]);
            }
        }
        rep(j,0,2){
            f[i+1][j]=max(f[i+1][j],f[i][j]+ct[j]*a[i+1]);
        }
    }
    printf("%lld\n",f[n][0]);
    return 0;
}






Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main()
{
    bool prime[10001];
    memset(prime,0,sizeof(prime));
    for(int i=2;i<sqrt(10001);i++){
        if(!prime[i])for(int j=i*2;j<10005;j+=i)prime[j]=1;
    }
    int n;
    while(cin>>n,n){
        for(int i=n;i>2;i--){
            if(!prime[i]&&!prime[i-2]){
                cout<<i-2<<" "<<i<<endl;
                break;
            }
        }
    }
}

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

int main(){
 while(1){
 int n,x;
 cin>>n>>x;
 
 if(n==0 && x==0)break;
 int ans=0;
 for(int a=1;a<=n;a++)
 for(int b=a+1;b<=n;b++)
 for(int c=b+1;c<=n;c++){
 if(a+b+c!=x)continue;
 ans++;
 }
 cout<<ans<<endl;
}
}


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

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

    int m;

    cin >> m;

    int p, x;

    for(int i = 0; i < m; i++){
        cin >> p >> x;

        cout << sum - t[p-1] + x << endl;

    } 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 30;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

bool collision_detection( double x1, double y1, double x2, double y2, double x3, double y3, double xp, double yp ) {
	x2 -= x1;
	x3 -= x1;
	xp -= x1;
	y2 -= y1;
	y3 -= y1;
	yp -= y1;
	double t_size = fabs( ( x2 * y3 - y2 * x3 ) / 2 );
	t_size -= fabs( ( x2 * yp -  y2 * xp ) / 2 );
	t_size -= fabs( ( x3 * yp -  y3 * xp ) / 2 );
	x2 -= xp;
	x3 -= xp;
	y2 -= yp;
	y3 -= yp;
	yp = xp = 0;
	t_size -= fabs( ( x2 * y3 - y2 * x3 ) / 2 );
	return fabs( t_size ) < 1e-10;
}

int main() {
	double x[ 4 ], y[ 4 ];
	while ( ~scanf( "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &x[ 0 ], &y[ 0 ], &x[ 1 ], &y[ 1 ], &x[ 2 ], &y[ 2 ], &x[ 3 ], &y[ 3 ] ) ) {
		bool print_yes = true;
		for ( int i = 0; i < 4; i++ ) {
			if ( collision_detection( x[ ( i + 1 ) % 4 ], y[ ( i + 1 ) % 4 ], x[ ( i + 2 ) % 4 ], y[ ( i + 2 ) % 4 ], x[ ( i + 3 ) % 4 ], y[ ( i + 3 ) % 4 ], x[ i ], y[ i ] ) ) {
				print_yes = false;
				break;
			}
		}
		printf( "%s\n", print_yes ? "YES" : "NO" );
	}
	return 0;
}

Measured memory_bytes: 1188
// Problem : C - K-th Substring
// Contest : AtCoder Regular Contest 097
// URL : https://atcoder.jp/contests/arc097/tasks/arc097_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using ll = long long;
using namespace std;
#define size(x) (int)x.size()

const int N = 1e6 + 1, mod = 1e9 + 7;

string s;
int k;
set<string> ms;

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> s >> k;
	for (int j = 1; j <= min(k, size(s)); j++) {
		for (int i = 0; i <= size(s) - j; i++) {
			ms.insert(s.substr(i, j));
		}
	}
	for (int t = 1; t < k; t++) {
		ms.erase(ms.begin());
	}
	cout << *ms.begin();
}


Measured memory_bytes: 1664
#include <stdio.h>

int main(void)
{

 int a,b;


scanf("%d %d",&a,&b) ;

 if(a < b){
 printf("a < b\n") ;

}else if(a > b){
 
printf("a > b\n");

}else{ printf("a == b\n");


}


 return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;


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

  string S;
  cin >> S;

  if(S.at(2)==S.at(3)&&S.at(4)==S.at(5)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def construct(N):
    for n in range(40, -1, -1):
        if N >= (1 << n) - 1:
            break
    p = []
    for i in range(1, n+1):
        p.append(i)
    N -= (1 << n) - 1
    for i in range(n-1, -1, -1):
        if N < 1 << i:
            continue
        n += 1
        p = p[:i] + [n] + p[i:]
        N -= 1 << i
    return p

N = int(input())
part = construct(N)
ans = part + [x + 1 for x in range(len(part))]
print(len(ans))
print(*ans, end=' ')
print()


Measured memory_bytes: 3064
import itertools
import numpy as np

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]

score = []
ans = 0
for A in itertools.combinations_with_replacement(range(1, M+1), N):
  for i in range(Q):
    a = abcd[i][0]
    b = abcd[i][1]
    c = abcd[i][2]
    d = abcd[i][3]
    if A[b-1]-A[a-1] == c:
      score.append(d)
  if ans <= sum(score):
    ans = sum(score)
  score.clear()
print(ans)

Measured memory_bytes: 27144
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
  int N, Q; cin >> N >> Q;
  vector<int> a(N);
  for(int i = 0; i < N; i++) cin >> a[i];
  for(int i = 0; i < Q; i++){
    int x; cin >> x;
    int right = 0, sum = 0, ans = 0;
    for(int left = 0; left < N; left++){
      while(sum + a[right] <= x && right < N){
        sum += a[right];
        right++;
      }
      ans += right - left;
      if(left == right) right++;
      else sum -= a[left];
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <stack>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, a[3];
string s[100000];

int next(int n) { return (n + 1) % 3; }
int prev(int n) { return (n - 1 + 3) % 3; }

signed main() {
	int i, j;
	
	cin >> n >> a[0] >> a[1] >> a[2];
	rep(i, n) {
		cin >> s[i];
		if (s[i] == "AC") { s[i] = "CA"; }
	}
	
	stack<int> stk[6];	//"AB", "BC", "CA" | "BA", "CB", "AC"
	rep(i, n) {
		a[s[i][0] - 'A']++;
		a[s[i][1] - 'A']--;
		stk[s[i][0] - 'A'].push(i);
		
		int t = s[i][0] - 'A';
		rep(j, 3) {
			while (!stk[t].empty() && a[next(t)] < 0) {
				int id = stk[t].top(); stk[t].pop();
				a[t] -= 2;
				a[next(t)] += 2;
				stk[t + 3].push(id);
			}
			t = prev(t);
		}
		if (a[0] < 0 || a[1] < 0 || a[2] < 0) { cout << "No" << endl; return 0; }
	}
	
	string coms[6] = {"AB", "BC", "CA", "BA", "CB", "AC"};
	static string ans[100000];
	
	rep(i, 6) {
		while (!stk[i].empty()) {
			int id = stk[i].top();
			stk[i].pop();
			ans[id] = coms[i];
		}
	}
	
	cout << "Yes" << endl;
	rep(i, n) cout << ans[i][0] << endl;
	return 0;
}

//一般的なテクを活かした解き方
//「片側に選択肢を寄せ、後で調整する」方針
//自分にとっては、これが自然に見えた。
//また、対称性を保って考察をおこなうため、s[i] = "AB", "BC", "CA"のいずれかとしておく。
//
//t[i] = s[i] or reverse(s[i])とし、文字t[i][0]と対応する変数を+1, t[i][1]と対応する変数を-1とする。
//例えばt[i] = "BA"なら、Bに1を足し, Aから1を引く。
//t[i]を上手く決められるか？という問題。このままでは2^N通りの候補があって大変。
//
//i=0,1,2,…の順番でt[i]を決めていく。
//とりあえず、t[i] = s[i]と仮置きしておいて進める。
//このまま何事もなければYes.
//A,B,Cのいずれかが負になってしまった瞬間iを考える。
//
//例えばAが負になったとする。このとき、t[j] = "CA" (j < i)なるjについてt[j] = "AC"と変えていき、Aを非負にする。
//非負にする最低限の調整をする。
//そのようなことをするjの組み合わせは重要ではなく、好きに選んでも良くて、例えば直前のものから選んでいく。
//非負にできなければNo. 非負にできたとき、今度はCが負になっていることがある。これについても同様にやる。
//Aを非負に -> Cを非負に -> Bを非負に、としていったときに、再びAが負になれば、どうやっても調整できない。（要検証）
//したがって、"No".
//
//B,Cが負になったときも同様におこなう。
//これで、最後までNoにならなければYes.
//
//実装方針：
//3回同じコードを書きたくはない。問題文中の変数はA->a[0], B->a[1], C->a[2]と置きなおして実装する。
//
//この解き方のメリット・デメリット
//メリット：明示的な場合分けをほとんどせずに解ける。
//デメリット：明示的な場合分けをしていないので、どんなケースでYes, Noなのかが分からないままACしてしまう。


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

#define X first
#define Y second

using namespace std;

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

int n, _n;
pii *a;
long long ans;

pii get_max(int l, int r, int L, int R, int v) {
	if(l <= L && R <= r) return a[v];
	if(l > R || r < L) return {0,0};
	return max(get_max(l, r, L, (L+R)/2, 2*v),
	           get_max(l, r, (L+R)/2 + 1, R, 2*v+1));
}

map<pii, bool> used;

void solve(int L, int R, int M) {
	if(L + 1 > R) return;
	if(used[{L,R}]) return;
	used[{L,R}] = 1;
	pii x = get_max(L, M-1, 1, n, 1);
	pii y = get_max(M+1, R, 1, n, 1);
	if(x < y) x = y;
	ll a = min(x.Y, M);
	ll b = max(x.Y, M);

	//cout << L << ' ' << a << ' ' << b << ' ' << R << ' ' << x.X << '\n';
	ll delta = (R - b + 1) * (a - L + 1) * x.X;
	//cout << delta << '\n';
	ans += delta;

	solve(L, b-1, a);
	solve(a+1, R, b);
}

int main() {
	ios_base::sync_with_stdio(0);

	cin >> _n;
	for(n = 1; n < _n; n *= 2);

	a = (pii*)malloc(2*n*sizeof(pii));

	for(int i = 0; i < n; i++) {
		if(i < _n) {
			int x;
			cin >> x;
			a[n+i] = {x, i+1};
		} else {
			a[n+i] = {0,0};
		}
	}
	for(int i = n-1; i; i--) a[i] = max(a[2*i], a[2*i + 1]);

	solve(1, _n, a[1].Y);

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 17664
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main() {
    val n = readLine()?.toInt() ?: return
    val a = intList()
    val map = hashMapOf<Int, Int>()
    a.forEach {
        map[it] = map.getOrDefault(it, 0) + 1
    }
    val one = map.values.size
    val two = map.values.count { it == 2 || (it > 2 && it % 2 == 0) }
    println((one - (two % 2)).toString())
}


Measured memory_bytes: 60032
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	vector<int> v(3);

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

	sort(v.begin(), v.end(), greater<int>());

	cout << v[0]-v[2] << endl;


	return 0;
}

Measured memory_bytes: 256
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
ll a[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
	double l;
	cin>>l;
	cout<<setprecision(10)<<fixed<<(l/3)*(l/3)*(l/3);
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 7552
#include<iostream>
#include<vector>
#include<string>
#include<tuple>
#include<algorithm>
#include<iomanip>

using namespace std;

int main(){
    char b;
    cin >> b;

    if(b == 'A')
    {
        cout << 'T' << endl;
    }
    else if(b == 'T')
    {
        cout << 'A' << endl;
    }
    if(b == 'G')
    {
        cout << 'C' << endl;
    }
    if(b == 'C')
    {
        cout << 'G' << endl;
    }
}

Measured memory_bytes: 256
n=int(input())
arr=list(map(int,input().split()))+[0]
arr=sorted(arr, reverse=True)
ans1=0
ans2=0
ans3=0
count=1
for i in range(n):
  if arr[i]!=arr[i+1]:
    if count>=2:
      if ans1==0:
        ans1=arr[i]
      elif ans2==0:
        ans2=arr[i]      
      if count>=4:
        if ans3==0:
          ans3=arr[i]
    count=1
  else:
    count+=1
print(max(ans1*ans2,ans3**2))

Measured memory_bytes: 14252
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		for(;;){

			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0){

				scan.close();
				break;
			}
			for(int i=0; i<H; i++){ //縦の列の繰り返し

				for(int s=0; s<W; s++){ //横の行の繰り返し

					if(i == 0 | i == H-1){ //1行または最終行の指定
						System.out.print("#");
					}else if(s == 0 | s == W-1){ //1列または最終列の指定

						System.out.print("#");
					}else{
						
						System.out.print(".");
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
}

Measured memory_bytes: 29592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, M;
    cin >> N >> M;
    string S = "";
    rep(i, N) S += 'x';
    rep(i, M){
        int s;
        char c;
        cin >> s >> c;
        if(S[s-1] != 'x' && S[s-1] != c){
            cout << -1 << endl;
            exit(0);
        }
        else S[s-1] = c;
    }
    if(S[0] == '0' && N != 1){
        cout << -1 << endl;
        exit(0);
    }
    if(S[0] == 'x'){
        if(N == 1) S[0] = '0';
        else S[0] = '1';
    }
    rep2(i, 1, N-1){
        if(S[i] == 'x') S[i] = '0';
    }
    cout << S << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

int main()
{
  int n, S;
  while (n = in(), S = in()){
    int bckt[128] = {};
    for (int i = 0; i < n; i++) bckt[in()]++;
    int tot = 0;
    for (int i = 1; i < 128; i++){
      if (!bckt[i]) continue;
      if (i + i > S) tot += bckt[i] * (bckt[i] - 1) / 2;
      for (int j = i + 1; j < 128; j++){
        if (i + j > S){
          tot += bckt[i] * bckt[j];
        }
      }
    }
    cout << tot << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  I n;
  cin >> n;
  set<I> s;
  REP(i,n){
    I j;
    cin >> j;
    s.insert(j);
  }
  /*
  V v(n);
  VIN(v);
  SORT(v);
  REV(v);
  I t=0,c=MAX;
  REP(i,n){
    if (v.at(i) < c){
      t++;
      c = v.at(i);
    }
  }
  cout << t << endl;
  */
  cout << s.size() << endl;
  return 0;
}



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

#define BUF_SIZE 100002
int main(void) {
  FILE *fp;
  fp = stdin;
  char line[BUF_SIZE];
  char buf[BUF_SIZE] = {0};
  int idx = 0;

  if(!fgets(line, BUF_SIZE, fp)) return 0;
  char *tmp;
  int s;
  for(tmp = line, s = 1; *tmp !='\n'; tmp++, s++) {
    if(!(s&1)) continue;
    buf[idx++] = *tmp;
  }
  buf[idx] = '\0';

  printf("%s\n", buf);

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int x;
  cin >> x;
  
  long long a,b;
  a=-200;
  while(a<=200){
    b=-200;
    while(b<=200){
      if(a*a*a*a*a-b*b*b*b*b==x){
        cout << a << " " << b <<endl;
        exit(0);
      }
      b++;
    }
  a++; 
  }
}

Measured memory_bytes: 3632
def dfs(p, reached):
    global N, G
    reached.append(p)
    for i in range(N):
        if G[p][i] and i not in reached:
            reached = dfs(i, reached[:])
    return reached

N, M = map(int, input().split())
G = [[False]*N for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a-1][b-1] = True
    G[b-1][a-1] = True

ans = 0
for i in range(N):
    for j in range(i):
        if G[i][j]:
            G[i][j] = False
            G[j][i] = False
            if len(dfs(0, [])) < N:
                ans += 1
            G[i][j] = True
            G[j][i] = True

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int N;
    cin >> N;
    if(N <= 999) {
        cout << "ABC" << endl;
    }
    else {
        cout << "ABD" << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n)
    {
        cin >> p[i];
        p[i]--;
    }

    vector<int> a(n), b(n);
    rep(i, n)
    {
        a[i] = i * n + 1;
        b[i] = n * n - i * n + 1;
    }

    rep(i, n)
    {
        a[p[i]] += i;
    }

    rep(i, n)
    {
        cout << a[i] << " ";
    }
    cout << endl;
    rep(i, n)
    {
        cout << b[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 896
#include <stdio.h>

int main(){
  int N,i,a,flag,A[100],c=0;

  scanf("%d",&N);

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

  flag = 1;

  while(flag){
    
    flag = 0;

    for(i=N-1; i > 0; i--){
      if(A[i] < A[i-1]){
	a = A[i];
	A[i] = A[i-1];
	A[i-1] = a;
	c += 1;
	flag = 1;
      }
    }

  }

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

  return 0;
}



Measured memory_bytes: 2144
#include <iostream>
#include <cstring>
#include <cstdio>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long  ll;

const int MAXN=100010;
ll ans[5];
char dai[MAXN];
char ch[5]={'M','A','R','C','H'};
ll dp[4][5];
int main()
{
    int n;
    while (scanf("%d",&n)!=EOF) {
        for(int i=0;i<=4;i++)ans[i]=0;
        char op;
        for(int i=1;i<=n;i++)
        {
            scanf("%s",dai);
            op=dai[0];
            for(int j=0;j<=4;j++)
                if(op==ch[j])ans[j]++;
        }
        cout<<ans[0]*(ans[1]*(ans[2]+ans[3]+ans[4])+ans[2]*(ans[3]+ans[4])+ans[3]*ans[4])+
        ans[1]*(ans[2]*(ans[3]+ans[4])+ans[3]*ans[4])+ans[2]*ans[3]*ans[4]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
n,y = map(int,input().split())
for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i+5000*j+1000*(n-i-j) == y:
            print(str(i)+" "+str(j)+" "+str(n-i-j))
            sys.exit()
print("-1 -1 -1")

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll n, m,ans;
	in(n);
	in(m);

	ans = m > 2 * n ? n : m / 2;
	m -= 2 * ans;

	ans += m / 4;
	outn(ans);
	return 0;

}


Measured memory_bytes: 256
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        //Compute c1 = new Compute();//calc

        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();

        //input
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        int c=-1;
        int cc=-1;

        for (int i=0;i<s.length();++i)
        {
            String ss = s.substring(i,i+1);
            if (ss.equals(","))
            {
                if (c==-1)
                {
                    c=i;
                }else
                {
                    cc=i;
                }
            }
        }

        String ans1 = s.substring(0,c);
        String ans2 = s.substring(c+1,cc);
        String ans3 = s.substring(cc+1,s.length());

        System.out.println(ans1+" "+ans2+" "+ans3);
    }
}

Measured memory_bytes: 21844