akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
  
#define N 100001
  
void Partition(int A[], int p, int r){
  int x, i, j;
  int temp;
  
  x = A[r];
  i = p-1;
  
  for(j = p; j <= r-1; j++){
    if(A[j] <= x){
      i = i + 1;
      //--------exchange
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
      //----------------
    }
  }
  
  //--------exchange
  temp = A[i + 1];
  A[i + 1] = A[r];
  A[r] = temp;
 //----------------
 
  //output
  for(j = 0; j <= r; j++){
    if(j == i + 1) printf("[%d]", A[j]);
    else printf("%d", A[j]);
    if(j != r) printf(" ");
  }
  printf("\n");
 
}
  
int main(){
  int n, i, p = 0, r;
  int A[N];
  
  //input and initialize
  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", &A[i]);
  r = n - 1;
  
  Partition(A, p, r);
  
  return 0;
}



Measured memory_bytes: 2128
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n';
#define no cout<<"No"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  i,j,k,l,n,cnt=0;
    string s;
    cin>>s;
    for(i=0;s[i];i++)
    if(s[i]=='1') cnt++;
        cout<<cnt<<endl;

            return 0;
}





Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,m;
  cin >> n >> m;
  int ans=0;
  for(int i=0;i<m;i++){
    int a;
    cin >> a;
    ans+=a;
  }
  if(n-ans>=0){
    cout << n-ans << endl;
  }
  else{
    cout << "-1" << endl;
  }
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <stack>
#include <unordered_set>

std::string replaceAll(const std::string& s, const std::string& find, const std::string& to);
int count_char(const std::string& s, char find);

