akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

struct edge {
    int to,cost;
    edge(int to,int cost) :
        to(to),cost(cost){}
};
struct state {
    int time,idx,ice_time;
    state(int time,int idx,int ice_time) :
        time(time),idx(idx),ice_time(ice_time){}
    bool operator>(const state& rth) const {
        this->time>rth.time;
    }
};
vector<edge> G[102];

int N,M,L,K,A,H;
bool ice[102];

// A->H
int dijk() {
    int d[102][102];
    rep(i,102) rep(j,102) d[i][j]=INF;
    d[A][M]=0;

    priority_queue<state,vector<state>,greater<state> > que;
    que.push(state(0,A,M));

    while(que.size()) {
        state s=que.top(); que.pop();
        int v=s.idx;
        int ice_time=s.ice_time;
        if(d[v][ice_time]<s.time) continue;

        if(ice[v]) {
            rep(i,G[v].size()) {
                edge e=G[v][i];
                for(int t=ice_time;t<=M;t++) {
                    if(t-e.cost>=0 && d[v][ice_time]+e.cost+t-ice_time<d[e.to][t-e.cost]) {
                        d[e.to][t-e.cost]=d[v][ice_time]+e.cost+t-ice_time;
                        que.push(state(d[e.to][t-e.cost],e.to,t-e.cost));
                    }
                }
            }
        }
        else {
            rep(i,G[v].size()) {
                edge e=G[v][i];
                if(ice_time-e.cost>=0 && d[v][ice_time]+e.cost<d[e.to][ice_time-e.cost]) {
                    d[e.to][ice_time-e.cost]=d[v][ice_time]+e.cost;
                    que.push(state(d[e.to][ice_time-e.cost],e.to,ice_time-e.cost));
                }
            }
        }
    }
    int res=INF;
    rep(i,102) res=min(res,d[H][i]);

    return res;

}

void solve() {
    rep(i,102) ice[i]=false;
    rep(i,102) G[i].clear();
    rep(i,L) {
        int a; cin>>a;
        ice[a]=true;
    }
    rep(i,K) {
        int a,b,c;
        cin>>a>>b>>c;
        G[a].pb(edge(b,c));
        G[b].pb(edge(a,c));

    }

    int ans=dijk();
    if(ans==INF) cout<<"Help!"<<endl;
    else cout<<ans<<endl;

}

int main() {
    while(cin>>N>>M>>L>>K>>A>>H) {
        if(N==0) break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 1468
/// DONOT COPY PASTA WITHOUT AUTHOR'S PERMISSION ///
 ///                   S S S                      ///
///                1 7 0 7 0 5 3                 ///

#include<bits/stdc++.h>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <stdlib.h>
#include<string>
///STL
#define mp make_pair
#define ss second
#define ff first
#define pb push_back
#define ist insert
///ONLINE JUDGE
#define io ios_base::sync_with_stdio;cin.tie(0);cout.tie(0)
#define READ freopen("input.txt","r", stdin)
#define case(i) "Case "<<i++<<": "
#define nscase(i) "Case "<<i++<<":"
///c shortcuts
#define sns(s) scanf("%s",&s)
#define snc(c) scanf("%c",&c)
#define snd(a) scanf("%d",&a)
#define snl(a) scanf("%lld",&a)
#define snul(a) scanf("%ull",&a)
///Loops
#define mem(a,b) memset(a, b, sizeof(a))
#define rep(i,k,n) for(int i=k;i<n;i++)
#define rev(j,n,k) for(int j=n;j>=k;j--)
#define TC int tc;cin>>tc;while(tc--)

///GCD LCM
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a / __gcd(a, b) ) * b)

///CONSTANTS
#define PI 2*acos(0.0)
#define MAX 1000000000
#define inf 1e18

///functions
#define base(n,b) floor(log(n)/log(b))+1
#define onecnt(x) __builtin_popcount(x)
#define to_binary(n,b) bitset<b>(n).to_string()

#define endl '\n'
#define esc cout<<"\n"

/*------------------------------Graph Moves----------------------------*/
///const int fx[]= {+1,-1,+0,+0};
///const int fy[]= {+0,+0,+1,-1};
///const int fx[]= {+0,+0,+1,-1,-1,+1,-1,+1};  // Kings Move
///const int fy[]= {-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
///const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
///const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef std::map<long long,int> mli;
typedef std::map<long long,long long> mll;
typedef std::map<int,int> mii;

///PBDS
using namespace __gnu_pbds;
typedef tree<
ll,
null_type,//set to another type while using map
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;

template <typename T>
std::string toString( T Number )
{
    std::ostringstream ss;
    ss << Number;
    return ss.str();
}

///constants
const ll ten5=100000;
const ll ten6 =1000000;
const ll ten7 =10000000;
const ll ten8 =100000000;
const ll ten9 =1000000000;
const ll mod=ten9+7;



