akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100005
int a[MAXN];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[a[i]]==i)
			ans++;
	}
	printf("%d\n",ans/2);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	const int INF = 1e9;
	int N;
	cin >> N;
	vector<int> a(N), b(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }
	for (int i = 0; i < N; ++i) { cin >> b[i]; }

	vector<vector<int>> dp((1<<N), vector<int>(55, INF));
	dp[0][0] = 0;
	for (int i = 0; i < (1<<N); ++i) {
		int n = __builtin_popcount(i);
		int cost = 0;
		for (int j = 0; j < N; ++j) {
			if ((i>>j) & 1) { continue; }

			int ii = i | (1<<j);
			int val = (abs(n - j) % 2 ? b[j] : a[j]);
			for (int k = 0; k < 55; ++k) {
				if (k > val || dp[i][k] == INF) { continue; }
				dp[ii][val] = min(dp[ii][val], dp[i][k] + cost);
			}
			++cost;
		}
	}
	int ans = INF;
	for (int i = 0; i < 55; ++i) { ans = min(ans, dp[(1<<N) - 1][i]); }
	cout << (ans < INF ? ans : -1) << endl;

	return 0;
}


Measured memory_bytes: 67840
#include <bits/stdc++.h>
#define int long long
using namespace std;

class BIT{
public:
  typedef long long ll;
  ll n;
  vector<ll> bit0, bit1;
  BIT(){n=-1;}
  BIT(ll n_){
    n=1;
    while(n<n_)n*=2;
    bit0.resize(n+1,0);
    bit1.resize(n+1,0);
  }
  
  ll sum(vector<ll> &b,ll i){
    ll s=0;
    while(i>0){
      s=(s+b[i]);
      i-=i&-i;
    }
    return s;
  }

  void add(vector<ll> &b,ll i,ll v){
    while(i<=n){
      b[i]=(b[i]+v);
      i+=i&-i;
    }
  }

  //[a,b]にxを加算(1<=a)
  void add (ll a,ll b,ll x){
    assert(a > 0 && n >= 0);

    add(bit0,a,-x*(a-1));
    add(bit1,a,x);
    add(bit0,b+1,x*b);
    add(bit1,b+1,-x);
  }

  //[a,b]のsumを得る(1<=a)
  ll sum(ll a,ll b){
    assert(a > 0 && n >= 0);
    ll res=0;
    res+=sum(bit0,b)+sum(bit1,b)*b;
    res-=sum(bit0,a-1)+sum(bit1,a-1)*(a-1);
    return res;
  }
};

string s;
int cnt[300];
int odd, even;
char oddc;

bool check(){
    
  for(int i=0;i<(int)s.size();i++) cnt[(int)s[i]]++;
  
  for(int i=0;i<300;i++){
    
    if( cnt[i] % 2 ){
      odd++;
      oddc = (char)i;
    }
    else even++;
    
  }
  
  return odd <= 1;
}

string make_string(){
  
  int cnt2[300];

  for(int i=0;i<300;i++) cnt2[i] = cnt[i]/2;
  
  string t;
  
  for(int i=0;i<(int)s.size();i++){
    
    int I = s[i];
    
    if( cnt2[I] == 0 ) continue;
    
    cnt2[I]--;

    t += s[i];
    
  }
  
  string rt = t;
  
  reverse( rt.begin(), rt.end() );
  
  if( odd == 1 ) t += oddc;
  
  t += rt;
  
  return t;
}

vector<int> idx[300];
int nex[300];

void solve(string t){
  
  for(int i=0;i<(int)s.size();i++){
    
    idx[(int)s[i]].push_back( i + 1 );
    
  }
  
  BIT bit = BIT((int)s.size());
  
  for(int i=0;i<(int)s.size();i++) bit.add( i + 1, i + 1, 1 );
  
  int ans = 0;
  
  for(int i=0;i<(int)t.size();i++){
    
    int c = t[i];
    
    int nidx = idx[c][nex[c]++];
    
    bit.add( nidx, nidx, -1 );
    
    ans += bit.sum( 1, nidx );
    
  }
  
  cout<<ans<<endl;
  
}

