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

int n;
int o[1005][1005];
vector<int> G[1000005];
int indeg[1000005];

int w(int i, int j) {
  return min(i, j) * 1000 + max(i, j);
}

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

  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < n - 1; j++) cin >> o[i][j];
    for (int j = 0; j < n - 2; j++) {
      G[w(i, o[i][j])].push_back(w(i, o[i][j + 1]));
      indeg[w(i, o[i][j + 1])]++;
    }
  }
  
  queue<int> q[2];
  int d = 0, mm = 0;
  for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++)
    if (!indeg[w(i, j)]) q[0].push(w(i, j));
  
  for (int i = 0;; i ^= 1) {
    if (q[i].empty()) break;
    while (!q[i].empty()) {
      int u = q[i].front();
      q[i].pop();
      mm++;
      for (int h : G[u]) {
        indeg[h]--;
        if (!indeg[h]) q[i ^ 1].push(h);
      }
    }
    d++;
  }
  
  if (mm == n * (n - 1) / 2) {
    cout << d << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    // 割引額のリストを作成してソートする
    int n, m;
    cin >> n >> m;
    priority_queue<ll> mq;
    ll total = 0;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        total += a;
        while (a != 0)
        {
            int af = a / 2;
            mq.push(a - af);
            a /= 2;
        }
    }
    for (int i = 0; i < m; i++)
    {
        if (mq.empty())
        {
            break;
        }
        total -= mq.top();
        mq.pop();
    }
    cout << total << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
};

Measured memory_bytes: 36256
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;

int dp[2][5001][2];

