akhauriyash/Code-Regression huggingface dataset:
n,a,b,c,d = map(int, input().split())
s = list(str(x) for x in input())

start = min(a,b)
stop = max(c,d)
ans=0

if a<b and c<d:
    for i in range(start, stop):
        if s[i] == "#" and s[i+1] == "#":
            ans = "No"
            break
    if ans == 0:
        ans = "Yes"

elif b<a  and d<c:
    for i in range(start-1, stop):
        if s[i] == "#" and s[i+1] == "#":
            ans = "No"
            break
    if ans == 0:
        ans = "Yes"

elif a<b and d<c:
    judge = 0

    for i in range(start-1, stop):
        if b-1 <=i <= d-2:
            if s[i]=="." and s[i+1]=="." and s[i+2]==".":
                judge = 1
        if s[i] == "#" and s[i+1] == "#":
            ans = "No"
            break

    if ans == 0:
        if s[b-2]=="." and s[b]==".":
            ans = "Yes"
        elif judge == 1:
            ans = "Yes"
        elif judge == 0:
            ans = "No"

elif b<a and c<d:
    judge = 0

    for i in range(start, stop):
        if a-1 <=i <= c-2:
            if s[i]=="." and s[i+1]=="." and s[i+2]==".":
                judge = 1
        if s[i] == "#" and s[i+1] == "#":
            ans = "No"
            break

    if ans == 0:
        if s[a-2]=="." and s[a]==".":
            ans = "Yes"
        elif judge == 1:
            ans = "Yes"
        elif judge == 0:
            ans = "No"
print(ans)

Measured memory_bytes: 5116
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define db double
#define ld long double
#define IOS  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#pragma GCC optimize(2)
#define ull unsigned long long
#define maxn 110
ll lcm(ll a,ll b){return a*b/__gcd(a,b);}
void dfs(){}
signed main()
{
    IOS
    ll n;
    cin>>n;
    ll ans=1;
    for (ll i = 2; i <=(ll)sqrt(n) ; ++i) {
        ll now=n;
        while(now%i==0){
            now/=i;
            if((now-1)%i==0){
                ans++;
                break;
            }
        }
    }
    n--;
    for (ll l = 1; l <=(ll)sqrt(n) ; ++l) {
        if(n%l==0){
            ans+=2;
            if(l==1)ans--;
            if(l*l==n)ans--;
        }
    }
    cout<<ans;
    return 0 ;
}


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

struct data{
  int p[10];
};

data A,B;

#define SZ (1<<17)

struct segtree{
  data t[SZ*2];
  data u[SZ*2];
  void init(int k=0,int l=0,int r=SZ){
    for(int i=0;i<10;i++){
      t[k].p[i]=0;
      u[k].p[i]=i;
    }
    
    if(r-l==1){
      t[k].p[0]=1;
      return;
    }
    
    int m=(l+r)/2;
    init(k*2+1,l,m);
    init(k*2+2,m,r);
    for(int i=0;i<10;i++){
      t[k].p[i]+=t[k*2+1].p[i];
      t[k].p[i]+=t[k*2+2].p[i];
    }
  }
  
  void add(data &td,data &ud,data &x){
    int tt[10];
    int uu[10];
    for(int i=0;i<10;i++){
      tt[ x.p[i] ]=td.p[i];
      uu[i]=x.p[ ud.p[i] ];
    }
    for(int i=0;i<10;i++){
      td.p[i]=tt[i];
      ud.p[i]=uu[i];
    }
  }
  
  void compute(int k,int l,int r){
    if(r-l==1)return;
    int L=k*2+1;
    int R=k*2+2;

    add(t[L],u[L],u[k]);
    add(t[R],u[R],u[k]);
    
    for(int i=0;i<10;i++){
      t[k].p[i]=t[L].p[i]+t[R].p[i];
      u[k].p[i]=i;
    }
  }

  data Get(int a,int b,int k=0,int l=0,int r=SZ){
    if(b<=l || r<=a)return A;
    compute(k,l,r);
    if(a<=l && r<=b){
      return t[k];
    }else{
      int m=(l+r)/2;
      data lc=Get(a,b,k*2+1,l,m);
      data rc=Get(a,b,k*2+2,m,r);
      for(int i=0;i<10;i++)lc.p[i]+=rc.p[i];
      return lc;
    }
  }
  
  void dfs(int a,int b,data d,int k=0,int l=0,int r=SZ){
    if(b<=l || r<=a)return;
    compute(k,l,r);
    if(a<=l && r<=b){
      add(t[k],u[k],d);
    }else{
      int m=(l+r)/2;
      dfs(a,b,d,k*2+1,l,m);
      dfs(a,b,d,k*2+2,m,r);
      for(int i=0;i<10;i++)
        t[k].p[i]=t[k*2+1].p[i]+t[k*2+2].p[i];
    }
  }

  void Add(int a,int b){
    data d;
    for(int i=0;i<10;i++)d.p[i]=i;
    swap(d.p[0],d.p[1]);
    dfs(a,b,d);
  }

  int get(int a,int b){
    data d=Get(a,b);
    return d.p[1];
  }
};


segtree T;

int n,q;
int parent[MAX_N];
vector<int> G[MAX_N];

vector<int> v;
map< int ,int > Find;
map< int ,int > Size;

void dfs(int pos){
  Size[pos]=1;
  Find[pos]=v.size();
  v.push_back(pos);
  for(int to:G[pos]){
    dfs(to);
    Size[pos]+=Size[to];
  }
}