signed main(){
  
  cin>>s;
  
  if( check() == false ){
    cout<<-1<<endl;
    return 0;
  }
    
  solve( make_string() );
  
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

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

	int ans=1e9;
	rep(p,101){
		int tmp=0;
		rep(i,n)tmp += (x[i]-p)*(x[i]-p);
		ans = min(ans,tmp);
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}

void Main()
{
    int n = 1e5+10;

    //IsPrime.resize(n+10);
    sieve(n+5);

    VI c(n);

    FOR(i,1,n){
        c[i] += c[i-1];
        if(i%2 == 0){
            continue;
        }
        if(IsPrime[i] && IsPrime[(i+1)/2]){
            c[i] ++;
        }
    }

    int q;cin>>q;
    REP(i,q){
        int l,r;cin>>l>>r;
        cout<<c[r]-c[l-1]<<endl;
    }







	return;
}

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

Measured memory_bytes: 1024
#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(){
    int n, x, t;
    cin >> n >> x >> t;
    cout << ((n+x-1)/x)*t << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <cstdlib> 
#define fio   ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define test() ll t; cin>>t; while(t--)
#define speed ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 1000000007
#define nax 1000005
#define pb push_back
#define mp make_pair
#define in insert
#define lpi(i,a,b) for(ll i=a;i<b;i++)
#define lpd(i,a,b) for(ll i=a;i>b;i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned int ui;
typedef long double ld;
 
struct Node{
    struct Node* left;
    struct Node* right;
    int data;
};
 
Node* newNode(int data)
{
    Node* node = new Node;
    node->data = data;
    node->left = NULL;
    node->right = NULL;
    return node;
}
 
int height(Node* root)
{
    if(root == NULL)
    {
        return 0;
    }
    queue < Node*> q;
    q.push(root);
    ll nc =0,h=0;
    nc = q.size();
    while(!q.empty())
    {
        cout<<q.front()->data<<endl;
        if(nc == 0)
        {
            h++;
            nc = q.size();
        }
        Node* node = q.front();
        q.pop();
        nc--;
        if(node->left !=NULL) q.push(node->left);
        if(node->right != NULL)q.push(node->right);
    }
    return h+1;
}
 
int main()
{
    fio;
    ll n;
    cin>>n;
    ll h[n];
    lpi(i,0,n){
        cin>>h[i];
    }
    ll ans[n];
    lpi(i,0,n){
        if(i==0)ans[i]=h[i];
        else if(i==1)ans[i]=abs(h[i]-h[i-1]);
        else if(i==2)ans[i]=min(abs(h[i]-h[i-1])+ans[i-1],abs(h[i]-h[i-2]));
        else ans[i] = min(abs(h[i]-h[i-1])+ans[i-1],abs(h[i]-h[i-2])+ans[i-2]);
    }
    cout<<ans[n-1];
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int main() {
	ll n;
	ll a,b;
	ll ans = 0;
	ll x[n];
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}

	for (int i = 0; i < n - 1; i++) {
		ll dif = x[i + 1] - x[i];
		ll cost = dif * a;
		if (cost < b) {
			ans += cost;
		} else {
			ans += b;
		}
	}
	
	cout << ans << endl;
	 
	
	return 0;	
}

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

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
x, y = map(int, input().split())
res = 0
if x == y:
  print(0)
  exit(0)
if x == 0 and (y < 0):
  print(abs(y) + 1)
  exit(0)
elif x == 0 and (y > 0):
  print(abs(y))
  exit(0)
if y == 0:
  if x < 0:
    print(abs(x))
  else: print(abs(x) + 1)
  exit(0)
if x * y > 0:
  if x < y: res = abs(y - x)
  else: res = abs(y - x) + 2
else:
  if x < y: res = abs(x + y) + 1
  else: res = abs(x + y) + 1
print(res)

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

ll choose2(ll n){
  return n*(n-1)/2;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n) a[i]--;
  vector<int> cnt(n);
  rep(i,n) cnt[a[i]]++;//入力例1で言うと1が3個、2が2個
  ll tot=0;
  //k番目のボールを取り除かないとき（フツーにn*(n-1)/2）
  rep(i,n) {
    tot+=choose2(cnt[i]);//入力例1で言うと3C2+2C2=4
  }
  //k番目のボールを取り除くとき
  rep(i,n) {
    ll ans=tot;
    //変化量の計算(例えば入力例1で1を取り除いたとき)
    ans-=choose2(cnt[a[i]]);//4-3C2
    ans+=choose2(cnt[a[i]]-1);//4-3C2+2C2
    cout << ans << endl;
  }
  return 0;
}
    
  

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = (to) - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define all(v) v.begin(), v.end()
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  int n, x;

  cin >> n >> x;
  V<int> a(n);

  rep(i, n) {
    cin >> a[i];
  }

  sort(a.begin(), a.end());

  int left = x;
  int count = 0;
  rep(i, n) {
    left -= a[i];

    if(left < 0) {
      break;
    }
    if(left == 0) {
      count++;
      break;
    }
    if(left > 0) {
      count++;
    }
  }
  if(left > 0) {
    count--;
  }

  cout << count << endl;
}

Measured memory_bytes: 3620
S = input()
T = input()
count = 0
max = 0
for j in range(len(T)):
  if T[j] == S[j]:
    count += 1
  if max < count:
    max = count

for i in range(1,len(S)-len(T)+1):
  count = 0
  for j in range(len(T)):
    if T[j] == S[i+j]:
      count += 1
  if max < count:
    max = count
print(len(T) - max)

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

