akhauriyash/Code-Regression huggingface dataset:
def z(z_dic, v: int):
    if v in z_dic:
        return z_dic[v]
    z = 0
    if v == 2:
        z = 1
    elif v > 2:
        z = int(v*(v-1)/2)
    z_dic.setdefault(v, z)
    return z


def main():
    n = int(input())

    ar = [0] * (n+1)
    ls = []

    for x in map(int, input().split()):
        ls.append(x)
        ar[x] += 1

    zls = []
    zls2 = []

    z_dic = {}

    for i in range(1, n+1):
        v = ar[i]
        zls.append(z(z_dic, v))
        zls2.append(z(z_dic, v-1))
    ss = sum(zls)

    for i in range(1, n+1):
        aa = ls[i-1]
        print(ss - zls[aa-1] + zls2[aa-1])
    #
    # itr = map(int, input().split())
    # dic = {}
    # for num in itr:
    #     dic.setdefault(num, 0)
    #     dic[num] += 1
    #     ls.append(num)
    #
    # for i in range(n):
    #     # ls[i]を除く
    #     a = ls[i]
    #     dic[a] -= 1
    #     res = 0
    #     for k, v in dic.items():
    #         if v < 2:
    #             continue
    #         elif v == 2:
    #             res += 1
    #         else:
    #             res += int(v*(v-1)/2)
    #     print(res)
    #     dic[a] += 1


main()


Measured memory_bytes: 27676
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
typedef pair<int, P> PP;
struct edge { int to, cost; };
int a[114514];
vector<P>ans;
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	sort(a, a + n);

	rep(i, (n + 1) / 2) {
		int x = i, y = n - 1 - i;
		if (x != y) {
			if (i & 1) {
				ans.push_back(P(i + 1, a[x]));
				ans.push_back(P(-i - 1, a[y]));
			}
			else {
				ans.push_back(P(-i - 1, a[x]));
				ans.push_back(P(i + 1, a[y]));
			}
		}
	}
	sort(ans.begin(), ans.end());
	int sum = 0;
	if ((n - 1) / 2 == n - 1 - (n - 1) / 2) {
		int x = (n - 1) / 2;
		sum += max(abs(ans[0].second - a[x]), abs(ans[n - 2].second - a[x]));
	}
	rep(i, ans.size()-1) {
		sum += abs(ans[i + 1].second - ans[i].second);
	}
	cout << sum << endl;
}

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

using namespace std;

using LL = long long;

template<typename T>
ostream& operator << (ostream& out, const vector<T>& v) {
    out << "[";
    for(const auto& x : v) {
        out << x << ", ";
    }
    return out << "]";
}

