akhauriyash/Code-Regression huggingface dataset:
a,b=list(map(int,input().split()))
s=input()
def Post(s,a):
    if s.count('-')!=1:
        return False
    for i in range(len(s)):
        if s.index('-')!=a:
            return False
        return True
if Post(s,a)==True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	int A, B;
	cin >> A >> B;
	if (A + B == 15) {
		cout << '+' << endl;
	}
	else if (A * B == 15) {
		cout << '*' << endl;
	}
	else {
		cout << 'x' << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _debug
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#define dout(i) //
#endif
using ll = long long;
using ull = unsigned long long;
using ul = unsigned;
const int maxn = 500001;
char w[maxn];
int n, c[maxn]{1};
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> (w+1);
	n = strlen(w+1);
	int res = 0;
	for(int i = 1;i <= n;++i){
		if(w[i] != w[i-1])c[i] = true;
		else if(!c[i-1])c[i] = true;
		else if(!c[i-2])c[i] = true;
	}
	for(int i = 1;i <= n;++i)res += c[i];
	cout << res << '\n';
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long

using namespace std;

signed main(){
    int n, sum, a;
    cin >> sum >> n;

    for(int i=0;i<n;i++){
        cin >> a;
        sum-=a;
    }

    if(sum<0) cout << "-1" << endl;
    else cout << sum << endl;
    
    return 0;
}       

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <inttypes.h>

//int compare_int(const void *a, const void *b){//qsort 整数比較<
//	return *(int*)a - *(int*)b;
//}
//int compare_int2(const void *a, const void *b){//qsort 整数比較>
//	return *(int*)b - *(int*)a;
//}
//
int main(void){
	long long int a,b,c,d;
	long long int ans1=0,ans2=0,ans3=0,ans4=0;

	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	ans1=a*c;ans2=a*d;ans3=b*c;ans4=b*d;
	if(ans1>ans2){
		if(ans1>ans3){
			if(ans1>ans4){
				printf("%lld",ans1);
			}else{
				printf("%lld",ans4);
			}
		}else{
			if(ans3>ans4){
				printf("%lld",ans3);
			}else{
				printf("%lld",ans4);
			}
		}
	}else{
		if(ans2>ans3){
			if(ans2>ans4){
				printf("%lld",ans2);
			}else{
				printf("%lld",ans4);
			}
		}else{
			if(ans3>ans4){
				printf("%lld",ans3);
			}else{
				printf("%lld",ans4);
			}
		}
	}

	return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int arr[55], pref[55];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> arr[i];
        pref[i] = arr[i] +  pref[i - 1];
    }
    int answer = -2e9;
    int sum1 = 0;
    for (int i = 0; i <= n; ++i) {
        int sum2 = 0;
        for (int j = i + 1; j <= n + 1; ++j) {
            if (i + n - j + 1 <= k) {
                multiset<int> l, r;
                for (int x = 1; x <= i; ++x) {
                    if (arr[x] < 0) {
                        l.insert(arr[x]);
                    }
                }
                for (int x = n; x >= j; --x) {
                    if (arr[x] < 0) {
                        r.insert(arr[x]);
                    }
                }
                int sum1 = 0;
                auto p1 = l.begin();
                for (int x = 0; x <= l.size(); ++x) {
                    if (x > 0) {
                        sum1 += *p1;
                        ++p1;
                    }
                    int sum2 = 0;    
                    auto p2 = r.begin();
                    for (int y = 0; y <= r.size(); ++y) {
                        if (y > 0) {
                            sum2 += *p2;
                            ++p2;
                        }
                        if (x + y <= k - (i + n - j + 1)) {
                            answer = max(answer, pref[i] + pref[n] - pref[j - 1] - sum1 - sum2);
                        } 
                    }
                }
            }
        }
    }
    cout << answer;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
typedef long long ll;
using namespace std;
const ll mod=1000000007;

ll pow(ll a,ll b,ll c){
  ll res=1;
  if(b>0){
    res=pow(a,b/2,c);
    if(b%2==0)res=res*res%c;
    else res=(res*res)%c*a%c;
  }
  return res;
}

ll combi(ll n,ll a){
  ll x=1,y=1;
  for(ll i; i<a;i++){
    x=x*(n-i)%mod;
    y=y*(i+1)%mod;
  }
  return x*pow(y,mod-2,mod)%mod;
}

int main() {
  ll n,a,b,c=1,g;
  cin >> n >> a >> b;
  c=pow(2,n,mod)-1;
  
  g=c-combi(n,a)-combi(n,b);
  if(g<0)g+=2*mod;
  g%=mod;
  cout<<g<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stdio.h>

#define MAX_3N 300'000

typedef long long ll;

using namespace std;

int A[MAX_3N]{};

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < 3 * N; ++i) {
    cin >> A[i];
  }
  sort(A, A + 3 * N);
  ll res = 0;
  for (int i = 3 * N - 2; i >= 3 * N - 2 - 2 * (N - 1); i -= 2) {
    res += A[i];
  }
  printf("%lld\n", res);
}

