akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>

int main()
{
	std::string str;
	std::cin >> str;
	std::copy(str.rbegin(), str.rend(),
			std::ostream_iterator<char>(std::cout));
	std::cout << std::endl;
	return 0;
}

Measured memory_bytes: 0
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(long n, long k) {
    if (k == 0) return n * n;

    long ans = 0;
    for (int b = 1; b <= n; b++) {
        // N = pb + r
        long p = n / b;
        long r = n % b;

        long x = max(b - k, 0) * p + max(r - k + 1, 0);
        ans += x;
    }
    return ans;
}

void main() {
    auto nk = readints;
    int n = nk[0], k = nk[1];
    writeln(calc(n, k));
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int hoge(int *L){ cin >> *L; return *L;}
int main(){
	int L,M,N;
	while(hoge(&L)){
		int j=0;
		for(int i=0;i<12;i++){
			if(L>0) j++;
			cin >> M >> N;
			L -= M-N;
		}
		if(L>0) cout << "NA" << endl;
		else cout <<  j << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#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 co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	ll A;
	string S;

	cin >> A >> S;

	ll B = (S[0] - '0') * 100;
	if (S.size() > 2) B += (S[2] - '0') * 10;
	if (S.size() > 3) B += (S[3] - '0');
	
	ll kotae = A * B / 100;

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int>v[100005];
set<int>s[100005];
int par[100005];
main()
{
    int n,m,i,j,x,y,ind;
    cin>>n>>m;
    for(i=1;i<=n-1+m;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
        s[y].insert(x);
    }
    for(i=1;i<=n;i++)
    {
        if(s[i].empty())
        {
            ind=i;break;
        }
    }
    queue<int>q;
    q.push(ind);
    while(!q.empty())
    {
        int top=q.front();q.pop();
        for(int i=0;i<v[top].size();i++)
        {
            int z=v[top][i];
            if(s[z].size()==1)
            {
                  q.push(z);par[z]=top;
            }
            s[z].erase(top);
        }
    }
    for(i=1;i<=n;i++)
    {
        cout<<par[i]<<endl;
    }
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> dp(100010, INF);
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  dp[0] = 0;
  dp[1] = abs(h[1]-h[0]);
  rep(i,n){
    rep(j,k+1){
    dp[i+j] = min(dp[i] + abs(h[i]-h[i+j]), dp[i+j]);
    }
  }
  cout << dp[n-1] << endl;
}

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

int main(){
    int N, P;
    cin >> N >> P;
    int even = 0, odd = 0, A[N];
    rep(i, N){
        cin >> A[i];
        if(A[i]%2) odd++;
        else even++;
    }
    if(odd == 0){
        if(P == 1) cout << 0 << endl;
        if(P == 0) cout << (1ll<<even) << endl;
    }
    else{
        ll a = 1ll<<(odd-1), b = 1ll<<even;
        cout << a*b << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int min_price(int sum) {
  int mod100 = sum % 100;
  int min_count = (mod100+4) / 5;
  if (min_count == 0) min_count = 1;
  return min_count * 100 + mod100;
}

int main() {
  int sum;
  scanf("%d", &sum);
  printf("%d\n", (min_price(sum) <= sum) ? 1 : 0);
}



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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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() {
  int N; cin >> N;
  int ans = 0;
  rep(i,N){
    int a;
    cin >> a;
    if(i%2 == 0){
      if(a %2 == 1){
        ans ++;
        PRINT(ans)
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n,r;
  cin>>n>>r;
  if(n>=10)
  {
    cout<<r;
  }
  else
  {
    cout<<r+100*(10-n);
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

  rep (i, n - 1) {
    if (v[i] > v[i + 1]) {
      if (v[i] == v[i + 1] + 1) {
        v[i + 1]++;
      } else {
        No;
        return 0;
      }
    }
  }
  Yes;

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef long double ld;

using namespace std;

int main(){
    cs;
    ld k;
    cin>>k;
    k/=3;
    cout<<fixed<<setprecision(12)<<k*k*k;
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s[3];
  rep(i,3) cin >> s[i];
  int idx = 0;
  while(s[0].size() > 0
        && s[1].size() > 0
        && s[2].size() > 0){
    char temp = s[idx][0];
    s[idx].erase(s[idx].begin());
    idx = temp - 'a';
  }
  if(s[0].size() == 0){
    cout << "A";
  }else if(s[1].size() == 0){
    cout << "B";
  }else{
    cout << "C";
  }
  cout << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

w_l = []
e_l = []

t = 0
for si in s:
    if si == 'W':
        t += 1
        w_l.append(t)
    else:
        w_l.append(t)

t = 0
for si in s:
    if si == 'E':
        t += 1
        e_l.append(t)
    else:
        e_l.append(t)

mn = 10000000000
res = 0

for i in range(1, n-1):
    res = w_l[i-1] + e_l[-1] - e_l[i]
    if res < mn:
        mn = res

if mn > e_l[-1]:
    mn = e_l[-1]

if mn > w_l[n-2]:
    mn = w_l[n-2]

print(mn)

Measured memory_bytes: 17996
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
    int64_t N, T, A;
    cin >> N >> T >> A;
    double max_near = 1 * 10000000;
    int max_point = 0;
    for (int i= 0; i < N; i++) {
        double H;
        cin >> H;
        double res = fabs(A - (T - (H * 0.006)));
        if (max_near > res) {
            max_near = res;
            max_point = i + 1;
        }
    }

    cout << max_point << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,A,B,C,D;
unordered_map<ull,ull> mp;
ull Func(ull n){
    if(n==0)return 0;
    if(n==1)return D;
    if(mp.count(n)!=0)return mp[n];
    ull ret=n*D;
    if(n%2==0)ret=min(ret,A+Func(n/2));
    else ret=min({ret,D+A+Func((n-1)/2),D+A+Func((n+1)/2)});
    if(n%3==0)ret=min(ret,B+Func(n/3));
    else{
        if(n%3==1)  ret=min({ret,D+B+Func((n-1)/3),D*2+B+Func((n+2)/3)});
        else        ret=min({ret,D+B+Func((n+1)/3),D*2+B+Func((n-2)/3)});
    }
    if(n%5==0)ret=min(ret,C+Func(n/5));
    else{
        for(ll i=-min((ull)4,n);i<=4;i++){
            if((n+i)%5!=0)continue;
            if(i==0)continue;
            ret=min(ret,D*abs(i)+C+Func((n+i)/5));
        }
    }
    return mp[n]=ret;
}
int main(){
    ll TC;
    cin>>TC;
    for(;TC>0;TC--){
        cin>>N>>A>>B>>C>>D;
        cout<<Func(N)<<endl;
        mp.clear();
    }
    return 0;
}

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


void solve(long long X, long long A, long long B){
  if((A-B) >= 0) {
    cout << "delicious" << endl;
  }
  else {
    cout << (((A-B) + X >= 0) ? "safe" : "dangerous") << endl;
  }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
  scanf("%lld",&X);
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
    solve(X, A, B);
    return 0;
}


Measured memory_bytes: 3648
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
    int p[] = new int[n];
    int pc[] = new int[n];
    int swapa = 0;
    int swapb = 0;
    int flg = 0;
    
    for (int i=0; i<n; i++){
      p[i] = Integer.parseInt(sc.next());
    }
    
    for (int i=0; i<n; i++){      
      swapa = p[i];
      
      for (int j=i; j<n; j++){
        for (int ii=0; ii<n; ii++){
          pc[ii] = p[ii];
      	}
        
        swapb = p[j];
        pc[j] = swapa;
        pc[i] = swapb;
        
        flg = 0;
        for (int k=0; k<n-1; k++){
          if (pc[k] > pc[k+1]) {
            flg++;
          }
        }
        if (flg==0){
          System.out.println("YES");
          return;
        }
      }
    }

	System.out.println("NO");


  }
}


Measured memory_bytes: 21972
import sys
from collections import Counter

s = input()

for i in range(1, len(s)):
    ts = s[:-i]
    if len(ts) % 2 != 0:
        continue
    #print(len(ts), ts, s[:len(ts)//2], s[len(ts)//2:])
    if ts[:len(ts)//2] == ts[len(ts)//2:]:
        print(len(ts))
        sys.exit()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#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,a;
    cin >> n >> a;
    int ans = (n+a-1)/a;
    cout << ans << endl;
}

Measured memory_bytes: 256
#union-findの勉強
import sys
def find(x,par):
  #根そのものならそれを出力、そうじゃなければ上を探す
  if par[x]==x:
    return x
  else:
    return find(par[x],par)

def union(x,y,par,rank):
  x=find(x,par)
  y=find(y,par)

  if x!=y:
    #rankは属する根の番号
    if rank[x]<rank[y]:
      par[x]=y
    else:
      par[y]=x
      if rank[x]==rank[y]:
        rank[x]+=1

def same(x,y,par):
  return find(x,par)==find(y,par)

n,k,l=map(int, input().split())    
apar=[]
bpar=[]
arank=[0]*n
brank=[0]*n

for i in range(n):
  apar.append(i)
  bpar.append(i)

for i in range(k):
  p,q = map(int, input().split())
  union(p-1,q-1,apar,arank)

for i in range(l):
  p,q = map(int, input().split())
  union(p-1,q-1,bpar,brank)

#apar,bparは、次元の数
  
num=[]
d={}
for i in range(n):
  #Nが10**5オーダーなので、とりあえず10**6離してラベリング
  num.append(find(i,apar)+find(i,bpar)*10**6)
  #辞書になければ項目＋、あったら数を増やす
  if num[-1] in d:
    d[num[-1]]+=1
  else:
    d[num[-1]]=1
        
res=''
for i in range(n):
  #最初だけ空白は入れない
  if i!=0:
    res+=' '
  #Nの順番に、鉄道・道路の2つの分野で次元が両方同じだったら手段が2通りになる
  res+=str(d[num[i]])
print(res)

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

#define FST first
#define SCD second
#define MODP 1000000007

typedef long long LL;
typedef pair<int, int> PA;

int cmp(PA x, PA y) {
    return x.SCD < y.SCD;
}

int pr[1010000];
int ptot = 0;
int v[1010000], cnt[1010000];
int fac[1010000];

void calc_prime() {
    for (int i=2;i<=1000000;++i) {
        if (!v[i]) {
            pr[ptot++] = i;
        }
        for (int j=0;j<ptot;j++) {
            if ((LL)pr[j] * i > 1000000) break;
            v[pr[j]*i] = 0;
            fac[pr[j]*i] = i;
            if (i%pr[j]==0) break;
        }
    }
}

int qpow(int x, int y) {
    int ret = 1, b = x;
    while (y) {
        if (y&1) ret = (LL) ret * b % MODP;
        b = (LL) b * b % MODP;
        y>>=1;
    }
    return ret;
}

int inv_(int x) {
    return qpow(x, MODP - 2);
}

int main() {
#ifdef FDB
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    int n, m, k, d;
    cin>>n;
    vector<int> a,b;
    calc_prime();
    for (int i=0;i<=n;++i) {
        int x;
        scanf("%d", &x);
        a.push_back(x);
    }
    for (int i=0;i<n;++i) {
        int x = a[i];
        map<int, int> tmp;
        while (fac[x]) {
            tmp[x/fac[x]] += 1;
            x=fac[x];
        }
        tmp[x] += 1;
        int inv = 1;
        for (auto i: tmp) {
            cnt[i.first] = max(cnt[i.first], i.second);
            inv = (LL)inv * qpow(inv_(i.first), i.second) %MODP;
            // inv = inv % MODP;
        }
        b.push_back(inv);
    }
    LL ans = 1;
    for (int i=0;i<ptot;++i) {
        ans = ans * qpow(pr[i], cnt[pr[i]]) % MODP;
    }
    // cout<<ans<<endl;
    LL ret = 0;
    for (int i=0;i<n;++i) {
        // cout<<b[i]<<endl;
        ret += ans * b[i] % MODP;
        ret %= MODP;
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 16128
from collections import deque
n,m=map(int,input().split())
maze=[[]for i in range(n)]
for i in range(m):
    r,l=map(int,input().split())
    maze[r-1].append(l-1)
    maze[l-1].append(r-1)

stamp=[-1]*n
queue=deque([0])
while queue:
    d=queue.popleft()
    for i in maze[d]:
        if stamp[i]==-1:
            stamp[i]=d
            queue.append(i)

print("Yes")
for i in range(1,n,1):
    print(stamp[i]+1)

Measured memory_bytes: 34184
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,char middle=' '){
    for(int i=0;i<vec_s.size();i++)printf("%d%c",vec_s[i],(i!=vec_s.size()-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,char middle=' '){
    for(int i=0;i<vec_s.size();i++)printf("%lld%c",vec_s[i],(i!=vec_s.size()-1?middle:'\n'));
}

int t[105];

int main(){
    int n,m;
    int i,j,k;
    int a,b,c;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>t[i];
    }
    a=0;
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            a+=t[i]*t[j];
        }
    }
    cout<<a<<endl;
}

Measured memory_bytes: 256
import re;[print(re.sub(r'0.','',''.join([str(10000+sum([eval(i[0]+'0'*'ixcm'.find(i[1]))for i in['1'+i for i in''.join(re.split(r'\d\w',s))]+re.findall(r'\d\w',s)]))[i]+'1mcxi'[i]for i in range(5)]).replace('1','')))for s in[input().replace(" ","")for i in range(int(input()))]]

Measured memory_bytes: 6876
function main()
    N,K = parse.(Int,split(readline()))
    A = parse.(Int,split(readline()))
    g_town = zeros(Int,N)
    reachs = zeros(Bool,N)
    p = 1
    first = second = -1
    for i in 1:N
        reachs[p] = true
        g_town[i] = p
        p = A[p]
        if reachs[p]
            first = findfirst(isequal(p),g_town)
            second = i+1
            g_town[second] = p
            break
        end
    end
    if K < second
        print(g_town[K+1])
    else
        k = K-first+1
        n = second - first
        print(g_town[first+k%n])
    end
end
main()

Measured memory_bytes: 201752
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll n;
	scanf("%lld",&n);
	puts(n%10==n/100?"Yes":"No");
}

Measured memory_bytes: 128
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)&&islower(c));}
void printvi(vector<int> v){rep(i,0,v.size()){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
void printvil(vector<int> v){rep(i,0,v.size()){cout<<v[i]<<endl;}}
void printvvi(vector<vector<int>> v){
    rep(i,0,v.size()){
        rep(j,0,v[i].size())cout<<v[i][j];
        cout<<endl;
    }
}
void printvstr(vector<string> v){
    rep(i,0,v.size()){
        cout<<v[i]<<endl;
    }
}

signed main (){
    int x;
    cin>>x;
    if(x==3||x==5||x==7)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
}
/*

*/


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

using namespace std;

int Hantei(int x[])
{
  int y=0;
  if((x[0]==x[1]&&x[1]==x[2])||(x[3]==x[4]&&x[4]==x[5])||(x[6]==x[7]&&x[7]==x[8])) 
    y=1;
  if((x[0]==x[3]&&x[3]==x[6])||(x[1]==x[4]&&x[4]==x[7])||(x[2]==x[5]&&x[5]==x[8]))
    y=1;
  if((x[0]==x[4]&&x[4]==x[8])||(x[2]==x[4]&&x[4]==x[6]))
    y=1;
  return y;
}

int main()
{
  int *bin=new int[9];
  for(int i=0;i<9;i++)
    cin>>bin[i];
  int n;
  cin>>n;
  
  for(int i=0;i<n;i++)
  {
    int x;
    cin>>x;
    for(int j=0;j<9;j++)
    {
      if(x==bin[j])
        bin[j]=0;
    }
  }
    
    int z;
    z=Hantei(bin);
    if(z==1)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();

    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        if (i * j == N) {
          System.out.println("Yes");
          return;
        }
      }
    }
    System.out.println("No");
  }
}

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

ll a,b,c,n,m;
ll ans=100000000000;

string s;

int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin>>c;
  cin>>a>>b;
  for(int i=a; i<=b; i++){
    if(i%c==0){
      cout<<"OK";
      return 0;
    }
  }
  cout<<"NG";

  return 0;
}



Measured memory_bytes: 3692
while True:
    try:
        a = list(map(int, input().split(',')))
    except EOFError:
        break
    v1, v2 = a[10], a[11]
    d = [0]
    for i in range(10): d.append(a[i] + d[-1])
    x = d[10] * v1 / (v1 + v2)
    for i in range(10):
        if d[i] < x <= d[i + 1]:
            print(i + 1)
            break

Measured memory_bytes: 6732
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

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

    for(int i = 0; i < 2; i++){
        if(c[i][0]-c[i][1] != c[i+1][0]-c[i+1][1] || c[i][0]-c[i][2] != c[i+1][0]-c[i+1][2]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=500100,mod=1000000007;
inline void Add(int &a,int b){a=a+b>=mod?a+b-mod:a+b;}
int n,a[maxn],f[1<<20][2],lst[1<<20],ans=0,now=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i),a[i]^=a[i-1];
	for(int i=1;i<(1<<20);i++) f[i][0]=1,lst[i]=0;
	if(a[n]==0){ans=1;for(int i=1;i<n;i++) if(a[i]==0) Add(ans,ans);}
	for(int i=1;i<n;i++)
	{
		if(a[i]==0) {now++;continue;}
		Add(f[a[i]][0],1ll*f[a[i]][1]*(now-lst[a[i]])%mod);
		Add(f[a[i]][1],f[a[i]][0]);lst[a[i]]=now;
	}
	for(int i=1;i<(1<<20);i++) Add(f[i][0],1ll*f[i][1]*(now-lst[i])%mod);
	if(a[n]==0){for(int i=1;i<(1<<20);i++)Add(ans,f[i][1]);}
	else ans=f[a[n]][0];
	cout<<ans<<endl;
}

Measured memory_bytes: 18012
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n;
	cin>>n;

	multiset<string>v;
	set<string> vi;
	
	for (ll i = 0; i < n; ++i){
		string S;
		cin>>S;
		sort(S.begin(),S.end());
		vi.insert(S);
		v.insert(S);
	}
	ll cont =0;
	for(auto it:vi)
		cont += v.count(it)*(v.count(it)-1)/2;
	
	cout<<cont;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int 
#define pb push_back
#define mp make_pair
#define endl "\n"
#define MOD 1e9+7
#define mem(x) memset(x, -1, sizeof(x))

template <typename T>
void print(T AA[], int nn){for(int ii=0; ii<nn; ii+=1){cout<<AA[ii]<<" ";}cout<<endl;}
template <typename T> inline void print(T nn){ cout << nn << endl;}
/* ----------------------------------------------------------------------------------- */

const int N=1e5+5;
int n, m;
vector<int> v[N];
int cache[N];

int dfs(int i){
    if(cache[i] != -1) return cache[i];
    int ans=0;
    for(int j=0; j<v[i].size(); j+=1){
        ans = max(ans, 1 + dfs(v[i][j]) );
    }
    cache[i] = ans;
    return ans;
}

int32_t main(){

    IOS

    mem(cache);
    cin >> n >> m;
    for(int i=0; i<m; i+=1){
        int x, y; 
        cin >> x >> y;
        v[x].pb(y);
    }
    int ans=0;
    for(int i=1; i<=n; i+=1){
        ans = max(ans, dfs(i));
    }
    print(ans);
    return 0;
}

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

int main()
{
    std::size_t N;
    std::cin >> N;

    std::int64_t total = 0;
    std::unordered_map<std::int64_t, std::int64_t> A_num;
    for(std::size_t i=0; i<N; ++i)
    {
        std::int64_t a;
        std::cin >> a;
        total += a;
        if(A_num.count(a) == 0)
        {
            A_num[a] = 1;
        }
        else
        {
            A_num[a] += 1;
        }
    }

    std::size_t Q;
    std::cin >> Q;
    for(std::size_t i=0; i<Q; ++i)
    {
        std::int64_t B, C;
        std::cin >> B >> C;

        const auto diff = C - B;

        if(A_num.count(B) == 0)
        {
            // do nothing.
            std::cout << total << std::endl;
        }
        else
        {
            // replace B by C
            total += diff * A_num[B];
            std::cout << total << std::endl;

            if(A_num.count(C) == 0)
            {
                A_num[C] = A_num[B];
                A_num[B] = 0;
            }
            else
            {
                A_num[C] += A_num[B];
                A_num[B] = 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 6720
#include <bits/stdc++.h>
#define BASE 1000000007
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int safe[n];
    fill(safe, safe + n, true);
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        safe[a] = false;
    }
    long dp[n + 1];
    dp[0] = dp[1] = 1;
    for (int i = 2; i <= n; i++) {
        dp[i] = 0;
        if (safe[i - 1]) {
            dp[i] += dp[i - 1];
            dp[i] %= BASE;
        }
        if (safe[i - 2]) {
            dp[i] += dp[i - 2];
            dp[i] %= BASE;
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 1408
n = int(input())
a = list(map(int, input().split()))
b = set(a)
c = sorted(list(b))
if len(b)==1 and c[0]==0:
  print("Yes")
  exit()
if c[0]==0:
  if n%2==0 and a.count(c[0])==n//2 and a.count(c[1])==n//2:
    print("Yes")
    exit()
  if n%2==1 and a.count(c[0])==n//2 and a.count(c[1])==n//2+1:
    print("Yes")
    exit()
if n%3!=0:
  print("No")
  exit()
if len(b)==2:
  if c[0]==0 and a.count(c[0])==n//3 and a.count(c[1])==(n//3)*2:
    print("Yes")
    exit()
if len(b)==3:
  p, q, r = c[0], c[1], c[2]
  if p^q==r or q^r==p or r^p==q:
    if a.count(c[0])==n//3 and a.count(c[1])==n//3 and a.count(c[2])==n//3:
      print("Yes")
      exit()
print("No")

Measured memory_bytes: 60784
N,M  = [int(x)for x in input().split()]

a = [0 for i in range(N+8)]

for i in range(M):
    a[int(input())] = 1

DP = [0 for i in range(N+8)]
DP[0] = 1
DP[1] = 1
if a[1] == 1:
    DP[1] = 0
for i in range(2,N+1):
    if a[i] == 0:
        DP[i] = (DP[i-2]+DP[i-1])%1000000007
    else:
        pass
#print(DP)
print(DP[N])

Measured memory_bytes: 7832
from collections import deque

n,m = map(int, input().split())
edges = [{} for i in range(n+1)]

for i in range(m):
    l, r, d = map(int, input().split())
    edges[l][r] = d
    edges[r][l] = d * -1

remains = set(range(1,n+1))
deq = deque()

min_ = -1 * 10**10
xs = [min_] * (n+1)

while( len(remains) > 0):
    deq.append( remains.pop() )
    while(len(deq) > 0):
        tmp = deq.popleft()
        if(xs[tmp]  == min_):
            xs[tmp] = 0
        tmp_x = xs[tmp]

        edge = edges[tmp]

        for key,val in edge.items():
            if(xs[key] == min_):
                xs[key] = tmp_x + val
                deq.append( key )
                remains.remove( key )
            else:
                if( xs[key] != tmp_x + val ):
                    print('No')
                    exit()

print('Yes')


Measured memory_bytes: 107420
import java.lang.Character;
import java.util.Scanner;

public class Main {

    static void solve(String s ) {
        char bruh = s.charAt(0);
        if(Character.isUpperCase(bruh)){
            System.out.println("A");
        } else System.out.println("a");

    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
            String input = in.next();
            solve(input);

    }
}

Measured memory_bytes: 35476
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,k;
    cin>>a>>b>>k;
    if(k>a)
    {
        k=k-a;
        a=0;
        if(k>b)
        {
            b=0;
        }
        else{
            b=b-k;
        }
    }
    else{
        a=a-k;
    }
    cout<<a<<" "<<b<<endl;
    return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<ll> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	VI a(5);
	int k;
	rep(i,5) cin >> a[i];
	cin >>k;
	bool ok=true;
	
	rep(i,5) rep2(j,i+1,5) if(abs(a[j] - a[i]) >k) ok=false;
	cout <<(ok? "Yay!":":(") <<"\n";
	return 0;
}

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

using namespace std;


int main() {
    int n,k;
    cin>>n>>k;
    int x[n],re=0;
    for (int i = 0; i < n; ++i) {
        cin>>x[i];
        re+=min(x[i],k-x[i]);
    }
    cout<<2*re<<endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
par = [i for i in range(N+1)]

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def same(x,y):
    return find(x) == find(y)

def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    par[x] = y

for i in range(M):
    a, b = map(int, input().split())
    unite(a,b)

res = []
for i in range(1,N+1):
    res.append(find(i))
ans = len(set(res)) -1

print(ans)

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

typedef vector<int > vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
#define sz(a)  int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define forn(i,n) for(int i=0;i<n;++i)
#define foru(i,n) for(int i=1;i<=n;++i)
#define fortr(i,v) for(auto &i:v)
#define set(n) __builtin_popcount(n)
#define ll long long
#define MOD 1000000007

int main()
{

	int a,b;
	cin>>a>>b;
	int p=0,q=0;
	foru(i,a)
	{
		p=p*10+b;
	}
	foru(i,b)
	{
		q=q*10+a;
	}
	if(a<b)cout<<q<<endl;
	else cout<<p<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i=0, i##_len=(ll)(n); i<i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;



int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	string s; ll k; cin >> s >> k;
	REP(i, s.size()) {
		if (s[i] == 'a') continue;
		ll x = 'z' + 1 - s[i];
		if (x <= k) {
			k -= x;
			s[i] = 'a';
		}
	}
	REP(i, k%26) {
		if ('z' == s.back()) s.back() = 'a';
		else s.back()++;
	}
	cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;


signed main(){
	//cout << fixed << setprecision(10);
	ll n; cin >> n;
	ll sum_gcd;
	ll m = 0;
	map<ll,ll> mp;
	bool ans = 1;
	vector<bool> vec(1001000,false);
	rep(i,0,n){
		ll a; cin >> a;
		if(mp[a] > 0 && a != 1){
			ans = 0;
		}
		mp[a]++;
		vec[a] = 1;
		if(i == 0)sum_gcd = a;
		else sum_gcd = __gcd(a,sum_gcd);
		chmax(m,a);
	}
	vector<bool> not_prime(m + 1);
	for(ll i = 2;i <= m;i++){
		if(not_prime[i])continue;
		ll cnt = 0;
		ll j = i;
		bool ok = true;
		while(j <= m){
			not_prime[j] = 1;
			if(vec[j])cnt++;
			if(cnt > 1){
				ok = 0;
				break;
			}
			j += i;
		}
		if(!ok){
			ans = 0;
			break;
		}
	}
//	cout << sum_gcd << endl;
	if(ans)cout << "pairwise coprime" << endl;
	else if(sum_gcd == 1)cout << "setwise coprime" << endl;
	else cout << "not coprime" <<endl;


	return 0;
}


Measured memory_bytes: 66268
#include <iostream>
#include <vector>
#include <cassert>
#include <cmath>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 300000;
int const modulo = 998244353;

class Mint{
private:
  void gcd(int a, int b, int &x, int &y) {
    if(b == 0) {
      x = 1;
      y = 0;
    } else {
      gcd(b, a % b, x, y);
      int aux = x;
      x = y;
      y = aux - a/ b * y;
    }
  }
public:
  int number;
  Mint(ll number_ = 0) {
    number = number_ % modulo;
  }
  Mint operator + (Mint a) {
    return (number + a.number);
  }
  Mint operator - (Mint a) {
    return (modulo + number - a.number);
  }
  Mint operator * (Mint a) {
    return (1LL * number * a.number);
  }
  Mint operator / (Mint a) {
    int x, y;
    gcd(a.number, modulo, x, y);
    x %= modulo;
    if(x < 0)
      x += modulo;
    return 1LL * x * number;
  }
  friend std::ostream &operator << (std::ostream& output, Mint a) {
    output << a.number;
    return output;
  }
};
Mint fact[5 + nmax];

void precompute() {
  fact[0] = 1;
  for(int i = 1; i <= nmax; i++)
    fact[i] = fact[i - 1] * i;
}

Mint comb(int n, int k) {
  if(0 <= k && k <= n)
    return fact[n] / fact[k] / fact[n - k];
  return 0;
}

int main() {
  ll n, a, b, k;
  std::cin >> n >> a >> b >> k;
  Mint result(0);
  precompute();
  for(int i = 0; i <= n; i++) {
    ll j = (k - i * a) / b;
    if((a * i + j * b) == k)
      result = result + comb(n, i) * comb(n, j);
  }
  std::cout << result;
  return 0;
}


Measured memory_bytes: 4820
//prepared by dumb
#include<bits/stdc++.h>
using namespace std;
#define   ll  long long int
#define   dl double
#define   llu unsigned long long int
#define   scll(x) scanf("%lld",&x)
#define   scld(x) scanf("%lf",&x)
#define   scull(x) scanf("%llu",&x)
#define   scch(x) scanf(" %c",&x)
#define   pb(x) push_back(x)
#define   pf(x) push_front(x)
#define   ppb() pop_back()
#define   ppf() pop_front()
#define   Pi acos(-1.0)
#define   inf 1000000000000000000
#define   mod 1000000007
#define   ff first
#define   ss second
#define   mpr make_pair
#define   debug(x) cout<<x<<'\n';
#define   eps 1e-8
// Creates a min heap
//priority_queue <int, vector<int>, greater<int> > pq;
//sin((x*pi)/180.0)[x in degree]
//sin(x)[x in radian]
//asin(x)[radian]
//(asin(x)*180)/pi[degree]
//or(|)//and(&)//xor(^)//not(~)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll lcm(ll a, ll b)
{
    return (a * b) / __gcd(a, b);
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll a, b, c=0, e, f = 0, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, z;
    ll cnt = 1, ans = 0, l1, l2, l3, c1 = 0, c2 = 0, c3 = 0, mx = 0, mn = 0;
    ll prevsum = 0, ans1 = 0, ans2 = 0, odd = 0, even = 0, hh, mm,d,x,y;
    string str, str1, str2,str3="",str4="";
   scll(n);
c=1;
c1=0;
   while(true)
   {
   	c1=(c1+c*7)%n;
     if(c1==0)
     {
     	f=1;
     	cout<<cnt;
     	break;
     }
   	c=c*10;
   	c=c%n;
   	cnt++;
   	if(cnt>10000000)
   		break;
   }
   if(f==0)
   cout<<-1;

return 0;
}

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

int main() {
	int n;cin>>n;
	vector<int> a(n);
	vector<long long> c(n+1,0);
	for(int i=0;i<n;i++){
		cin>>a[i];
		c[a[i]]++;
	}
	long long sum=0;
	for(int i=0;i<=n;i++){
		sum+=c[i]*(c[i]-1)/2;
	}
	for(int i=0;i<n;i++){
		cout<<sum-c[a[i]]*(c[a[i]]-1)/2+(c[a[i]]-1)*(c[a[i]]-2)/2<<endl;
	}
	return 0;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long li;

const int maxn = 1e5;
int n, a[maxn];

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);

  int begin = 0, ans = 0;
  while (begin < n) {
    ++ans;
    int type = 0;
    ++begin;
    while (begin < n) {
      if (a[begin] < a[begin - 1]) {
        if (type == -1) {
          break;
        }
        type = 1;
      } else if (a[begin] > a[begin - 1]) {
        if (type == 1) {
          break;
        }
        type = -1;
      }
      ++begin;
    }
  }

  printf("%d\n", ans);
  return 0;
}


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



int main(){
    int n,l;
    cin>>n>>l;
    int mi=l,ans=0;
    rep(i,n){
        ans+=l+i;
        if((abs(l+i)<=abs(mi))) mi=i+l;
    }
    ans-=mi;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

#include <iostream>
using i64 = long long;
template<i64 M> struct modint { i64 a;
  constexpr modint(const i64 x = 0): a((x%M+M)%M){}
  constexpr i64 value() const { return a; }
  constexpr modint inv() const { return this->pow(M-2); }
  constexpr modint pow(i64 r) const {
    modint ans(1); modint aa = *this;
    while(r) { if(r & 1) ans *= aa; aa *= aa; r >>= 1; }
    return ans;
  }
  constexpr modint& operator=(const i64 r) { a = (r % M + M) % M; return *this; }
  constexpr modint& operator+=(const modint r) { a += r.a; if(a >= M) a -= M; return *this; }
  constexpr modint& operator-=(const modint r) { a -= r.a; if(a < 0) a += M; return *this; }
  constexpr modint& operator*=(const modint r) { a = a * r.a % M; return *this; }
  constexpr modint& operator/=(const modint r) { (*this) *= r.inv(); return *this; }
  constexpr modint operator+(const modint r) const { return modint(*this) += r; }
  constexpr modint operator-(const modint r) const { return modint(*this) -= r; }
  constexpr modint operator*(const modint r) const { return modint(*this) *= r; }
  constexpr modint operator/(const modint r) const { return modint(*this) /= r; }
  constexpr bool operator!=(const modint r) const { return this->value() != r.value(); }
};

template<const i64 M> std::ostream& operator<<(std::ostream& os, const modint<M>& m) { os << m.value(); return os; }

#include <vector>
#include <tuple>
using i64 = long long;

template<class T>
std::vector<T> build_factorial(int N) {
  std::vector<T> fact(N);
  std::vector<T> finv(N);
  fact[0] = T(1);
  for(int i = 1;i < N;i++) {
    fact[i] = fact[i - 1] * T(i);
  }
  return fact;
}

const int mod = 1000003;
using fp = modint<mod>;

int main() {
  i64 Q;
  cin >> Q;
  auto fact = build_factorial<fp>(mod * 2);

  auto solve = [&](i64 x, i64 n) {
    if(x == 0 || x + n - 1 >= mod) return fp(0);
    return fact[x + n - 1] / fact[x - 1];
  };

  while(Q--) {
    i64 x, d, n;
    cin >> x >> d >> n;
    if(d == 0) {
      cout << fp(x).pow(n) << endl;
    }
    else {
      cout << solve((fp(x)/fp(d)).value(), n) * fp(d).pow(n) << endl;
    }
  }
}


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

using namespace std;

const int N = 2e5+5;
int n, m, pai[N], sz[N];

int find(int x){
	if (pai[x] == x)
		return x;
	return pai[x] = find(pai[x]);
}

void join(int a, int b){
	a = find(a);
	b = find(b);
	if (a != b){
		pai[b] = a;
		sz[a] += sz[b];
		sz[b] = 0;
	}
}

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	scanf("%d %d", &n, &m);

	for (int i = 1; i <= n; i++){
		pai[i] = i;
		sz[i] = 1;
	}

	for (int i = 0; i < m; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		join(a, b);
	}

	int ans = 0;

	for (int i = 1; i <= n; i++){
		ans = max(ans, sz[i]);
	}

	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 5324
#include <stdio.h>
#include <string.h>

// 循環文字列sと文字列pが与えられ、sの連続した文字でpが作れるかを判定
int main()
{
	char achInputS[100], achInputP[100];
	int iLengthS, iLengthP;
	int iCnt1, iCnt2;

	scanf("%s", achInputS);
	scanf("%s", achInputP);

	iLengthS = strlen(achInputS);
	iLengthP = strlen(achInputP);

	// achInputSはループするように添え字を剰余にして先頭から探索
	for (iCnt1 = 0; iCnt1 < iLengthS; iCnt1++)
	{
		for (iCnt2 = 0; iCnt2 < iLengthP; iCnt2++)
		{
			// 異なる文字なら抜ける
			if (achInputS[(iCnt1 + iCnt2) % iLengthS] != achInputP[iCnt2])
			{
				break;
			}
		}
		if (iCnt2 == iLengthP)
		{
			printf("Yes\n");
			return 0;
		}
	}

	printf("No\n");

	return 0;
}


Measured memory_bytes: 2104
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

S = list(input())
print(2 * len(list(filter(lambda x: x == "+", S))) - 4)

Measured memory_bytes: 9484
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define p1d(a,n)                for(int ix=0;ix<n;ix++) out<<a[ix]<<" "; out<<endl
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define range(v)                v.begin(),v.end()
#define w(x)                    while(x--)
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

void ssolve(std::istream& in, std::ostream& out){
        string s;
        s(s);
        if(s[2] == s[3] && s[4] == s[5]){
            out<<"Yes"<<endl;
        }else{
            out<<"No"<<endl;
        }
}

class ACoffee {
public:
	void solve(std::istream& in, std::ostream& out) {
        ios_base::sync_with_stdio(false);
        in.tie(0);out.tie(0);
        int t;
        int READ = 0;
        if(READ) s(t);
        else t = 1;
        while(t--){
            ssolve(in, out);
        }
	}
};


integer main() {
	ACoffee solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a , b;
    cin >> a >> b;
    if (1 <= a && a <= 13 && 1 <= b && b <= 13)
    {
        if (a == 1 || b == 1 || a == b)
        {
            if (a == b)
                cout << "Draw";
            else if (a == 1)
                cout << "Alice";
            else if (b == 1)
                cout << "Bob";
        }
         else
        {
            if (a > b)
                cout << "Alice";
            else if (b > a)
                cout << "Bob";
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
using namespace std;
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
string s;
int main(){
    cin>>s;
    int ans=0,l=s.length();
    for(int i=1;i<l;i++)if(s[i]!=s[i-1])ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 512