template<typename S, typename T>
ostream& operator << (ostream& out, const pair<S, T>& p) {
    return out << "{" << p.first << ", " << p.second << "}";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(auto& a : A) {
        cin >> a;
    }
    int lo = 0, hi = 1000000000;
    while(lo + 1 < hi) {
        int m = (lo + hi) / 2;
        LL r = 0;
        for(int n = 0; n < N; ++n) {
            r += (A[n] - 1) / m;
        }
        if(r <= K) {
            hi = m;
        } else {
            lo = m;
        }
    }
    cout << hi << "\n";
    
    
    return 0;
}


Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    ll ans = 1;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(a[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    for(int i = 0; i < n; i++)
    {
        if(ans > ans * a[i])
        {
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }
    ll B = 1e18;
    if(ans > B)
    {
        cout << -1 << endl;
    }
    else cout << ans << endl;
}


Measured memory_bytes: 4052
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define tisic 47
#define soclose 1e-8
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
using uint = unsigned int;
using cat = long long;
using dbl = long double;
constexpr dbl pi = 3.14159265358979323846;
using namespace std;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<int> P(N);
	vector< vector<int> > G(N);
	for(int i = 0; i < N; i++) {
		cin >> P[i];
		if(P[i] > 0) G[--P[i]].push_back(i);
	}
	vector<char> vis(N, 0);
	vector<int> sz;
	queue<int> q;
	for(int i = 0; i < N; i++) if(P[i] == -1) {
		q.push(i);
		int sz_cur = 0;
		while(!q.empty()) {
			sz_cur++;
			vis[q.front()] = 1;
			for(auto s : G[q.front()]) q.push(s);
			q.pop();
		}
		sz.push_back(sz_cur);
	}
	int cyc = 0, K = sz.size();
	for(int i = 0; i < N; i++) if(!vis[i]) {
		cyc++;
		int cur = i;
		for(int j = 0; j < N; j++) cur = P[cur];
		q.push(cur);
		vis[cur] = 1;
		while(!q.empty()) {
			for(auto s : G[q.front()]) if(!vis[s]) {
				vis[s] = 1;
				q.push(s);
			}
			q.pop();
		}
	}
	cat mod = 1000000007;
	vector<cat> cnt(K+1, 0);
	cnt[0] = 1;
	for(int i = 0; i < K; i++) for(int j = K-1; j >= 0; j--)
		cnt[j+1] = (cnt[j+1] + cnt[j] * sz[i]) % mod;
	vector<cat> pw(N+1, 1);
	for(int i = 1; i <= N; i++) pw[i] = (N-1) * pw[i-1] % mod;
	cat ans = pw[K] * (N - cyc) % mod;
	if(K) {
		cat f = 1;
		for(int i = 2; i <= K; i++) {
			f = f * (i-1) % mod;
			ans = (ans - f * pw[K-i] % mod * cnt[i]) % mod;
		}
		for(int i = 0; i < K; i++) ans = (ans - pw[K-1] * (sz[i]-1)) % mod;
	}
	if(ans < 0) ans += mod;
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 3944
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
    char c;
    cin>>c;
    char s=c+1;
    cout<<s<<endl;
}



Measured memory_bytes: 256
import string

N,K = list(map(int,input().split()))
numbers = "0123456789"
alphabets = string.ascii_letters
characters = numbers + alphabets

def base_cvt(value, n=2):
    tmp = int(value)  
    result = ''
    tmp = int(value)
    while tmp >= n:
        idx = tmp%n
        result = characters[idx] + result
        tmp = int(tmp / n)
    idx = tmp%n
    result = characters[idx] + result
    return result

print(len(str(base_cvt(N,K))))

Measured memory_bytes: 38704
from collections import deque
d=deque()
n=int(input())
lists=list(map(int,input().split()))
if n%2==0:
    for i in range(n):
        x=lists[i]
        if i%2==0:
            d.append(x)
        else:
            d.appendleft(x)
else:
    for i in range(n):
        x=lists[i]
        if i%2==0:
            d.appendleft(x)
        else:
            d.append(x)
d=list(d)
print(*d)

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

int main() {
 
  int x, y;
  cin >> x >> y;
  
  int X;
  int Y;

  if (x == 2) {
    X = 3; 
  } else if (x == 4 || x == 6 || x == 9 || x == 11) {
    X = 2; 
  } else {
    X = 1; 
  }

  if (y == 2) {
    Y = 3; 
  } else if (y == 4 || y == 6 || y == 9 || y == 11) {
    Y = 2; 
  } else {
    Y = 1; 
  }

  if (X == Y) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 384
n, mw = map(int, input().split())
w = []
v = []

for i in range(n):
    ww, vv = map(int, input().split())
    w.append(ww)
    v.append(vv)

dp = [[float("inf")] * (n*(10**3+1)) for i in range(n + 1)]
dp[0][0] = 0

for i in range(n):
    for j in range(n*1001):
        if j < v[i]:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]]+w[i])

for i in range(n * 1001):
    if dp[n][i] <= mw:
        ans = i

print(ans)