int main()
{
    io;

   int n;
   cin>>n;

   map<string,int>m;
   map<string,int>::iterator it;
   string s;
   int mx=-100;
   for(int i=0;i<n;i++){
        cin>>s;
        m[s]++;
        mx=max(m[s],mx);
   }
   vector<string>ans;

   for(it=m.begin();it!=m.end();it++){
    if(it->ss==mx) ans.pb(it->ff);
   }
   sort(ans.begin(),ans.end());

   for(int i=0;i<ans.size();i++){
    cout<<ans[i]<<endl;
   }
}



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

int main(void) {
    int n;
    scanf("%d", &n);
    char s[n][101];
    int t[n];
    for (int i = 0; i < n; i++) {
        scanf("%s", s[i]);
        scanf("%d", &t[i]);
    }
    char x[101];
    scanf("%s", x);

    int k = 0, flag = 0;
    for (int i = 0; i < n; i++) {
        if (strcmp(x, s[i]) == 0) {
            k = i+1;
            break;
        }
    }
    int ans = 0;
    for (int i = k; i < n; i++) {
        ans += t[i];
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<list>
using namespace std;


queue<char> q;
int m, h;
string s;
char ch;



int main(){
    while (cin >> s && s != "-") {
        q = queue<char>();
        for (int i = 0; i < s.size(); i++) {
            q.push(s[i]);
        }
        cin >> m;
        for (int i = 0; i < m; i++) {
            cin >> h;
            while (h != 0) {
                ch = q.front(); q.pop();
                q.push(ch);
                h--;
            }
        }
        while (!q.empty()) {
            cout << q.front();
            q.pop();
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
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;}

const int INF = 100000; 

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

    int dp[20];
    for(int i = 1; i <= n; i++) dp[i] = INF;
    dp[0] = 1;
    for(int i = 1; i <= n; i++){
        chmin(dp[i], dp[i-1] + k);
        chmin(dp[i], dp[i-1] * 2);
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define boido void
#define innto int
#define suitti switch
#define keesu case
#define bureeku break
#define meinn main
#define chaa char
#define foa for
#define ifu if
#define ritaann return
#define sukyannefu scanf
#define purinntoefu printf

boido kaitenn(innto daisu[6], innto komanndo) {
	innto tennpu;
	suitti (komanndo) {
		keesu 'E':
			tennpu = daisu[0];
			daisu[0] = daisu[3];
			daisu[3] = daisu[5];
			daisu[5] = daisu[2];
			daisu[2] = tennpu;
			bureeku;
		keesu 'N':
			tennpu = daisu[0];
			daisu[0] = daisu[1];
			daisu[1] = daisu[5];
			daisu[5] = daisu[4];
			daisu[4] = tennpu;
			bureeku;
		keesu 'S':
			tennpu = daisu[0];
			daisu[0] = daisu[4];
			daisu[4] = daisu[5];
			daisu[5] = daisu[1];
			daisu[1] = tennpu;
			bureeku;
		keesu 'W':
			tennpu = daisu[0];
			daisu[0] = daisu[2];
			daisu[2] = daisu[5];
			daisu[5] = daisu[3];
			daisu[3] = tennpu;
			bureeku;
	}
}

innto meinn(boido) {
	innto daisu[6];
	chaa komanndo[128];
	innto ai;
	foa (ai = 0; ai < 6; ai++) {
		ifu (sukyannefu("%d", &daisu[ai]) != 1) ritaann 1;
	}
	ifu (sukyannefu("%127s", komanndo) != 1) ritaann 1;
	foa (ai = 0; komanndo[ai] != '\0'; ai++) {
		kaitenn(daisu, komanndo[ai]);
	}
	purinntoefu("%d\n", daisu[0]);
	ritaann 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  string O, E;
  cin >> O >> E;
  for (int i = 0; i < O.size(); i++) {
    cout << O.at(i);
    if (i < E.size()) {cout << E.at(i);}
  }
}

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

using namespace std;

typedef long long int ll;
#define pb push_back
#define ALL(a) (a).begin() , a.end()

int mod = 1e9 + 7;
int add(int a, int b){
	if(a + b >= mod)return a+ b - mod;
	return a + b;
}
int mul(int a, int b){
	return 1LL * a * b  % mod;
}
int const N = 200 * 1010;

/********************i**********************************/
void solve(){
	int a, b;
	cin >> a >> b;
	if(a == b){cout << "Yes\n";
	}
	else cout << "No\n";
}

/******************************************************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int t;
	t = 1;
	// cin >> t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        vector<int> a(n);
        for (int i = 0; i < n; i ++) {
                scanf("%d", &a[i]);
        }
        int cnt = 1;
        vector<int> b;
        for (int i = 1; i < n; i ++) {
                if (a[i - 1] == a[i]) {
                        cnt ++;
                } else {
                        b.push_back(cnt);
                        cnt = 1;
                }
        }
        b.push_back(cnt);
        int ans = 0;
        for (int i = 0; i < (int) b.size(); i ++) {
                ans += b[i] / 2;
        }
        printf("%d\n", ans);
        return 0;
}



Measured memory_bytes: 256
'use strict';
const main = val => {
  const s = val[0].trim();
  const t = val[1].trim();
  let ans = 0;
  for (let i = 0; i < s.length; i++) {
    if (s[i] == t[i]) ans++;
  }
  console.log(ans);
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 9420
program sample
	implicit none
    character(100) ::word
    integer :: count,a
    
    read(*,*) word
    
    a=len_trim(word)
    
    if (word(a-6:a) == 'keyence') then
    	write(*,*) 'YES'
    else if (word(1:1) == 'k' .and. word(a-5:a) == 'eyence') then
    	write(*,*) 'YES'
    else if (word(1:2) == 'ke' .and. word(a-4:a) == 'yence') then
    	write(*,*) 'YES'
    else if (word(1:3) == 'key' .and. word(a-3:a) == 'ence') then
    	write(*,*) 'YES'
    else if (word(1:4) == 'keye' .and. word(a-2:a) == 'nce') then
    	write(*,*) 'YES'
    else if (word(1:5) == 'keyen' .and. word(a-1:a) == 'ce') then
    	write(*,*) 'YES'
    else if (word(1:6) == 'keyenc' .and. word(a:a) == 'e') then
    	write(*,*) 'YES'
    else if (word(1:7) == 'keyence') then
    	write(*,*) 'YES'
    else
    	write(*,*) 'NO'
    end if
    
    stop
end program sample

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 262144
long long geko = 1;
vector<pair<long long, long long>> wow;
int main() {
	iostream::sync_with_stdio(false);
	cin.tie(0);
#define int long long
	long long n, k;
	cin >> n >> k;
	REP(i, n) {
		long long a, b;
		cin >> a >> b;
		wow.push_back(make_pair(a, b));
	}
	sort(wow.begin(), wow.end());
	long long ans = 0;
	while (geko <= k) {
		geko *= 2;
	}
	geko /= 2;
	vector<int> nya;
	while (k != 0) {
		nya.push_back(k % 2);
		k /= 2;
	}
	long long stock = 0;
	reverse(nya.begin(), nya.end());
	for (int i = 0;i < nya.size();++i) {
		if (nya[i] == 1) {
			long long biting = geko - 1 + stock;
			long long pre_ans = 0;
			for (int q = 0;q < wow.size();++q) {
				if ((wow[q].first & biting) == wow[q].first) {
					pre_ans += wow[q].second;
				}
			}
			stock += geko;
			ans = max(ans, pre_ans);
		}
		else {
			long long biting = stock;
			long long pre_ans = 0;
			for (int q = 0;q < wow.size();++q) {
				if ((wow[q].first & biting) == wow[q].first) {
					pre_ans += wow[q].second;
				}
			}
			ans = max(ans, pre_ans);
		}
		geko /= 2;
	}
	long long biting = stock;
	long long pre_ans = 0;
	for (int q = 0;q < wow.size();++q) {
		if ((wow[q].first & biting) == wow[q].first) {
			pre_ans += wow[q].second;
		}
	}
	ans = max(ans, pre_ans);
	cout << ans << endl;
	return 0;
}

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

const int INF=(1<<21);


int main(void){
    int n,m; cin >> n >> m;
    int c[m+1], dp[m+1][n+1];

    c[0]=0;
    for(int i=1; i<=m; i++) cin >> c[i];

    for(int i=0; i<=m; i++) dp[i][0]=0;
    for(int j=0; j<=n; j++) dp[0][j]=INF;

    for(int i=1; i<=m; i++){
        for(int j=1; j<=n; j++){
            if(j>=c[i]) dp[i][j]=min(dp[i-1][j], dp[i][j-c[i]]+1);
            else dp[i][j]=dp[i-1][j];
        }
    }

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

}


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

using namespace std;
int din[3005][3005],i,j,n,n1,nr,q;
char s[3005],t[3005],sol[3005];
int main()
{
    cin>>s;
    cin>>t;
    n=strlen(s);
    n1=strlen(t);
    for (i=1;i<=n;i++)
    {
        for (j=1;j<=n1;j++)
        {
            if (s[i-1]==t[j-1])
            {
                din[i][j]=din[i-1][j-1]+1;
            }
            else
            {
                din[i][j]=max(din[i-1][j],din[i][j-1]);
            }
        }
    }
    if (din[n][n1]==0)
    {
        cout<<" ";
        return 0;
    }
    i=n;
    j=n1;
    nr=din[n][n1];
    while (nr)
    {
        if (s[i-1]==t[j-1])
        {
            sol[++q]=s[i-1];
            i--;
            j--;
            nr--;
        }
        else
        {
            if (din[i][j-1]>din[i-1][j])
            {
                j--;
            }
            else
            {
                i--;
            }
        }
    }
    for (i=q;i>=1;i--)
    {
        cout<<sol[i];
    }
    return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

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

int main( void ){
	string S, T;
	cin >> S >> T;
	cout << T << S << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include<cstdio>
    #include<cstring>
    #include<algorithm>
    #define boynextdoor return puts("0"),0
    using namespace std;
    const int N=100005,mod=1000000007;
    int n,x,ans=1,ring[N],to[N],f[N],e[N][2];
    char ch[5000005],*p=ch;
    bool vis[N];
    inline int rd(){
    	register int res=0;
    	while(*p<'0'||*p>'9'){
    		p++;
    	}
    	while(*p>='0'&&*p<='9'){
    		res=res*10+*p-'0';
    		p++;
    	}
    	return res;
    }
    int main(){
    	fread(ch,5000000,1,stdin);
    	n=rd();
    	for(int i=1;i<=n;i++){
    		to[i]=rd();
    		if(!e[to[i]][0]){
    			e[to[i]][0]=i;
    		}else if(!e[to[i]][1]){
    			e[to[i]][1]=i;
    		}else{
    			boynextdoor;
    		}
    	}
    	for(int i=1;i<=n;i++){
    		if(!vis[i]){
    			int now=i,siz=0,last=0,prod=1;
    			bool flag=false;
    			while(!vis[now]){
    				vis[now]=true;
    				now=to[now];
    			}
    			int beg=now;
    			do{
    				siz++;
    				if(e[to[now]][0]!=now){
    					swap(e[to[now]][0],e[to[now]][1]);
    				}
    				now=to[now];
    			}while(now!=beg);
    			do{
    				now=to[now];
    				if(e[now][1]){
    					flag=true;
    					break;
    				}
    			}while(now!=beg);
    			if(!flag){
    				ring[siz]++;
    				continue;
    			}else{
    				beg=now;
    			}
    			do{
    				now=to[now];
    				last++;
    				if(e[now][1]){
    					flag=true;
    					int tmp=e[now][1],dep=0;
    					while(tmp){
    						dep++;
    						vis[tmp]=true;
    						if(e[tmp][1]){
    							boynextdoor;
    						}else{
    							tmp=e[tmp][0];
    						}
    					}
    					if(dep>last){
    						boynextdoor;
    					}else if(dep<last){
    						prod=prod*2%mod;
    					}
    					last=0;
    				}
    			}while(now!=beg);
    			ans=1LL*ans*prod%mod;
    		}
    	}
    	for(int i=1;i<=n;i++){
    		if(!ring[i]){
    			continue;
    		}
    		int flag=(i&1)&&i!=1;
    		f[0]=1,f[1]=flag+1;
    		for(int j=2;j<=ring[i];j++){
    			f[j]=(1LL*f[j-2]*(j-1)%mod*i+(f[j-1]<<flag))%mod;
    		}
    		ans=1LL*ans*f[ring[i]]%mod;
    	}
    	printf("%d\n",ans);
    	return 0;
    }

Measured memory_bytes: 3328
import sys
import math
input = sys.stdin.readline

def factorization(num):
    MAX_PRIME = int(math.sqrt(num)) + 1
    primes = []
    is_prime = [True] * (MAX_PRIME+1)
    for i in range(2, MAX_PRIME+1):
        if is_prime[i]:
            primes.append(i)
            for j in range(2*i, MAX_PRIME+1, i):
                is_prime[j] = False
    insu = []
    tmp = num
    max_count = 0
    for i in range(len(primes)):
        count = 0
        while tmp%primes[i] == 0:
            tmp //= primes[i]
            count += 1
        if count > 0:
            insu.append((primes[i], count))
            max_count = max(max_count, count)
        if tmp == 1:
            break
    if tmp != 1:
        insu.append((tmp, 1))
    return insu, max_count

def main():
    N, M = map(int, input().split())

    MOD = int(1e9) + 7

    insu, max_count = factorization(M)
    
    kai = [1] * (max_count + N)
    for i in range(1, max_count + N):
        kai[i] = (kai[i-1] * i) % MOD
    
    ans = 1
    tmp = pow(kai[N-1], MOD-2, MOD)
    for prime, count in insu:
        ans *= kai[count + N - 1] * tmp * pow(kai[count], MOD-2, MOD)
        ans %= MOD
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 7036
#include <bits/stdc++.h>
    using namespace std;
    #define F first
    #define S second
    #define ll long long
    #define pb push_back
    #define all(X) X.begin(),X.end()
    #define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    ll n,k,a[2010],be,af,ans,mod=1e9+7;
    ll po(ll x,ll y)
    {
        if(y==0)
            return 1;
        if(y&1)
            return (x*po(x,y-1))%mod;
        ll t=po(x,y/2)%mod;
        return (t*t)%mod;
    }
    int main()
    {
        go;
        //cout<<po(3,2)<<endl;
        cin>>n>>k;
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(a[i]>a[j])
                {
                    if(i<j)
                        af++;
                    else
                        be++;
                }
            }
        }
        //cout<<be<<" "<<af<<endl;
        ll x=(k*(k+1)/2)%mod;
        ans=(x*af)%mod;
        ll y=(k*(k-1)/2)%mod;
        ans=(ans+(be*y)%mod)%mod;
        //ans=(ans+)
        ans=(ans%mod+mod)%mod;
        cout<<ans;
        return 0;
    }

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

int main()
{
   int a, b;
    scanf("%d %d", &a, &b);
    
    
    if ((a+b)%3 == 0 or a%3 ==0 or b%3 ==0)
    {
        printf("Possible");
    }
    
    else 
    {
        printf("Impossible");
    }
   return 0;
}

Measured memory_bytes: 256
N = int(input())

dic = [3, 5, 7]

ans = list()
def dfs(s):
    if s:
        if int(s) <= N:
            if len(set(s)) == 3:
                ans.append(s)
        else:
            return
    dfs(s+"3")
    dfs(s+"5")
    dfs(s+"7")

dfs("")
print(len(ans))

Measured memory_bytes: 10964
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {

int a,b;
cin >> a >> b;
cout << a*b << endl;

  return 0;
}


Measured memory_bytes: 3632
L, R = [int(i) for i in input().split()]
min_mod = (L * R) % 2019 

if R - L > 2019:
    min_mod = 0
else :
    for i in range(L, R):
        for j in range(i+1,R+1):
            if min_mod > (i * j) % 2019:
                min_mod =(i * j) % 2019
                if min_mod == 0:
                    break
print(min_mod)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ot(x) cout<<x<<" ";
#define pb push_back
#define in insert
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld long double
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define fa(i,a) for(auto i:a)
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define f1(i,a) for(i=1;i<=a;i++)
#define f2(i,a) for(i=2;i<=a;i++)
#define fy(i,a) for(auto i:a)
#define next cout<<"\n";
#define ull unsigned long long int
#define sp(n) cout<<fixed<<setprecision(n);
#define  gcd(a,b)    __gcd(a,b)
#define bs  binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
#define mod 1000000007


int main()
{
   fast
   ll n,d,i;cin>>n>>d;
   ll x[n],y[n];
   vector< double >v;
   f(i,n){
       cin>>x[i]>>y[i];
       double s=sqrt(pow(x[i],2)+pow(y[i],2));
       v.pb(s);
   }
   double j,c=0;
   f(j,v.size()){
       if(v[j]<=d){
           c++;
       }
   }
   cout<<c;
  return 0;
}




Measured memory_bytes: 8120
var GET = (function () {function f(s) {return new g(s);}function g(s) {this._s = s.trim().split("\n");}g.prototype.getValue = function (n) {return this._s[n];};g.prototype.getArray = function (n) {return this.stoa(this._s[n]);};g.prototype.slice = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stox(v));};g.prototype.sliceArray = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stoa(v));};g.prototype.stoa = function (s) {return s.split(" ").map(v => this.stox(v));};g.prototype.stox = function (v) {var i = +v;return (i === i) ? i : v;};return f;})();
var o = GET(require("fs").readFileSync("/dev/stdin", "utf8"));

function permutation(arr) {
    var permArr = [],
        usedChars = [];
    function permute(input) {
        var i, ch;
        for (i = 0; i < input.length; i++) {
            ch = input.splice(i, 1)[0];
            usedChars.push(ch);
            if (input.length == 0) {
                permArr.push(usedChars.slice());
            }
            permute(input);
            input.splice(i, 0, ch);
            usedChars.pop();
        }
        return permArr
    };

    return permute(arr);
}

console.log(main());
function main(){
    var N = o.getValue(0);
    var locations = o.sliceArray(1);

    var i = 0;

    var result = permutation(locations);

    var sum = 0;
    for(var i = 0; result.length > i; i++) {
        var record = result[i];
        for(var j = 0; record.length > j + 1; j++) {
            sum += Math.sqrt(Math.pow(record[j][0] - record[j + 1][0], 2) + Math.pow(record[j][1] - record[j + 1][1], 2));
        }
    }

    return sum / result.length
}


Measured memory_bytes: 29108
#include <iostream>
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define MAX 1000
using namespace std;
int ans;
int n,m,a,maxr;
struct road{
  int h,p,q;
};
road r[MAX];
int main() {
  while(true){
    cin >> n >> m >> a;
    if(n==0&&m==0&&a==0) return 0;
    maxr = 0;
    rep(i,m){
      r[i] = road();
      cin >> r[i].h >> r[i].p >> r[i].q;
      if(maxr<r[i].h) maxr = r[i].h;
    }
    for(int i = maxr;i>0;i--){
      rep(j,m){
        if(i==r[j].h){
          if(a==r[j].p){
            a = r[j].q;
          }else if(a==r[j].q) a = r[j].p;
        }
      }
    }
    cout << a << endl;
  }
  return 0;
}

Measured memory_bytes: 1172
object Main {
  def main(args: Array[String]): Unit = {
    val Array( nums, dis ) = scala.io.StdIn.readLine.split(" ").map{_.toInt}
    var count = 0

    val dis_2 = dis*dis.toLong
    ( 0 until nums ).foreach{ i =>
      val Array( x, y ) = scala.io.StdIn.readLine.split(" ").map{_.toInt}
      val check_dis = x*x.toLong + y*y.toLong
      if( check_dis <= dis_2 ) count += 1
    }
    println( count )

  }
}

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

const int N = 8;

int n;
pair <int, int> P[N];

void input() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> P[i].first >> P[i].second;
    return;
}

double dis(pair <int, int> p, pair <int, int> q) {
    double d1 = p.first - q.first, d2 = p.second - q.second;
    return sqrt(d1 * d1 + d2 * d2);
}

void solve() {
    cout.precision(10);
    double sum = 0.0;

    int fact = 1;
    for (int i = 1; i <= n; i++)
        fact *= i;

    for (int i = 0; i < fact; i++) {
        double cor = 0.0;
        for (int i = 0; i < n - 1; i++)
            cor += dis(P[i], P[i + 1]);
        //cerr << " ** " << cor << endl;
        sum += cor;

        next_permutation(P, P + n);
    }

    cout << sum / fact << fixed << endl;
    return;
}

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


Measured memory_bytes: 256
var
	i,j,k,n:Longint;
	a:array[1..50]of int64;
	L,ans:int64;
	flag:Boolean;
begin
	read(n);
	for i:=1 to n do read(a[i]);
	while true do begin
		for i:=n downto 2 do begin
			flag:=false;
			for j:=1 to i-1 do begin
				if a[j]<a[j+1]then begin
					L:=a[j];
					a[j]:=a[j+1];
					a[j+1]:=L;
					flag:=true;
				end;
			end;
			if not flag then break;
		end;
		if a[1]<n then break;
		k:=1;
		while(k+1<=n)and(a[k+1]+k>=n)and(a[k]-a[k+1]<=n)do inc(k);
		if k=n then begin
			k:=1;
			while(k+1<=n)and(a[1]-a[k+1]<=k)do inc(k);
		end;
		if k<n then begin
			L:=(a[1]-a[k+1])div(n+1);
			if L<=0 then L:=1;
			inc(ans,L*k);
			for i:=1 to n do begin
				if i>k then inc(a[i],L*k)
				else inc(a[i],L*(k-1-n));
			end;
		end else begin
			L:=a[1]-n+1;
			inc(ans,L*n);
			writeln(ans);
			exit;
		end;
	end;
	writeln(ans);
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in1(x) int x; cin>>x;
#define in2(x, y) int x, y; cin>>x>>y;
#define in3(x, y, z) int x, y, z; cin>>x>>y>>z;
#define in4(x, y, z, w) int x, y, z, w; cin>>x>>y>>z>>w;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
using namespace std;
bool primes[1000001];vi prime; void seive(); int gcd(int a, int b); int power(int x, int y);

int32_t main(void){
	IOS;
	in3(l, r, d);
	int ans = (r/d) - (l/d);
	if(l%d == 0) ans += 1;
	cout<<ans<<endl;
}

void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}
int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}
int power(int x, int y){ int res = 1;x = x % mod; if (x == 0) return 0;
while (y > 0){ if(y & 1) res = (res*x) % mod; y = y>>1; x = (x*x) % mod;} return res;}


Measured memory_bytes: 3608
n=int(input())
from collections import Counter
MOD=10**9+7
#nの素因数分解(O(n**0.5)
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass

ans=Counter()
for i in range(1,n+1):
  tmp=prime_factor(i)
  ans+=Counter(tmp)

res=1
for j in ans.values():
  res*=(j+1)
  res%=MOD
print(res%MOD)

Measured memory_bytes: 41840
h,w = gets.split.map(&:to_i)
map = []
h.times do
  x = gets.chomp.chars
  map << x
end

dp = Array.new(h).map{Array.new(w)}
map[0][0] == "." ? dp[0][0] = 0 : dp[0][0] = 1

for i in 0..(h-1)
  for j in 0..(w-1)
    if i == 0 && j != 0
      dp[i][j] = dp[i][j-1]
      dp[i][j] += 1 if map[i][j-1] == "." && map[i][j] == "#"
    elsif i != 0 && j == 0
      dp[i][j] = dp[i-1][j]
      dp[i][j] += 1 if map[i-1][j] == "." && map[i][j] == "#"
    elsif i != 0 && j != 0
      x = dp[i-1][j]
      x += 1 if map[i-1][j] == "." && map[i][j] == "#"
      y = dp[i][j-1]
      y += 1 if map[i][j-1] == "." && map[i][j] == "#"
      dp[i][j] = [x,y].min
    end
  end

end
puts dp[h-1][w-1]

Measured memory_bytes: 2812
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
# define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ull i=a;i<b;i++)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define trace(s,a) cout<<s<<a,nl
#define MAXN 100002

int main(){
	

    ll n, m;
    cin>>n>>m;
    pair< ll, ll > p[m];
    for(ll i=0; i<m; i++){
    	cin>>p[i].first>>p[i].second;
    }
  	sort(p, p+m);

  	ll l, r;
  	l = p[0].first;
  	r = p[0].second;
  	ll flag = 0;

  	for(ll i=1; i<m; i++){
  		if(p[i].first <= r){
  			if(p[i].second > r){
  				l = p[i].first;
  			}else{
  				l = p[i].first;
  				r = p[i].second;
  			}
  		}else{
  			cout<<0;
  			flag = 1;
  			break;
  		}
  	}
  	if(flag == 0){
  		cout<<r - l + 1;
  	}

}

Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
using ll = long long;

int n, m, s, t;
vector<int> e[100010];
int dp[100010][3];
queue<int> q;
void bfs() {
	dp[s][1] = 1;

	q.emplace(s*3+1);
	while (!q.empty()) {
		int v = q.front() / 3, mod = q.front() % 3;
		q.pop();

		int nc = dp[v][mod] + 1;
		for (int d : e[v])
			if (!dp[d][nc % 3])
				dp[d][nc % 3] = nc, q.emplace(d*3+(nc%3));
	}
}
int main() {
	scanf("%d %d", &n, &m);
	int u, v;
	for (int i = 0; i < m; i++) {
		scanf("%d %d", &u, &v);
		e[u].emplace_back(v);
	}
	scanf("%d %d", &s, &t);
	bfs();
	if (dp[t][1])
		printf("%d\n", (dp[t][1] - 1) / 3);
	else
		printf("-1\n");
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
      int flag=0;
      int n;
      cin>>n;
      int a[n];
      REP(i,n)
      {
        cin>>a[i];
        if(a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0)
        flag++;
      }
      if(flag)cout<<"DENIED";
      else cout<<"APPROVED";
  }
  return 0;
}

Measured memory_bytes: 384
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


int main() {
	int a, p;
	cin >> a >> p;

	ANS((a * 3 + p) / 2);



	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,k,w[109],v[109];
long long dp[109][100009];
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>w[i]>>v[i];
    dp[0][w[0]] = v[0];
    for(int i=1;i<n;i++){
        for(int j=0;j<=k;j++){
            if(j-w[i] >= 0) dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
            else dp[i][j] = dp[i-1][j];
        }
    }
    long long mx = 0;
    for(int i=0;i<=k;i++){
        mx = max(mx,dp[n-1][i]);
    }
    cout<<mx<<endl;
}

Measured memory_bytes: 79360
n=int(input())
x,y=1,1
for i in range(n):
  a,b=map(int,input().split())
  if x%a==0:
    x1=x//a
  else:
    x1=x//a+1
  if y%b==0:
    y1=y//b
  else:
    y1=y//b+1
  z1=max(x1,y1)
  x,y=a*z1,b*z1
print(x+y)

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

int main(void){
    
    //入力
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<long long> A(X), B(Y), C(Z);
    for (int i = 0; i < X; i++) cin >> A[i];
    for (int i = 0; i < Y; i++) cin >> B[i];
    for (int i = 0; i < Z; i++) cin >> C[i];
    
    //AとBの全探索をした後にソートする
    vector<long long> AB;
    for (int i = 0; i < X; i++){
        for (int j = 0; j < Y; j++){
            AB.push_back(A[i] + B[j]);
        }
    }
    sort(AB.begin(), AB.end());
    reverse(AB.begin(), AB.end());
    
    //ABのK番目までとCの全探索をした後にソートする
    vector<long long> ABC;
    for (int i = 0; i < min(K, (int)AB.size()); i++){
        for (int j = 0; j < Z; j++){
            ABC.push_back(AB[i] + C[j]);
        }
    }
    sort(ABC.begin(), ABC.end());
    reverse(ABC.begin(), ABC.end());
    
    //ABCのK番目までを出力する
    for (int i = 0; i < K; i++){
        cout << ABC[i] << endl;
    }
}

Measured memory_bytes: 43240
import sys

def main():
    M1, D1 = map(int, input().split())
    M2, D2 = map(int, input().split())

    if(M1==2 and D1==28):
        if(M2==M1+1 and D2==1):
            print('1')
            sys.exit()

    if(M1==4 or M1==6 or M1==9 or M1==11 and D1==30):
        if(M2==M1+1 and D2==1):
            print('1')
            sys.exit()

    if(M1==1 or M1==3 or M1==5 or M1==7 or M1==8 or M1==10 or M1==12 and D1==31):
        if(M2==M1+1 and D2==1) or (M1==12 and M2==1 and D2==1):
            print('1')
            sys.exit()

    print('0')

main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<vector<int>>bin(3,vector<int>(3));
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
cin >> bin.at(i).at(j);
}
}
vector<vector<int>>bin_f(3,vector<int>(3));
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
bin_f.at(i).at(j)=0;
}
}
int n;
cin >>n;
vector<int>num(n);
for(int i=0;i<n;i++){
cin>>num.at(i);
}
for(int i=0;i<n;i++){
for(int j=0;j<3;j++){
for(int k=0;k<3;k++){
if(num.at(i)==bin.at(j).at(k)){
bin_f.at(j).at(k)=1;
}

}
}
}
int output =0; 
for(int i=0;i<3;i++){
if(bin_f.at(i).at(0)==1&&bin_f.at(i).at(1)==1&&bin_f.at(i).at(2)==1){
output =1;
}
}
for(int i=0;i<3;i++){
if(bin_f.at(0).at(i)==1&&bin_f.at(1).at(i)==1&&bin_f.at(2).at(i)==1){
output =1;
}
}
if(bin_f.at(0).at(0)==1&&bin_f.at(1).at(1)==1&&bin_f.at(2).at(2)==1){
output =1;
}
if(bin_f.at(0).at(2)==1&&bin_f.at(1).at(1)==1&&bin_f.at(2).at(0)==1){
output =1;
}

if(output==1){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
} 
}

Measured memory_bytes: 3636
using System;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var _ = Console.ReadLine().Split();
            var d = int.Parse(_[0]);
            var x = int.Parse(_[1]);

            var a = new int[n];
            for(var i = 0; i < n; i++){
                a[i] = int.Parse(Console.ReadLine());
            }

            var count = 0;
            foreach(var i in a){
                var idx = 0;
                while(idx * i + 1 <= d){
                    count++;
                    idx++;
                }
            }

            Console.WriteLine(x + count);
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<algorithm>
using namespace std;
int p[110];
int rem[1100];
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	int ret=0;
	for(int i=0;i<c;i++){
		for(int j=0;j<a;j++){
			if(rem[(i+1)*p[j]%b]==0){
				ret++;
			}else rem[(i+1)*p[j]%b]--;
		}
		if(i){
			for(int j=0;j<a;j++){
				rem[(i+1)*p[j]%b]++;
			}
		}
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 1032
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t = 1;
const ll inf = hell ;
bool is(string s){
	string s2=s;
	reverse(all(s2));
	return s==s2;
}
void solve(){
	ll n, ans=0;
	cin>>n;
	map<ll,ll> mapa;
	vector<ll> v(n);
	rep(i,0,n){
		cin>>v[i];
		mapa[v[i]]++;
	}
	for(auto x : mapa )
		ans += ((x.se-1)*x.se)/2;
	rep(i,0,n){
		ll tmp = mapa[v[i]], tmp2 = mapa[v[i]]-1;
		cout<<ans-((tmp-1)*tmp)/2+((tmp2-1)*tmp2)/2<<"\n";
	}
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cin >> t ;
    while(t--){
        solve();
    }
    return 0 ;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

ll N,M;

bool ok(ll mid,vector<ll> &a){
  ll cnt = 0;
  rep(i,N) {
    int plc = lower_bound(a.begin(),a.end(),mid - a[i]) - a.begin();
    cnt += (N - plc);
  }
  return (cnt >= M);
}

int main() {
  cin>>N>>M;
  vector<ll> a(N),s(N+1,0);
  rep(i,N) cin>>a[i];
  sort(a.begin(),a.end());
  rep(i,N) s[i+1] = s[i] + a[i];
  int l = 0, r = 200010,mid;
  while(r-l>1) {
    mid = (r+l)/2;
    if(ok(mid,a)) l = mid;
    else r = mid;
  }
  ll cnt =0 ,sum = 0;
  rep(i,N) {
    int plc = lower_bound(a.begin(),a.end(),r-a[i]) - a.begin();
    sum += (s[N] - s[plc]);
    // cout<<sum<<endl;
    sum += a[i] * (N - plc);
    // cout<<sum<<endl;
    cnt += N - plc;
  }
  // cout<<"cnt "<<cnt<<" l "<<l<<" r "<<r<<endl;
  sum += l * (M - cnt);
  cout<<sum<<endl;
}


Measured memory_bytes: 4804
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

ll n, m, q, ans;
vector<ll> a, b, c, d;

void dfs(vector<ll> v){
    if(v.size() == n+1){
        ll now = 0;
        rep(i,q){
            if(v[b[i]]-v[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans, now);
        return;
    }
    v.push_back(v.back());
    while(v.back() <= m){
        dfs(v);
        v.back()++;
    }
}

int main(void)
{
    cin >> n >> m >> q;
    a = b = c = d = vector<ll>(q);
    rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    dfs(vector<ll>(1,1));
    cout << ans << endl;
    return 0;
}

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

bool dp[20][2005];
int a[20];
int main()
{
    memset(dp,0,sizeof dp);
    for(int i=0;i<20;i++) dp[i][0] = 1;
    int n;cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    dp[n-1][a[n-1]]=1;
    for(int i=n-2;i>=0;i--){
        for(int j=a[i];j<=2000;j++){
            dp[i][j] = dp[i+1][j-a[i]] || dp[i+1][j];
        }
    }
    int m,x;cin>>m;
    for(int i=0;i<m;i++){
        cin>>x;
        if(dp[0][x]) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3164
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int a;
	cin>>a;
	a=a%10;
	if((a==2)||(a==4)||(a==5)||(a==7)||(a==9))
		cout<<"hon";
	else if((a==0)||(a==1)||(a==6)||(a==8))
		cout<<"pon";
	else
		cout<<"bon";
	return 0;
}

Measured memory_bytes: 3632
//start of jonathanirvings' template v3.0.3 (BETA)

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

string a,b;

int main()
{
  a = GetString();
  b = GetString();
  while (SIZE(a) < SIZE(b)) a = '0' + a;
  while (SIZE(a) > SIZE(b)) b = '0' + b;
  REP(i,SIZE(a))
  {
    if (a[i] < b[i])
    {
      puts("LESS");
      return 0;
    } else if (a[i] > b[i]) {
      puts("GREATER");
      return 0;
    }
  }
  puts("EQUAL");
  return 0;
}










Measured memory_bytes: 256