int main(){
  T.init();
  
  scanf("%d %d",&n,&q);
  parent[0]=-1;
  for(int i=1;i<n;i++){
    scanf("%d",&parent[i]);
    parent[i]--;
    G[ parent[i] ].push_back(i);
  }
  

  
  dfs(0);
  for(int i=0;i<n;i++){
    char str[5];
    scanf("%s",str);
    
    data d;
    for(int j=0;j<10;j++)d.p[j]=j;
    swap(d.p[0],d.p[1]);
    if(str[0]=='G')T.dfs( Find[i],Find[i]+1,d);
  }
  
  for(int i=0;i<q;i++){
    int id;
    scanf("%d",&id);
    id--;
    T.Add( Find[id], Find[id]+Size[id] );
    
    int cnt=T.get( 0,n);
    if(cnt > n/2)printf("broccoli\n");
    else printf("cauliflower\n");


  }
  return 0;
}



Measured memory_bytes: 50068
#include <stdio.h>

int main(void) {
    int antenna[5];
    int k;
    int c = 0;

    for (int i = 0; i < 5; i++) 
        scanf("%d", &antenna[i]);
    scanf("%d", &k);

    for (int i = 0; i < 4; i++) {
        for (int j = i+1; j < 5; j++) {
            if((antenna[i]-antenna[j]<=k && antenna[i]-antenna[j]>0) || (antenna[j]-antenna[i]<=k && antenna[i]-antenna[j]<0)){
                c++;
            }
        }
    }

    if(c==10) {
        printf("Yay!\n");
    }
    else {
        printf(":(\n");
    }
    return 0;
}



Measured memory_bytes: 128
n, m = map(int, raw_input().split())
ans = []
aa = []
for i in range(n):
    a = map(int, raw_input().split())
    aa.append(a)
    ans.append(0)
b = []
for i in range(m):
    a = input()
    b.append(a)
for i in range(n):
    for j in range(m):
        ans[i] += aa[i][j] * b[j]
for i in range(len(ans)):
    print(ans[i])

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

using i64 = long long;

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

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getc() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

i64 D[13];
i64 E[13];
char s[100001];
const i64 M = 1000000007;
signed main() {
	D[0] = 1;
	scanf("%s", s);
	i64 i = 0;
	while(true) {
		char c = s[i];
		if (c == 0) {
			break;
		} else if (c == '?') {
			REP(r, 13) {
				i64 s = 0;
				REP(j, 10) {
					s += D[(j - r + 13) * 9 % 13];
				}
				E[r] = s % M;
			}
		} else {
			i64 d = c - '0';
			/*
			REP(r, 13) {
				E[r] = D[(d - r + 13) * 9 % 13];
			}
			*/
			E[0] = D[d * 9 % 13];
			E[1] = D[(d + 12) * 9 % 13];
			E[2] = D[(d + 11) * 9 % 13];
			E[3] = D[(d + 10) * 9 % 13];
			E[4] = D[(d + 9) * 9 % 13];
			E[5] = D[(d + 8) * 9 % 13];
			E[6] = D[(d + 7) * 9 % 13];
			E[7] = D[(d + 6) * 9 % 13];
			E[8] = D[(d + 5) * 9 % 13];
			E[9] = D[(d + 4) * 9 % 13];
			E[10] = D[(d + 3) * 9 % 13];
			E[11] = D[(d + 2) * 9 % 13];
			E[12] = D[(d + 1) * 9 % 13];
		}
		swap(D, E);
		++i;
	}
	printf("%d", D[5]);
}


Measured memory_bytes: 256
#include <stdio.h>

int ans[50] = {};