int main(){
  int N;
  cin >> N;
  vector<string> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
    if(A[i] == "Y"){
      cout << "Four" << endl;
      return 0;
    }
  }  
  cout << "Three" << endl;
    
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
// const ll MOD=998244353;
 
ll dp[2020][2020];
 
int main(){
  int N,M; cin>>N>>M;
  int S[N],T[M];
  rep(i,N) cin>>S[i];
  rep(i,M) cin>>T[i];
  if(N==1&&M==1){
    cout<<1+(S[0]==T[0])<<endl;
    return 0;
  }else if(N==1){
    int cnt=1;
    rep(i,M) cnt+=(T[i]==S[0]);
    cout<<cnt<<endl;
    return 0;
  }else if(M==1){
    int cnt=1;
    rep(i,N) cnt+=(S[i]==T[0]);
    cout<<cnt<<endl;
    return 0;
  }
  dp[0][0]=1;
  rep(i,N+1) rep(j,M+1){
    if(i&&j) (dp[i][j]=dp[i][j]-dp[i-1][j-1]*2%MOD+MOD)%=MOD;
    (dp[i+1][j+1]+=dp[i][j])%=MOD;
    if(S[i]==T[j]) (dp[i+1][j+1]+=dp[i][j])%=MOD;
    (dp[i+1][j]+=dp[i][j])%=MOD;
    (dp[i][j+1]+=dp[i][j])%=MOD;
  }
  cout<<dp[N][M]<<endl;
  return 0;
}

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

typedef long long int   ll;
typedef pair<ll, ll>    pll;
typedef pair<int, int>  pii;

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'

ll pw(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
    return pw(a * a % mod, b / 2, mod) % mod;
}

const ll N    = 1e5 + 10;
const ll MOD  = 1e9 + 7;
const ll INF  = 1e18;

int n, A[N], even, odd, one, ind;

bool solve() {
    odd = even = ind = 0;
    for (int i = 0; i < n; i++) {
        if (A[i] & 1) {
            odd++;
            ind = i;
            one = (A[i] == 1);
        }
    }
    even = (n - odd) & 1;
    if (one)
        return even;
    if (even)
        return true;
    if (odd > 1)
        return false;
    if (n == 1)
        return false;
    A[ind]--;
    int g = 0;
    for (int i = 0; i < n; i++) {
        g = __gcd(g, A[i]);
    }
    for (int i = 0; i < n; i++) {
        A[i] /= g;
    }
    return !solve();
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    cout << (solve() ? "First" : "Second") << endl;
    return 0;
}

Measured memory_bytes: 4024
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int main()
{
    ll n;

    cin >> n;

    cout << (n-1)*n / 2 << endl;
}


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

int N;
int A[210];