int main(){
  int N, a[10000];
  cin >> N;
  for(int i = 0; i < N - 1; i++){
    cin >> a[i];
  }

  fill_n( **dp, 2 * 5001 * 2, INF);

  // dp[i][false] <- dp[i - 1][false]は切らなみ dp[i - 1][true]は切り身
  // dp[i][true] <- dp[i - 1][true]は切らなみ   dp[i - 1][false]は切り身

  // ケーキの長さもほしみありそう

  dp[0][0][false] = dp[0][1][true] = 0;
  for(int i = 0; i < N - 1; i++){
    for(int j = N / 2; j >= 0; j--){ // 今の長さ
      dp[(i + 1)&1][j][false] = min( dp[i&1][j][false], dp[i&1][j][true] + a[i]);
      if(j > 0){
        dp[(i + 1)&1][j][true] = min( dp[i&1][j - 1][true], dp[i&1][j - 1][false] + a[i]);
      }
    }
    for(int j = 0; j <= N / 2; j++){
      dp[i&1][j][false] = dp[i&1][j][true] = INF;
    }
  }
  cout << min( dp[(N - 1)&1][N / 2][false], dp[(N - 1)&1][N / 2][true]) << endl;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
typedef pair <int, int> PR;
priority_queue <PR> qua;
#define mst(x) memset(x, 0, sizeof(x))
vector <int> vec;
int n, k;
int a[maxx];

void Init() {
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
}

int main() {
	Init();
	sort(a + 1, a + n + 1);
	int ans = Inf;
	for(int i = 1; i + k - 1 <= n; i++) {
		ans = min(ans, a[i + k - 1] - a[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }
signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    int ans = INF;
    for(int i=1;i*i<=n;i++){
        if((n % i) == 0){
            //cout<<i<<' '<<n/i<<endl;
            int y = n / i;
            chmin(ans, y+i -2);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main() {
    string s, p;
    cin >> s;
    cin >> p;
    string s2 = s + s;
    // cout << s2 << endl;
    int m = s2.find(p);
    if(m != s2.npos) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#include <list>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    string s;
    cin >> s;
    for (int i = 0; true; i++)
    {
        if (s[0] == 'A')
        {
            break;
        }
        else
        {
            s.erase(0, 1);
        }
    }
    for (int i = 0; true; i++)
    {
        if (s[s.size() - 1] == 'Z')
        {
            break;
        }
        else
        {
            s.erase(s.size() - 1, 1);
        }
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 640
/*      ###########################
            #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/      
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007  
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn) 
{  
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}  
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    return b==0?a:gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    // ll temp = eulerstotientfunction(m);
    return modpow(x,m-2,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
} 
int main()
{
    //fastio();
    ll n;
    cin >> n;
    ll arr[n+1];
    for(ll i=1;i<=n;i++)
        cin >> arr[i];
    ll count =0 ;
    for(ll i=1;i<=n;i++)
    {
        if(arr[i]!=i)
        {
            if(arr[arr[i]]==i)
            {
                swap(arr[arr[i]],arr[i]);
                count++;
            }
        }
    }
    if(count>1)
        cout << "NO" << endl;
    else
    {
        for(ll i=1;i<n;i++)
        {
            if(arr[i]>arr[i+1])
            {
                cout << "NO" << endl;
                return 0;
            }
        }
        cout << "YES" << endl; 
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const ll MOD = 1e9 + 7;

int n;
map<int, int> mm;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x;
		scanf("%d", &x);
		++mm[x];
	}
	for (int i = 0; i < n; ++i) {
		int l = i;
		int r = n - 1 - i;
		--mm[abs(l - r)];
		if (mm[abs(l - r)] < 0) {
			cout << 0 << "\n";
			return 0;
		}
	}
	int k = n / 2;
	ll ans = 1;
	for (int i = 0; i < k; ++i)
		ans = (ans * 2) % MOD;
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 3200
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

int main() {
    SS(int,n,m)
    p(n*(n-1)/2+m*(m-1)/2);
}

Measured memory_bytes: 256
def base3(K):
    tmp=K
    S=""
    while(True):
        S=str(tmp%3)+S
        tmp=tmp//3
        if tmp==0:
            break
    return S
L=int(input())
T=base3(L)[::-1]
N=len(T)
A=[]
for i in range(N-1):
    tmp=3**i
    for k in range(3):
        A.append((i+1,i+2,k*tmp))
bef=0
for i in range(N)[::-1]:
    tmp=3**i
    for k in range(int(T[i])):
        A.append((i+1,N+1,bef+k*tmp))
    bef+=int(T[i])*tmp
print(N+1,len(A))
for p in A:
    print(p[0],p[1],p[2])


Measured memory_bytes: 3064
def main():
    s=input()
    rs=s[::-1]
    c1="maerd"
    c2="remaerd"
    c3="esare"
    c4="resare"
    t = ""
    cc=0
    while cc < len(rs):
        if rs[cc]=="m":
            t = t+c1
            cc += 5
        elif rs[cc]=="e":
            t = t+c3
            cc += 5
        elif rs[cc] =="r":
            if len(rs[cc:]) < 3:
                return "NO"
            elif rs[cc:cc+3] == "rem":
                t = t+c2
                cc += 7
            elif rs[cc:cc+3] == "res":
                t = t+c4
                cc += 6
            else:
                return "NO"
        else:
            return "NO"
    if rs == t:
        return "YES"
    else:
        return "NO"

print(main())

Measured memory_bytes: 3316
import java.util.*;
class Main{
  static long gcd (long m, long n) {
   if(m<n) return gcd(n,m);
   if(n==0) return m;
     return gcd(n,m%n);
  }
  static long lcm(long m,long n){
    return m/gcd(m,n)*n;
  }
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int N=scan.nextInt();
    long[] T=new long[N];
    for(int i=0;i<N;i++){
      T[i]=scan.nextLong();
    }
    long tmp;
    if(N==1){
      tmp=T[0];
    }
    else{
      tmp=lcm(T[0],T[1]);
      for(int i=2;i<N;i++){
        tmp=lcm(tmp,T[i]);
      }
    }
      
    System.out.println(tmp);
  }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int64_t i = 0; i < n; ++i)
using namespace std;

int main() {
  char c;
  set<char> p;
  string s;
  cin >> s;
  rep(i, s.size()) p.insert(s[i]);
  if(p.size() == 26) cout << "None" << endl;
  else{
    rep(i, 26){
      if(!p.count('a' + i)){
        c = 'a' + i;
        break;
      }
    }
    cout << c << endl;
  }
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}


struct edge { long long to, cost;};	
typedef pair<long long, long long> P_dij;	
void dijkstra(const long long s, const long long n,	
  vector< vector<edge> > const &G, vector<long long> & d){	
  d.resize(n);	
  for(int i=0; i<n; i++) d[i] = INF; 	
  priority_queue<P_dij, vector<P_dij>, greater<P_dij>> que;	
  d[s] = 0;	
  que.push(P_dij(0, s));	
  while (!que.empty()) {	
    P_dij p = que.top();	
    que.pop();	
    long long v = p.second;	
    if(d[v] < p.first)continue;	
    for(int i=0;i<G[v].size(); i++){	
      edge e = G[v][i];	
      if(d[e.to] > d[v] + e.cost){	
        d[e.to] = d[v] + e.cost;	
        que.push(P_dij(d[e.to], e.to));	
      }	
    }	
  }	
}	

int main() {
  int n,m,s,t;
  cin >> n >> m;
  vector<vector<edge>> graph((n + 10) * 3);

  rep(i, m) {
    int u,v;
    cin >> u >> v;
    graph[u].push_back({v + n, 1});
    graph[u+n].push_back({v + 2 * n, 1});
    graph[u+2*n].push_back({v, 1});
  }
  
  cin >> s >> t;

  vector<ll> d;
  dijkstra(s, (n + 10) * 3, graph, d);
  if (d[t] != INF) {
    cout << d[t] / 3 << endl;
  } else {
    cout << -1 << endl;
  }
  
}


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

int op[11] = {0};
int n;

void dfs (int x, int m) {
    if (x == n) {
        for (int i = 0; i <= min (25, max (op[x - 1] + 1, m + 1)); i ++)  {
            for (int j = 1; j < n; j ++) 
                printf ("%c", 'a' + op[j]);
            printf ("%c\n", 'a' + i);
        }
        return ;
    }
    for (int i = 0; i <= min (25, max (op[x - 1] + 1, m + 1)); i ++) {
        op[x] = i;
        dfs (x + 1, max (op[x], m));
    }
}

int main () {
	cin >> n;
    op[1] = 0;
    if (n == 1) cout << "a" << endl;
    else dfs (2, 0);
	return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
set<string> c;
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=100000000000000000;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
map<ll,ll> mp;

int main(){
int h,w,k;
cin>>h>>w>>k;
vector<vector<ll>> dp(h+1,vector<ll>(w,0));
dp[0][0]=1;
for(int i=0;i<h;i++){
   for(int bit=0;bit<(1<<(w-1));bit++){
       bool ok=true;
       for(int mask=0;mask<w-2;mask++){
           if((bit>>mask)%4==3)ok=false;//末尾11（隣接しているところ）を弾く
       }
       if(!ok)continue;
       vector<int> move(w);
       for(int j=0;j<w;j++)move.at(j)=j;
       for(int j=0;j<w-1;j++){
           if(bit&(1<<j))swap(move.at(j),move.at(j+1));//横線引かれていたらゴール入れ替え
       }
       //配るDP
       for(int j=0;j<w;j++){
           dp[i+1][move.at(j)]+=dp[i][j];
           dp[i+1][move.at(j)]%=mod;
       }
   }
}
cout<<dp[h][k-1]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i, n){
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y.begin(), y.end());
    int tmp = y[n / 2 - 1];
    rep(i,n){
        if(x[i]<=tmp)
            cout << y[n / 2] << endl;
            else
                cout << tmp << endl;
    }
    return 0;
}

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

#define INT32_MIN -2147483647-1

int main()
{
	int n, max = INT32_MIN, min;
	cin >> n;
	cin >> min;
	int x;

	for (int i = 1; i < n; i++) {
		cin >> x;
		max = (x - min) > max ? x - min : max;
		min = min > x ? x : min;
	}
	cout << max << "\n";
	return 0;
}

Measured memory_bytes: 1168
package main

import (
	"fmt"
	"sort"
)

func main() {
	var s int

	fmt.Scan(&s)
	hoge := make([]int, s)

	for i := range hoge {
		fmt.Scan(&hoge[i])
	}

	sort.Ints(hoge)

	ans := 0

	for i := 0; i < s; i++ {
		for j := i+1; j < s; j++ {
			for k := j+1; k < s; k++ {
				if (hoge[k] != hoge[j]) && (hoge[i] != hoge[j]) && (hoge[k] != hoge[i]) {
					if hoge[i]+hoge[j] > hoge[k]{
						ans++
					}
				}
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1844
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<set>
#include<vector>
#include<map>
#include<unordered_map>

#define ll long long
using namespace  std;
int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a%b);
}
ll qpow(ll a, ll b) {
	ll ans = 1, base = a;
	while (b) {
		if (b & 1) {
			ans *= base;
		}
		base *= base;
		b >>= 1;
	}
	return ans;
}

/*A*/

//int main() {
//	ios::sync_with_stdio(0);
//	int l, r,d; cin >> l >> r >> d;
//	cout << (r / d) - (l - 1) / d << endl;
//}

/*B*/

int main() {
	ios::sync_with_stdio(0);
	int n; cin >> n;
	int cnt = 0;
	for (int i = 1; i <= n; ++i) {
		int tmp; cin >> tmp;
		if (i % 2 && tmp % 2) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

/*C*/

//int main() {
//	ios::sync_with_stdio(0);
//}

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

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using dijkstra = priority_queue<T, vector<T>, greater<T>>;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fbo find_by_order  // k th index
#define ook order_of_key   // strictly smaller than k
#define PI acos(-1.0)
#define inf 0x3f3f3f3f
#define max_ull 18446744073709551615
#define max_ll 9223372036854775807
#define lead_zero(x) __builtin_clzll(x)
#define trail_zero(x) __builtin_ctzll(x)
#define total_1s(x) __builtin_popcountll(x)
#define first_1(x) __builtin_ffsll(x)
#define log2_(x) __builtin_clz(1) - __builtin_clz(x)
#define isLeap(x) ((x % 400 == 0) || (x % 100 ? x % 4 == 0 : false))
#define QUERY           \
    int test;           \
    scanf("%d", &test); \
    for (int _T = 1; _T <= test; _T++)
#define FAST ios_base::sync_with_stdio(0), cin.tie(0)
#define all(v) v.begin(), v.end()
#define reunique(v) v.resize(std::unique(all(v)) - v.begin())
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define ff first
#define ss second
#define MERGE(v1, v2, v) merge(all(v1), all(v2), back_inserter(v))
#define MP make_pair
#define EB emplace_back
#define read freopen("input.txt", "r", stdin)
#define write freopen("output.txt", "w", stdout)
#define in_range(v, r, l) upper_bound(all(v), r) - lower_bound(all(v), l)
#define LCM(a, b) (a / __gcd(a, b)) * b;

ll rdn(int y, int m, int d) {
    /* Rata Die day one is 0001-01-01 */
    if (m < 3)
        y--, m += 12;
    return 365 * y + y / 4 - y / 100 + y / 400 + (153 * m - 457) / 5 + d - 306;
}
/* Direction arrays */
/*int dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1};                             */  // 4Direction
/*int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1};         */  // 8Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1};     */  // KnightDirection
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1};                */  // HexagonalDirection
/* int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; */


int main() {
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes\n";
    }    
    else{
        cout<<"No\n";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int a[100002] = { 0 };
int main(){
	int n, m, cnt = 0, point = 1, move;
	cin >> n >> m;
	for (int i = 2; i <= n; i++){
		cin >> a[i];
	}
	for (int i = 0; i<n; i++){
		a[i + 1] += a[i];
	}
	for (int i = 0; i<m; i++){
		cin >> move;
		if (move>0)
			cnt += a[move + point] - a[point];
		else
			cnt += a[point] - a[point + move];
		point += move;
		cnt %= 100000;
	}
	cout << cnt % 100000 << endl;
	return 0;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(2 * a - 1, 2 * b - 1));

    return 0;
}


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

using namespace std;

#define ll long long
#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())

char buff[(int) 2e7 + 17];
const ll inf = (ll) 1e9 + 7ll;

const int maxn = (int) 1e6 + 17;

ll a, b;

bool read() {
    if (scanf("%lld %lld", &a, &b) != 2)
        return false;

    return true;
}

void solve() {
    auto z = b / a;
    int ans = 0;

    for (int k = 0; k <= 64; ++k)
        if ((1ull << k) <= z)
            ans = k;
        else
            break;

    printf("%d\n", ans + 1);
}

int main() {
#if SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}


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

using namespace std;

int main(){
	int n;
  	cin >> n;
  	vector<int> a(n);
  	int maxi = INT_MIN;
  	int maxIdx = -1;
  	int maxi2 = INT_MIN;
  	for(int i=0;i<n;i++){
      cin >> a[i];
      if(a[i] >= maxi){
      	maxi2 = maxi;
        maxi = a[i];
        maxIdx = i;
      }else if(a[i] > maxi2){
      	maxi2 = a[i];
      }
    }
  	for(int i=0;i<n;i++){
    	if(i!=maxIdx) cout << maxi << endl;
        else cout << maxi2 << endl;
    }
	return 0;
}

Measured memory_bytes: 2432
#include <algorithm>
#include <cmath>
#include <functional>
#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;
  string s;
  cin >> s;

  vector<int> v(N);
  rep(i, N) {
    if (s[i] == 'R') {
      v[i] = 0;
    } else if (s[i] == 'G') {
      v[i] = 1;
    } else {
      v[i] = 2;
    }
  }

  vector<vector<int>> cnt(N, vector<int>(3, 0)), rcnt(N, vector<int>(3, 0));
  rep(i, N - 1) {
    copy(cnt[i].begin(), cnt[i].end(), cnt[i + 1].begin());
    cnt[i + 1][v[i]]++;
  }
  rep(i, N - 1) {
    copy(rcnt[N - 1 - i].begin(), rcnt[N - 1 - i].end(),
         rcnt[N - 1 - i - 1].begin());
    rcnt[N - 1 - i - 1][v[N - 1 - i]]++;
  }

  int64_t result = 0;
  rep(i, N) {
    result += cnt[i][(v[i] + 1) % 3] * rcnt[i][(v[i] + 2) % 3] +
              cnt[i][(v[i] + 2) % 3] * rcnt[i][(v[i] + 1) % 3];
  }

  rep(j, N) {
    for (int d = 1; j - d >= 0 && j + d < N; d++) {
      if (v[j] != v[j - d] && v[j] != v[j + d] && v[j - d] != v[j + d]) {
        result--;
      }
    }
  }

  cout << result << endl;

  return 0;
}

Measured memory_bytes: 3944
#include<stdio.h>
#define N 100

int n, pos, count = 0;
int pre[N], in[N], post[N];

int find(int in[n], int root){
  int i;
  for(i = 0; i < n; i++){
    if(in[i] ==  root) return i;
  }
  return in[n - 1];
}

void rec(int l, int r){
  int root, m;
  if(l >= r) return;
  root = pre[pos++];
  m = find(in, root);
  rec(l, m);
  rec(m + 1, r);
  post[count++] = root;
}

void solve(){
  int i;
  pos = 0;
  rec(0, n);
  for(i = 0; i < n; i++){
    if(i) printf(" ");
    printf("%d", post[i]);
  }
  printf("\n");
}

int main(){
  int i, k;
  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &k);
    pre[i] = k;
  }

  for(i = 0; i < n; i++){
    scanf("%d", &k);
    in[i] = k;
  }

  solve();

  return 0;
}

Measured memory_bytes: 600
int main(){
	int i,x,y;
	
	for(i=1;i<=3000;i++){
		scanf("%d%d",&x,&y);
		if(x==0 && y==0)break;
		if(x<=y)
			printf("%d %d\n",x,y);
		else
			printf("%d %d\n",y,x);
	}
	return 0;
}

Measured memory_bytes: 600
from fractions import gcd

def lcm(a,b):
    return a*b//gcd(a,b)

n=int(input())
a=[int(i) for i in input().split()]
l=1
mod=10**9+7
for i in range(n):
    l=lcm(l,a[i])
ans=0
#print(l)
for i in a:
    #print(l//i)
    ans+=l//i
print(ans%mod)

Measured memory_bytes: 6108
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                int N = sc.nextInt();
                int A = sc.nextInt();
                long[][] dp = new long[N+1][N*50 + 1];
                dp[0][0]++;
                int m = 0;
                for (int i = 0; i < N; i++) {
                        int x = sc.nextInt();
                        for (int j = N - 1; j >= 0; j--) {
                                for (int k = N*50-x; k >=0; k--) {
                                        dp[j+1][k+x] += dp[j][k];
                                }
                        }
                }
                long ans = 0;
                for (int i = 1; i <= N; i++) {
                        ans += dp[i][i*A];
                }
                System.out.println(ans);
        }
}

Measured memory_bytes: 11168
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
const int inf=0x3f3f3f3f;
const int rd[4]={1,0,-1,0};
const int cd[4]={0,1,0,-1};

int h,w,k,sr,sc,d[805][805],res=inf;
char a[805][805];

inline bool inside(int r,int c){
    return r>=0 && r<h && c>=0 && c<w;
}

inline int casts(int r,int c){
    int x0=c,x1=w-c-1,y0=r,y1=h-r-1;
    return (min(min(x0,x1),min(y0,y1))+k-1)/k;
}

int main(){
    memset(d,inf,sizeof d);
    scanf("%d %d %d",&h,&w,&k);
    for(int i=0;i<h;i++){
        scanf("%s",a[i]);
        for(int j=0;j<w;j++)if(a[i][j]=='S')sr=i,sc=j;
    }
    queue<pair<int,int> > q;
    q.push(make_pair(sr,sc));
    d[sr][sc]=0;
    while(!q.empty()){
        pair<int,int> p=q.front();q.pop();
        res=min(res,casts(p.first,p.second)+1);
        if(d[p.first][p.second]==k)continue;
        for(int k=0;k<4;k++){
            int rr=p.first+rd[k],cc=p.second+cd[k];
            if(!inside(rr,cc) || a[rr][cc]=='#')continue;
            if(d[rr][cc]!=inf)continue;
            q.push(make_pair(rr,cc));
            d[rr][cc]=d[p.first][p.second]+1;
        }
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 3456
#include<stdio.h>

int main(){

  int a;
  scanf("%d",&a);
  
  if(a==25)
    printf("Christmas");
  if(a==24)
    printf("Christmas Eve");
  if(a==23)
    printf("Christmas Eve Eve");
  if(a==22)
    printf("Christmas Eve Eve Eve");
  
 
}

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

using namespace std;

void Compress(vector<string>& B, int H, int W, int x, int y) {
  bool can_compress = true;
  for (int x2 = 0; x2 < W; x2++) {
    if (B[y][x2] == '#') {
      can_compress = false;
      break;
    }
  }

  if (can_compress) {
    for (int x2 = 0; x2 < W; x2++) {
      B[y][x2] = ' ';
    }
  }

  can_compress = true;
  for (int y2 = 0; y2 < H; y2++) {
    if (B[y2][x] == '#') {
      can_compress = false;
      break;
    }
  }

  if (can_compress) {
    for (int y2 = 0; y2 < H; y2++) {
      B[y2][x] = ' ';
    }
  }
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> B(H);
  for (int y = 0; y < H; y++) cin >> B[y];

  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (B[y][x] != '.') continue;
      Compress(B, H, W, x, y);
    }
  }

  for (int y = 0; y < H; y++) {
    string S = "";
    for (int x = 0; x < W; x++) {
      if (B[y][x] != ' ') S += B[y][x];
    }
    if (S != "") cout << S << "\n";
  }

  return 0;
}


Measured memory_bytes: 256
using System;

class D
{
	static void Main()
	{
		var h = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
		long n = h[0], x = h[1];

		var p = new long[n + 1]; p[0] = 1;
		var c = new long[n + 1]; c[0] = 1;
		for (int i = 0; i < n; i++)
		{
			p[i + 1] = 2 * p[i] + 1;
			c[i + 1] = 2 * c[i] + 3;
		}
		Console.WriteLine(Find(n, x, p, c));
	}

	static long Find(long n, long x, long[] p, long[] c)
	{
		return n == 0 ? 1 :
			x <= 1 ? 0 :
			x <= c[n - 1] + 1 ? Find(n - 1, x - 1, p, c) :
			x <= c[n - 1] + 2 ? p[n - 1] + 1 :
			x <= c[n] - 1 ? p[n - 1] + 1 + Find(n - 1, x - c[n - 1] - 2, p, c) :
			p[n];
	}
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

bool check_same(string s,string u){
    if(s.size()!=u.size())return false;
    rep(i,s.size()){
        if(s[i]!=u[i]){
            return false;
        }
    }
    return true;
}

int main(){
    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string u;
    cin>>u;
    if(check_same(s,u))a--;
    else b--;
    cout<<a<<" "<<b<<endl;


    return 0;

}
/*


*/


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef struct {
	char suit, value;
}card;
void change(card* a, card* b)
{
	card c;
	c.suit = b->suit;
	c.value = b->value;
	b->suit = a->suit;
	b->value = a->value;
	a->suit = c.suit;
	a->value = c.value;
}
void BubbleSort(card* sort, int N)
{
	int i, j,flag=1;
	for (i = 0; i < N && flag == 1; i++) //flag注意不要错误，错误只会进行一次冒泡排序
	{
		flag = 0;
		for (j = N - 1; j > i; j--)
			if (sort[j - 1].value > sort[j].value)
			{
				change(&sort[j - 1], &sort[j]);
				flag = 1;
			}
	}
}
void SelectionSort(card* sort, int N)
{
	int i, j,min;
	for (i = 0; i < N; i++)
	{
		for (min = i, j = i; j < N; j++)
			if (sort[j].value < sort[min].value)
				min = j;
		if (min != i)
			change(&sort[min], &sort[i]);
	}
}
void isStable(card* in, card* out,int N) //已知冒泡排序的稳定的，只要比较排序和冒泡排序的suit就可以了
{
	int i ;
	for(i=0;i<N;i++)
		if (in[i].suit != out[i].suit)
		{
			cout << "Not stable" << endl;
			return;
		}
	cout<< "Stable" << endl;
}
void print(card* sort, int N)
{
	for (int i = 0; i < N - 1; i++)
		cout << sort[i].suit << sort[i].value << ' ';
	cout << sort[N-1].suit << sort[N-1].value << endl;
}
int main()
{
	int N, i, j;
	card in[36],Bubble[36],Select[36];
	cin >> N;
	for (i = 0; i < N; i++)
	{
		cin >> in[i].suit>>in[i].value;
		Bubble[i].suit = in[i].suit;
		Select[i].suit = in[i].suit;
		Bubble[i].value = in[i].value;
		Select[i].value = in[i].value;
	}
	BubbleSort(Bubble, N);
	print(Bubble, N);
	cout << "Stable" << endl;
	SelectionSort(Select, N);
	print(Select, N);
	isStable(Bubble, Select, N);
	return 0;
}


Measured memory_bytes: 3064
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 c = a*b;
		
		if(c%2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}
}

Measured memory_bytes: 35660
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  int N;
  cin >> N;
  vector<P> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i).first;
    a.at(i).second = i + 1;
  }
  sort(ALL(a));
  for(int i = 0; i < N; i++){
    cout << a.at(i).second << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 1664
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

n = int(input()) 
#n,x = [int(i) for i in readline().split()]
a = [int(i) for i in readline().split()]

def zeta_transform(a,n): #高速ゼータ変換
    b = [[i,0] for i in a]
    for i in range(n):
        I = 1<<i
        for j in range(1<<n):
            if not j&I:
                if b[j][0] > b[j^I][0]:
                    b[j^I][0],b[j^I][1] = b[j][0], b[j^I][0]
                    if b[j][1] > b[j^I][1]:
                        b[j^I][1] = b[j][1]
                elif b[j][0] > b[j^I][1]:
                    b[j^I][1] = b[j][0]
    return b

#print(a)
za = zeta_transform(a[:],n)
#print(zeta_transform(a[:],n),"zeta-a")

for i, zi in enumerate(za):
    if not i: ans = 0
    else:
        i1,i2 = za[i]
        ans = max(ans,i1+i2)
        print(ans)    




Measured memory_bytes: 123980
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++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(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]))
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    return 0;
}

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

template <typename T>
void print(const T &v);

int main()
{
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

//AOJ 0515

signed main(){
	int a, b, n, x, y;
	int dp[20][20];
	while (1) {
		cin >> a >> b >> n;
		if (a + b == 0) break;
		rep(i, 0, 20) {
			rep(j, 0, 20) {
				dp[i][j] = 0;
			}
		}
		rep(i, 0, n) {
			cin >> x >> y;
			x--;
			y--;
			dp[x][y] = -1;
		}
		dp[0][0] = 1;
		rep(i, 0, a) {
			rep(j, 0, b) {
				if (i != 0 && dp[i][j] != -1) {
					dp[i][j] += max((int)0, dp[i - 1][j]);
				}
				if (j != 0 && dp[i][j] != -1) {
					dp[i][j] += max((int)0, dp[i][j - 1]);
				}
			}
		}
		cout << dp[a - 1][b - 1] << endl;
	}
}

Measured memory_bytes: 1156
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,ans;
  cin>>a>>b;
  ans=a+b;
  if(ans>=24){
    ans-=24;
  }
  cout<<ans<<"\n";
  
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

int main() {
    ios::sync_with_stdio(false);
    Int a, b, k;
    cin >> a >> b >> k;
    vector<Int> res;
    for (Int i = 1; i <= 100; i++) {
        if (a < i || b < i) break;
        if (a % i == 0 && b % i == 0) res.emplace_back(i);
    }
    dump(res[res.size() - k]);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n,m,q;
  cin>>n>>m>>q;
  vector<int> as(q),bs(q),cs(q),ds(q);
  for(int i=0;i<q;i++)
    cin>>as[i]>>bs[i]>>cs[i]>>ds[i],as[i]--,bs[i]--;

  int ans=0;
  vector<int> A(n);
  MFP([&](auto dfs,int x,int l)->void{
    if(x==n){
      int sum=0;
      for(int i=0;i<q;i++)
        if(A[bs[i]]-A[as[i]]==cs[i]) sum+=ds[i];
      chmax(ans,sum);
      return;
    }
    for(int i=l;i<=m;i++){
      A[x]=i;
      dfs(x+1,i);
    }
  })(0,1);
  cout<<ans<<newl;
  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;

int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

bool check(string &s)
{
  for(int i=0;i<s.size()/2;i++)
  {
    if(s[i]!=s[s.size()-1-i])return 0;
  }
  return 1;
}

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

 

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

int ans=0;

for(auto i : mp)
{
   ans+=(i.second)*(i.second-1)/2;
}
int res=ans;

for(int i=0;i<n;i++)
{
  int k=mp[v[i]];
  ans-=(k)*(k-1)/2;
  ans+=(k-1)*(k-2)/2;
  cout<<ans<<"\n";
  ans=res;
}



}




Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <list>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
#include <ctime>
#include <assert.h>
using namespace std;

const unsigned long long BASE = (unsigned long long)(1e9 + 7);

#define FROM_0(i, n) for(int i = 0; i < (n); i++)
#define FROM_S(i, s, e) for(int i = (s); i < (e); i++)
#define ITER_BEGIN_END(iter, vec) for(auto iter = vec.begin(); iter != vec.end(); iter++)

int main()
{
    long long n;
    cin >> n;
    long long a = 1, b = 2, c = 1;
    FROM_0(i, n)
    {
        a = (a * 10) % BASE;
        b = (b * 9) % BASE;
        c = (c * 8) % BASE;
    }
    long long ret = (a - b + c);
    if (ret < 0)
        ret += BASE;
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

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

using namespace std;

typedef unsigned long ul;
using namespace std;
const int MAX = 101;

int a, b, c, d, e, k;


int main() {

    cin >> a >> b >> c >> d >> e >> k;

    int maxa = max(a, max(b, max(c, max(d, e))));
    int mina = min(a, min(b, min(c, min(d, e))));

    if (maxa - mina > k) {
        cout << ":(";
    } else {
        cout << "Yay!";
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		List<String> atcg = new ArrayList<String>();
		atcg.add("A");
		atcg.add("C");
		atcg.add("G");
		atcg.add("T");

		Scanner in = new Scanner(System.in);
		String[] S = in.next().split("");
		int max = 0;
		int len = 0;
		for (int i = 0; i < S.length; i++) {
			if(atcg.contains(S[i])) {
				len++;
				if(len > max) {
					max = len;
				}
			}else {
				len=0;
			}
		}

		System.out.println(max);
		in.close();
	}

}


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

int main(){
    int d,r;
    double f;
    int a,b;
    cin>>a>>b;
    d = a/b;
    r = a%b;
    f = (double)a/b;
    cout<<d<<' '<<r<<' ';
    cout<<fixed<<setprecision(8)<<f<<'\n';
}


Measured memory_bytes: 3276
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n;
double p[3333],dp[3333][3333],ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>p[i];
	dp[1][1]=p[1];
	dp[1][0]=1.0000-p[1];
	for(int i=2;i<=n;i++)
		for(int j=0;j<=n;j++)
		{
			dp[i][j]=dp[i-1][j]*(1.0000-p[i]);
			if(j>0)
				dp[i][j]+=dp[i-1][j-1]*p[i];
		}
	for(int i=n/2+1;i<=n;i++)
		ans+=dp[n][i];
	cout<<fixed<<setprecision(10)<<ans;
	return 0;
}

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

int main() {
	int a, b, x;
	a = b = 0;
	for (int i = 0; i < 3; ++i) {
		cin >> x;
		if (x == 5) a++;
		else if (x == 7) b++;
	}
	if (a == 2 && b == 1) cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
const int INF = 1001001001;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^8 -> 8回
// double pi = M_PI or acos(-1)
// printf("%.10f\n", ans);

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h.at(i);
    int pre = -999;
    rep(i, n) {
        if (pre <= h.at(i) - 1) {
            pre = h.at(i) - 1;
        } else if (pre == h.at(i)) {
            pre = h.at(i);
        } else {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 3688
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    String out ="";
    while (scanner.hasNext()) {
      String line = scanner.nextLine();
      String[] p = line.split(" ");
      Deque<String> stack = new ArrayDeque<String>();
      for (int ii = 0; ii < p.length; ii++) {
        stack.addLast(p[ii]);
      }
      Deque<Double> work = new ArrayDeque<Double>();
      for (;;) {
        if (stack.isEmpty()) {
          out += work.pop() + "\n";
          break;
        }
        String pp = stack.pop();
        if (!isNumber(pp)) {
          double a = work.pop();
          double b = work.pop();
          double c = 0;
          if (pp.equals("+")) {
            c = b + a;
          } else if (pp.equals("-")) {
            c = b - a;
          } else if (pp.equals("*")) {
            c = b * a;
          } else if (pp.equals("/")) {
            c = b / a;
          }
          work.push(c);
        } else {
          work.push(Double.parseDouble(pp));
        }
      }
    }
    System.out.print(out);
  }

  private static boolean isNumber (String str) {
    try {
      Double.parseDouble(str);
      return true;
    } catch (NumberFormatException nfex) {
      return false;
    }
  }
}

Measured memory_bytes: 15448
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const [N] = r.nn()

    return N >= 30 ? 'Yes' : 'No'
  }

  const _io = (i = 0) => {
    const str: string = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map((v) => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map((line) => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}


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

using ll = long long;

int main() {
    int m;
    vector<int> res(1000001, 0);
    for(int i=1; i<1000001; ++i) {
        int t = i;
        while(t % 2 == 0) {
            t /= 2;
        }
        while(t % 3 == 0) {
            t /= 3;
        }
        while(t % 5 == 0) {
            t /= 5;
        }
        res[i] = t == 1;
    }
    for(int i=1; i<1000001; ++i) {
        res[i] += res[i-1];
    }
    while(cin >> m, m) {
        int n;
        cin >> n;
        cout << res[n] - res[m-1] << endl;
    }
}


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

using namespace std;

const int MAX_N = 200010;
int N;
int A[MAX_N], B[MAX_N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> A[i];
	for (int i = 0; i < N; i++)
		cin >> B[i];
	
	reverse(B, B + N);
	
	int e = -1, a, b, x, y;
	
	for (int i = 0; i < N; i++) {
		if (A[i] == B[i]) {
			e = A[i];
			a = i;
			break;
		}
	}
	
	if (e == -1) {
		cout << "Yes\n";
		for (int i = 0; i < N; i++)
			cout << B[i] << " ";
		cout << "\n";
		return 0;
	}
	
	for (int i = N - 1; i >= 0; i--) {
		if (A[i] == B[i]) {
			b = i;
			break;
		}
	}
	
	for (int i = 0; i < N; i++) {
		if (A[i] == e || B[i] == e) {
			x = i;
			break;
		}
	}
	
	for (int i = N - 1; i >= 0; i--) {
		if (A[i] == e || B[i] == e) {
			y = i;
			break;
		}
	}
	
	int k = a, i = 0, j = N - 1;
	while (k <= b) {
		if (i < x) {
			swap(B[i], B[k]);
			++i;
			++k;
			continue;
		}
		if (j > y) {
			swap(B[j], B[k]);
			--j;
			++k;
			continue;
		}
		break;
	}
	
	if (k <= b) cout << "No\n";
	else {
		cout << "Yes\n";
		for (int i = 0; i < N; i++)
			cout << B[i] << " ";
		cout << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 5200