Measured memory_bytes: 311560
#include<bits/stdc++.h>
using namespace std;
int main()
{int n;
 cin>>n;
 int c=0;
 while(n>0)
 {
   if(n%10==7)
   {
     c++;
     break;
   }
   
   n=n/10;
 }
 if(c>0)
   cout<<"Yes";
 else
   cout<<"No";
 
 return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

int main() {
    ll n;
    cin >> n;

    ll sum[200100];

    REP(i, 200100) {
        sum[i] = 0;
    }

    for (ll i = 2; i <= n; i++) {
        ll a;
        cin >> a;
        sum[a]++;
    }

    for (ll i = 1; i <= n; i++) {
        MSG(sum[i])
    }
}


Measured memory_bytes: 5200
#import numpy as np
#import functools
#import operator
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm
#import collections

#N = int(input())
#a,b= map(int,input().split())
#P = list(map(int,input().split()))
#B = list(map(int,input().split()))
S= str(input())
#prod = functools.partial(functools.reduce, operator.mul)
#c=np.array(A)
#p=np.prod(A)

w = S.count('W')
b = S.count('B')
c=0
v=0
for i in range(len(S)):
    if S[i]=='B':
        v+=1
        c += (len(S)-b + v) - (i +1)
print(c)


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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){
    string S;
    cin >> S;
    char x = S.at(0);
    int cnt = 0;
    for(int i = 1;i < S.size(); i++){
        if(x != S.at(i)) cnt++;
        x = S.at(i);
    }
    print(cnt);
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const double PI = acos(-1);

//解説AC

ll gcd(ll x, ll y) {
	int r = 0;
	if (x < y) swap(x, y);

	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vll A(N);
	ll m = 0;
	REP(i, N) {
		cin >> A[i];
		m = max(m,A[i]);
	}
	ll gc = gcd(A[0], A[1]);
	FOR(i, 2, N) {
		gc = gcd(gc, A[i]);
	}
	if (K % gc == 0 && m >= K)cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 1272
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v: Vec<usize> = read_vec();
    let (h, w) = (v[0], v[1]);
    let mut grid = vec![vec![-1; h]; w];
    let mut que = std::collections::VecDeque::new();
    let mut checked = 0;
    for i in 0..h {
        let s = read::<String>().chars().collect::<Vec<_>>();
        for j in 0..w {
            if s[j] == '#' {
                grid[j][i] = 0;
                que.push_back((j, i));
                checked += 1;
            }
        }
    }

    while let Some((cur_x, cur_y)) = que.pop_front() {
        if checked == h * w {
            break;
        }
        if cur_x > 0 && grid[cur_x - 1][cur_y] == -1 {
            grid[cur_x - 1][cur_y] = grid[cur_x][cur_y] + 1;
            que.push_back((cur_x - 1, cur_y));
            checked += 1;
        }
        if cur_x < grid.len() - 1 && grid[cur_x + 1][cur_y] == -1 {
            grid[cur_x + 1][cur_y] = grid[cur_x][cur_y] + 1;
            que.push_back((cur_x + 1, cur_y));
            checked += 1;
        }
        if cur_y > 0 && grid[cur_x][cur_y - 1] == -1 {
            grid[cur_x][cur_y - 1] = grid[cur_x][cur_y] + 1;
            que.push_back((cur_x, cur_y - 1));
            checked += 1;
        }
        if cur_y < grid[0].len() - 1 && grid[cur_x][cur_y + 1] == -1 {
            grid[cur_x][cur_y + 1] = grid[cur_x][cur_y] + 1;
            que.push_back((cur_x, cur_y + 1));
            checked += 1;
        }
    }
    let mut ans = 0;
    for i in 0..h {
        for j in 0..w {
            ans = max(ans, grid[j][i]);
        }
    }

    println!("{:?}", ans);
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll H, W;
    cin >> H >> W;
    vector<string> a(H);
    REP(i,0,H) cin >> a[i];
    
    vector<bool> x(W), y(H);
    REP(i,0,H) {
        bool f = false;
        REP(j,0,W) {
            if(a[i][j] == '#') f = true; 
        }
        y[i] = f;
    }
    REP(i,0,W) {
        bool f = false;
        REP(j,0,H) {
            if(a[j][i] == '#') f = true; 
        }
        x[i] = f;
    }
    REP(i,0,H) {
        REP(j,0,W) {
            if(x[j] && y[i]) cout << a[i][j];
        }
        if(y[i]) cout << endl;
    }

    return 0;
}

/*



*/

Measured memory_bytes: 3588
#include <iostream>

using namespace std;

unsigned long long a[100043];

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  unsigned long long res = 1;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (a[i] == 0) {
      printf("0\n");
      return 0;
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (res * a[i] > 1000000000000000000 || res * a[i] < res) {
      printf("-1\n");
      return 0;
    }
    res *= a[i];
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4404
/**In the name of ALLAH*/

#include<bits/stdc++.h>

using namespace std;
#define pri(n)          printf("%d\n",n)
#define prll(n)         printf("%lld\n",n)
#define prd(n)          printf("%lf\n",n)
#define scll(n)         scanf("%lld",&n)
#define sci(n)          scanf("%d",&n)
#define scd(n)          scanf("%lf",&n)
#define pi              acos(-1)
#define ll              long long
#define pb              push_back
#define vsort(v)        sort(v.begin(),v.end())
#define asort(n)        sort(ar,ar+n)
#define for1(i,n)       for(i=1;i<=n;i++)
#define for0(i,n)       for(i=0;i<n;i++)
#define mod             1000000007
#define watch(x)        cout << (#x) << " is " << (x) <<"\n";
#define yes             cout<<"YES\n"
#define no              cout<<"NO\n"
#define LIMIT           100000 /**upto 10^8*/

ll xorr(ll n)
{
    if(n%4==0) return n;
    else if(n%4==1) return 1;
    else if(n%4==2) return n+1;
    else return 0;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);/**Dont't use scanf of printf*/
    ll t,i,pro,x,k,j,a,b,cnt,q,sum,index,r,n;
    cin>>a>>b;
    if(a<=1) a==0;
    else a--;
    cout<<(xorr(b)^xorr(a))<<endl;



    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int N;
char S;
string R;

int main(void){
	//IO("test.in", "test.out");
	R = "Three";
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%c", &S);
		if(S == 'Y') R = "Four";
	}
	cout << R << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int q = sc.nextInt();
    int[] s = new int[100001];
    for(int i = 1;i<=100000;i++){
      if(sosu(i)&&sosu((i+1)/2))s[i]=s[i-1]+1;
      else s[i]=s[i-1];
    }
    for(int i = 0;i < q;i++){
      int l = sc.nextInt();
      int r = sc.nextInt();
      System.out.println(s[r]-s[l-1]);
    }
  }
  public static boolean sosu(int n){
    if(n==1)return false;
    if(n==2)return true;
    if(n%2==0)return false;
    for(int i = 3;i <= Math.sqrt(n);i+=2)if(n%i==0)return false;
    return true;
  }
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    ll s; cin >> s;
    
    const ll y = 1'000'000'000;
    
    // p * y - 1 * x = s
    ll x = y - (s % y);
    x %= y;
    ll p = (s + x)/y;
    
    vll a(6);
    a[0] = a[1] = 0;
    a[2] = p; a[5] = y;
    a[3] = 1;
    a[4] = x;
    rep(i, 6) cout << a[i] << " ";
    cout << endl;
    return;
}

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