int main(){
    cin >> N;
    for(int i = 0; i < N; ++i) cin >> A[i];

    int res = 0;

    //操作が行える限り操作を繰り返す
    while (true) {
        bool exist_odd = false;
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;
        }
    if  (exist_odd) break;

    //操作が行えるなら操作を実際に行う
    for (int i = 0; i < N; ++i) {
        A[i] /= 2;
    }
    ++res; //操作回数をインクリメント
    }
    cout << res << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void) {
	int d, n;
	
	scanf("%d %d", &d, &n);
	
	if (d == 0 && n == 100)
		printf("101\n");
	else if (d == 1 && n == 100)
		printf("10100\n");
	else if (d == 2 && n == 100)
		printf("1010000\n");
	else
		printf("%d\n", (int)pow(100, d) * n);
	
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int sort(int a, int b,int c);
int main(void)
{
	int a, b, c= 0;
	scanf("%d%d%d", &a,&b,&c);
	sort(a, b, c);
	return 0;
}
int sort(int a,int b,int c)
{
	int temp = 0;
	if (a >= b){
		temp = a;
		a = b;
		b = temp;
	}
	if (b >= c){
		temp = b;
		b = c;
		c = temp;
	}
	if (a >= b) {
		temp = a;
		a = b;
		b = temp;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}


Measured memory_bytes: 2040
#include <vector>
#include <iostream>
#include <set>

using namespace std;
// 人はn人 
// m組の友達関係
// k組のブロック関係
// a, bは友達関係
// c, dはブロック関係
//
//
//

static const int MAX_N = 100001;
int par[MAX_N];
int size[MAX_N];

void init(int n) {
  for(int i=0;i<n;i++) {
    par[i] = i;
    size[i] = 1;
  }
}

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

  int root = find(par[x]);
  size[x] = size[root];
  return par[x] = root;
}

int group_size(int x) {
  int root = find(x);
  return size[root];
}

void unite(int x, int y) {
  int root_of_x = find(x);
  int root_of_y = find(y);
  if(root_of_x == root_of_y)
    return;

  int united_size = size[root_of_y] + size[root_of_x];
  par[root_of_y] = root_of_x;
  size[root_of_x] = united_size;
}

bool same(int x, int y) {
  return find(x) == find(y);
}

vector<int> friend_suggestions(int n, int m, int k, int a[], int b[], int c[], int d[]) {
  init(n);

  vector<set<int>> friends; 
  vector<set<int>> blocks; 
  for(int i=0;i<n;i++) {
    friends.push_back(set<int>());
    blocks.push_back(set<int>());
  }

  for(int i=0;i<m;i++) {
    int aa = a[i] - 1;
    int bb = b[i] - 1;

    unite(aa, bb);
    friends[aa].insert(bb);
    friends[bb].insert(aa);
  }

  for(int i=0;i<k;i++) {
    int cc = c[i] - 1;
    int dd = d[i] - 1;
    blocks[cc].insert(dd);
    blocks[dd].insert(cc);
  }
  /*
  cout << "Friends group size ======" << endl;
  for(int i=0;i<n;i++) {
    cout << i << " size -> " << group_size(i) << endl;
  }
  cout << "=========================" << endl;
  */
  vector<int> ans;
  for(int i=0;i<n;i++) {

    int num_of_friends_in_group = 0;
    for(auto iter = friends[i].begin(); iter != friends[i].end();iter++) {
      if(same(i, *iter)) {
	  num_of_friends_in_group++;
      }
    }
    // cout << i << " -> direct_friends_num: "  << num_of_friends_in_group << endl;

    int num_of_blocks_in_group = 0;
    for(auto iter = blocks[i].begin(); iter != blocks[i].end();iter++) {
      if(same(i, *iter)) {
	  num_of_blocks_in_group++;
      }
    }
    // cout << i << " -> direct_block_num: "  << num_of_blocks_in_group << endl;
    int g_size = group_size(i);
    ans.push_back(g_size - 1 - num_of_friends_in_group - num_of_blocks_in_group);
  }

  return ans;
}

int main() {
  int n, m, k;
  cin >> n;
  cin >> m;
  cin >> k;

  int a[m], b[m];
  for(int i=0;i<m;i++) {
    cin >> a[i];
    cin >> b[i];
  }

  int c[k], d[k];
  for(int i=0;i<k;i++) {
    cin >> c[i];
    cin >> d[i];
  }

  vector<int> ans = friend_suggestions(n, m, k, a, b, c, d);
  for(int i = 0; i<n;i++) {
    cout << ans[i];
    if(i != n-1) {
      cout << " ";
    }
  }
}

Measured memory_bytes: 34460
/*
                                Bismillahi-r-Rahmani-r-Rahim
                                        RhIeyAaD
                                    IIT-7th Batch,JU
*/
#include<bits/stdc++.h>
using namespace std;

#define pf(a)           printf("%lld\n", a)
#define sf(a)           scanf("%lld", &a)
#define line(a)         getline(cin,(a))
#define ll              long long int
#define MAX             2134567891
#define MID(l,r)        (l+r)>>1
#define fr(i,n)         for(i=0;i<n;i++)
#define rep(i,n)        for(i=1;i<=n;i++)
#define per(i,a,n)      for(i=n;i>=a;i--)
#define FOR(i,a,n)      for(i=a;i<=n;i++)
#define ALL(n)          n.begin(),n.end()
#define mem(x,n)        memset(x,n,sizeof(x))
#define T_C(t)          printf("Case %lld: ",t)
#define TC(t)           printf("Case %lld:\n",t)
#define ans(t,c)        printf("Case %lld: %lld\n",t,c)
#define SETP(n)         cout<<setprecision(n)<<fixed
#define READ            freopen("F:\\Project\\Test_Case.txt","r",stdin)
#define WRITE           freopen("F:\\Project\\Output_Test.txt","w",stdout)
#define IO              ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define PAIR            pair<ll,ll>
#define MP              make_pair
#define pb(a)           push_back(a)
#define ff              first
#define ss              second
#define MOD             1000000007///10^9
#define p6              1000007 ///10^6->6 zero after 1 **
#define hlw             printf("hlw\n");
#define SN              4*p6
#define NN              111
#define N               p6

ll x[N],y[N],z[N],n;
string s,S;
vector<ll>v;
//map <ll,ll> mp;

int main()
{
    //IO;
    //while(1)
    //READ;WRITE;
{
    ll a=0,b=0,c=0,d,e,f,g,i,j,k,l,m,p,q,r,u,w,t,tc,in,mod,loc,diff,val,sz,lo,hi,mid,mn=MAX,mx=0,sum=0,ans=0;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])cout<<"Yes\n";
    else cout<<"No\n";
}
    return 0;
}

/*

*/
/// Check for constraint 0 or 1?
/// long long or double? sqrt or division will work fine??


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define pii 3.14
#define mod (ll)(1e9+7)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(1e5 + 5)

void solve()
{
    string s;
    cin>>s;

    ll sum = 0;
    for(char el : s)
        sum += (el-'0');
    if(sum%9)
        cout<<"No";
    else
        cout<<"Yes";
}