Measured memory_bytes: 4384
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
typedef pair<int,int> P;
typedef pair<P,P> PP;
bool vis[50][50][50][50];
int H,W,dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
string sl[50],sr[50];
bool okl(int x,int y){
	return 0<=x&&x<H&&0<=y&&y<W&&sl[x][y]!='#';
}
bool okr(int x,int y){
	return 0<=x&&x<H&&0<=y&&y<W&&sr[x][y]!='#';
}
void bfs(int slx,int sly,int srx,int sry){
	queue<PP> que;
	que.push(PP(P(slx,sly),P(srx,sry)));
	vis[slx][sly][srx][sry]=1;
	while(!que.empty()){
		PP pp=que.front();
		que.pop();
		int lx=pp.fs.fs,ly=pp.fs.sc,rx=pp.sc.fs,ry=pp.sc.sc;
		if(sl[lx][ly]=='%'||sr[rx][ry]=='%') continue;
		rep(di,4){
			int lnx=lx+dx[di],lny=ly+dy[di],rnx=rx+dx[di],rny=ry+dy[di];
			if(!okl(lnx,lny)) lnx=lx,lny=ly;
			if(!okr(rnx,rny)) rnx=rx,rny=ry;
			if(vis[lnx][lny][rnx][rny]) continue;
			vis[lnx][lny][rnx][rny]=1;
			que.push(PP(P(lnx,lny),P(rnx,rny)));
		}
	}
	
}
int main(){
	while(true){
		cin>>W>>H;
		if(H==0) break;
		rep(i,H){
			cin>>sl[i]>>sr[i];
			reverse(all(sr[i]));
		}
		int lx,ly,rx,ry,ax,ay,bx,by;
		rep(i,H) rep(j,W) if(sl[i][j]=='L') lx=i,ly=j;
		rep(i,H) rep(j,W) if(sr[i][j]=='R') rx=i,ry=j;
		rep(i,H) rep(j,W) if(sl[i][j]=='%') ax=i,ay=j;
		rep(i,H) rep(j,W) if(sr[i][j]=='%') bx=i,by=j;
		rep(i,H) rep(j,W) rep(k,H) rep(h,W) vis[i][j][k][h]=0;
		bfs(lx,ly,rx,ry);
		if(vis[ax][ay][bx][by]) puts("Yes");
		else puts("No");
	}
}

Measured memory_bytes: 8240
using System;

namespace abc121A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            string[] stri = Console.ReadLine().Split();
            int C = int.Parse(stri[0]);
            int D = int.Parse(stri[1]);
            int E = (A * B) - ((B * C) + (A * D) - (C * D));
            Console.WriteLine(E);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n+1);
  for(int i=0;i<n;i++){
    int s;
    cin >> s;
    a.at(i) =s;
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int alice=0;
  int bob=0;
  for(int i=0;i<n;i+=2){
    alice +=a.at(i);
    bob +=a.at(i+1);
  }
  cout << alice -bob;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n;
    cin>>n;
  if(n==3){
    cout<<"Yes"<<endl;
    for(int i=0; i<5; i++) cout<<i+1<<" "<<i+2<<endl;
    return 0;
  }
    int p=1;
    while(p<=n){
        if(p==n){
            cout<<"No"<<endl;
            return 0;
        }
        p<<=1;
    }
    p>>=1;
    cout<<"Yes"<<endl;
    if(n%2==1){
        for(int i=1; i<p-1; i++){
            cout<<i<<" "<<i+1<<endl;
        }
        cout<<p-1<<" "<<n+1<<endl;
        for(int i=1; i<p-1; i++){
            cout<<i+n<<" "<<i+1+n<<endl;
        }
        for(int i=p; i<n; i+=2){
            cout<<i<<" "<<i+1<<endl;
            cout<<i+1<<" "<<1<<endl;
            cout<<1<<" "<<n+i<<endl;
            cout<<n+i<<" "<<n+i+1<<endl;
        }
        return 0;
    }
    vector<int> v;
    set<int> st;
    for(int i=0; i<20; i++){
        if(p==(1<<i)) break;
        if(n&(1<<i)) v.push_back(1<<i), st.insert(1<<i);
    }
    v.push_back(n^p^1);
    int t=(int)v.size()-1;
    st.insert(n^p^1);
    for(int i=1; i<p; i++){
        if(st.find(i)==st.end()) v.push_back(i);
    }
    for(int i=0; i<p-2; i++){
        cout<<v[i]<<" "<<v[i+1]<<endl;
    }
    cout<<v[p-2]<<" "<<v[0]+n<<endl;
    for(int i=0; i<p-2; i++){
        cout<<v[i]+n<<" "<<v[i+1]+n<<endl;
    }
    for(int i=p; i<n; i+=2){
        cout<<i<<" "<<i+1<<endl;
        cout<<i+1<<" "<<v[t]<<endl;
        cout<<i+n<<" "<<v[0]<<endl;
        cout<<i+n<<" "<<i+n+1<<endl;
    }
    cout<<2*n<<" "<<p+n<<endl;
    cout<<n<<" "<<v[t-1]<<endl;
    return 0;
}