int main() {
    std::string s;
    std::cin >> s;
    if (s.size() < 3 || s.size() % 2 == 0) {
        std::cout << "No" << std::endl;
        return 0;
    }
    
    std::stack<std::string> stack;
    std::unordered_set<std::string> visited;
    stack.push(s);
    visited.insert(s);

    while (!stack.empty()) {
        auto str = stack.top(); stack.pop();
        if (str == "ABC") {
            std::cout << "Yes" << std::endl;
            return 0;
        }
        for (auto c : { 'A', 'B', 'C' }) {
            auto next = str;
            int correct_count = count_char(next, c);
            next = replaceAll(next, "ABC", {c});
            if (next.size() != str.size() - correct_count * 2) {
                continue;
            }
            if (!visited.count(next)) {
                visited.insert(next);
                stack.push(next);
            }
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}

std::string replaceAll(const std::string& s, const std::string& find, const std::string& to) {
    std::string::size_type pos = 0;
    std::string result = s;
    while ((pos = result.find(find, pos)) != std::string::npos) {
        result.replace(pos, find.length(), to);
        pos += to.length();
    }
    return result;
}

int count_char(const std::string& s, char find) {
    int count = 0;
    for (auto c : s) {
        if (c == find) count++;
    }
    return count;
}


Measured memory_bytes: 9252
h, w = map(int, input().split())
ans = []

# 行チェック
for hi in range(h):
    row = [s for s in input()]
    # 行が全て白だと追加しない
    if row.count('.') == w:
        continue
    else:
        ans.append(row)

# 列チェック
removeindex = []
for wi in range(w):
    blnRem = True
    for row in ans:
        if row[wi] == '#':
            blnRem = False
            break
    if blnRem:
        removeindex.append(wi)

# 表示
for row in ans:
    for i, col in enumerate(row):
        if i in removeindex:
            continue
        print(col, end='')
    print()


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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;
const double PI=3.1415926535897932;

ll N, ans=0, tmp=0;
vector<ll> A, FV, BV;
set<ll> F, B;

signed main(){
    cin >> N;
    A.resize(N);
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        a--;
        A[a] = i;
    }
    F.insert(-1);
    F.insert(N);
    for(int i=0;i<N;i++) {
        set<ll>::iterator itr = F.lower_bound(A[i]);
        BV.push_back(*itr);
        itr--;
        FV.push_back(*itr);
        F.insert(A[i]);
    }
    for(int i=0;i<N;i++) {
        //ans += 1+COM(BV[i]-FV[i]-1, 2)-COM(A[i]-FV[i]-1, 2)-COM(A[i]-BV[i]-1, 2);
        tmp = 1+max(0LL, BV[i]-FV[i]-1)*max(0LL, BV[i]-FV[i]-2)/2-max(0LL, A[i]-FV[i]-1)*max(0LL, A[i]-FV[i]-2)/2-max(0LL, BV[i]-1-A[i])*max(0LL, BV[i]-2-A[i])/2;
        ans += (i+1)*tmp;
        //cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17372
#include<bits/stdc++.h>
using namespace std;
string s[10005];
int main()
{
	int n,ans=0,k=0,cnt1=0,cnt2=0,cnt3=0;
	cin>>n;
	for(int i=0;i<n;i++)
	 {cin>>s[i];
	  for(int j=0;j<s[i].size()-1;j++)
	   if(s[i][j]=='A'&&s[i][j+1]=='B')ans++;
	  if(s[i][0]=='B'&&s[i][s[i].size()-1]=='A')cnt1++;
	  else if(s[i][0]=='B')cnt2++;
	  else if(s[i][s[i].size()-1]=='A')cnt3++; 
	 } 
	ans+=min(cnt2,cnt3);
	if(!cnt2&&!cnt3)ans+=max(0,cnt1-1);
	else ans+=cnt1;
	cout<<ans<<endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h> 
using namespace std;
const long INF=1000000000000000;
const long MOD=1000000007;

int main() {
    long A,B;
    cin>>A>>B;
    
    if(A+B>=10) cout<<"error"<<endl;
    else cout<<A+B<<endl;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
from bisect import bisect_right

def main():
    N, M, K = map(int, readline().rstrip().split())
    A = list(map(int, readline().rstrip().split()))
    B = list(map(int, readline().rstrip().split()))

    a_acc, b_acc = A[:], B[:]
    for i in range(1, N):
        a_acc[i] += a_acc[i-1]
    
    for i in range(1, M):
        b_acc[i] += b_acc[i-1]
    
    res = 0
    for i, a in enumerate(a_acc):
        if a > K:
            break
        left = K - a
        j = bisect_right(b_acc, left)
        res = max(res, i + 1 + j)
    
    res = max(res, bisect_right(a_acc, K))
    res = max(res, bisect_right(b_acc, K))

    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 47636
#include <cstdio>

int main(){
    int N, K, X, Y;
    scanf("%d %d %d %d", &N, &K, &X, &Y);

    if (N >= K) {
        printf("%d", K*X + (N-K)*Y);
    }
    else {
        printf("%d", N*X);
    }

    return 0;
}


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

int main() {
	int a,b,c;
	double S, s;
	scanf("%d %d %d",&a,&b,&c);
	s = (a+b+c)/2;
	printf("%d\n",(int)sqrt(s*(s-a)*(s-b)*(s-c)));
	return 0;
}


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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("fibsubseq.in","r",stdin)
#define write()         freopen("fibsubseq.out","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long int
#define endll           printf("\n")
#define pf              printf
#define pi              acos(-1.0)
#define eps             1e-10
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())

bool Check(unsigned int  N,int pos){return (bool)(N & (1LL<<pos));}
ll  Set(unsigned int N,int pos){    return N=N | (1LL<<pos);}
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MX 100005
#define mod  1000000007
#define mod1 1000000009
#define var    int ii,i,j,k,z=0,c=0,t,x,y,l,r,mid,n,m
//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};

ll f[200006],inv[2000006],a[3005];
vector<pll> v;

ll bigmod(ll x,ll y,ll m)
{
    if(y==0)return 1;
    ll n=bigmod(x,y>>1,m);
    n*=n;n%=m;
    if(y&1)n=(n*x)%m;
    return n;
}

int main()
{
    ll var;
    f[0]=1;n=200004;
    for(i=1;i<=n;i++)f[i]=(f[i-1]*i)%mod;
    inv[n]=bigmod(f[n],mod-2,mod);
    for(i=n-1;i>=0;i--)
    {
        inv[i]=(inv[i+1]*(i+1))%mod;
    }
    sfl(x);sfl(y);sfl(m);

    z=f[x+y-2]*inv[y-1]%mod*inv[x-1]%mod;
    for(i=0;i<m;i++)
    {
        sfl(l);sfl(r);
        v.pb({l,r});
    }
    ll h=x,w=y;
    sort(v.begin(),v.end());
    for(i=m-1;i>=0;i--)
    {
        x=v[i].xx,y=v[i].yy;
        x=h-x+1,y=w-y+1;
        c=f[x+y-2]%mod*inv[y-1]%mod*inv[x-1]%mod;
        for(j=m-1;j>=0;j--)
        {
            if(i==j)continue;
            x=v[j].xx-v[i].xx+1,y=v[j].yy-v[i].yy+1;
            if(x<=0 || y<=0)continue;
            n=f[x+y-2]%mod*inv[y-1]%mod*inv[x-1]%mod;
            n=(n*a[j])%mod;
            c=(c-n+mod)%mod;
        }
        a[i]=c;
        x=v[i].xx,y=v[i].yy;
        c=c*f[x+y-2]%mod*inv[y-1]%mod*inv[x-1]%mod;
        z=(z-c+mod)%mod;
    }
    cout<<z<<endl;
}


Measured memory_bytes: 4864
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a>b)swap(a,b);
	if(b>c)swap(b,c);
	if(a>b)swap(a,b);
	if(d>e)swap(d,e);
	cout<<a+d-50<<endl;
	return 0;
	}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    string ans="APPROVED";
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        if(x%2==0){
            if(x%3!=0 && x%5!=0) ans="DENIED";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int M=pow(10,9)+7;
	vector<vector<int>> A;
		vector<int> P;
	vector<vector<ll>> dp;
inline ll add(ll a,ll b)
{
	a+=b;
	if(a>=M)a-=M;
	return a;
}
inline ll mul(ll a,ll b)
{
	a*=b;
	return a%M;
}
ll dfs(int v,int col)
{
	if(A[v].size()==0)return  dp[v][col]=1;
	if(A[v].size()==1 and P[v]==A[v][0])return dp[v][col]=1LL;
	if(dp[v][col]!=-1)return  dp[v][col];
	ll &ans= dp[v][col];
	
	if(col==0)// black
	{
		ans=1;
		for(int x:A[v])
		{
			if(P[v]==x)continue;
			P[x]=v;
			ans=mul(ans , dfs(x,1-col) );
		}
		
	}
	else
	{
		ans=1;
		for(int x:A[v])
		{
			if(P[v]==x)continue;
			P[x]=v;
			ans=mul(ans , add(dfs(x,col),dfs(x,1-col)) );
		}
	}
	return ans;
}

int main() {
	
	int n;
	cin>>n;
	A.resize(n);
	dp.resize(n,vector<ll>(2,0));
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		a--,b--;
		A[a].push_back(b);
		A[b].push_back(a);
	}

	dp.assign(n,vector<ll>(2,-1));
	P.assign(n,0);
	ll a1=dfs(0,0);
	P.clear();
	P.assign(n,0);
	ll a2=dfs(0,1);
	cout<<(a1+a2)%M<<endl;
	
	
}


Measured memory_bytes: 22944
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
#define int long long
int z[1919][1919];
int x[114514];
pair<int,int> a[114514];
signed main(){
	ic(n) ic(k)
	rep(0,i,n)cin>>x[i];
	int ans=0;
	rep(0,i,n){
		if(x[i]>=k)ans++;
	}
	c(ans)
}		

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

int main()
{
    long long N;
    cin >> N;
    if (N % 2 == 0)
    {
        cout << N << endl;
    }
    else
    {
        cout << N * 2 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Khela_Sesh ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
const int sz =  1e5+10;
int dp[sz];
vector<int> ad[sz];
int Longest(int u)
{
    int &ret=dp[u];
    if(~ret) return ret;
    ret=0;
    int p;
    for(auto xx: ad[u]) {
       p=Longest(xx);
       ret=max(ret,p);
    }
    ret+=1;
    return ret;
}
int main()
{
    Khela_Sesh
    int a,b,c,i,j,k,q,p,x,y,sum,ct,ct1,m,l,r,len,x1,y1,mn,t,n,mx;
    char ch;
    double d;
    string str1,str2;
    bool bl,bl1;
    while(cin>>n>>m)
    {
        for(i=0;i<=n+2;i++) ad[i].clear();
        memset(dp,-1,sizeof dp);
        for(i=1;i<=m;i++)
        {
            cin>>p>>q;
            ad[p].pb(q);
        }
        mx=0;
        for(i=1;i<=n;i++){
            p=Longest(i);
            if(p>mx) mx=p-1;
        }
        pf("%d\n",mx);
    }


}



Measured memory_bytes: 7552
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <stack>

using namespace std;

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

const ll mod = 1e9 + 7;
const ll mmod = 998244353;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<vector<ll>> g;
vector<vector<ll>> par;
vector<vector<ll>> dp;
vector<ll> d;


int main() {
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    string s;
    cin >> s;
    
    for (int i = 0; i < s.size(); ++i)
    {
        if (s[i] == '?')
        {
            s[i] = 'D';
        }
    }
    
    cout << s << endl;
    
    return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 = 1e9;
const LL LLINF = 1e16;

// i日目に活動jをしたとき、それまでに得られる幸福度の最大値
int dp[100010][3];
int a[101010][3];
int main(){
    int N;
    cin >> N;
    // ループで回せる形で幸福度を持つ
    for(int i=0; i<N; i++)for(int j=0; j<3; j++) cin >> a[i][j];

    for(int j=0; j<3; j++) dp[0][j] = 0;
    for(int i=0; i<N; i++){
        for(int j=0; j<3; j++)for(int k=0; k<3; k++){
            if(j == k) continue;    // 前日と同じ活動はしない
            // i+1日目に活動kをする
            // aは0-indexedに対し、dpテーブルは1-indexedで日付を持っているのに留意
            dp[i+1][k] = max(dp[i+1][k], dp[i][j]+a[i][k]);
        }
    }
    int ans = 0;
    for(int j=0; j<3; j++) ans = max(ans, dp[N][j]);
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include<stdio.h>
int main(){
    int a,b,c,val=0;
    scanf("%d %d %d",&a,&b,&c);
    if(a%(b+c)==c)
        printf("%d\n",a/(b+c));
    else
        printf("%d\n",(a/(b+c))-1);
    return 0;    
}


Measured memory_bytes: 128
#include<algorithm>
#include<vector>
#include<limits>
#include<cstdio>
#include<cstring>
#define rep(i,a) for(int i=0;i<(a);++i)
#define clr(a,v) memset((a),(v),sizeof(a))

const int MAX_V = 15, INF = std::numeric_limits<int>::max()>>2;

int V, E;
std::vector<std::vector<int> > d( MAX_V, std::vector<int>( MAX_V, INF ) );
int dp[1<<MAX_V+1][MAX_V];

int sv;

int rec( int S, int v )
{
    if( S == (1<<V)-1 && v == sv )
        return dp[S][v] = 0;

    if( ~dp[S][v] )
        return dp[S][v];

    int ret = INF;

    rep( u, V ) if( !(S>>u&1) )
        ret = std::min( ret, rec( S|1<<u, u )+d[v][u] );

    return dp[S][v] = ret;
}

int main()
{
    scanf( "%d%d", &V, &E );
    rep( i, E )
    {
        int s, t;
        scanf( "%d%d", &s, &t );
        scanf( "%d", &d[s][t] );
    }

    int ans = INF;
    rep( v, V )
    {
        clr( dp, -1 );
        sv = v;
        ans = std::min( ans, rec( 0, v ) );
    }

    printf( "%d\n", ans==INF?-1:ans );

    return 0;
}

Measured memory_bytes: 6628
function Main(stdin) {
    var input = stdin.split('\n').map(function(line) {
        return line.split(' ').map(function(numStr) {
            return parseInt(numStr, 10);
        });
    });
    var N = input[0][0];
    var edges = input[1];

    var sumEdgesLength = edges.reduce(function(acc, current) {
        return acc + current;
    }, 0);
    var maxEdgeLength = Math.max.apply(null, edges);
    if (maxEdgeLength < sumEdgesLength - maxEdgeLength) {
        console.log('Yes');
    } else {
        console.log('No');
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9420
N,M=map(int,input().split())
List = []
for i in range (M):
  List.append(list(map(int, input().split())))
resList = [0]*N
for i in range(M):
  resList[List[i][0]-1]+=1
  resList[List[i][1]-1]+=1
for element in resList:
  print(element)

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

const int MOD = (int)1e9+7;

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0;i<N;i++)	cin >> A.at(i);
	
	sort(A.begin(),A.end());
	A.push_back(-1);
	//for(int i=0;i<N+1;i++)	cout << A.at(i) << ",";
	//cout << endl;
	int count1=0;
	int count2=0;
	int same=1;
	for(int i=0;i<N;i++){
		if(A.at(i)==A.at(i+1))	same++;
		else{
			while(same>2){
				int x=same/3;
				int y=same%3;
				same=x+y;
			}
			if(same==1)	count1++;
			if(same==2)	count2++;	
			same=1;
		}
	}
	//cout << count1 << endl;
	//cout << count2 << endl;
	
	int ans=count1;
	ans+=(count2/2)*2;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <fstream>
#include <string>
#include <map>

using namespace std;


bool search(int idx,string &str){
	if(str[idx+1] == 'O' && str[idx+2] == 'I'){
		return true;
	}
	else
		return false;
}

int main(){

	string str;
	while(cin >> str){
		map<char,int> cnt;
		for(int i = 0; i < str.size()-2; i++){
			if(str[i] == 'J' || str[i] == 'I'){
				if(search(i,str))
					cnt[str[i]]++;
			}
		}
		cout << cnt['J'] << endl;
		cout << cnt['I'] << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> P2;
     
int main(){
  int N, M;
    int ans = 0;
    cin >> N >> M;
    int room[101];
    memset(room, 0, sizeof(room));
    P2 pro[101];
    
    for(int i = 1 ; i <= M ; i++){
      cin >> pro[i].second.first >> pro[i].second.second;
      pro[i].first = pro[i].second.second - pro[i].second.first;
      for(int j = pro[i].second.first ; j <= pro[i].second.second ; j++){
	room[j]++;
      }
    }   
    int cnt = 0;
    for(int i = 1 ; i <= N ; i++){
      if(room[i] != 0) cnt++;
    }
    if(cnt != N) cout << "Impossible" << endl;
    else{
      sort(pro, pro+M);
      for(int i = 1 ; i <= M ; i++){
	bool flag = 0;
	for(int j = pro[i].second.first ; j <= pro[i].second.second ; j++){
	  room[j]--;
	  if(room[j] == 0) flag = 1;
	}
	if(flag){
	  ans++;
	  for(int j = pro[i].second.first ; j <= pro[i].second.second ; j++){
	    room[j]++;
	  }
	}
      }
      cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-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;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b,c,d;
	string s;
	cin>>n>>a>>b>>c>>d;
	a--;b--;c--;d--;
	cin>>s;
	bool e=true,f=true,ee=false,ff=false;
	for(int i=a;i<c;i++){
		if(s[i]=='#'&&s[i+1]=='#')e=false;
	}
	for(int i=b;i<d;i++){
		if(s[i]=='#'&&s[i+1]=='#')f=false;
	}
	for(int i=a;i<c;i++){
		if((i!=0&&s[i]!='#')&&s[i]!='#'&&(i+1!=n&&s[i+1]!='#'))ee=true;
	}
	for(int i=b;i<=d;i++){
		if((i!=0&&s[i-1]!='#')&&s[i]!='#'&&(i+1!=n&&s[i+1]!='#'))ff=true;
	}
	if(c<d)Yn(f&&e);
	else Yn(e&&f&&ff);
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define LL                  long long
#define ull                 unsigned long long LL
#define scl(n)              scanf("%lld", &n)
#define scf(n)              scanf("%lf", &n)
#define sci(n)              scanf("%d", &n)
#define scii(n,m)           scanf("%d %d",&n,&m)
#define sciii(n,m,p)        scanf("%d %d %d",&n,&m,&p)

#define MOD                 1000000007
#define MODP                99999999999973LL
#define pb                  push_back
#define mp                  make_pair
#define pp                  pair<LL,LL>
#define memo(a,b)           memset(a,b,sizeof(a))
#define INF                 1e9
#define EPS                 1e-8
#define Pi                  acos(-1.0)
LL bigmod(LL b, LL p, LL md){if(p==0) return 1;if(p%2==1){ return ((b%md)*bigmod(b,p-1,md))%md;} else {LL y=bigmod(b,p/2,md);return (y*y)%md;}}
#define N 3000

string str[N];
LL dp[N][N];
int main()
{
    int n,m;
    cin>>n>>m;


    for(int i=0;i<n;i++)
    {
        cin>>str[i];
    }
    dp[0][0]=1LL;

    for(int i=0;i<n;i++)
    {

        for(int j=0;j<m;j++)
        {
            if(str[i][j]=='#')
                dp[i][j]=0;
            else
            {
                if(i!=0)
                    dp[i][j]=(dp[i-1][j]%MOD);
                if(j!=0)
                    dp[i][j]+=(dp[i][j-1]%MOD);
                dp[i][j]%=MOD;

            }
        }
    }

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

    return 0;
}



/* LL dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */ // 4 Direction
/* LL dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
/* LL dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* LL dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


Measured memory_bytes: 24832
#include <iostream>

using namespace std;

int main(void)
{
  unsigned long long int H, ans, num;
  
  ans = 0;
  num = 1;

  cin >> H;

  while(H != 1)
  {
    H /= 2;
    ans += num;
    num *= 2;
  }

  cout << ans + num;
  
  return 0;
}


Measured memory_bytes: 256
S = input()
res = 'No'
if len(S) % 2 == 0 and len(S) > 0:
    res = 'Yes'
    for i in range(int(len(S)/2)):
        # print(S[i*2:i*2+2])
        if S[i*2:i*2+2] != 'hi':
            res = 'No'
            break
print(res)
    

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

int main()
{
		int x, y, temp, i;
for(i=1; i <=3000; i++)
{
		cin >> x >> y;
		if(x==0 && y==0) break;
		
		if(x>y)
{
			int temp = x;
			x = y;
			y = temp;
		}
		cout << x << " " << y <<endl;
	}
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
  IOS();
  int r;
  cin>>r;
  if( r<1200 ) cout<<"ABC"<<endl;
  else if( r<2800 ) cout<<"ARC"<<endl;
  else cout<<"AGC"<<endl;
}


Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<math.h>
using namespace std;
int main(){
  long long n;
  std::cin >> n;
  long long m=5;
  long long ans=0;
  if(n%2==0){
    while (n/m!=0) {
      ans+=n/(m*2);
      m*=5;

    }
  }else ans=0;

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,a,i,j,ans=0;
  vector<vector<int>> c(10,vector<int>(10));
  cin>>n;
  for(a=1;a<=n;a++) {
    if (a<10) i=a;
    else if (a<100) i=a/10;
    else if (a<1000) i=a/100;
    else if (a<10000) i=a/1000;
    else if (a<100000) i=a/10000;
    else if (a<1000000) i=a/100000;
    c.at(i).at(a%10)++;
  }
  for(i=1;i<10;i++) for(j=1;j<10;j++) ans+=c.at(i).at(j)*c.at(j).at(i);
  cout<<ans<<endl;
}

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

int N;
ll H[5000], P[5000];
ll sumP=0;
ll minH=1e9;

ll dp[5001][5001];

int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>H[i]>>P[i];
    minH=min(minH,H[i]);
    sumP+=P[i];
  }
  ll tmp = minH / sumP * sumP;
  if(tmp>0){
    cout<<N<<endl;
    return 0;
  }

  for(int i=0;i<=N;i++)
    for(int j=0;j<=N;j++)
      dp[i][j]=(1LL<<60);
  dp[0][0]=0;
  
  vector< Pair > vec;
  for(int i=0;i<N;i++){
    vec.push_back( Pair( H[i]+P[i] , i ) );
  }
  sort(vec.begin(),vec.end());

  for(int i=0;i<N;i++){
    int id=vec[i].second;
    
    ll h=H[id];
    ll p=P[id];
    
    for(int j=0;j<N;j++){
      if(dp[i][j] == (1LL<<60) )continue;
      if(dp[i][j]<=h)dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+p);
      dp[i+1][j]=min(dp[i+1][j] , dp[i][j]);
    }
  }
  ll ans=0;
  for(int i=0;i<=N;i++)
    for(int j=0;j<=N;j++)
      if(dp[i][j]!=(1LL<<60))
        ans=max(ans,(ll)j);
  
  cout<< ans <<endl;
  return 0;
}


Measured memory_bytes: 195968
#include<stdio.h>

int main(void)

{
    int a,b,op,wa,sa,seki,sho;

    while(1){

    scanf("%d %c %d",&a,&op,&b);

    if( op == '+' )
    {
        wa = a + b;
        printf("%d\n",wa);
    }
    else if( op == '-' )
    {
        sa = a - b;
        printf("%d\n",sa);
    }
    else if( op == '*' )
    {
        seki = a * b;
        printf("%d\n",seki);
    }
    else if( op == '/' )
    {
        sho = a / b;
        printf("%d\n",sho);
    }
    else if( op == '?' )break;
    }

        return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << 6 - a - b << endl;

}


Measured memory_bytes: 892
R, G, B, N = map(int, input().split())
list_a = [R, G, B]
list_a.sort()
ans = 0
for i in range(N//list_a[2]+1):
  nn = N-i*list_a[2]
  for j in range(nn//list_a[1]+1):
    nnn = nn-j*list_a[1]
    if nnn%list_a[0] == 0:
      ans+=1
print(ans)

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

int main(void)
{
	int A, B, count = 0;
	char s[10];

	scanf("%d %d", &A, &B);

	if (10000 <= A && A <= B && B <= 99999) {}
	else exit(1);

	for (int i = A; i <= B; i++) {
		sprintf(s, "%d", i);
		int j = 0, k = 4;
		if (s[j] == s[k] && s[j + 1] == s[k - 1])
			count++;
	}

	printf("%d", count);

	return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    bool res = true;
    int now_max = -1;
    rep(i,n) {
        if( h[i] < now_max -1) {
            res = false;
            break;
        }
        now_max = max(now_max,h[i]);
    }
    if (res) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 640
/*input
4
20 11 9 24
*/

// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{ll res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(ll* a, ll* b){shuffle(a,b,grndm);}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	ll n; cin >> n;
	vector<ll> v(n);
	ll tot = 0;
	for(ll i = 0; i < n; i++) {
		cin >> v[i];
		tot ^= v[i];
	}
	for(int i = 0; i < n; i++) {
		cout << (tot ^ v[i]) << " ";
	}
	cout << endl;
	return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  char a[n][n], b[m][m];
  rep(i, n){
    rep(j, n) cin >> a[i][j];
  }
  rep(i, m){
    rep(j, m) cin >> b[i][j];
  }
  bool can = false;
  rep(i, n-m+1){
    rep(j, n-m+1){
      bool same = true;
      rep(k, m){
        rep(l, m) if(a[i+k][j+l] != b[k][l]) same = false;
      }
      if(same) can = true;
    }
  }
  cout << (can? "Yes": "No") << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            } else {
                for (int i = 0; i < H; i++) {
                    for (int j = 0; j < W; j++) {
                        System.out.print("#");
                    }
                    System.out.print("\n");
                }
                System.out.print("\n");
            }
        }
    }
}


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

int main(){
    int n,l;
    cin >> n >> l;
    vector<string> s(n);
    for(int i=0;i<n;i++) cin >> s[i];
    sort(s.begin(), s.end());
    for(auto& s_i : s) cout << s_i;
    cout << endl;
    return 0;
}


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

const int N = 250010;
const int mod[] = {1000000007, 1000000009};
const int P[] = {131, 233};

typedef long long LL;

int Pow[2][N * 2]; char s[N];

inline int FUCK(int x, int y, int mod) {
    int res = 1;
    for (; y; y >>= 1, x = (LL)x * x % mod) if (y & 1) res = (LL)res * x % mod;
    return res;
}

struct Data {
    int val[2];

    Data(int a = 0, int b = 0) {val[0] = a, val[1] = b;} 

    Data operator + (const Data &b) {
        Data res;
        res.val[0] = (val[0] + b.val[0]) % mod[0];
        res.val[1] = (val[1] + b.val[1]) % mod[1];
        return res;
    }

    Data operator - (const Data &b) {
        Data res;
        res.val[0] = (val[0] - b.val[0] + mod[0]) % mod[0];
        res.val[1] = (val[1] - b.val[1] + mod[1]) % mod[1]; 
        return res;
    }

    Data operator * (const int b) {
        Data res = *this;
        int a = b >= 0 ? Pow[0][b] : FUCK(P[0], (LL)(mod[0] - 2) * (-b) % (mod[0] - 1), mod[0]);
        int c = b >= 0 ? Pow[1][b] : FUCK(P[1], (LL)(mod[1] - 2) * (-b) % (mod[1] - 1), mod[1]);
        res.val[0] = (LL)res.val[0] * a % mod[0];
        res.val[1] = (LL)res.val[1] * c % mod[1];
        return res;
    }

    bool operator < (const Data &b) const {
        if (val[0] != b.val[0]) return val[0] < b.val[0];
        return val[1] < b.val[1];
    }
};

map<Data, int> mp;

inline void increase(Data &a, int b) {
    a = a + (Data){Pow[0][b], Pow[1][b]};
}

inline void decrease(Data &a, int b) {
    a = a - (Data){Pow[0][b], Pow[1][b]};
}

int main() {
    int n; scanf("%d%s", &n, s + 1); Data all;
    Pow[0][0] = Pow[1][0] = 1;
    for (int i = 0; i <= 1; i++)
        for (int j = 1; j <= n * 2; j++)
            Pow[i][j] = (LL)Pow[i][j - 1] * P[i] % mod[i];
    for (int i = 1, ls = 0; i <= n; i++) {
        if (s[i] == '<') ls--;
        else if (s[i] == '>') ls++;
        else if (s[i] == '+') increase(all, ls + n);
        else decrease(all, ls + n);
    }
    Data fuck; mp[all] = 1; LL res = 0;
    for (int i = 1, ls = 0; i <= n; i++) {
        if (s[i] == '<') ls--;
        else if (s[i] == '>') ls++;
        else if (s[i] == '+') increase(fuck, ls + n);
        else decrease(fuck, ls + n);
        res += mp[fuck], mp[fuck + all * ls]++;
    }
    printf("%lld\n", res);
    return 0;
}//

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

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

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

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

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

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

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


// TODO: write
int main() {
  #define int ll
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  map<int,int> m;
  rep(i,n){
    m[a[i]]++;
  }
  
  int ans = 0;
  map<int,int> o;
  for(auto&& tmp : m){
    o[tmp.fi] = tmp.se*(tmp.se-1)/2 - (tmp.se-1)*(tmp.se-2)/2;
    ans += tmp.se*(tmp.se-1)/2;
  }
  rep(i,n){
    print(ans - o[a[i]]);
  }
  
  return 0;
}


Measured memory_bytes: 18944
#include <stdio.h>
using namespace std;
#include <iostream> 

int main(void){
  int a[50][4];
  int b[50][4];
  int i=0, j, k;
  int h, br;
  int num=0;

  /*
  for ( i=0; i<2; i++) {
    scanf("%d %d %d %d", &a[i][0], &a[i][1], &a[i][2], &a[i][3]);
    scanf("%d %d %d %d", &b[i][0], &b[i][1], &b[i][2], &b[i][3]);
  }*/

  while(cin>>a[i][0]>>a[i][1]>>a[i][2]>>a[i][3]){
  	scanf("%d %d %d %d", &b[i][0], &b[i][1], &b[i][2], &b[i][3]);
  	num++;
  	i++;
  }
  
  for ( i=0; i<num; i++) {
  	for(j=0;j<4;j++) {
  	  for(k=0;k<4;k++) {
  		if ( a[i][j]==b[i][k] ) {
  		  if ( j==k ) {
  		  	h++;
  		  } else {
  		  	br++;
  		  }
  		}
  	  }
  	}
  	printf("%d %d\n",h, br);
  	br = h = 0;
  }


  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int Answer=0;
  
  vector<int> vec(N);
  for (int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  if (N%2 == 0){
    for (int i=0; i<(N/2); i++){
      Answer += vec.at(2*i) - vec.at(2*i+1);
    }
  }  
  else {
    for (int i=0; i<((N-1)/2); i++){
      Answer += vec.at(2*i)-vec.at(2*i+1);
    }
    Answer += vec.at(N-1);
  }
  
  cout << Answer << endl;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define re register
const int mod=1e9+7;
struct eg{int x,y,c;}e[4010],e1[4010];
inline bool cmp(const eg&A,const eg&B){return A.c<B.c;}
int fa[2010];
int find(re int a){return a==fa[a]?a:fa[a]=find(fa[a]);}
int ex(re int a,re int b)
{
	re int ans=1;
	for(;b;b>>=1,a=(long long)a*a%mod)if(b&1)ans=(long long)ans*a%mod;
	return ans;
}
int main()
{
	re int n,m;
	re long long x,x1=0;
	scanf("%d%d%lld",&n,&m,&x);
	for(re int i=1;i<=n;i++)fa[i]=i;
	for(re int i=1;i<=m;i++)scanf("%d%d%d",&e[i].x,&e[i].y,&e[i].c),e1[i]=e[i];
	std::sort(e+1,e+m+1,cmp);
	for(re int i=1;i<=m;i++)if(find(e[i].x)!=find(e[i].y))x1+=e[i].c,fa[fa[e[i].x]]=fa[e[i].y];
	for(re int i=1;i<=n;i++)fa[i]=i;
	re int m1=0,m2=0,mk=0;
	for(re int i=1;i<=m;i++)
	{
		re int j1=i;
		while(j1<m&&e[j1+1].c==e[j1].c)j1++;//printf("***%d %d %lld\n",i,j1,x1);
		for(re int i1=i;i1<=j1;i1++)if(find(e[i1].x)!=find(e[i1].y))m1++;
		for(re int i1=i;i1<=j1;i1++)if(find(e[i1].x)!=find(e[i1].y))fa[fa[e[i1].x]]=fa[e[i1].y];
		for(re int i1=1;i1<=m;i1++)
		if(e1[i1].c!=-1&&find(e1[i1].x)==find(e1[i1].y))
		{
			if(e1[i1].c-e[i].c==x-x1)m2++;
			if(e1[i1].c-e[i].c<=x-x1)mk++;
			e1[i1].c=-1;
		}
		i=j1;
	}//printf("**%d %d %d\n",m1,m2,mk);
	re int ans;
	if(x==x1)
	{
		ans=(long long)(ex(2,m1)-2)*ex(2,m-m1)%mod;
	}else
	{
		ans=2ll*(ex(2,m2)-1)*ex(2,m-mk)%mod;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
A, B, C, X, Y = list(map(int, input().split()))
max_AB = max(X, Y)
ans = float('inf')
for i in range(0, max_AB + 1):
    X_num = max(X - i, 0)
    Y_num = max(Y - i, 0)
    ans = min(X_num * A + Y_num * B + 2 * C * i, ans)
print(ans)


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

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

using ll = long long;

ll pow(ll a, ll n, ll m) {
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a % m) {
		if (n % 2LL == 1LL) {
			ret = ret * a % m;
		}
	}
	return ret;
}

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007LL;

int main() {
  ll N;
  cin >> N;
  vector<bitset<62>> v(N);
  for(ll i = 0LL; i < N; i++) {
    ll n;
    cin >> n;
    bitset<62> bit(n);
    v.at(i) = bit;
  }
  vector<ll> num(62,0LL);
  for(ll i = 0LL;i < N; i++) { 
    for(int j = 0; j < 62; j++) {
      if(!v.at(i).test(j)) num[j]++;
    }
  }
  ll ans = 0LL;
  for(ll i = 0LL; i < 62LL; i++){
    ans += (pow(2,i,mod)*(N-num[i])%mod)*num[i]%mod;
    ans%=mod;
  }
  ans %= mod;
  if(ans<0LL) ans += mod;
  cout<<ans << endl;
}
        

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
pair<int,int> arr[100050];
int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
    {
        scanf("%d", &arr[i].first);
        arr[i].second = i;
    }
    sort(arr + 1, arr + 1 + n);
    int ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        if(abs(arr[i].second - i) & 1)
            ++ans;
    }
    printf("%d\n", ans >> 1);
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, P;
	while (cin >> N >> P) {
		if (N == 0 && P == 0) return 0;
		vector<long long> V(N, 0);
		long long NOW = P;
		for (int i = 0; ; i++) {
			if (NOW == 0) NOW = V[i % N], V[i % N] = 0;
			else NOW--, V[i % N]++;
			if (V[i % N] == P) {
				cout << i % N << endl;
				break;
			}
		}
	}
}


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

bool isLowerEqual(vector<int> &v, int index){
 return (v[index] >= v[index+1]);
}

int max(vector<int> &v){
  int max=0;
  for(int i=0;i<v.size();i++){
    if(v[i]>max)
      max = v[i];
  }
  return max;
}

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  vector<int> maxValues(n);
  int index=0;
  for(int i=0;i<maxValues.size()-1;i++){
    if(isLowerEqual(h, i))
      maxValues[index]++;
    else
      index++;
  }
  cout << max(maxValues) << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std ;
#define ll long long int  


int main()
{ 
  ll n  ;
  cin>>n; 
  ll arr[n+ 1]  ;
 
  int c = 0  ; 

  ll ans = 0  ; 

  for(ll i =  1 ;  i<= n ;  ++i)
  	 {
  	 	cin>>arr[i]  ;
    	 }
 for(int i  = n ;  i  > 0  ; --i)
 {

 	if(arr[i] == i)
 		c++ ; 
 	else
 		break ; 
 }
  


  for(ll i  = 1  ; i < n ; ++i)
  {
  	
     if(arr[i] == i)
     {
     	 swap(arr[i]  , arr[i+1] )  ; 
     	 ans++ ;
     	
     }

  }
  if(c % 2 != 0 )
  {
  	ans++ ;
  }

	cout<<ans ; 
return  0 ; }

Measured memory_bytes: 1024
x,k,d=map(int,input().split())
x,d=abs(x),abs(d)
m=x//d
if m>=k:
    print(x-k*d)
else:
    t=k-m
    t=t%2
    if t==0:
        print(x-m*d)
    else:
        print(min(x-m*d+d,abs(x-(m+1)*d)))

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

using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, a, b) for (int64_t i = (a); i < (b); ++i)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main() {
  int n, m, R;
  cin >> n >> m >> R;
  vector<int> r(R);
  for (int i = 0; i < R; i++) {
    int k;
    cin >> k;
    r[i] = k - 1;
  }
  vector<vector<ll>> d(n, vector<ll>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j)
        d[i][j] = 0;
      else
        d[i][j] = INF;
    }
  }

  for (int i = 0; i < m; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    d[a - 1][b - 1] = c;
    d[b - 1][a - 1] = c;
  }
  for (int k = 0; k < n; k++) {      // 経由する頂点
    for (int i = 0; i < n; i++) {    // 始点
      for (int j = 0; j < n; j++) {  // 終点
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  SORT(r);
  ll ans = INF;
  do {
    ll total = 0;
    for (int i = 0; i < R - 1; i++) {
      total += d[r[i]][r[i + 1]];
    }
    ans = min(total, ans);
  } while (next_permutation(r.begin(), r.end()));
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int arr[100005];
int dp[3005][3005];
int anss  = 0 ;
char rep[100005];
int c=0;
string str1,str2;
int lcs(int first,int last)
    {
        if(first<=0|last<=0)
            {
                return 0;
            }
        if(dp[first][last]!=-1)
            return dp[first][last];
        if(str1[first]==str2[last]&&(first!=str1.size()&&last!=str2.size()))
        {
            dp[first][last]=1+lcs(first-1,last-1);
            anss = max(anss,dp[first][last]);
 
        }
        else
            {
            dp[first][last] = max(dp[first][last],max(lcs(first-1,last),lcs(first,last-1)));
            }
        return dp[first][last];
 
    }
void printstring()
    {
        int i = str1.size();
        int j = str2.size();
        //int idx = anss;
        int idx=lcs(str1.size()-1,str2.size()-1);
        char str[anss+1];
        str[idx+1]='\0';
        while(i>0&&j>0)
        {
            if(str1[i]==str2[j])
            {
                str[idx]= str1[i];
                idx--;
                i--;
                j--;
            }
            else if(dp[i-1][j]>dp[i][j-1])
            {
                i--;
            }
            else
                j--;
        }
        cout<<str<<endl;
    }
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    for(int i=0;i<3006;i++)
        for(int j=0;j<3006;j++)
            dp[i][j]=-1;
    cin>>str1>>str2;
    str1="X"+str1;
    str2="Y"+str2;
    string ans="";
    int n = min(str2.size(),str1.size());
    int n1 = max(str2.size(),str1.size());
    //lcs(str1.size()-1,str2.size()-1);
    printstring();
 
}
 
 

Measured memory_bytes: 39280