int main()
{
    fio;
    ll tc = 1;
    //cin>>tc;
    while(tc--)
    {
        solve();
    }
}


Measured memory_bytes: 3744
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <iterator>
#include <algorithm>

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

multiset<int> AA;
int result = 0;

void findAndReduce() {
    while (!AA.empty()) {
        auto itr = AA.rbegin();
        auto a = *itr;
        //itrを削除
        AA.erase(AA.find(a));
        int tw = 1;
        for (int i = 1; i < 40; ++i) {
            tw *= 2;
            if(tw > a){
                break;
            }
        }
        auto b = tw - a;
        auto itr2 = AA.find(b);
        if (itr2 == AA.end()) {
            continue;
        }
        AA.erase(itr2);
        result++;
    }
}

int main() {

    int N;
    cin >> N;

    for (int i = 0; i < N; ++i) {
        int n;
        cin >> n;
        AA.insert(n);
    }


    findAndReduce();

    cout << result << endl;


    return 0;
}

Measured memory_bytes: 9600
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.immutable._
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}

object Main {
  def solve(sc: => Scanner): Unit = {
    println("ai1333" + (new String(new Array[Char](sc.nextInt / 100)).replace("\0", "3")))
  }

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}


Measured memory_bytes: 45092
#include <bits/stdc++.h>
#define LL               long long
#define PB               push_back
using namespace std;
int main (){
  int n; cin>>n;
  if (n<600) cout<< 8 ;
  else if (n<800) cout<<7  ;
  else if (n<1000) cout<<6  ;
  else if (n<1200) cout<< 5 ;
  else if (n<1400) cout<< 4 ;
  else if (n<1600) cout<< 3;
  else if (n<1800) cout<<2  ;
  else cout<< 1 ;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll A, B;
  cin >> A >> B;
  ll g = __gcd(A,B);
  ll s = g;
  ll ans = 1;
  for(int i=2; i<=sqrt(s); i++){
    if(g%i==0){
      ans+=1;
      while(g%i==0){
        g/=i;
      }
    }
  }
  if(g>1){
    ans++;
  }
  cout << ans;
  
}


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

int main() {
  vector<string> V(7);
  V = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
  string S;
  cin >> S;
  for (int i = 0; i < 7; i++) {
    if (S == V.at(i)) return cout << 7 - i << "\n", 0;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
int main()
{
	ll n,m,v,p;
	cin >> n >> m >> v >> p;
	vector<ll> a(n);
	for(int i = 0;i<n;i++)cin >> a[i];
	ll L = 0,R = n;
	sort(a.rbegin(),a.rend());
	while(R-L>1)
	{
		ll M = (L+R)/2;
		ll cost = m*v;
		vector<P> b(n);

		for(int i = 0;i<n;i++)
		{
			b[i].first = a[i];
			b[i].second = m;
		}
		b[M].first  += m;
		b[M].second = 0;
		cost -= m;
		ll x = b[M].first;
		sort(b.begin(),b.end());
		//Mで均す
		for(int i = 0;i<n;i++)
		{
			if(x <= b[i].first)continue;
			ll now = min(cost,x-b[i].first);
			now = min(now,b[i].second);
			b[i].second -= now;
			b[i].first += now;
			cost -= now;
		}
		for(int i = 0;i<n;i++)
		{
			if(x < b[i].first)
			{
				ll now = min(cost,b[i].second);
				b[i].first+=now;
				b[i].second -= now;
				cost -= now;
			}
		}
		sort(b.rbegin(),b.rend());
		for(int i = 0;i<n;i++)
		{
			ll now = min(cost,b[i].second);
			b[i].first+=now;
			b[i].second -= now;
			cost-=now;
		}
		sort(b.rbegin(),b.rend());
		//cout << M << "x="<<x<<endl;
		//cout << "L R" << L <<' ' << R << endl;
		//cout << b[p-1].first << endl;
		//for(int i = 0;i<n;i++)cout << b[i].first << ' ' ;cout << endl;
		if(b[p-1].first<=x)L = M;
		else R= M;
	}
	cout << R << endl;
}


Measured memory_bytes: 5636
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long


void solve()
{
   int n;
   cin>>n;
   int cnt=0;
   int a=-1,b=-1;
   
   for(int i=0;i<n;i++)
   {
        int x,y;
        cin>>x>>y;
        
        
        if(x==y)
        {
            cnt++;
        }
        else
        {
            if(cnt>=3)
            {
                 cout<<"Yes";
                 return;
            }
            cnt=0;
        }
   }
   
   if(cnt>=3)
   {
       cout<<"Yes";
       return;
   }
   
   
   cout<<"No";
}

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
	int t=1;
//	cin>>t;
	while(t--)solve();
	    
   
}

Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<bitset<2000> > win(n);
    for(int i=1; i<n; ++i){
        string s;
        cin >> s;
        for(int j=0; j<i; ++j){
            if(s[j] == '1')
                win[i][j] = true;
            else
                win[j][i] = true;
        }
    }

    vector<bitset<2000> > dpl(n), dpr(n);
    for(int i=0; i<n; ++i)
        dpl[i][i] = dpr[i][i] = true;
    for(int len=1; len<n; ++len){
        for(int i=len; i<n; ++i)
            dpr[i-len][i] = (dpr[i-len] & dpl[i-1] & win[i]).any();
        for(int i=0; i+len<n; ++i)
            dpl[i+len][i] = (dpl[i+len] & dpr[i+1] & win[i]).any();
    }

    bitset<2000> ans = dpl[n-1] & dpr[0];
    cout << ans.count() << endl;

    return 0;
}