Measured memory_bytes: 3068
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>

typedef long long ll;

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int len = s.size();
	
	int flag = 1;
	for(int i = 0; i<len-1 ; i++){
		if(s[i] == s[i+1]){
			printf("%d %d\n",i+1,i+2);
			flag = 0;
			break;
		} 
		else if(s[i]==s[i+2] && i<len-2){
			printf("%d %d\n",i+1,i+3);
			flag = 0;
			break;
		}
	}
	if(flag){
		printf("-1 -1\n");
		
	}
	
	return 0;
}




Measured memory_bytes: 512
using System;

namespace B_FizzBuzz_Sum
{
    class Program
    {
        static void Main(string[] args)
        {
            long ans = 0;
            int n = int.Parse(Console.ReadLine());
            for (int i = 1; i <= n; i++)
            {
                if(i % 3 == 0 || i % 5 == 0)
                {
                }
                else
                {
                    ans += i;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27476
#include<iostream>
using namespace std;
int main(){
   int n;
   cin>>n;
   int price[n];
   int ans=0;
   int max=0;
   for(int i=0;i<n;i++){
      cin>>price[i];
      ans+=price[i];
      if(max<price[i])max=price[i];
   }
   ans-=max/2;
   cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
int main()
{
    string s;
    cin>>s;
    int i,flag=0;
    for(i=1;i<=s.size();i++)
    {
        flag++; 
    }
    cout<<s[0]<<flag-2<<s[s.size()-1]<<endl; 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
//#define int long long

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]) {
	bool all_visited = true;

	for (int i = 0; i < N; i++)
	{
		if (visited[i] == false)all_visited = false;
	}

	if (all_visited) {
		return 1;
	}

	int ret = 0;

	for (int i = 0; i < N; i++)
	{
		if (graph[v][i] == false)continue;
		if (visited[i])continue;

		visited[i] = true;
		ret += dfs(i, N, visited);
		visited[i] = false;
	}

	return ret;
}

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

	int N, M;
	cin >> N >> M;

	for (int i = 0; i < M; i++)
	{
		int A, B;
		cin >> A >> B;
		graph[A - 1][B - 1] = graph[B - 1][A - 1] = true;
	}

	bool visited[nmax];
	for (int i = 0; i < N; i++)
	{
		visited[i] = false;
	}

	visited[0] = true;
	cout << dfs(0, N, visited) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ans=0;
int main()
{
	long long n;
	cin>>n;
	if(n%2!=0)
		cout<<"0";
	else
	{
		for(long long i=10;i<=n;i*=5)
		{
			ans+=(n/i);
		}
		cout<<ans;
	}
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
 
int main(void) {
 
    // 1_8-A Toggling Cases
     
    char str[1200];
    int i=0;
    int n;
    gets(str);
 
    for(i=0; str[i]!='\0'; i++){
        if('A'<=str[i] && str[i]<='Z'){
            str[i] += ('a' - 'A');
        }else if('a'<=str[i] && str[i]<='z'){
            str[i] += ('A' - 'a');
        }
        putchar(str[i]);
    }
    putchar('\n');
 
        return 0;
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define drep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

//---------------------------------------------------------------------------------------------------

void _main() {
    ll X, now=100, count = 0;
    cin >> X;
    while(X>now) {
        now = ll((long double)now * 1.01);
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3652
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll(n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    bool ok = true;
    for (int x: a)
        if ((x % 2 == 0) && !(x % 3 == 0 || x % 5 == 0)){
            ok = false;
            break;
        }
    if (ok) cout << "APPROVED";
    else cout << "DENIED";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 200;
const int dx[] = {0,1,1,0,-1,-1,0};
const int dy1[] = {1,0,-1,-1,-1,0,0};
const int dy2[] = {1,1,0,-1,0,1,0};
const int dt[] = {1,1,1,1,1,1,1};

struct edge{
	int to;
	int cost;
};

struct pos{
    int x,y,t;
	bool operator<(const pos& another) const {
		if(x != another.x){
			return x < another.x;
		}else if(y != another.y){
			return y < another.y;
		}else{
			return t < another.t;
		}
	}
};

int d[6*MAX_N*MAX_N];
vector<edge> G[6*MAX_N*MAX_N];
map<P,int> mp;
map<pos,int> zip;
pos trans[6*MAX_N*MAX_N];

void dijkstra(int s)
{
	priority_queue<P,vector<P>,greater<P> > que;
	d[s] = 0;
	que.push(P(0,s));
	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		vector<edge>::iterator it = G[v].begin();
		rep(i,G[v].size()){
			if(d[G[v][i].to] > d[v] + G[v][i].cost){
				d[G[v][i].to] = d[v] + G[v][i].cost;
				que.push(P(d[G[v][i].to],G[v][i].to));
			}
		}
	}
}

int main()
{
    int sx,sy,gx,gy;
    cin >> sx >> sy >> gx >> gy;
    int n;
    cin >> n;
    rep(i,n){
        int x,y;
        cin >> x >> y;
        mp[P(x,y)]++;
    }
    int lx,ly;
    cin >> lx >> ly;
    int cnt = 0;
    for(int i = -lx;i<=lx;i++){
        for(int j=-ly;j<=ly;j++){
			if(mp[P(i,j)] == 1){
				continue;
			}
            rep(k,6){
				trans[cnt] = (pos){i,j,k};
                zip[(pos){i,j,k}] = cnt++;
            }
        }
    }
    rep(i,cnt){
        int x = trans[i].x;
        int y = trans[i].y;
        int t = trans[i].t;
        int ord = abs(x*y*t) % 6;
        rep(j,7){
			int nx,ny,nt;
			if(x % 2 == 0){
				nx = x + dx[j];
				ny = y + dy1[j];
				nt = (t + dt[j])%6;
			}else{
				nx = x + dx[j];
				ny = y + dy2[j];
				nt = (t + dt[j])%6;
			}
			if(mp[P(nx,ny)] == 1){
				continue;
			}
            if(-lx<=nx && nx<=lx && -ly<=ny && ny<=ly){
                G[i].push_back((edge){zip[(pos){nx,ny,nt}],(j==ord?0:1)});
            }
        }
    }
	rep(i,cnt){
		d[i] = INF;
	}
    dijkstra(zip[(pos){sx,sy,0}]);
    int ans = INF;
    rep(i,6){
        ans = min(ans,d[zip[(pos){gx,gy,i}]]);
    }
    if(ans == INF){
        cout << "-1\n";
    }else{
        cout << ans << "\n";
    }
}

Measured memory_bytes: 48352
#include<iostream>
#include<vector>
// #include<climits>
#include<algorithm>
// #include<string>
// #include<stack>
// #include<queue>
// #include<algorithm>

using namespace std;

int lis(vector<long long int> &dp){
        int ans = 0, anchor = 0;
        for (int i = 0; i < dp.size(); ++i) {
            if (i > 0 && dp[i-1] > dp[i]) anchor = i;
            ans = max(ans, i - anchor + 1);
        }
        return ans-1;
}

int main(){
    int N;
    cin>>N;
    vector<long long int> dp(N,1);
    for(int i=N-1;i>=0;i--)
        cin>>dp[i];
    cout<<lis(dp)<<endl;
    
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <climits>
#define ll long long
#define INF 10000000000000000
using namespace std;
ll N;
struct edge{ ll to, cost;};
vector<edge> G[100005];
ll d[100005],d_to[100005],d_back[100005];
typedef pair<ll,ll> P;
ll dijkstra(int s){
    priority_queue<P, vector<P>,greater<P>> que;
    fill(d,d+N,INF);
    d[s] = 0;
    que.push(P(0,s));
 
    while(!que.empty()){
        P p = que.top(); que.pop();
        ll v = p.second;
        if(d[v] < p.first)continue;
 
        for(ll i=0;i<G[v].size();i++){
            edge e = G[v][i];
            if( d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}
int main(){
    cin >> N;

    ll x,y,z;
    for(int i=0;i<N-1;i++){
        cin >> x >> y >> z;
        x--; y--;
        G[x].push_back(edge{y,z});
        G[y].push_back(edge{x,z});
    }
    dijkstra(0);

    for(int i=0;i<N;i++){
        if(d[i]%2==0){
            cout << 0 << endl;
        }else{
            cout << 1 << endl;
        }
    }
}


Measured memory_bytes: 8704
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(){
	vector<int> v;

	for(int i = 0; i < 10; i++){
		int h;
		cin >> h;
		v.push_back(h);
	}

	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());

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

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int64_t N; 
  cin >> N;
  int64_t power = 1;
  int64_t ans = 1;
  int64_t C = 1000000007;
  
  rep(i, N){
  	power = power * (i+1);
    power = power % C;
  }
  cout << power << endl;
  return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int MAX_V =100000;
vector<int> G[MAX_V];
bool vis[MAX_V];
int ord[MAX_V];
int low[MAX_V];
vector<pii> Brides;//橋
/*頂点u がDFS tree の根であるとき, その次数が1 より大きければ関節点である(明らかに木を(次数) 個の木に分断する.)
そうでないとき, 頂点u のある子vについてordu≦lowvが成り立てば頂点u は関節点となる.(u を介して親の方へ進まなければならないから,u が消えるとv 以下の部分木は孤立してしまう.)*/
/*橋 ⇔ordu<lowv となることがわかる. (これは, 後退辺で遡ってもu の訪問時刻より早い頂点に訪れることが不可能である, ということを示している.) これはlowlink を求めるDFS を行いながらO(1) 時間で判定ができるので, O(n+m) 時間で橋を列挙することができる.*/
/*? low[u] は, uから以下の方法で辿り着ける頂点
での ord の最小値 
1. DFS 木の辺を根から葉の向きへ進む (何度でも) 
2. 後退辺を葉から根の向きへ進む (1 回まで)*/
void dfs(int v,int p,int &k){
	ord[v] = k++;
	low[v] =ord[v];
	vis[v] =true;
	int ct = 0;//次数
	for(int i =0;i <G[v].size();i++){
		if(!vis[G[v][i]]){
			ct++;
			dfs(G[v][i],v,k);
			low[v] =min(low[v],low[G[v][i]]);
			if(ord[v] <low[G[v][i]]){
				Brides.push_back(mp(min(v,G[v][i]),max(v,G[v][i])));
			}
		}else if(G[v][i]!=p){//後退辺をたどる
			low[v] =min(low[v],ord[G[v][i]]);
		}
	}
}
int V,E;
int main(){
	cin>>V>>E;
	for(int i =0;i < E;i++){
		int s,t;
		cin>>s>>t;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	int k = 0;
	for(int i =0;i < V;i++){
		if(!vis[i]){
			dfs(i,-1,k);
		}
	}
	sort(Brides.begin(),Brides.end());
	for(int i =0;i < Brides.size();i++){
		cout <<Brides[i].first<<" "<<Brides[i].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 5344
#include <iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include <iomanip> 
#include <stack> 
#include <cmath> 

#define maxn 100001
#define LL long long
#define inf 10000000000
#define mod 1000000007
#define pi 3.14159265359
using namespace std;
int dx[9] = { 1,0,-1,0,1,1,-1,-1 };
int dy[9] = { 0,1,0,1,1,-1,1,-1 };


LL n, m, k;
LL arr[maxn];
LL arr2[maxn];
int visit[maxn][2];
//int cache[maxn];
//int c[maxn];
//int g[maxn];
//int dfsnum = 0;
//vector<vector<int>>rvi;
//vector<vector<int>>scc;
//vector<pair<int, int>>ett;
//stack<int>st;
//bool flg = 1;
//LL s, d;
//
//int findp(int a) {
//	if (a == c[a])return a;
//	return c[a] = findp(c[a]);
//}
//void unionp(int a, int b) {
//	a = findp(a);
//	b = findp(b);
//
//	if (g[a] < g[b])swap(a, b);
//	c[b] = a;
//	g[a] += g[b];
//	g[b] = 1;
//
//}
//LL power(LL x, LL y) {
//	LL ret = 1;
//	while (y > 0) {
//		if (y % 2) {
//			ret *= x;
//			ret %= mod;
//		}
//		x *= x;
//		x %= mod;
//		y /= 2;
//	}
//	return ret;
//}
//void dfs2(int v) {
//	cache[v] = 1;
//	scc.back().push_back(v);
//	for (int nv : rvi[v]) {
//		if (cache[nv])continue;
//		dfs2(nv);
//	}
//
//}
//LL fac(LL n) {
//	if (n == 1) return 1;        
//	return (n * fac(n - 1) - power(2,n-1) )%mod;
//}
//int fac2(LL n) {
//	LL res, i;
//	if (n == 1)return n;
//	res = n;
//	for (int i = n - 1; i > 0; --i) {
//		res *= i;
//		res %= mod;
//	}
//	return res;
//}

LL gcd(LL a, LL b) {
	while (b != 0) {
		LL r = a % b;
		a = b;
		b = r;
	}
	return a;
}
vector<LL>vi;
vector<vector<int>>graph;
void dfs(int v, int p) {
	arr2[v] = 1;
	for (int nv : graph[v]) {
		if (nv == p)continue;
		dfs(nv, v);
		arr2[v] += arr2[nv];
	}
	if (p != 0)
		vi.push_back(arr2[v] * (n - arr2[v]));
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//int t;   cin >> t; cin.ignore();
	int t = 1;
	for (int test_case = 0; test_case < t; ++test_case) {
		int flg = 0;
		LL ans1 = 0, ans2 = 0;
		string ans[2] = { "NO","YES"};
		cin >> n >> k >> m;
		ans1 = n / k * m;
		if (n%k)ans1 += m;;
		cout << ans1<< '\n';
	}
	return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#define mod 1000000007
#define ten5 100000
using namespace std;



int main()
{
    int m,n,o=0,i,j,k,num[3];
    int sum=0,range=0;
    //long long int m,n,o,i,j,k=0;
    //vector <int> v;
    //float f,g,h;
    char c,d;
    //string a;
    cin>>m>>n;
    if(m>9||n>9) cout<<-1;
    else cout<<m*n;
    return 0;
}





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

int main(){
	int a,b[10],x=0,y=0;
	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> b[i];
		x += b[i];
		if (y < b[i])y = b[i];
	}
	if (y < x - y)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

	
	

	

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


int main() {
	ll a, b, k;
	cin >> a >> b >> k;
	if (a >= k) {
		cout << a - k <<" "<< b << endl;
	}
	else if (a < k && a + b >= k) {
		cout << 0 <<" "<< b - (k - a) << endl;
	}
	else cout << 0 <<" "<< 0 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n; cin >> n;
    vi a(n);
    rep(i,n){
        cin >> a[i];
        a[i] -= i+1;
    }
    sort(a.begin(), a.end());
    int x = n/2;
    if(n % 2 == 0) x--;
    int b = a[x];
    
    ll ans = 0;
    rep(i,n){
        ans += abs(a[i]-b);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3960
# -*- coding: utf-8 -*-
n = int(input())
a = [int(_) for _ in input().split()]

# my initial attempt below ############################
# from itertools import combinations
# INF = 10 ** 15
# combs = combinations(range(1, n), 3)
# grief = INF
# for comb in combs:
#     p = sum(a[:comb[0]])
#     q = sum(a[comb[0]:comb[1]])
#     r = sum(a[comb[1]:comb[2]])
#     s = sum(a[comb[2]:])

#     tmp = max(p, q, r, s) - min(p, q, r, s)
#     if tmp < grief:
#         grief = tmp

# print(grief)  # running time limit error

# solution below ######################################
cumul_sum = [0]
for i, ai in enumerate(a):
    cumul_sum.append(ai + cumul_sum[i])


def cal_sum(left, right):
    return cumul_sum[right] - cumul_sum[left]


def two_pointers(l, r, split):
    left_sum = cal_sum(l, split)
    right_sum = cal_sum(split, r)
    diff = abs(left_sum - right_sum)

    for i in range(split, r):
        tmp_left_sum = cal_sum(l, i)
        tmp_right_sum = cal_sum(i, r)
        tmp_diff = abs(tmp_left_sum - tmp_right_sum)

        if diff >= tmp_diff:
            left_sum = tmp_left_sum
            right_sum = tmp_right_sum
            diff = tmp_diff
        else:
            return i - 1, diff, left_sum, right_sum

    else:
        return r - 1, tmp_diff, tmp_left_sum, tmp_right_sum


l_split = 1
r_split = 3
griefs = []
for i in range(2, n - 1):
    # left
    l_split, l_diff, p, q = two_pointers(0, i, l_split)
    # right
    r_split, r_diff, r, s = two_pointers(i, n, r_split)

    griefs.append(max(p, q, r, s) - min(p, q, r, s))

print(min(griefs))


Measured memory_bytes: 28816
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC118 {
	class ABC118_B {
		static void Main(string[] args) {
			var NM = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var N = NM[0];
			var M = NM[1];
			var matrix = new int[N, M];
			for (int i = 0; i < N; i++) {
				var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				for (int j = 0; j < input[0]; j++) {
					matrix[i, input[j+1]-1] = 1;
				}
			}

			var sum = 0;
			for (int i = 0; i < M; i++) {
				var count = 1;
				for (int j = 0; j < N; j++) {
					count *= matrix[j, i];
				}
				sum += count;
			}

			Console.WriteLine(sum.ToString());
		}

	}
}


Measured memory_bytes: 13396
from collections import namedtuple
from operator import itemgetter, attrgetter

def bubble_sort(a):
    a = a[:]
    n = len(a)

    for i in range(n):
        for j in range(n - 1, i, -1):
            if a[j].value < a[j - 1].value:
                a[j], a[j - 1] = a[j - 1], a[j]
    return a


def selection_sort(a):
    a = a[:]
    n = len(a)

    for i in range(n):
        minj = i
        for j in range(i, n):
            if a[j].value < a[minj].value:
                minj = j
        a[i], a[minj] = a[minj], a[i]

    return a

class Card(namedtuple('Card', ['suit', 'value'])):
    def __str__(self):
        return '{0}{1}'.format(self.suit, self.value)

parser = lambda s: Card(s[0], int(s[1:]))

n = int(input())
a = list(map(parser, input().split()))

stable_sorted = sorted(a, key = attrgetter('value'))
bubble_sorted = bubble_sort(a)
selection_sorted = selection_sort(a)

print(' '.join(list(map(str, bubble_sorted))))
if stable_sorted == bubble_sorted:
    print('Stable')
else:
    print('Not stable')

print(' '.join(list(map(str, selection_sorted))))
if stable_sorted == selection_sorted:
    print('Stable')
else:
    print('Not stable')

Measured memory_bytes: 8128
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_variables)]
        #[allow(unused_mut)]
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("parse error")
    };
}

fn main() {
    input!{
        n: i32,
        m: usize,
        v: [i32; m]
    }
    let s: i32 = v.iter().sum();
    println!("{}", cmp::max(-1, n - s));
}


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

int main() {
   string S;
   cin >> S;
   cout << S.at(0) << S.at(1) << S.at(2) << endl;
   return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

int		main(void)
{
	string N;
	cin >> N;

	ll sum = 0;
	for (int i = 0; N[i]; i++)
		sum += N[i] - '0';
	if (sum % 9 == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}



Measured memory_bytes: 3744
/**
 *   author: r1933
**/
#include "bits/stdc++.h"

using namespace std;

#define all(x) x.begin(), x.end()
using i64 = long long;

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B, C;
  cin >> A >> B >> C;
  cout << (A == B && B == C ? "Yes" : "No") << "\n";
  return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
A = list(map(int, input().split()))
A.sort()
sum_A = []
for a in A:
	if len(sum_A) > 0:
		sum_A.append(sum_A[len(sum_A)-1] + a)
	else:
		sum_A.append(a)
op = []
for i in range(M):
	B,C = map(int,input().split())
	op.append((C, B))

op.sort()
c,b = op.pop()
sum_C = []
for i in range(N):
	if len(sum_C) > 0:
		sum_C.append(sum_C[len(sum_C)-1] + c)
	else:
		sum_C.append(c)
	b -= 1
	if b == 0:
		if len(op) > 0:
			c,b = op.pop()
		else:
			c,b = 0, 10**5

base = sum_A[N-1]
ans = base
for i in range(N):
	ans = max(ans, base + sum_C[i] - sum_A[i])
print(ans)

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


void Prime_factorization (int N, vector<int> &vec){
  for(int i = 2;i<= N;i++){
    while(N%i==0){
      N /= i;
      vec[i]++;
    }
  }
}
  
  
int main() {
  int N;
  cin >> N;
  vector<int> V(N+1);
  for(int i = 2; i<=N; i++){
    Prime_factorization(i,V);
  }
  long long ans = 1;
  for(int i = 2;i<= N;i++){
    ans *= V[i]+1;
    ans %= 1000000007;
  }
  /*
  rep(i,N+1){
    cout << V[i] << endl;
  }
  */
  cout << ans << endl;
}
      

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

int sx,sy,tx,ty;
string S = "";

int main(){
	cin >> sx >> sy >> tx >> ty;
	tx -= sx;
	ty -= sy;
	for(int i=0;i<tx;i++) S = S + 'R';
	for(int i=0;i<ty;i++) S = S + 'U';
	for(int i=0;i<tx;i++) S = S + 'L';
	for(int i=0;i<ty;i++) S = S + 'D';
	S = S + 'D';
	for(int i=0;i<tx+1;i++) S = S + 'R';
	for(int i=0;i<ty+1;i++) S = S + 'U';
	S = S + "LU";
	for(int i=0;i<tx+1;i++) S = S + 'L';
	for(int i=0;i<ty+1;i++) S = S + 'D';
	S = S + 'R';
	cout << S << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF = 1e9;
const long long INFL = 1LL<<60;

int main() {
  ll s;
  cin >> s;
  ll x1 = 0, y1 = 0, x2 = 1e+9, y2 = 1, x3 = 0, y3 = 0;

  x3 = (x2 - s % x2) % x2;
  y3 = (s + x3) / x2;

  cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  ll ans = INFL;
  for(int p = 1;p <= 100;++p){
    ll tmp = 0;
    rep(i,n){
      tmp += (a[i]-p)*(a[i]-p);
    }
    chmin(ans,tmp);
  }
  print(ans);
  return 0;
}



Measured memory_bytes: 256
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl     '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii      map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
void solve()
{
  ll n;
  cin>>n;
  ll a[n];
  ll cnt[n+1]={0};
  rep(i,0,n) cin>>a[i],cnt[a[i]]++;
  ll ans=0;
  rep(i,1,n+1) ans+=cnt[i]*(cnt[i]-1)/2;
  rep(i,0,n) 
  {
    cout<<ans+(cnt[a[i]]-1)*(cnt[a[i]]-2)/2-(cnt[a[i]])*(cnt[a[i]]-1)/2<<endl;
  }
}
signed main()
{
  
    /***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);
    /***********************************/
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS=1;
//  cin>>TESTS;
  while(TESTS--)
  {
    solve();
    
  }
  TIME
  return 0;
}

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

int main() {
  int n,Y;
  cin>>n>>Y;
  int x = -1, y = -1, z = -1;
  rep(i,n+1) rep(j,n+1-i){
    if(5000*i+9000*j == - Y + 10000*n) {
      y = i; z =j; x = n - y - z;
    }
  }
  cout << x << ' ' << y << ' ' << z << endl;
}



Measured memory_bytes: 256
from collections import deque
import collections
import math

h,w = map(int, input().split())
c = [list(input()) for i in range(h)]

def bfs():
    res=0
    for y in range(h):
        for x in range(w):
            if c[y][x]=='.':
                c[y][x]=math.inf
                res += 1
    c[0][0]=0
    que=deque([[0,0]])
    while que:
        y,x=que.popleft()
        for i,j in [(1,0),(0,1),(-1,0),(0,-1)]:
            ny,nx=y+i,x+j
            if h > ny >= 0 and w > nx >= 0:
                dist=c[ny][nx]
                if dist!='#':
                    if dist>c[y][x]+1:
                        c[ny][nx]=c[y][x]+1
                        que.append([ny,nx])
            else:
                pass
    if c[h-1][w-1] ==math.inf:
        return (-1)
    else:
        return res - c[h-1][w-1] -1

print (bfs())

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> s(m), c(m);
    for (int i = 0; i < m; i++) cin >> s[i] >> c[i];
    
    int l;
    if (n == 1) l = 0;
    else if (n == 2) l = 10;
    else l = 100;

    for (int i = l; i < 1000; i++) {
        string t = to_string(i);
        t += "  ";
        bool f = true;
        for (int j = 0; j < m; j++) {
            if (t[s[j]-1] != ('0' + c[j])) {
                f = false;
                break;
            }
        }
        if (f) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main()
{
    fast_cin;
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif

    string s;
    cin>>s;

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


}


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

#define NUM 123456

unsigned int list[NUM];

void makelist(void);

int main(void){
  unsigned int i,j,n,ans;
  makelist();
  while(scanf("%u",&n) && n){
    ans=0;
    if(n==1){
      puts("1");
      continue;
    }else if(n==2){
      puts("1");
      continue;
    }
    for(i=((n+1)>>1);i<n;i++) if(list[i]!=0) ans++;
    printf("%u\n",ans);
  }
  return 0;    
}

void makelist(void){
  unsigned int i,j;
  for(i=0;i<NUM;i++) list[i]=(i<<1)+1;
  for(i=1;i*i<NUM;i++){
    if(list[i]==0) continue;
    for(j=(i*(i+1))<<1;j<NUM;j+=(i<<1)+1) list[j]=0;
  }
}

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

#define MAX 20

int N;
int H[MAX];

int main() {
	cin >> N;
	for( int i = 0; i < N; i++ ) {
		cin >> H[i];
	}
	int ans = 1;
	int ma = H[0];
	for( int i = 1; i < N; i++ ) {
		if( H[i] >= ma ) {
			ma = H[i];
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,k,r,s,p;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    int ans=0;
    rep(i,n){
        if(i>=k&&t[i]==t[i-k]){
            t[i]='a';
            continue;
        }
        if(t[i]=='r') ans+=p;
        else if(t[i]=='s') ans+=r;
        else if(t[i]=='p') ans+=s;
    }
    cout<<ans;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const ll MOD=1e9+7;

int main(){
    string S, T;
    cin >> S >> T;
    int res=0;
    for(int i=0; i<S.size(); i++){
        if(S[i] != T[i]) res++;
    }
    cout << res << endl;
    return 0;
}

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

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

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

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T & a, const T & b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a > k)cout << ":(" << endl;
	else cout << "Yay!" << endl;
	return 0;
}


Measured memory_bytes: 256