int main()
{
	int n, m;
	int a, b;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		scanf("%d %d", &a, &b);
		ans[a]++;
		ans[b]++;
	}
	for (int i = 1; i <= n; i++)
	{
		printf("%d\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;
    int i;
    int ans = 0;
    int count = 0;
    cin >> n;
    vector<int> h(n);

    for (i = 0; i < n; i++)
    {
        cin >> h[i];
    }

    for (i = 1; i < n; i++)
    {
        if (h[i] <= h[i - 1])
        {
            count++;
            ans = max(count, ans);
        }
        else
        {
            count = 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

ll n;
int main()
{
	cin>>n;
	ll ans=1;
	for(re ll i=2;i*i<n;++i) if((n-1)%i==0) {ans+=2;if(n==i*i+1) --ans;}
	for(re ll i=2;i*i<=n;++i) if(n%i==0)
	{
		ll n0=n;
		while(n0%i==0) n0/=i;
		if(n0%i==1) ++ans;
		if(i*i==n) continue;
		n0=n;ll i0=n/i;
		while(n0%i0==0) n0/=i0;
		if(n0%i0==1) ++ans;
	}
	if(n!=2) ++ans;
	cout<<ans<<endl;
	return 0;
}
/////////////////////

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


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

  int N, K;
  cin >> N >> K;
  vector<int> as(N);
  F0R(i, N) {
    cin >> as[i];
  }
  sort(rng(as));
  i64 result = 0;
  F0R(i, K) {
    result += as[i];
  }
  cout << result;
}
#endif


Measured memory_bytes: 3656
import bisect
n,k=map(int,input().split())
s=list(map(int,input()))
f=[0 for i in range(n)]
f[0]=1-s[0]
for i in range(1,n):f[i]=(1-s[i])*(s[i-1]^s[i])
for i in range(n-1):f[i+1]+=f[i]
ans=0
for l in range(n):
    r=bisect.bisect_right(f,k+f[l]*s[l])
    ans=max(ans,r-l)
print(ans)

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

int main()
{
	int r = {};
	cin >> r;
	if (r < 1200) {
		cout << "ABC" << endl;

	}else
	if (r < 2800) {
		cout << "ARC" << endl;
		}
	else {
		cout << "AGC" << endl;

			
		}

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int pay,remain,ans=0;

	while(1){
		cin>>pay;
		if(pay==0){
			break;
		}
		remain=1000-pay;
		ans=0;
		while(remain>=500){
			remain-=500;
			ans++;
		}
		while(remain>=100){
			remain-=100;
			ans++;
		}
		while(remain>=50){
			remain-=50;
			ans++;
		}
		while(remain>=10){
			remain-=10;
			ans++;
		}
		while(remain>=5){
			remain-=5;
			ans++;
		}
		while(remain>=1){
			remain-=1;
			ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
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;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;
using namespace atcoder;

int n,m;

template<typename T>
struct StronglyConnectedComponents{
	vector<vector<T>> g,rg;
	vector<T>vs,cmp;//1回目のdfsの帰り順の並び,トポロジカル順序
	vector<bool>used;
	int num;//強連結成分の個数

	StronglyConnectedComponents(const vector<int> &x,const vector<int> &y):num(0){//"有向"グラフを渡す
		int v=n;
		g.resize(v);
		rg.resize(v);
		used.resize(v);
		cmp.resize(v,-1);
		auto a=x,b=y;
		rep(i,m){
			add_edge(a[i],b[i]);
		}
		for(int i=0;i<m;++i){
			if(!used[a[i]])dfs(a[i]);
		}
		rep(i,n){
			if(!used[i])dfs(i);
		}
		reverse(vs.begin(),vs.end());
		for(int i=0;i<v;++i){
			if(cmp[vs[i]]==-1){
				rdfs(vs[i],num);
				num++;
			}
		}
	}

	void add_edge(int u,int v){
		g[u].emplace_back(v);
		rg[v].emplace_back(u);
	}

	void dfs(int v){
		used[v]=true;
		for(auto x:g[v]){
			if(!used[x]){
				dfs(x);
			}
		}
		vs.emplace_back(v);
	}

	void rdfs(int v,int num){
		cmp[v]=num;
		for(auto x:rg[v]){
			if(cmp[x]==-1)rdfs(x,num);
		}
	}
};

void solve(){
	cin>>n>>m;
	vector<int>a(m),b(m);
	rep(i,m)cin>>a[i]>>b[i];
	StronglyConnectedComponents<int>scc(a,b);
	vector<vector<int>>ans(scc.num+5);
	rep(i,n){
		ans[scc.cmp[i]].eb(i);
	}
	cout<<scc.num<<"\n";
	rep(i,scc.num){
		if(ans[i].size()){
			cout<<ans[i].size();
		}
		for(auto e:ans[i]){
			cout<<" "<<e;
		}
		cout<<"\n";
	}
}


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


Measured memory_bytes: 83524
A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(A[K-1])

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

int main() {
  int N, ans=0;
  cin >> N;
  
  if (N == 100000) ans = 90909;
  if (N <= 99999) ans = N - 9090;
  if (N <= 9999) ans = 909;
  if (N <= 999) ans = N - 90;
  if (N <= 99) ans = 9;
  if (N <= 9) ans = N;
  
  cout << ans << endl;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I=ll(A);I<ll(B);++I)

int main(){
	double a,b,c,S,L,h;
	cin >> a >> b >> c;
	c *= M_PI/180.0;
	S = a*b*sin(c)/2.0;
	h = b*sin(c);
	L = a+b+sqrt(a*a+b*b-2.0*a*b*cos(c));
	cout<<fixed<<setprecision(10)<<S<<endl<<L<<endl<<h<<endl;
}


Measured memory_bytes: 3528
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    K = II()


    used = [0] * K
    q = 7
    for i in range(K):
        q %= K
        if q == 0:
            print(i+1)
            return
        if used[q]:
            print(-1)
            return
        used[q] = 1
        q = 10*q + 7


if __name__ == '__main__':
    solve()


Measured memory_bytes: 16792
import java.util.Arrays;
import java.util.Scanner;
public class Main{

	/**
	 * @param args
	 */
	
	class AOJ_0138 implements Comparable<AOJ_0138>{
		Integer num;
		Double time;
		
		public int compareTo(AOJ_0138 o){
			return time.compareTo(o.time);
		}
	}
	
	void doIt(){
		int m = 0;
		Scanner sc = new Scanner(System.in);
		AOJ_0138[] data = new AOJ_0138[8];
		AOJ_0138[] sub = new AOJ_0138[18];
		for(int i=0; i<3; i++){
			for(int k=0; k<8; k++){
				data[k] = new AOJ_0138();
				data[k].num = sc.nextInt();
				data[k].time = sc.nextDouble();
			}
			Arrays.sort(data);
			System.out.printf("%d %.2f\n", data[0].num, data[0].time);
			System.out.printf("%d %.2f\n", data[1].num, data[1].time);
			for(int k=2; k<8; k++, m++){
				sub[m] = data[k];
			}
		}
		Arrays.sort(sub);
		System.out.printf("%d %.2f\n", sub[0].num, sub[0].time);
		System.out.printf("%d %.2f\n", sub[1].num, sub[1].time);
	}
	
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		new Main().doIt();
		
	}

}

Measured memory_bytes: 18264
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   map<string,int> c;
   int n;
   cin >> n;
   while(n--){
      string s;
      cin >> s;
      c[s]++;
   }
   cout << "AC x " << c["AC"] << '\n';
   cout << "WA x " << c["WA"] << '\n';
   cout << "TLE x " << c["TLE"] << '\n';
   cout << "RE x " << c["RE"] << '\n';
   return 0;
} 


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

int main(){
  string s;
  cin >> s;
  int n=s.size();
  int k=0;
  for(int i=0;i<n/2;i++){
    if(s.at(i)!=s.at(n-i-1))
      k++;
  }
  cout << k << endl;
}

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

bool isLetter(char a){
    if((a-'a'>=0&&a-'a'<=26)||(a-'A'>=0&&a-'A'<=26))return true;
    return false;
}

int main(){
    int n;
    cin>>n;
    string s[n+1];
    rep(i,n+1){
        cin>>s[i];
    }
    vector<vector<string>> s0str(n+1);

    rep(k,n+1){
        s0str[k].push_back("");
        rep(i,s[k].length()){
           // cout<<s0str[k][j]<<endl;
//            cout<<(isLetter(s[k][i]))<<" "<<isdigit(s[k][i+1])<<endl;
            bool ok1 = isLetter(s[k][i]) && isdigit(s[k][i+1]);
            bool ok2 = isdigit(s[k][i]) && isLetter(s[k][i+1]);
            s0str[k][s0str[k].size() - 1] += s[k][i];
            if (ok1 || ok2) s0str[k].push_back("");
        }
    }

    for(int i=1;i<n+1;i++){
        int minLen = min(s0str[0].size() , s0str[i].size());
        int k = 0;
            //cout<<s0str[i][k]<<" "<<s0str[0][k]<<endl;
        while(k < minLen && s0str[0][k] == s0str[i][k]){
            //cout<<s0str[i][k]<<" "<<s0str[0][k]<<endl;
            k++;
        }
        //cout<<minLen<<" "<<k<<endl;
        if(k == minLen && s0str[0].size() <= s0str[i].size()){
            cout<<"+"<<endl;
            continue;
        }else if(k == minLen && s0str[0].size() > s0str[i].size()){
            cout<<"-"<<endl;
            continue;
        }
      //  cout<<s0str[i][k][0] <<" "<< isdigit(s0str[i][k][0])<<endl;
        if(isdigit(s0str[0][k][0]) && isdigit(s0str[i][k][0])){
            if(stoi(s0str[0][k]) > stoi(s0str[i][k])){
              //  cout<<s0str[i][k]<<endl;
                cout<<"-"<<endl;
            }else{
                cout<<"+"<<endl;
            }
        }else if (isdigit(s0str[0][k][0]) || isdigit(s0str[i][k][0])) {
            if (isdigit(s0str[0][k][0])) {
                cout << "+" << endl;
            } else {
                cout << "-" << endl;
            }
        } else {
            if(s0str[0][k] > s0str[i][k]){
                cout<<"-"<<endl;
            }else{
                cout<<"+"<<endl;
            }
        }
    }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int dist[220][220];
const int INF = 1001001001;
int n,m,r;
int main()
{
    cin >>n >>m >> r;
    vector<int> p(r);
    rep(i,r)cin >>p[i];
    sort(p.begin(),p.end());
    rep(i,n)rep(j,n)dist[i][j] = INF;
    int ans = 1001001001;
    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        dist[a][b] = dist[b][a] = c;

    }
    rep(i,n)rep(j,n)rep(k,n)dist[j][k] = min(dist[j][k],dist[j][i]+dist[i][k]);
    do{
        int res = 0;
        rep(i,r-1)res += dist[p[i]-1][p[i+1]-1];
        
        ans = min(ans,res);

    }while(next_permutation(p.begin(),p.end()));
    cout <<ans << endl;



    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std; 
int main()
{
  ll n,k;
  ll h[200005];
  ll num=0;

  cin>>n>>k;
  for(int i=0;i<n;i++) cin>>h[i];
  sort(h,h+n,greater<int>());

  for(int i=0;i<k;i++) h[i]=0;

  for(int i=0;i<n;i++) num+=h[i];

  cout<<num<<endl;
  return 0;
}


Measured memory_bytes: 1792
// AOJ 0117 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0117)
#include<cstdio>
#include<algorithm>
#include<limits>
#define rep(i,a) for(int i=0;i<(a);++i)

const int MAX_N = 20, INF = std::numeric_limits<int>::max()>>4;

int n, m;
int d[MAX_N][MAX_N];
int x1, x2, Y1, y2;

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

	rep( i, n ) rep( j, n )
		d[i][j] = i==j?0:INF;

	rep( i, m )
	{
		int a, b, c, di;
		scanf( "%d,%d,%d,%d", &a, &b, &c, &di );
		--a; --b;
		d[a][b] = c;
		d[b][a] = di;
	}

	rep( k, n ) rep( i, n ) rep( j, n )
		d[i][j] = std::min( d[i][j], d[i][k]+d[k][j] );

	scanf( "%d,%d,%d,%d", &x1, &x2, &Y1, &y2 );
	--x1; --x2;

	printf( "%d\n", Y1-d[x1][x2]-d[x2][x1]-y2 );

	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mp[1000010],r[1000010],sz[1000010];
ll get_root(ll x){
	if(mp[x]==x) return x;
	else mp[x]=get_root(mp[x]);
	return mp[x];
}
void combine(ll x,ll y){
	if(r[x]<r[y]){
        sz[get_root(y)]+=sz[get_root(x)];
        mp[get_root(x)]=get_root(y);

    }
	else if(r[y]<r[x]){
        sz[get_root(x)]+=sz[get_root(y)];
        mp[get_root(y)]=get_root(x);
    }
	else {
        sz[get_root(y)]+=sz[get_root(x)];
		mp[get_root(x)]=get_root(y);
		r[get_root(y)]+=1;
	}
}
bool check(ll x,ll y){
	return get_root(x)==get_root(y);
}
void init(){
    
    for (ll i=0;i<1000010;i++){
		mp[i]=i;
        sz[i]=1;
	}
}
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(0);
	ll n,e,i,x,y,sum=0,k,m;
	cin>>n>>m>>k;
    ll outdegree[n+1];
    for (i=1;i<=n;i++)outdegree[i]=0;
	init();
	for (i=0;i<m;i++){
		cin>>x>>y;
        outdegree[x]++;
        outdegree[y]++;
		if (!check(x,y))combine(x,y);
	}
    ll ans[n+1];
	for (i=1;i<=n;i++){
		ans[i]=sz[get_root(i)]-1-outdegree[i];
	}
    sum/=2;
    for (i=0;i<k;i++){
        cin>>x>>y;
        if (check(x,y)){
            ans[x]--;
            ans[y]--;
        }
    }
	for (i=1;i<=n;i++){
        if (i!=1)cout<<' ';
        cout<<ans[i];
    }
    
}

Measured memory_bytes: 21760
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
    int a,b,c,d;
    int ans=0;

    cin>>a>>b>>c>>d;
    if(a>b){
        ans+=b;
    }else{
        ans+=a;
    }
    if(c>d){
        ans+=d;
    }else{
        ans+=c;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    n, t = ns()
    a = na()

    res = dict()
    s_num = a[0]
    for i in range(1, n):
        tmp = a[i] - s_num
        if tmp > 0:
            if tmp in res.keys():
                res[tmp] += 1
            else:
                res[tmp] = 1

        s_num = min(s_num, a[i])

    print(res[max(res.keys())] if n != 1 else 0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24872
#include<stdio.h>
int main()
{
  int H, W;
  
  while(1){
    int i, j;
    scanf("%d %d", &H, &W);
    //ループの終了条件
    if(H == 0 && W == 0)
      break;
    //行
    for(i = 0;i < H ;i++){
      //列
      for(j = 0;j < W;j++){
	printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> s;
	y = (s[0]-'0')*10+s[1]-'0';
	m = (s[2]-'0')*10+s[3]-'0';
	if (y==0) y=13;
	if (m==0) m=13;
	if ((y>12)&&(m>12)) cout << "NA" << endl;
	else if ((y>12)&&(m<=12)) cout << "YYMM" << endl;
	else if ((y<=12)&&(m>12)) cout << "MMYY" << endl;
	else cout << "AMBIGUOUS" << endl;
	return 0;
}


Measured memory_bytes: 3592
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){



		Scanner sc = new Scanner(System.in);
		// 整数の入力
		//int n = sc.nextInt();
		String s = sc.next();
		String[] ss = s.split("");
		boolean check =false;//false> true<
		ArrayList<Integer> zeroList = new ArrayList<>();
		
		for(int i=0;i<ss.length;i++) {
			if(!check) {
				if(ss[i].equals("<")){
					zeroList.add(i);
					check=true;
				}
			}else {
				if(ss[i].equals(">"))check=false;
			}
		}
		
		if(ss[ss.length-1].equals(">"))zeroList.add(ss.length);
		
		int[] a = new int[ss.length+1];
		for(int i =0;i<a.length;i++) {
			a[i]=-1;
		}
		for(int i =0;i<zeroList.size();i++) {
			a[zeroList.get(i)] =0;
			int index = zeroList.get(i)-1;
			while(index>-1&&ss[index].equals(">")) {
				if(a[index]<a[index+1]+1) {
					a[index]=a[index+1]+1;
				}
				index--;
			}
			index = zeroList.get(i);
			while(index<ss.length&&ss[index].equals("<")) {
				a[index+1]=a[index]+1;
				index++;
			}
		}
		
		long  sum = 0;
		for(int i =0;i<a.length;i++) {
			sum +=a[i];
		}
		System.out.println(sum);
		
		/*
		TreeMap<Integer,Integer> treeMap = new TreeMap<>();//sorted no duplication
		treeMap.put(b[n], n);
		*/

	}

	

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 67868
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long;

int main()
{
ll x,k,d;
cin >> x >> k >> d;
x = abs(x);
ll straight = min(k,x/d);
k -= straight;
x -= straight*d;

if(k%2==0){
	cout << x << endl;
} else {
	cout << d-x << endl;
}
return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int x,y;
    cin >> x >> y;
    if (x % y == 0) cout << -1 << endl;
    else cout << x << endl;
}

int main() {
    solve();
    
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

N, *XYU = map(str, sys.stdin.read().split())

UD = {}
UR = {}
UL = {}
DU = {}
DR = {}
DL = {}
RU = {}
RD = {}
RL = {}
LU = {}
LD = {}
LR = {}

for i in range(int(N)):
  X = int(XYU[3*i])
  Y = int(XYU[3*i+1])
  U = XYU[3*i+2]
  if U == 'U':
    if X in UD.keys():
      UD[X].append(Y)
    else:
      UD[X] = [Y]
    if X+Y in UR.keys():
      UR[X+Y].append(X)
    else:
      UR[X+Y] = [X]
    if X-Y in UL.keys():
      UL[X-Y].append(X)
    else:
      UL[X-Y] = [X]
  elif U == 'D':
    if X in DU.keys():
      DU[X].append(Y)
    else:
      DU[X] = [Y]
    if X+Y in DL.keys():
      DL[X+Y].append(X)
    else:
      DL[X+Y] = [X]
    if X-Y in DR.keys():
      DR[X-Y].append(X)
    else:
      DR[X-Y] = [X]
  elif U == 'R':
    if Y in RL.keys():
      RL[Y].append(X)
    else:
      RL[Y] = [X]
    if X+Y in RU.keys():
      RU[X+Y].append(X)
    else:
      RU[X+Y] = [X]
    if X-Y in RD.keys():
      RD[X-Y].append(X)
    else:
      RD[X-Y] = [X]
  else:
    if Y in LR.keys():
      LR[Y].append(X)
    else:
      LR[Y] = [X]
    if X+Y in LD.keys():
      LD[X+Y].append(X)
    else:
      LD[X+Y] = [X]
    if X-Y in LU.keys():
      LU[X-Y].append(X)
    else:
      LU[X-Y] = [X]

def dist(X,Y):
  minimum = -1
  X_len = len(X)
  X_index = 0
  Y_len = len(Y)
  Y_index = 0
  while X_index<X_len and Y_index<Y_len:
    x = X[X_index]
    y = Y[Y_index]
    if x<y:
      if minimum == -1:
        minimum = y-x
      else:
        minimum = min(minimum, y-x)
      X_index += 1
    else:
      Y_index += 1
  return minimum

second = -1

for x in UD.keys():
  if x in DU.keys():
    distance = dist(sorted(UD[x]),sorted(DU[x]))
    if distance>0:
      if second == -1:
        second = 5*distance
      else:
        second = min(second,5*distance)

for x in RL.keys():
  if x in LR.keys():
    distance = dist(sorted(RL[x]),sorted(LR[x]))
    if distance>0:
      if second == -1:
        second = 5*distance
      else:
        second = min(second,5*distance)

for x in UR.keys():
  if x in RU.keys():
    distance = dist(sorted(RU[x]),sorted(UR[x]))
    if distance>0:
      if second == -1:
        second = 10*distance
      else:
        second = min(second,10*distance)

for x in UL.keys():
  if x in LU.keys():
    distance = dist(sorted(UL[x]),sorted(LU[x]))
    if distance>0:
      if second == -1:
        second = 10*distance
      else:
        second = min(second,10*distance)

for x in RD.keys():
  if x in DR.keys():
    distance = dist(sorted(RD[x]),sorted(DR[x]))
    if distance>0:
      if second == -1:
        second = 10*distance
      else:
        second = min(second,10*distance)

for x in LD.keys():
  if x in DL.keys():
    distance = dist(sorted(DL[x]),sorted(LD[x]))
    if distance>0:
      if second == -1:
        second = 10*distance
      else:
        second = min(second,10*distance)

if second == -1:
  print('SAFE')
else:
  print(second)

Measured memory_bytes: 199092
#include <iostream>
#include <cmath>
using ll = long long;
using namespace std;

const int MAX_N = 1 << 17;

int n;
ll dat[MAX_N*2 - 1];

void init() {
    int n_ = n;
    n = 1;
    while(n < n_) n *= 2;
    for(int i=0; i<2*n - 1; ++i) {
        dat[i] = 0;
    }
}

void update(int i, ll x) {
    i += n-1;
    dat[i] = x;
    while(i > 0) {
        i = (i-1)/2;
        dat[i] = max(dat[2*i+1], dat[2*i+2]);
    }
}

ll query(ll a, ll b, int k, int l, int r) {
    if(r <= a || b <= l) {
        return 0;
    }
    if(a <= l && r <= b) {
        return dat[k];
    } else {
        ll vl = query(a, b, k*2 + 1, l, (r+l)/2);
        ll vr = query(a, b, k*2 + 2, (r+l)/2, r);
        return max(vl, vr);
    }
}

int main() {
    cin >> n;
    ll sum = 0;
    int n2 = n;
    init();
    for(int i=0; i<n2; ++i) {
        ll x;
        cin >> x;
        sum += x;
        update(x-1, x+query(0, x, 0, 0, n)); // x <= n
    }
    cout << sum - dat[0] << endl;
}


Measured memory_bytes: 5144
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;
template<typename T>
T fastPow(T a, T b, T mod = 0) {
	if (a == 0 and b == 0) {
		return -1;
	}
	if (a == 0) {
		return 0;
	}
	if (b == 0) {
		return 1;
	}
	long long tmp = fastPow(a, b / 2, mod);
	if (mod != 0) {
		if (b % 2 == 0) {
			return (tmp * tmp) % mod;
		}
		else {
			return ((tmp*tmp) % mod * (a % mod)) % mod;
		}
	}
	else {
		if (b % 2 == 0) {
			return (tmp*tmp);
		}
		else {
			return tmp * tmp * a;
		}
	}
}


int main() {
	ll numPoint, goalPoint;
	cin >> numPoint >> goalPoint;
	vector <pair<ll, ll>> probList;
	probList.resize(numPoint + 1);

	for (ll i = 1; i <= numPoint; i++) {
		ll point, comp;
		cin >> point >> comp;
		probList[i] = make_pair(point, comp);
	}

	vector<bool> getComp;
	getComp.resize(numPoint + 1);

	ll ans = INT64_MAX;
	for (ll q = 0; q < pow(2LL, numPoint); q++) {
		ll nowQ = q;
		ll p = 1;
		while (nowQ > 0) {
			getComp[p] = nowQ % 2;
			p++;
			nowQ /= 2;
		}

		ll tmpSum = 0;
		ll numSolve = 0;
		for (ll i = 1; i <= numPoint; i++) {
			if (getComp[i] == true) {
				numSolve += probList[i].first;
				tmpSum += probList[i].first * i * 100;
				tmpSum += probList[i].second;
			}
		}
		if (tmpSum < goalPoint) {
			ll nowQuestion = numPoint;
			while (nowQuestion > 0) {
				if (getComp[nowQuestion] == true) {
					nowQuestion--;
					continue;
				}
				ll restPoint = goalPoint - tmpSum;
				if (restPoint > nowQuestion * 100 * probList[nowQuestion].first) {
					tmpSum += nowQuestion * 100 * probList[nowQuestion].first;
					numSolve += probList[nowQuestion].first;
					nowQuestion--;
					continue;
				}
				ll numSolveTmp = 0;
				if (restPoint % (nowQuestion * 100) == 0) {
					numSolveTmp = restPoint / (nowQuestion * 100);

				}
				else {
					numSolveTmp = restPoint / (nowQuestion * 100) + 1;
				}
				tmpSum += numSolveTmp * nowQuestion * 100;
				numSolve += numSolveTmp;
				break;
			}
		}
		if (numSolve < ans && tmpSum >= goalPoint) {
			ans = numSolve;
		}
		//cout << ans << endl;

	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define f(i,l,h) for(ll i=l;i<h;i++)
#define fr(i,h,l) for(ll i=h;i>=l;i--)

using namespace std;

typedef pair<ll,ll> pll;
const ll INF=(ll)(1e9+7);
typedef vector<ll> vll;
map<ll,ll>mp;
ll fun(ll n)
{
    mp.clear();
    mp[1]=1;
    ll ans=0;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p == 0) {
            ll temp=p;
            while (n % p == 0){
                if(mp[temp]==0){
                    ans++;
                    mp[temp]=1;
                    n/=temp;
                    temp=p;
                }else {
                    if((n/temp)%p!=0){
                        n/=temp;
                    }else temp*=p;
                }
            }
        }
    }
    if(n!=1){
        ans++;
    }

    return ans;
}



int main()
{
    //cout << "Hello world!" << endl;
    ll n;
    cin>>n;
    cout<<fun(n)<<endl;

}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define var auto
using namespace std;
using ll = long long;
using P = pair<int, int>;
// sort(A.begin(), A.end(), cmp)
bool cmp(P a, P b) { return a.second < b.second; }
#ifdef DEBUG
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; cout << a << endl; return 1; } cout << a << endl; return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; cout << a << endl; return 1; } cout << a << endl; return 0; }
#else
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; }
#endif
const ll INF = 1LL << 60;
const int MAX_ITEM = 10e4+10; // 10^5
ll dp[1000010][2] = {0};

int main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  s += '0'; // 91 とか、繰り上がりの桁が必要なことがある
  int n = s.size();
  rep(i,n+1)rep(j,2) {
    dp[i][j] = INF;
  }

  dp[0][0] = 0;

  rep(i,n) {
    int x = s[i] - '0';

    // i桁目で繰り下がりがない場合
    chmin(dp[i+1][0], dp[i][0] + x);
    chmin(dp[i+1][1], dp[i][0] + (10 - x));

    if (i == 0) continue;
    chmin(dp[i+1][0], dp[i][1] + x + 1);
    chmin(dp[i+1][1], dp[i][1] + (10 - x - 1));
  }

  cout << dp[n][0] << endl;

  return 0;
}


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

long long int co[200010];

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

    for(int i=0;i<200010;++i)   co[i] = 0;

    int A[n];
    for(int i=0;i<n;++i)
    {
        cin>>A[i];
        co[A[i]]++;
    }
    
    long long int ans = 0;
    for(int i=0;i<200010;++i)   ans += (co[i]*(co[i]-1))/2;
    for(int pos=0;pos<n;++pos)  cout<<ans - (co[A[pos]]*(co[A[pos]]-1))/2 + ((co[A[pos]]-1)*(co[A[pos]]-1 -1))/2<<"\n";

    return 0;
}

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

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

using ll = long long;
#define INF 1e9


int main(){
  int a, b, c;
  cin >> a >> b >> c;

  if(a+b==c || a+c==b || b+c == a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  int a=0,b=0,c=0,d=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='N') a++;
    else if(s[i]=='S') b++;
    else if(s[i]=='E') c++;
    else d++;
  }
    if(max(a,b)>0 && min(a,b)==0) cout << "No";
    else if(max(c,d)>0 && min(c,d)==0) cout << "No";
    else cout << "Yes";
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007

using namespace std;
using P = pair<long, long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };

vector<edge>tree[100010];
long long dist[100010];
long long dp[100005][4];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	string S;
	cin >> S;

	string ans = "Sunny";
	if (S == "Sunny") {
		ans = "Cloudy";
	}
	else if (S== "Cloudy") {
		ans = "Rainy";
	}
	cout << ans << endl;
}


Measured memory_bytes: 4480
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto xy = readln.split.to!(int[]);
    auto x1 = xy[0];
    auto y1 = xy[1];
    auto x2 = xy[2];
    auto y2 = xy[3];

    int x3 = x2 + y1 - y2;
    int y3 = y2 - x1 + x2;
    int x4 = x3 + x1 - x2;
    int y4 = y3 + y1 - y2;

    writefln("%d %d %d %d", x3, y3, x4, y4);
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

all = 3 ** N

odd = 1 if A[0] % 2 == 1 else 2
for n in range(N-1):
    odd *= 1 if A[n+1] % 2 == 1 else 2

print(all-odd)


Measured memory_bytes: 2940
import numpy as np

h, w = map(int, input().split())
S = list(list(input()) for _ in range(h))
S = np.array(S)
S_int = np.zeros_like(S, dtype=int)
S_int[S=='.'] = 1

def getLR(d, width, height):
  L = np.zeros_like(d)
  R = L.copy()
  L[:][0] = 0
  R[:][-1] = 0
  for i in range(1, width):
    ridx = width - 1 - i
    L[:,i] = d[:,i] * (L[:,i-1] + d[:,i-1])
    R[:,ridx] = d[:,ridx] * (R[:,ridx+1] + d[:,ridx+1])
  return L, R

L, R = getLR(S_int, w, h)
U, D = getLR(S_int.T, h, w)
print((L+R+U.T+D.T).max() + 1)

Measured memory_bytes: 265084
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <cmath>

using namespace std;

int main()
{
    string A, B;
    cin >> A >> B;
    int a = A.length(); int b = B.length();
    if (a > b) {
        cout << "GREATER\n";
        return 0;
    }
    else if (a < b) {
        cout << "LESS\n";
        return 0;
    }
    for (int i=0; i<a; i++) {
        if (A[i] > B[i]) {
            cout << "GREATER\n";
            return 0;
        }
        else if (A[i] < B[i]) {
            cout << "LESS\n";
            return 0;
        }
    }
    cout << "EQUAL\n";
    
    return 0;
}

Measured memory_bytes: 3548
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n, h = f()
    swords = []

    for i in range(n):
        swords.append(f())
    
    maxa = max([x[0] for x in swords])

    swords = sorted(swords, key = lambda x: -x[1])

    cnt = 0
    sumh = 0
    for i in range(n):
        if swords[i][1]>maxa:
            sumh += swords[i][1]
            cnt += 1
            if sumh >= h:
                print(cnt)
                return
        else:
            break

    cnt += (h- sumh+maxa-1)//maxa

    print(cnt)






solve()


Measured memory_bytes: 32844
from collections import defaultdict
from heapq import heappop, heappush


class Graph(object):
    """
    隣接リストによる有向グラフ
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    """
    ダイクストラ法（二分ヒープ）による最短経路探索
    計算量: O((E+V)logV)
    """

    def __init__(self, graph, start):
        self.g = graph.graph

        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        # 最短経路での1つ前のノード
        self.prev = defaultdict(lambda: None)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        """
        startノードからgoalノードまでの最短距離
        """
        return self.dist[goal]

    def shortest_path(self, goal):
        """
        startノードからgoalノードまでの最短経路
        """
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]


g = Graph()
N = int(input())
for i in range(N-1):
    u, v, w = [int(i) for i in input().split()]
    g.add_edge(u-1, v-1, w)
    g.add_edge(v-1, u-1, w)

d = Dijkstra(g, 0)

ans = []
for i in range(N):
    if d.dist[i] % 2 == 0 :
        ans.append(0)
    else:
        ans.append(1)

if sum(ans)==0:
    ans[-1] = 1

for i in range(N):
    print(ans[i])

Measured memory_bytes: 71980
fun main(args: Array<String>) {
    val numList = readLine()?.split(" ").orEmpty()

    val numN = numList[0].toInt()
    val numM = numList[1].toInt()

    var resultN = 0
    var resultM = 0
    
    if(numN > 2){
        var denomN = 1
        for(i in numN - 2 .. 2){
            denomN *= i
        }
        var numerN = denomN * numN * (numN - 1)
        resultN = numerN / (denomN * 2)
    }else if(numN == 2){
        resultN = 1
    }

    if(numM > 2){
        var denomM = 1

        for(i in numM - 2 .. 2){
            denomM *= i
        }
        var numerM = denomM * numM * (numM - 1)
        resultM = numerM / (denomM * 2)
    }else if(numM == 2){
        resultM = 1
    }

    println(resultN + resultM)

}



Measured memory_bytes: 38052
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
    int64_t n,d;
    cin>>n>>d;
    vector<int64_t> x(n);
    vector<int64_t> y(n);
    int count=0;
    int64_t sum;
    for (int i = 0; i < n; i++)
    {
        cin>>x.at(i)>>y.at(i);
        if ((x.at(i)*x.at(i)+y.at(i)*y.at(i))<=d*d)
        {
            count++;
        }
        

    }
    cout<<count<<endl;



    
    

    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int X,Y;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>X>>Y;
	if(X>Y) swap(X,Y);
	FOR(i,Y) cout<<X;
	cout<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256