Measured memory_bytes: 1920
#include <stdio.h>
#include <math.h>
int main(void){
    int num, temp, i, j, count = 0;
    
    scanf("%d", &num);
    
    for(i = 0; i < num; i++){
        scanf("%d", &temp);
        for(j = 2; j <= sqrt(temp); j++){
            if(temp % j == 0) break;
        }
        if(j > sqrt(temp) || sqrt(temp) < 2) count++;
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    string s, t;
	ll cal = 0;
    cin >> s >> t;
    ll n = s.length();
    for (ll i = 0; i<n; i++){
    	if (s[i]==t[i]) cal++;
	}
	cout << cal;
	return 0;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

const ll INF = 1LL << 60;

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;}


int main() {
  int n;cin>>n;
  map<int,int> cnt;
  rep(i,n){int a;cin>>a;cnt[a-1]++;cnt[a+1]++;cnt[a]++;}
  int ans=1;
  for(auto x:cnt)chmax(ans,x.second);
  cout<<ans;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}

class UnionFind
{
public:
    vector<ll> par; // 各元の親を表す配列
    vector<ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL)
    {
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_)
    {
        siz.assign(sz_, 1LL); // assign: 再代入
        par.resize(sz_);      // resize: 再確保
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x)
    { // 根の検索
        while (par[x] != x)
        {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y])
            swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y)
    { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x)
    { // 素集合のサイズ
        return siz[root(x)];
    }
};

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;
}

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

////////////////////////////////////////

const ll mod = 1e9 + 7;

////////////////////////////////////////

int main(){
    int X, A;
    cin >> X >> A;
    if(X<A) cout << "0" << endl;
    else cout << "10" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
namespace atcoder
{
    class Program
    {
        static void Main()
        {
            var A = new ReadLine();
            var d = A.B();
            for (int i = 0; i < 1500; i++)
            {
                if (d[0]== Math.Floor(i * 0.08) && d[1] == Math.Floor(i * 0.1))
                {
                    Console.WriteLine(i);
                    break;
                }
                if (i == 1300)
                {
                    Console.WriteLine("-1");

                }
            }

        }
        
    }

    class ReadLine
    {
        public int Number()
        {
            int vs = int.Parse(Console.ReadLine());
            return vs;
        }
        public int[] B()
        {

            int[] vs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            return vs;
        }
        public string[] C()
        {

            string[] vs = Console.ReadLine().Split(' ').ToArray();
            return vs;
        }
    }
}

Measured memory_bytes: 13396
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var cards = { "S":[] , "H":[], "C":[], "D":[] };
  var shcd = [ 'S', 'H', 'C', 'D' ];
  for( var key in cards ) {
    for( var i=1; i<=13; i++ ) {
      cards[key].push( i );
    }
  }
  var data = input.split( '\n' );
  
  for( var i=1; i<data.length; i++ ) {
    var p = data[i].split( ' ' );
    var k = 'S';
    if( 'S' == p[0] ) {
      k = 'S';
    } else if( 'H' == p[0] ) {
      k = 'H';
    } else if( 'C' == p[0] ) {
      k = 'C';
    } else if( 'D' == p[0] ) {
      k = 'D';
    }
    var res = cards[k].indexOf( Number( p[1] ) );
    if( -1 != res ) {
        cards[k].splice( res, 1 );
    }
  }
  for( var i=0; i<4; i++ ) {
    for( var j = 0; j<cards[ shcd[i] ].length; j++ ) {
      console.log( shcd[i]+" "+cards[ shcd[i] ][j] );
    }
  }
});