Measured memory_bytes: 3612
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MOD 1000000007
 
using namespace std;
 
int main() {
    int N; cin >> N;
    vector<string> A,B;
    A.push_back("a");
    
    for (int i = 1; i < N; i++)
    {
       int Q = A.size();
        for (int j = 0; j < Q; j++)
        {
            string X = A[j];
            int CNT_ALP[26] = {0};
            int cnt = 0;
            for (int k = 0; k < A[j].length(); k++)
            {
                if(CNT_ALP[A[j][k] - 'a'] == 0){
                    CNT_ALP[A[j][k] - 'a']++;
                    cnt++;
                }
            }
            char z = 'a';
            for (int k = 0; k < cnt+1; k++)
            {
                string Z = std::string() + z; 
                B.push_back(X+Z);
                z++;
            }
            
        }
        
            A.clear();
            for (int k = 0; k < B.size(); k++)
            {
                A.push_back(B[k]);
            }
            B.clear();
    }
    for (int i = 0; i < A.size(); i++)
    {
        cout << A[i] << endl;
    }
    
}

Measured memory_bytes: 10224
// Author: Sayantanu
#include <bits/stdc++.h>

using namespace std;

#define ll long long int
const int mod = 1e9 + 7;
#define INF INT_MAX

int main() {
    //code
    ll n,w;
    cin>>n>>w;
    vector<ll> dp(w+1,0);
    // maximum value for a particular i between 0 and n
    ll weight,value;
    for(int i=0;i<n;i++){
        cin>>weight>>value;
        vector<ll> temp(dp.begin(),dp.end());
        for(int j=0;j<=(w-weight);j++){
            temp[j+weight] = max(dp[j+weight],dp[j]+value);
        }
        dp = temp;
    }

    ll ans = 0;
    for(int i=0;i<=w;i++){
        ans = max(ans,dp[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4804
#include<bits/stdc++.h> 
using namespace std;
typedef long long int ll;
#define fo(i,s,e_ex) for(i=s;i<e_ex;i++)
#define MOD 1000000007//998244353
 
ll arr[105],dp[105][100005];
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll i,j,n,k;
	cin>>n>>k;
	for(i=1;i<=n;i++) cin>>arr[i];
	dp[0][0]=1; //BASE CASE
	for(i=1;i<=k;i++) dp[0][i]=0; //BASE CASE
	for(i=1;i<=n;i++){
		for(j=1;j<=k;j++)
			dp[i-1][j]=(dp[i-1][j]+dp[i-1][j-1])%MOD;
			
		for(j=0;j<=k;j++){
			ll mn=j-arr[i]-1;
			dp[i][j]=dp[i-1][j];
			if(mn>=0) dp[i][j]=(dp[i][j]-dp[i-1][mn]+MOD)%MOD;
		}
	}
	cout<<dp[n][k]<<endl;
	return 0;
}

Measured memory_bytes: 82480
#include <iostream>
#include <vector>
#include <math.h>
#include <queue>
#include <map>

int main(){
  int N;
  scanf("%d", &N);
  std::vector<long long> A(N+5);
  std::vector<long long> B(N+5);
  for (int i=0; i<N+1; i++){
    scanf("%lld", &A[i]);
  }
  for (int i=0; i<N; i++){
    scanf("%lld", &B[i]);
  }
  long long ans =0;
  for (int i=0; i<N; i++){
    long long dead = std::min(A[i],B[i]);
    B[i] -= dead; 
    ans+=dead;
    dead = std::min(A[i+1],B[i]);
    A[i+1] -= dead;
    ans+=dead;
  }
  printf("%lld\n",ans);
  return 0;
}

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

int main() {
	//おまじない
	cin.tie(0);
	ios::sync_with_stdio(false);
	

	int A, B;
	cin >> A >> B;

	if (A <= 8 && B <= 8) cout << "Yay!\n";
	else cout << ":(\n";

	Would you please return 0;

}


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

int main() {
  int N; string S; bool res = true;
  cin >> N >> S;
  if (N % 2 != 0) res = false;
  else {
    for (int i = 0; i < N / 2; i++) {
      if (S[i] != S[N / 2 + i]) res = false;
    }
  }
  if (res) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);
  cout << fixed << boolalpha;
  cerr << fixed << boolalpha;


  string s;
  map <char, int> m;
  cin >> s;
  for (auto && elem : s)
  {
    ++ m [elem];
  }
  auto ans = m.size () == 2u;
  cout << (ans ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
using namespace std;
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 100010
#define INF 1000000817
#define mo 1000000007
#define ll long long
int n,m;
int a[N],b[N];
int nq;
pair<int,int> q[N];
int p[N],np;
int f[N];
int t[N];
void add(int x,int c){
	for (;x<=np;x+=x&-x)
		(t[x]+=c)%=mo;
}
int query(int x){
	ll r=0;
	for (;x;x-=x&-x)
		r+=t[x];
	return r%mo;
}
int main(){
//	freopen("in.txt","r",stdin);
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i)
		scanf("%d",&b[i]);
	for (int i=1;i<=m;++i)
		scanf("%d",&a[i]);
	for (int i=1,j=1;i<=n;++i){
		for (;j<=m && a[j]<b[i];++j);
		if (j==m+1 || j==1) continue;
		q[++nq]=make_pair(a[j]-b[i],b[i]-a[j-1]);
	}
	for (int i=1;i<=nq;++i)
		p[++np]=q[i].second;
	sort(p+1,p+np+1);
	np=unique(p+1,p+np+1)-p-1;
	for (int i=1;i<=nq;++i)
		q[i].second=-(lower_bound(p+1,p+np+1,q[i].second)-p);
	sort(q+1,q+nq+1),nq=unique(q+1,q+nq+1)-q-1;
//	for (int i=1;i<=nq;++i)
//		printf("%d %d\n",q[i].first,q[i].second);
	for (int i=1;i<=nq;++i){
		f[i]=1+query((-q[i].second)-1);
		add(-q[i].second,f[i]);
	}
	ll ans=1;
	for (int i=1;i<=nq;++i)
		ans+=f[i];
	ans%=mo;
	printf("%lld\n",ans);
	return 0;
}



















Measured memory_bytes: 5664
EPS = 1e-9
n, m, l = gets.split.map(&:to_i)
p, t, v = n.times.map{ gets.split.map(&:to_f) }.transpose

prob_set = n.times.map{ [0] * (m + 1) }

factorial = (1..m).each_with_object([1]) { |i, arr| arr << arr[-1] * i }
n.times do |i|
  (m + 1).times do |j|
    prob_set[i][j] = (p[i] / 100.0) ** j * (1 - p[i] / 100.0) ** (m - j) * factorial[m] / factorial[m - j] / factorial[j]
  end
end
prob_sum = prob_set.map{ |ps| (0..m).map{ |i| ps[i..-1].reduce(:+) } }

n.times do |i|
  ret = 0
  (m + 1).times do |j|
    prob = prob_set[i][j]
    time = l / v[i] + t[i] * j
    n.times do |k|
      next if i == k
      base = l / v[k]
      upper = (time - base) / t[k] + EPS
      if upper >= m || time - base == 0 && t[k] == 0 || v[i] == 0 && v[k] == 0
        prob = 0
        break
      end
      upper = upper < 0 ? 0 : upper.ceil
      prob *= prob_sum[k][upper]
    end
    ret += prob
  end
  puts '%.8f' % ret
end

Measured memory_bytes: 9164
import sys
import numpy as np
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit('(i4,i4[::1])', cache=True)
def solve(N, P):
    W = N + 2
    dp = np.zeros((W, W), np.int32)
    for _ in range(4):
        dp = dp.T[::-1]
        for n in range(1, (N + 1) // 2 + 1):
            dp[n, n:-n] = n
    filled = np.zeros_like(dp)
    filled[1:-1, 1:-1] = 1
    dp = dp.ravel()
    filled = filled.ravel()
    stack = np.empty_like(dp)
    ans = 0
    for n in P:
        n -= 1
        h, w = divmod(n, N)
        v = (h + 1) * W + (w + 1)
        ans += dp[v] - 1
        filled[v] = 0
        k = min(dp[v - 1], dp[v + 1], dp[v - W], dp[v + W])
        if dp[v] == k:
            return ans
        p = 0
        stack[0] = v
        dp[v] = k
        while p >= 0:
            v = stack[p]
            p -= 1
            for dx in (-1, 1, -W, W):
                w = v + dx
                k = dp[v] + filled[w]
                if dp[w] > k:
                    dp[w] = k
                    p += 1
                    stack[p] = w
    return ans

N = int(readline())
P = np.array(read().split(), np.int32)

print(solve(N, P))

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

int main() {
	int N, A, count = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A;
		count += A % 2;
	}
	if (count % 2 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
using namespace std;
int dist[21][21], x[21][21], sx, sy, gx, gy, H, W; string S;
int main() {
	while (true) {
		cin >> H >> W; if (H == 0 && W == 0)break;
		for (int i = 0; i < 441; i++)dist[i / 21][i % 21] = 99999;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				char c; cin >> c; dist[i][j] = 99999;
				if (c == 'A') { sx = i; sy = j; x[i][j] = 0; }
				if (c == 'B') { gx = i; gy = j; x[i][j] = 0; }
				if (c == '#') { x[i][j] = 1; }
				if (c == '.') { x[i][j] = 0; }
			}
		}
		queue<pair<int, int>>Q; Q.push(make_pair(sx, sy)); dist[sx][sy] = 0;
		int dx[4] = { 1,0,0,-1 }, dy[4] = { 0,-1,1,0 };
		while (!Q.empty()) {
			int a1 = Q.front().first, a2 = Q.front().second; Q.pop();
			for (int i = 0; i < 4; i++) {
				int cx = a1 + dx[i], cy = a2 + dy[i];
				if (cx < 0 || cy < 0 || cx >= H || cy >= W)continue;
				if (dist[cx][cy] > dist[a1][a2] + 1 && x[cx][cy] == 0) {
					dist[cx][cy] = dist[a1][a2] + 1;
					Q.push(make_pair(cx, cy));
				}
			}
		}
		cin >> S; for (int i = 0; i < 10; i++)S += S; bool OK = false;
		for (int i = 0; i < 1000; i++) {
			if (gx >= 0 && gx < H && gy >= 0 && gy < W) {
				if (dist[gx][gy] <= i) { cout << i << ' ' << gx << ' ' << gy << endl; OK = true; break; }
			}
			if (S[i] != '5') {
				gx += dx[(S[i] - '2') / 2]; gy += dy[(S[i] - '2') / 2];
				if (gx == -1)gx = 0; if (gx == H)gx = H - 1;
				if (gy == -1)gy = 0; if (gy == W)gy = W - 1;
			}
		}
		if (OK == false)cout << "impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include <cstdio>
using namespace std;

int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  if ((a+b+c)%2 == 0 && ((a+b+c)/2 == a || (a+b+c)/2 == b || (a+b+c)/2 == c)) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}


Measured memory_bytes: 128
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[2010][2010], pos[2][2010];

const int SIZE = 1 << 15;
struct segtree {
    int node[2*SIZE];
    segtree() {
        memset(node, 0, sizeof(node));
    }
    void init() {
        memset(node, 0, sizeof(node));
    }
    void update(int x, int val) {
        x += SIZE - 1;
        node[x] += val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = node[2*x+1] + node[2*x+2];
        }
    }
    int query(int a, int b, int l=0, int r=SIZE, int k=0) {
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        int mid = (l + r) / 2;
        int vl = query(a, b, l, mid, 2*k+1);
        int vr = query(a, b, mid, r, 2*k+2);
        return vl + vr;
    }
};
 
segtree seg;
signed main() {
    fill(dp[0], dp[2010], INF);
    dp[0][0] = 1;
    int N; cin >> N;

    for(int i=0; i<2*N; i++) {
        char c; int val; cin >> c >> val; val--;
        int col = (c == 'B' ? 1 : 0);
        pos[col][val] = i;
    }

    // black, white
    for(int i=0; i<=N; i++) {
        seg.init();
        for(int k=0; k<i; k++) seg.update(pos[1][k], 1);
        for(int j=0; j<=N; j++) {
            int target = i + j;
            // printf("target = %lld\n", target);
            
            // new! (i)
            if(i != N) {
                int inv1 = seg.query(pos[1][i], 2*N);
                // printf("%lld, %lld, inv1 = %lld, cost = %lld\n", i, j, inv1, pos[1][i] + inv1 - target);
                chmin(dp[i+1][j], dp[i][j] + (pos[1][i] + inv1 - target));
            }

            // new! (j)
            if(j != N) {
                int inv2 = seg.query(pos[0][j], 2*N);
                // printf("%lld, %lld, inv2 = %lld, cost = %lld\n", i, j, inv2, pos[0][j] + inv2 - target);
                chmin(dp[i][j+1], dp[i][j] + (pos[0][j] + inv2 - target));
                // printf("update: %lld\n", pos[0][j]);
                seg.update(pos[0][j], 1);
            }
        }
    }
    cout << dp[N][N] - 1 << endl;
    return 0;
}

Measured memory_bytes: 32384
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=750;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	if(N<1000)
		cout<<"ABC"<<endl;
	else
		cout<<"ABD"<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 998244353;


void solve() {
    int x;
    cin >> x;
    cout << 8 - (x - 400) / 200 << endl;
}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <map>
#include <climits>
#include <bitset>

#define ll long long
const ll MOD = 1e9 + 7;
const ll INF = 1 << 29;


int main()
{
    ll N;
    std::cin >> N;
    std::vector<ll> S(N + 1, 0);
    for (auto i=0; i<N; ++i)
    {
        ll a;
        std::cin >> a;
        S[i+1] = S[i] + a;
    }

    std::sort(S.begin(), S.end());

    ll result = 0;
    ll candidates = 1;
    for (auto i=1; i<N+1; ++i)
    {
        if (S[i] - S[i-1] == 0)
            candidates++;

        if (S[i] != S[i - 1] || i == N)
        {
            // 候補から2つ選ぶので xC2 = x * (x - 1) / 2
            result += candidates * (candidates - 1) / 2;
            candidates = 1;
        }
    }

    std::cout << result << std::endl;
}


Measured memory_bytes: 4848
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int t = sc.nextInt();

        int count = (int)(t + 0.5) / a;
        System.out.println(count * b);

    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
 

int main() {
	ll a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22){
		cout << "bust";
	}
	else{
		cout << "win";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    int N,M;

    cin >> N >> M;

    if (N==M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }






    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int S, h, m ,s;
	scanf("%d\n", &S);
	
	h = S / 60 / 60 % 60;
	m = S / 60 % 60;
	s = S % 60;
	
	printf("%d:%d:%d\n", h, m, s);
	
	return 0;
}


Measured memory_bytes: 2100
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
string S;
int main() {
	cin >> S; int cnt = 0;
	for (int i = 1; i < S.size(); i++) {
		if (S[i - 1] != S[i])cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
  
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
  
using namespace std;
  
typedef long long ll;
typedef pair<int, int> P;

const int INF = 1<<29;

string A, B;
int dfs(int borrow, int K, int i){
	if(i == A.size()) return 0;
	int bi = (borrow>>i)&1;
	int res = 0;
	if(K > 0 && bi){
		res = dfs(borrow&(~(1<<i)), K-1, i);
	}
	int C = 0;
	if(A[i] - bi >= B[i]){
		C = (A[i] - bi - B[i]);
	}else{
		C = (A[i] - bi + 10 - B[i]);
		borrow |= (1<<i+1);
	}
	return max(res, C + 10*dfs(borrow, K, i+1));
}

int main(){
	int K;
	cin >> A >> B >> K;

	reverse(all(A));
	reverse(all(B));

	while(B.size() < A.size()) B += '0';

	cout << dfs(0, K, 0) << endl;

    return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
struct edge{ll to;};
struct graph{
    ll N; //ノードの個数
    vector<vector<edge> > G;
    vector<ll> depth;
    vector<bool> used;
    bool nibu=true;

    graph(ll n): N(n), G(N), depth(N,INF2), used(N,false) {}

    void add_edge(ll s, ll t){
        G[s].emplace_back((edge){t});
        G[t].emplace_back((edge){s}); //無向ならON
    }

    void dfs(ll v=0, ll d=0){
        used[v]=true;
        depth[v]=d;
        for(auto E : G[v]){
            if(used[E.to] == false) dfs(E.to, d+1);
            else if((depth[E.to]-d)%2==0) nibu=false;
        }
    }
};

//--MAIN-----------------------------------
void Main() {
    ll N,M; cin>>N>>M;
    graph g(N);
    rep(i,M){
        ll a,b; cin>>a>>b;
        g.add_edge(--a,--b);
    }
    g.dfs();
    if(g.nibu==false){
        cout<< (N*(N-1))/2-M <<"\n";
    }
    else{
        ll x=0,y=0;
        rep(i,N){
            x+=g.depth[i]%2==0;
            y+=g.depth[i]%2==1;
        }
        cout<< (x*y)-M <<"\n";
    }
    
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

int main(void) {
  int flag = 0;
  string s;
  cin >> s;
  if(s.at(0) == '1'&&s.at(1) == '0') {
    flag += 1;
  }
  if(s.at(0) == '1'&&s.at(1) == '1') {
    flag += 1;
  }
  if(s.at(0) == '1'&&s.at(1) == '2') {
    flag += 1;
  }
  if(s.at(0) == '0'&&s.at(1) != '0') {
    flag += 1;
  }
  if(s.at(2) == '1'&&s.at(3) == '0') {
    flag += 10;
  }
  if(s.at(2) == '1'&&s.at(3) == '1') {
    flag += 10;
  }
  if(s.at(2) == '1'&&s.at(3) == '2') {
    flag += 10;
  }
  if(s.at(2) == '0'&&s.at(3) != '0') {
    flag += 10;
  }
  if(flag == 1) {
    cout << "MMYY";
  }
  if(flag == 10) {
    cout << "YYMM";
  }
  if(flag == 11) {
    cout << "AMBIGUOUS";
  }
  if(flag == 0) {
    cout << "NA";
  }
  cout << endl;
  return 0;
}


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

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

    vector<int> a(n);
    int max_a = 0, next_max_a = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;

        a.at(i) = x;

        if (x > max_a)
            max_a = x;
        else if (x <= max_a)
            next_max_a = max(next_max_a, x);
    }

    for (auto i : a)
        cout << (i == max_a ? next_max_a : max_a) << endl;
}

Measured memory_bytes: 4048
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int n;
    cin >> n;
    VL x(n), y(n);
    REP(i,n){
        ll xt = in(), yt = in();
        x[i] = xt + yt;
        y[i] = yt - xt;
    }
    ll xmin = *min_element(ALL(x));
    ll xmax = *max_element(ALL(x));
    ll ymin = *min_element(ALL(y));
    ll ymax = *max_element(ALL(y));
    ll ans = max(xmax - xmin, ymax - ymin);
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;

ll p[64];

void ins(ll x)
{
    for (int i = 60; i >= 0; --i)
    {
        if (x >> i)
        {
            if (!p[i])
            {
                p[i] = x;
                break;
            }
            x ^= p[i];
        }
    }
}
ll num[100010];
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    ll x, sum = 0;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> num[i];
        sum ^= num[i];
    }
    for (int i = 0; i < n; ++i)
    {
        for (int j = 60; j >= 0; --j)
        {
            if (((sum >> j) & 1) == 1 && ((num[i] >> j) & 1) == 1)
            {
                num[i] -= 1ll << j;
            }
        }
        ins(num[i]);
    }
    x = 0;
    for (int i = 60; i >= 0; --i)
    {
        x = max(x, x ^ p[i]);
    }
    cout << x + (x^sum);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(string, s, t);

  int ans = 0;
  for (int i = 0; i < min(sz(s), sz(t)); ++i) {
    if (s.at(i) == t.at(i)) ans++;
  }

  cout << ans << endl;

  return 0;
}

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

int main(){
    vector<int> H(0,0);
    int N;
    cin >> N;
    int max=0;
    int ans=0;
    for(int i=1;i<=N;i++){
        int h;
        cin >> h;
        if(h >= max){
            max = h;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


int main(){
    int N; cin >> N;
    VLL a(3*N);
    REP(i, 3*N) cin >> a[i];
    RSORT(a);
    ll ans(0);
    FORS(i, 1, N) ans += a[2*i - 1];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560