Measured memory_bytes: 7640
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int N;
	int d[99];
	int num[100] = {0}; // 1 <= d_i <= 100
	int answer = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> d[i];
		num[d[i]]++;
	}

	for (int j = 1; j <= 100 ; j++) {
		if (num[j] > 0) {
			answer++;
		}
	}
	
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define BUF_SIZE 4096
int main(void) {
  char line[BUF_SIZE];
  FILE* fp;
  fp = stdin;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int num, i;
  sscanf(line, "%d", &num);
  //int arr[200] = {0};
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  char* tmpbuf = line;
  int min = 100;
  for(i = 0; i < num; i++) {
    char *tmp = strtok(tmpbuf, " ");
    int m = strtol(tmp, NULL, 10);
    int power = 0;
    while((!(m&1)) && m != 0) {
      m >>= 1;
      power++;
    }
    if(power < min) min = power;
    if(min==0) break; // cut-break;
    tmpbuf = NULL;
  }
  printf("%d\n", min);
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            if (!IsCirculation(s))
            {
                Console.WriteLine("No");
            }
            else if (!IsCirculation(s.Substring(0, (s.Length - 1) / 2)))
            {
                Console.WriteLine("No");
            }
            else if (!IsCirculation(s.Substring((s.Length + 2) / 2)))
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }

        private static bool IsCirculation(string str)
        {
            var isEven = str.Length % 2 == 0;
            var halfCnt = str.Length / 2;
            if (isEven)
            {
                return str.Substring(0, halfCnt) == new string(str.Substring(halfCnt)
                    .Reverse().ToArray());
            }

            return str.Substring(0, halfCnt) == new string(str.Substring(halfCnt + 1).Reverse().ToArray());
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  int N;cin>>N;
  int ans=0;
  std::vector<int> a(N),b(N);
  for(int i=0;i<N;i++)cin>>a[i]>>b[i];
  bool nn=1;for(int i=0;i<N;i++)if(a[i]!=b[i])nn=0;if(nn){cout<<0<<endl;return 0;}
  for(int i=0;i<N;i++)ans+=b[i];
  int m=LINF;
  for(int i=0;i<N;i++)if(a[i]>b[i])m=min(m,b[i]);
  ans-=m;cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n, t[200010];
long long a[200010], x[200010], ans;
int main () {
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) scanf ("%lld", &a[i]), a[i] += a[i - 1], x[i] = a[i];
	sort (x + 1, x + n + 1);
	for (int i = 1; i <= n; i++) {
		if (a[i] == 0) ans++;
		a[i] = lower_bound (x + 1, x + n + 1, a[i]) - x;
		ans += t[a[i]]; t[a[i]]++;
	}
	printf ("%lld\n", ans);
	return 0;
}

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

int main(){
  int a,b,c,d,e,k;
  int s[55];
  bool bl=true;
  cin>>s[0]>>s[1]>>s[2]>>s[3]>>s[4]>>k;
  for(int i=0;i<4;++i){
    for(int j=i+1;j<5;++j){
      if(abs(s[i]-s[j])>k)bl=false;
    }
  }
  if(bl)cout<<"Yay!";
  else cout<<":(";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
const ll maxSum = 50*50+1;
int main() {
    ll N ;
    cin >> N ;
    ll a[N] ;
    for(ll i = 0 ; i < N ; i++){
        cin >> a[i] ;
    }
     
    sort(a , a+N);
    ll ans = 0 ;
    for(ll l = 0 ; l < N ; l++){
        for(ll j = l+1 ; j < N ; j++ ){
            for(ll k = j+1 ; k < N ; k++){
                //cout << l << " " << j << " " << k << endl;;
                if((a[l] + a[j]) > a[k]){
                    if(a[j] != a[l] &&a[j] != a[k]&&a[k] != a[l]){
                    if(l != k && k != j && l != j ){
                    ans++ ;
                    
                    }
                    }
                }
            }
        }
    }
    cout << ans  << endl;
   
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int MOD = 1000000007;
const int N = 100005;

int r, res, i, j, n, x, tab[N], p[N], p2[N], pp, pp2;

int inverse(int a, int n = MOD - 2) {
	int r = 1;
	while (n) {
		if (n % 2) r = (r * 1LL * a) % MOD;
		a = (a * 1LL * a) % MOD;
		n >>= 1;
	}
	return r;
}


int main() {
scanf("%d %d", &n, &x);
for (i=0;i<n;i++) scanf("%d", &tab[i]);
sort(tab, tab + n);

for (i=0;i<x;i++) p[i] = 0;
p[x] = 1;

for (i=n-1;i>=0;i--) {
	pp = inverse(i + 1);
	pp2 = (pp * 1LL * i) % MOD;
	for (j=0;j<=x;j++) if (p[j] > 0) {
		p2[j % tab[i]] = ((pp * 1LL * p[j]) + p2[j % tab[i]]) % MOD;
		p2[j] = ((pp2 * 1LL * p[j]) + p2[j]) % MOD;
	}
	for (j=0;j<=x;j++) {
		p[j] = p2[j];
		p2[j] = 0;
	}
}
r = 1;
for (i=2;i<=n;i++) r = (r * 1LL * i) % MOD;
res = 0;
for (j=1;j<=x;j++) res = ((((r * 1LL * p[j]) % MOD) * j) + res) % MOD;
printf("%d\n", res);
return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
//ABC166E;ペア探索問題
int main(){
	int num, height[200001] = {};  
	long long int ans = 0;

	scanf("%d", &num);
	for(int member_i = 1; member_i <= num; member_i++){
		int h_temp;
		scanf("%d", &h_temp);

		//Lend_iとRend_jが等しい(i, j)が求めるペア
		int Lend_i = member_i - h_temp;
		int Rend_i = member_i + h_temp;

		//[Rend_i=Lend_j -> i<j]に注意
		if(Lend_i > 0)
			ans += height[Lend_i];
		if(Rend_i < num)
			height[Rend_i]++;
	}

	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 2516
/*
    Problem 37
    https://onlinejudge.u-aizu.ac.jp/problems/DPL_1_A
*/
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>
using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int MAX = 50005;
/* global variables */
vector<int> dp(MAX, 0);
/* function */
/* main */
int main(){
    int N, M;
    cin >> M >> N;
    vector<int> coins(N + 1, 0);
    for (int i = 1; i <= N; i++) cin >> coins[i];
    for (int m = 1; m <= M; m++) {
        if (m >= coins[1]) dp[m] = dp[m - coins[1]] + 1;
    }
    for (int m = 1; m <= M; m++) {
        for (int i = 2; i <= N; i++) {
            if (m >= coins[i]) dp[m] = min(dp[m], dp[m - coins[i]] + 1);
        }
    }
    cout << dp[M] << '\n';
}



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

int n;
string s;
int sub(int k) {
  int l[26]{}, r[26]{};
  for (int i = 0; i < k; ++i) {
    ++l[s[i] - 'a']; 
  }
  for (int i = k; i < n; ++i) {
    ++r[s[i] - 'a']; 
  }
  int sum = 0;
  for (int i = 0; i < 26; ++i) {
    sum += (l[i] > 0 && r[i] > 0);
  }
  return sum;
}

int main() {
  cin >> n >> s;
  int mx = 0;
  for (int i = 1; i < n; ++i) {
    mx = max(mx, sub(i));
  }
  cout << mx << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

class Card 
{
public:
    char c_suit;
    int c_value;
};

void bubble(Card a[], int n) 
{
    for (int i = 0; i < n; i++) {
        for ( int j = n - 1; j >= i; j--) {
            if ( a[j].c_value < a[j - 1].c_value ) {
                Card t = a[j];
                a[j] = a[j - 1];
                a[j - 1] = t;
            }
        }
    }
}

void selection(Card a[], int n) 
{
    for ( int i = 0; i < n; i++ ) {
        int minj = i;
        for (int j = i; j < n; j++ ) {
            if ( a[j].c_value < a[minj].c_value ) {
                minj = j;
            }
        }
        Card t = a[i];
        a[i] = a[minj];
        a[minj]  = t;
    }
}

    
void print(Card a[], int n) 
{
    for ( int i = 0; i < n; i++ ) {
        if (i > 0) cout << " ";
        cout << a[i].c_suit << a[i].c_value;
    }
    cout << endl;
}

bool isStable(Card c1[], Card c2[], int n)
{
    for (int i = 0; i < n; i++ ) {
        if ( c1[i].c_suit != c2[i].c_suit) {
            return false;
        }
    }
    return true;
}

int main()
{
    Card c1[100], c2[100];
    int n;
    char ch;

    cin >> n;
    for ( int i = 0; i < n; i++) {
        cin >> c1[i].c_suit >> c1[i].c_value;
    }

    for (int i = 0; i < n; i++ ){
        c2[i] = c1[i];
    }

    bubble(c1, n);
    selection(c2, n);

    print(c1, n);
    cout << "Stable" << endl;

    print(c2, n);
    if (isStable(c1, c2, n)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
#include <ctype.h>
	int data[100];
	int sp=0;
	
	int empty(){
		return sp <= 0;
	}
	
	int top(){
		return data[sp-1];
	}
	
	void pop(){
		sp--;
	}
	
	void push(int v){
		data[sp] = v;
		sp++;
	}
	
	int main(){
		int v, t;
		while(scanf("%d",&v) !=EOF){
			if(v!=0){
				push(v);
			} else{
				t=top();
				printf("%d\n",t);
				pop();
			}
		}
	}

Measured memory_bytes: 1744
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

N, M = map(int, input().split())
S = input()
T = input()

a = lcm(N, M)
b = lcm(a//N, a//M)

l = [0]
tmp = 0
while tmp < a:
    tmp += b
    if tmp < a:
        l.append(tmp)

#print(a, b, l)

check = 0

for i in range(len(l)):
#    print(S[l[i]//(a//N)], T[l[i]//(a//M)])
    if S[l[i]//(a//N)] == T[l[i]//(a//M)]:
        pass
    else:
        check = 1 

if check == 0:
    ans = a
else:
    ans = -1

print(ans)

Measured memory_bytes: 6240