akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) < (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;
using unit= unsigned;
using ull = unsigned long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vvi = vector<vi>;
using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
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; }
template<class T>T gcd(T a, T b){ if (b==0){ return a; }else{ return gcd(b, a%b); }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
constexpr double eps = 1e-10;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;

void _main() {
  int N, K;
  cin >> N >> K;
  vi V(N);
  rep(i, 0, N) cin >> V[i];

  int ans = 0;
  rep(l, 0, K+1) rep(r, 0, K-l+1) {
    if (l + r > N) break;
    vi S;
    int d = K - l - r;
    int t = 0;
    rep(li,   0, l) { t += V[li]; S.emplace_back(V[li]); }
    rep(ri, N-r, N) { t += V[ri]; S.emplace_back(V[ri]); }
    sort(all(S));

    rep(i, 0, d) {
      if (i >= sz(S)) break;
      if (S[i] > 0) break;
      t -= S[i];
    }
    chmax(ans, t);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

if i() == 1:
    print('Hello World')
else:
    print(i()+i())

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

int n, H[500005];

void maxHeapify(int i) {
    int l, r, largest;
    l = 2 * i;
    r = 2 * i + 1;
    
    if(r <= n && H[r] > H[i]) largest = r;
    else largest = i;
    if(l <= n && H[l] > H[largest]) largest = l;
    
    if(largest != i){
        swap(H[i], H[largest]);
        maxHeapify(largest);
    }else return;
}



int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> H[i];
    for(int i = n / 2; i >= 1; i--) maxHeapify(i);
    for(int i = 1; i <= n; i++) cout << " " << H[i];
    cout << endl;
    
    
    return 0;
}


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

int main()
{
  int N;
  cin >> N;
  int num = -1;
  int count = 0;
  int rep = 0;
  while (N > 0)
  {
    int cur = N % 10;
    N /= 10;
    if (cur != num)
    {
      rep = max(count, rep);
      count = 0;
      num = cur;
    }
    ++count;    
  }

  if (max(count, rep) >= 3)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int r; std::cin >> r;
    std::cout << 3*r*r << std::endl;
    return 0;
}


Measured memory_bytes: 256
#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;

template<typename T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long
#define pi pair<ll,ll>
#define __   ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define mod 1000000007
#define base 1949313259

ll Set(ll N,ll pos){ return N=N | (1LL<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1LL<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1LL<<pos)); }


ll ar[]={0,0,1,-1};
ll br[]={1,-1,0,0};

string s,s1,s2;
ll n,m;
ll arr[500010];
ll brr[500010];
vector<ll>v,v1;

map<ll,ll>mp;
ll vis[500005];
int main()
{__
        ll i,j,a,b,c,d,e,f,g,x,y,z,t,k,l;

        ll ans=0;

        cin>>s;

        for(i=0;i<2;i++){
            if(s[i]!=s[i+1]) break;
        }

        if(i==2) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
}




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

typedef long long ll;

const int Maxn = 2005;

int n, x;
int a[Maxn], b[Maxn];
ll res = 1000000000000000000ll;

ll Get()
{
    ll res = 0;
    for (int i = 1; i <= n; i++)
        res += a[i];
    return res;
}

int main()
{
    scanf("%d %d", &n, &x);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    for (int i = 0; i <= n; i++) {
        res = min(res, Get() + ll(i) * x);
        for (int j = n; j >= 1; j--) {
            int prv = j == 1? n: j - 1;
            b[j] = min(a[j], a[prv]);
        }
        for (int j = 1; j <= n; j++)
            a[j] = b[j];
    }
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int n,count=0,P=0,W=0,G=0,Y=0;
    string s;
    cin>>n;
    for (int i=0;i<n;i++) {
        cin>>s;
        if (s=="P"&&P==0) {
            count++;
            P=1;
        } else if (s=="W"&&W==0) {
            count++;
            W=1;
        } else if (s=="G"&&G==0) {
            count++;
            G=1;
        } else if (s=="Y"&&Y==0) {
            count++;
            Y=1;
        }
    }
    if (count==3) {
        cout<<"Three"<<endl;
    } else if (count==4) {
        cout<<"Four"<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int n,a;
string s,sa;
signed main()
{
	cin>>n>>s>>sa;
	rep(i,n){
		cout<<s[i]<<sa[i];
	}
}

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

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

int main()
{
	int n;
	int i,j,k,l,m;
	while(1){
		cin >> n;
		if(n==0) break;
		
		int dp[31][51][51];
		for(i=0;i<=n;i++) for(j=0;j<=n;j++){
			for(k=0;k<31;k++){
				dp[k][i][j]=-1;
			}
		}
		for(i=1;i<=n;i++) dp[0][i][i]=1;
		
		vector<int> vi[31];
		for(i=1;i<=n;i++){
			int in;
			cin >> in;
			for(j=0;j<in;j++){
				int in2;
				cin >> in2;
				vi[in2].push_back(i);
			}
		}
		for(i=1;i<=30;i++){
			for(j=1;j<=n;j++){
				for(k=1;k<=n;k++){
					dp[i][j][k]=dp[i-1][j][k];
					dp[i][k][j]=dp[i-1][k][j];
				}
			}
			for(j=0;j<vi[i].size();j++){
				for(k=0;k<j;k++){
					dp[i][vi[i][j]][vi[i][k]]=1;
					dp[i][vi[i][k]][vi[i][j]]=1;
					for(l=1;l<=n;l++){
						if(dp[i-1][l][vi[i][j]]==1){
							dp[i][l][vi[i][k]]=1;
						}
						if(dp[i-1][l][vi[i][k]]==1){
							dp[i][l][vi[i][j]]=1;
						}
					}
				}
			}
		}
		
		int ff=0;
		for(i=1;i<=30;i++){
			for(j=1;j<=n;j++){
				int f=0;
				for(k=1;k<=n;k++){
					if(dp[i][k][j]==-1){
						f=1;
						break;
					}
				}
				if(f==0){
					cout << i << endl;
					ff=1;
					break;
				}
			}
			if(ff==1) break;
			
		}
		if(ff==0) cout << -1 << endl;
	}
		
	return 0;	
}

Measured memory_bytes: 1240
s = gets.chomp.split("")
a = s.length
x = []
y = []
for num in 0..a-1 do
  if num.even?
    x << s[num]
  else
    y << s[num]
  end
end
if x.include?("L") || y.include?("R")
  puts "No"
else
  puts "Yes"
end

Measured memory_bytes: 1916
using System;
namespace ABC143B
{
    public class EmptyClass
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] arr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            long sum = 0;
            for (int i = 0; i < arr.Length-1; i++)
            {
                for (int j = i+1; j < arr.Length; j++)
                {
                    sum += arr[i] * arr[j];
                }
            }
            Console.WriteLine(sum);
        }
    }
}


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

struct StNode
{
  StNode* m_poParnt;
  StNode* m_poLeft;
  StNode* m_poRigt;
  int m_nKey;

  StNode(int nNo) :
    m_poParnt(nullptr), m_poLeft(nullptr), m_poRigt(nullptr), m_nKey(nNo)
  { }
};

void fnPreOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  cout << " " << poNode->m_nKey;
  fnPreOrder(poNode->m_poLeft);
  fnPreOrder(poNode->m_poRigt);
}

void fnInOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnInOrder(poNode->m_poLeft);
  cout << " " << poNode->m_nKey;
  fnInOrder(poNode->m_poRigt);
}

void fnInsert(StNode*& rpoRoot, StNode* poNewNod)
{
  StNode* poParnt = nullptr;
  StNode* poNode = rpoRoot;

  while (poNode != nullptr)
  {
    poParnt = poNode;
    if (poNewNod->m_nKey < poNode->m_nKey)
      poNode = poNode->m_poLeft;
    else
      poNode = poNode->m_poRigt;
  }

  poNewNod->m_poParnt = poParnt;
  if (poParnt == nullptr)
    rpoRoot = poNewNod;
  else if (poNewNod->m_nKey < poParnt->m_nKey)
    poParnt->m_poLeft = poNewNod;
  else
    poParnt->m_poRigt = poNewNod;
}

void fnBinSchTree(StNode*& rpoRoot)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; ++i)
  {
    string sCmd;
    cin >> sCmd;
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      StNode* poNewNod = new StNode(nNo);
      fnInsert(rpoRoot, poNewNod);
    }
    if (sCmd[0] == 'p')
    {
      fnInOrder(rpoRoot);
      cout << endl;
      fnPreOrder(rpoRoot);
      cout << endl;
    }
  }
}

void fnPstOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnPstOrder(poNode->m_poLeft);
  fnPstOrder(poNode->m_poRigt);
  delete poNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  StNode* poRoot = nullptr;

  fnBinSchTree(poRoot);
//fnPstOrder(poRoot);
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
Int inf = 1e9;
Int mod = 1e9+7;

typedef long long ll;

ll merge_cnt(vector<Int> &a) {
    Int n = a.size();
    if (n <= 1) { return 0; }

    ll cnt = 0;
    vector<Int> b(a.begin(), a.begin()+n/2);
    vector<Int> c(a.begin()+n/2, a.end());

    cnt += merge_cnt(b);
    cnt += merge_cnt(c);

    Int ai = 0, bi = 0, ci = 0;
    // merge の処理
    while (ai < n) {
        if ( bi < b.size() && (ci == c.size() || b[bi] <= c[ci]) ) {
            a[ai++] = b[bi++];
        } else {
            cnt += n / 2 - bi;
            a[ai++] = c[ci++];
        }
    }
    return cnt;
}

int main() {
    Int n, k;
    cin >> n >> k;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] -= k;
    }
    vector<Int> b(n + 1, 0);
    for (Int i = 0; i < n; i++) {
        b[i + 1] = b[i] + a[i];
    }
    dump(n * (n + 1) / 2 - merge_cnt(b));
    return 0;
}

Measured memory_bytes: 6528
# -*- coding: utf-8 -*-


def main():
    """Function."""
    o = str(input())
    e = str(input())

    txt = ""
    for i in range(len(e)):
        txt += o[i] + e[i]

    if len(o) > len(e):
        txt += o[-1]

    print(txt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define f1(a,b,c) for(int c=a;c<=b;c++)
#define f2(a,b,c) for(int c=a;c>=b;c--)
#define f3(a,b,c) for(int c=a;c;c=b)
#define so1(a,n) sort(a+1,a+n+1,mycmp);
#define so2(a,n) sort(a+1,a+n+1);
#define ll long long
#define itn int
#define ubt int 
const int twx=2e5+100;
const int inf=0x3f3f3f3f;
ll read()
{
    ll sum=0;
    ll flag=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            flag=-1;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        sum=((sum*10)+c-'0');
        c=getchar();
    }
    return sum*flag;
}
int n,k;
int p[twx];
int b[twx];
void init()
{
	n=read();
    k=read();
    vector<int> a(n);
    f1(0,n-1,i)
    {
        cin>>a[i];
    }
    int sorted=0;
    int cnt=0;
    f1(0,n-2,i)
    {
        if(a[i]<a[i+1])
        {
            cnt++;
        }
        else
        {
            cnt=0;
        }
        if(cnt==k-1)
        {
            sorted++;
        }
    }
    set<int> s;
    f1(0,k-1,i)
    {
        s.insert(a[i]);
    }
    int ans=1;
    f1(0,n-k-1,i)
    {
        ans++;
        auto it=s.begin();
        auto ittt=s.end();
        ittt--;
        if(a[i]==*it&&a[i+k]>*ittt)
        {
            ans--;
        }
        s.erase(a[i]);
        s.insert(a[i+k]);
    }
    if(sorted)
    {
        ans-=sorted-1;
    }
    printf("%d",ans);
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    init();
    return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
  int d, t;
  double x, y, theta;

  x = 0;
  y = 0;
  theta = 90;
  while (1) {
    scanf("%d,%d", &d, &t);
    if (!d && !t) break;
    x += d*cos(theta/180.0*M_PI);
    y += d*sin(theta/180.0*M_PI);
    theta -= t;
  }
  cout << ((x>=0.0) ? (int)floor(x) : (int)ceil(x)) << endl;
  cout << ((y>=0.0) ? (int)floor(y) : (int)ceil(y))<< endl;

  return 0;
}

Measured memory_bytes: 1216
N, M = map(int, input().split())

a=[]
b=[]
for i in range(M):

    X, Y= map(int, input().split())
    a.append(X)
    b.append(Y)
    
    if a[0]<a[i]:
      a[0]=a[i]
      
    if b[0]>b[i]:
      b[0]=b[i]

res=b[0]-a[0]+1

if res<0:
  res=0

print(res)

Measured memory_bytes: 10980
#include <stdio.h>
#include <string.h>

int main(){
  int N,K,Q;
  int tmp;
  int P[1000005] = {0};
  scanf("%d %d %d",&N,&K,&Q);
  for(int i=0; i<Q; i++){
    scanf("%d",&tmp);
    P[tmp]++;
  }
  for(int i=1; i<=N; i++){
    if(K-Q+P[i]>0){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }
}

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

int main(){
  int x,y,a,b,c,d,ans=0;
  cin>>y>>x;
  x/=1000;
  d=x-y;
REP(i,(int)d/36+1){
  int s=(int)(-d/4)+i;
  a=4*s+d;
  b=-9*s-2*d;
  c=y-a-b;
  if(a>=0 && b>=0 && c>=0){
    cout<<a<<" "<<b<<" "<<c<<"\n";
    return 0;
  }

}
  cout<<"-1 -1 -1\n";
  return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	int ans = 0;
	rep(i, 1, N + 1) {
		if (i % 2 == 0)continue;
		map<int, int>mp;
		int x = i;
		for (int j = 2;j * j <= x;++j) {
			if (x % j == 0) {
				while (x % j == 0) {
					x /= j;
					mp[j]++;
				}
			}
		}
		if (x > 1)mp[x]++;
		int cnt = 1;
		for (auto p : mp) {
			cnt *= (p.second + 1);
		}
		if (cnt == 8)++ans;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = []
b = [0]*n
look = 1
end = 0
count = 0
for i in range(n):
    a.append(int(input()))
while end == 0:
    count += 1
    b[look-1] = 1
    look = a[look - 1]
    if b[look - 1] == 1:
        end = -1
    else:
        if look == 2:
            end = count
print(end)

Measured memory_bytes: 7852
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a,b,c,d;cin>>a>>b>>c>>d;
    cout << max(min(b,d)-max(a,c),0) << endl;
    return 0;
}

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

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

using namespace std;

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

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


int main(){
    int N; cin >> N;
    vector<ll> A(N);
    for(auto &x : A){
        cin >> x;
    }
    sort(all(A), greater<int>());
    ll res=0;
    int i=0, pos=0;
    while(i < N-1){
        if(i == 0) res+=A[pos], pos++;
        else{
            res+=A[pos];
            if(i%2 == 0) pos++;
        }
        i++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4832
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

class Union_Find {
    public:
    std::vector<int> par;
    Union_Find() {}
    Union_Find(int n){
        par.resize(n, 0);
        reset();
    }

    void reset() {
        // サイズは変えずに初期状態に戻す。
        for (int i = 0; i < par.size(); i++) {
            par[i] = i;
        }
    }

    void simplify(int x) {
        std::vector<int> path;
        while (par[x] != x) {
            path.push_back(x);
            x = par[x];
        }
        for (int p : path) {
            par[p] = x;
        }
    }
    
    int find(const int x){
        simplify(x);
        return par[x];
    }
    
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if (x != y) {
            par[y] = x;
            // 改造する時は「根になっているノードの親を変更する」という原則が守られていることに注意。
        }
    }

    std::unordered_map<int, std::vector<int>> get_group(const int begin, const int end) {
        assert(0 <= begin && end < par.size());
        std::unordered_map<int, std::vector<int>> ret;
        for (int i = begin; i <= end; i++) {
            ret[find(i)].push_back(i);
        }
        return ret;
    }
};

const int MAX_N = 60;
const int MAX_M = MAX_N * MAX_N;

int N, M;
int a[MAX_M], b[MAX_M];

Union_Find uf = Union_Find(MAX_N);

int calc_without(int c) {
    uf.reset();
    for (int i = 1; i <= M; i++) {
        if (i != c) {
            uf.unite(a[i], b[i]);
        }
    }
    auto group = uf.get_group(1, N);
    return group.size();
}

int main(int argc, char **argv) {
    std::cin >> N >> M;
    for (int i = 1; i <= M; i++) {
        std::cin >> a[i] >> b[i];
    }

    int ret = 0;
    for (int i = 1; i <= M; i++) {
        if (1 < calc_without(i)) {
            ret++;
        }
    }

    std::cout << ret << std::endl;
    return 0;

}



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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    while (cin >> a >> b) {
        cout << floor(log10(a + b)) + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3344
#include <bits/stdc++.h>                                           
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;	
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
  
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const int inf = 1e9, maxn = 2e5 + 48, mod = 1e9 + 7, N = 2e6 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;



int n, k, f[N], rf[N], ans;
char s[N];

int binpow (int a, int n) {
	if (n < 0)
		return 0;
	int res = 1;
	while (n) {
		if (n & 1)
			res = res * 1ll * a % mod;
		n >>= 1;
		a = a * 1ll * a % mod;
	}

	return res;
}


void precalc () {
	f[0] = 1;
	for (int i = 1; i < N; ++i)
		f[i] = f[i - 1] * 1ll * i % mod;
	rf[N - 1] = binpow(f[N - 1], mod - 2);
	for (int i = N - 2; i >= 0; --i)
		rf[i] = rf[i + 1] * 1ll * (i + 1) % mod;
}


void add (int &x, int y) {
	x += y;
	if (x >= mod)
		x -= mod;
	if (x < 0)
		x += mod;
}

int cnk (int n, int k) {
	if (n < k)
		return 0;
	return f[n] * 1ll * rf[k] % mod * rf[n - k] % mod;
}

main () {
	precalc();
	scanf("%d\n%s", &k, s);
	n = strlen(s);
	for (int i = 1; i <= n + k; ++i) 
		add(ans, cnk(i - 1, n - 1) * 1ll * binpow(25, i - n) % mod * binpow(26, n + k - i) % mod);
	
	cout << ans << endl;
}



                      

Measured memory_bytes: 20288
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, res, ans;

int main()
{
	in >> N;
	std::vector<LL>a(N);
	rep(i, N)
	{
		in >> a[i];
		while (a[i] % 2 == 0)
		{
			++ans;
			a[i] /= 2;
		}
	}
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 384
import sys
import numpy as np
from collections import defaultdict

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = np.array([1] + lr())
A = (A-1) % K
N += 1
Acum = (A.cumsum() % K).tolist()
d = defaultdict(int)
answer = 0
for i, x in enumerate(Acum):
    answer += d[x]
    d[x] += 1
    if i >= K-1:
        d[Acum[i-(K-1)]] -= 1

print(answer)


Measured memory_bytes: 43360
#include<iostream>  
 
using namespace std;  
   
char table[100][100];  
int W, H;  
const int direction[4][2] = {{ -1, 0 },  { 1, 0 },  { 0, -1 },  { 0, 1 }};  
   
void dfs(int x, int y, char cur)  
{  
  table[x][y] = 'x';  
  for (int i = 0; i < 4; ++i)  
  {  
    int nx = x + direction[i][0];  
    int ny = y + direction[i][1];  
    if (nx >= 0 && nx < W && ny >= 0 && ny < H && table[nx][ny] == cur)  
    {  
      dfs(nx, ny, cur);  
    }  
  }  
}  
   
int main()  
{  
   
  while (cin >> H >> W, W > 0)  
  {  
    int res = 0;  
    int x, y;  
    for (y = 0; y < H; ++y)  
    {  
      for (x = 0; x < W; ++x)  
      {  
        cin >> table[x][y];  
      }  
    }  
   
    for (y = 0; y < H; ++y)  
    {  
      for (x = 0; x < W; ++x)  
      {  
        if (table[x][y] != 'x')  
        {  
          dfs(x, y, table[x][y]);  
          ++res;  
        }  
      }  
    }  
    cout << res << endl;  
  }  
  return 0;  
} 

Measured memory_bytes: 3476
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>

using namespace std;
typedef long long ll;

int main(){
        ios_base::sync_with_stdio(false);
        int n, m;
        cin >> n >> m;
        vector<int> s(n), t(n);
        for(int i = 0; i < n; ++i){ cin >> s[i] >> t[i]; }
        vector<int> p(m + 1);
        for(int i = 0; i < m; ++i){ cin >> p[i]; }
        sort(p.begin(), p.end());
        vector<int> odd_integral(m + 1);
        vector<int> even_integral(m + 1);
        for(int i = 0; i < m; ++i){
                odd_integral[i + 1] = odd_integral[i];
                if(i % 2 == 1){ odd_integral[i + 1] += p[i + 1] - p[i]; }
                even_integral[i + 1] = even_integral[i];
                if(i % 2 == 0){ even_integral[i + 1] += p[i + 1] - p[i]; }
        }
        ll answer = 0;
        for(int i = 0; i < n; ++i){
                vector<int>::iterator it = lower_bound(p.begin(), p.end(), s[i]);
                int spos = --it - p.begin();
                it = lower_bound(p.begin(), p.end(), t[i]);
                int tpos = --it - p.begin();
                const vector<int> &integral =
                        (spos % 2 == 0 ? even_integral : odd_integral);
                if(tpos < spos){
                        answer += integral[spos] - integral[tpos + 1];
                        answer += s[i] - p[spos];
                        if(tpos % 2 == spos % 2){ answer += p[tpos + 1] - t[i]; }
                }else if(tpos > spos){
                        answer += integral[tpos] - integral[spos + 1];
                        answer += p[spos + 1] - s[i];
                        if(tpos % 2 == spos % 2){ answer += t[i] - p[tpos]; }
                }else{
                        answer += abs(s[i] - t[i]);
                }
        }
        cout << answer << endl;
        return 0;
}

Measured memory_bytes: 3120
N,X,M = map(int, input().split())

LOOP = [X]
wk = X
s = set()
s.add(X)
flg = True
for i in range(N-1):
  a = wk * wk % M
  if a == 0:
    print(sum(LOOP))
    exit(0)
  if a in s:
    wk = a
    flg = False
    break
  LOOP.append(a)
  s.add(a)
  wk = a
#print(LOOP)
if flg:
  print(sum(LOOP))
else:
  for i in range(len(LOOP)):
    if LOOP[i] == wk:
      beg_i = i
      break
  fin_i = len(LOOP) -1
  ans = sum(LOOP[:beg_i])
  N -= beg_i
  L = LOOP[beg_i:]
  LS = len(L)
  #print(LS)
  ans += sum(L) * (N//LS)
  N = N % LS
  ans += sum(L[:N])
  print(ans)


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

using namespace std;

int a, b, c, x;

int main()
{
  cin >> a >> b >> c;
  int x = max(a, max(b, c));
  if (3 * x % 2 == (a + b + c) % 2)
    cout << (3 * x - a - b - c) / 2;
  else {
    x++;
    cout << (3 * x - a - b - c) / 2;
  }
  return 0;
}


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

#define y1 dmytxdy
#define fi first
#define se second
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;

template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,tot;
int v[200005],nxt[200005],h[100005],du[100005],dep[100005],f[100005],ans[100005];
bool vis[100005];
vector<int> vec;

void addedge(int x,int y){
	v[++tot]=y; nxt[tot]=h[x]; h[x]=tot; du[x]++;
	v[++tot]=x; nxt[tot]=h[y]; h[y]=tot; du[y]++;
}

void dfs(int u,int fa){
	for(int p=h[u];p;p=nxt[p]){
		if(v[p]==fa) continue;
		dep[v[p]]=dep[u]+1,f[v[p]]=u;
		dfs(v[p],u);
	}
}

int main(){
	n=readint();
	for(int i=1;i<n;i++) addedge(readint(),readint());
	dep[1]=f[1]=0; dfs(1,-1);
	int maxa=0,x=0,y=0;
	for(int i=1;i<=n;i++) if(chkmax(maxa,dep[i])) x=i;
	dep[x]=f[x]=0; dfs(x,-1);
	maxa=0;
	for(int i=1;i<=n;i++) if(chkmax(maxa,dep[i])) y=i;
	vis[x]=vis[y]=1;
	int tmp=f[y];
	while(tmp!=x) vec.push_back(du[tmp]-1),vis[tmp]=1,tmp=f[tmp];
	for(int i=1;i<=n;i++) if(!vis[i]&&nxt[h[i]]) return printf("-1\n"),0;
	int tl=0,tr=vec.size()-1,fl=0;
	for(int i=0;i<vec.size();i++){
		if(vec[tl]>vec[tr]) fl=-1;
		else if(vec[tl]<vec[tr]) fl=1;
		tl++,tr--;
		if(fl!=0) break;
	}
	if(fl<0) reverse(vec.begin(),vec.end());
	ans[1]=1,ans[n]=n;
	int now=1;
	for(int i=0;i<vec.size();i++){
		for(int j=2;j<=vec[i];j++) ans[now+j-1]=now+j;
		ans[now+vec[i]]=now+1;
		now+=vec[i];
	}
	for(int i=1;i<=n;i++) printf("%d ",ans[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 9592
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int tap = std.nextInt();
        int needCount = std.nextInt();
        int count = 0;
        while (needCount > tapCount(count, tap)) {
            count++;
        }

        System.out.println(count);
    }

    private static int tapCount(int count, int tap) {
        if (count == 1) {
            return tap;
        } else {
            return tap * count - (count - 1);
        }
    }
}


Measured memory_bytes: 23760
#include <bits/stdc++.h> 
using namespace std; 
int gi() { 
	int res = 0, w = 1; 
	char ch = getchar(); 
	while (ch != '-' && !isdigit(ch)) ch = getchar(); 
	if (ch == '-') w = -1, ch = getchar(); 
	while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar(); 
	return res * w; 
} 
const long double PI = acos(-1.0); 
const int Mod = 200003, G = 2; 
const int MAX_N = 2e5 + 5; 
struct comp { long double x, y; } f[MAX_N << 2]; 
comp operator + (const comp &l, const comp &r) { return (comp){l.x + r.x, l.y + r.y}; } 
comp operator - (const comp &l, const comp &r) { return (comp){l.x - r.x, l.y - r.y}; } 
comp operator * (const comp &l, const comp &r) { return (comp){l.x * r.x - l.y * r.y, l.x * r.y + l.y * r.x}; } 
int Limit, rev[MAX_N << 2]; 
void FFT_prepare(int len) { 
	int p = 0; 
	for (Limit = 1; Limit <= len; Limit <<= 1) ++p; 
	for (int i = 1; i < Limit; i++) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (p - 1)); 
} 
void FFT(comp p[], int op) { 
	for (int i = 1; i < Limit; i++) if (i < rev[i]) swap(p[i], p[rev[i]]); 
	for (int i = 1; i < Limit; i <<= 1) { 
		comp rot = (comp){cos(PI / i), op * sin(PI / i)}; 
		for (int j = 0; j < Limit; j += i << 1) { 
			comp w = (comp){1, 0}; 
			for (int k = 0; k < i; k++, w = w * rot) { 
				comp x = p[j + k], y = w * p[i + j + k]; 
				p[j + k] = x + y, p[i + j + k] = x - y; 
			} 
		} 
	} 
	if (op == -1) { 
		for (int i = 0; i < Limit; i++) p[i].x /= Limit; 
	} 
} 
int N, mp[MAX_N]; 

int main () { 
	for (int j = 1, i = 0; i < Mod - 1; i++) mp[j] = i, j = G * j % Mod; 
	N = gi(); 
	long long ans = 0; 
	for (int i = 1; i <= N; i++) { 
		int x = gi(); 
		if (x) f[mp[x]].x += 1, ans -= 1ll * x * x % Mod; 
	} 
	FFT_prepare(Mod << 1); 
	FFT(f, 1); 
	for (int i = 0; i < Limit; i++) f[i] = f[i] * f[i]; 
	FFT(f, -1); 
	for (int i = 0, v = 1; i < Mod * 2; i++) { 
		ans += 1ll * v * (long long)(f[i].x + 0.5);
		v = v * G % Mod; 
	} 
	ans /= 2; 
	printf("%lld\n", ans); 
    return 0; 
} 

Measured memory_bytes: 23284
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INF = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[MAX][MAX];

int prim()
{
	int u,minv;
	int d[MAX],p[MAX],color[MAX];
	
	for(int i=0;i<n;i++){
		d[i] = INF;
		p[i] = -1;
		color[i] = WHITE;
	}
	
	d[0] = 0;
	
	while(1){
		minv = INF;
		u = -1;
		for(int i=0;i<n;i++){
			if(minv > d[i] && color[i] != BLACK){
				u = i;
				minv = d[i];
			}
		}
		if(u == -1)break;
		color[u] = BLACK;
		for(int v=0;v<n;v++){
			if(color[v] != BLACK && M[u][v] != INF){
				if(d[v]>M[u][v]){
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}
	int sum = 0;
	for(int i=0;i<n;i++){
		if(p[i]!=-1) sum += M[i][p[i]];
	}
	
	return sum;
}

int main()
{
	cin >> n;
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			int e;
			cin >> e;
			M[i][j] = (e==-1)?INF:e;
		}
	}
	
	cout << prim() <<endl;
	
	
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <set>
#include <list>
#include <utility>
#include <queue>
#include <memory>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

using namespace std; 

int
main(int argc, char const *argv[])
{
    int64_t a, b;
    cin >> a >> b;
    int64_t ans = 0;
    if (b <= 1) {
	cout << 0 << endl;
	return 0;
    }
    if (a <= 1) {
	return 0;
    } else {
    ans = (b - 1) / (a - 1);
    if ( b - 1 > (a - 1) * ans) {
	ans++;
    }
    cout << ans << endl;
    }
    return 0;
}
 


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            List<string> input = new List<string>();
            for(int i = 0; i < n; i++)
            {
                input.Add(Console.ReadLine());
            }
            var sorted = input.OrderBy(x => x).ToArray();

            int count = 0;
            
            if (sorted.Length > 0)
            {
                count++;
            }

            for(int i = 1; i < sorted.Length; i++)
            {
                if(sorted[i-1]!= sorted[i])
                {
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 45760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> m;
    rep(i, N){
        cin >> A[i];
        m[A[i]]++;
    }
    ll ans = 0;
    
    for(auto it = m.begin(); it != m.end(); ++it) {
        ll j = it->second;
        if (j >= 2){
            ans += j * (j - 1)/2;
        }
    }
    rep(k, N){
        ll ans2 = ans;
        ll j = m[A[k]];
        if (j >= 2){
            ans2 -= j * (j - 1)/2;
            ans2 += (j - 1) * (j - 2)/2;
        }
        cout << ans2 << endl;
    }
    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    set<char> sorted;
    string s;
    cin >> s;
    REP(i,s.size())sorted.insert(s.at(i));
    for(int i=0;;i++){
        if(sorted.find(i + 'a') == sorted.end()){
            cout << (char)(i + 'a') << "\n";
            break;
        }
        if(i + 'a' == 'z'){
            cout << "None" << "\n";
            break;
        }
    }
    // cout << "\n";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    ll k, a, b;
    cin >> k >> a >> b;
    ll ans = 1 + k;
    if (a < b){
        ll sum = a;
        k -= a - 1;
        sum += (b-a) * (k / 2);
        k %= 2;
        if (k) sum++;
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

N = input()
ls = []
for _ in range(N):
    A, B = map(int, raw_input().split())
    ls.append((A + B, A, B))
ls.sort(reverse = True)

ans = 0
for i in range(N):
    if i % 2 == 0:
        ans += ls[i][1]
    else:
        ans -= ls[i][2]

print ans

Measured memory_bytes: 21888
#include <iostream>
#include <algorithm>
#include <set>
#include <cstring>
using namespace std;

int main(){
  int n;
  cin >> n;
  while(n--){
    string s;
    cin >> s;
    set<string> ans;
    string a, b;
    for(int i = 0 ; i < s.size() ; i++){
      a = s.substr(0, i);
      b = s.substr(i);
      ans.insert(a+b);
      ans.insert(b+a);
      reverse(a.begin(), a.end());
      ans.insert(a+b);
      ans.insert(b+a);
      reverse(b.begin(), b.end());
      ans.insert(a+b);
      ans.insert(b+a);    
      reverse(a.begin(), a.end());
      ans.insert(a+b);
      ans.insert(b+a);        
    }
    
    cout << ans.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1292
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int mod = 1e+7;

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

  int n;
  cin >> n;
  vector<int> a(n), b;
  rep(i,n) cin >> a[i];
  b = a;
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  rep(i,n) {
    if(a[i] == b[0]) cout << b[1] << endl;
    if(a[i] != b[0]) cout << b[0] << endl;
  }
  return 0;
}

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

int main() {
  ll n, ans = 0;
  cin >> n;
  map<string, ll>mp;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  for (auto &e : mp) {
    ans += e.second * (e.second - 1) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 11136
x,n = map(int, input().split())
if n==0:
    print(x)
    exit()
p=list(map(int,input().split()))

mi = 101
ans=-1
for i in range(-1,102):
    if i in p:
        continue
    if abs(x-i) < mi:
        ans = i
        mi = abs(x-i)
print(ans)

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

using namespace std;
using P = pair<int, int>;

struct edge { int to, cost; };
void dijkstra(vector<vector<edge>>& G, vector<int>& d, int s) {
	priority_queue<P, vector<P>, greater<P>> que;
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first) { continue; }

		for (int i = 0; i < G[v].size(); ++i) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<edge>> g(N * 3);
	for (int i = 0; i < M; ++i) {
		int u, v;
		cin >> u >> v;
		u = (u - 1) * 3;
		v = (v - 1) * 3;
		g[u].push_back({v + 1, 1});
		g[u + 1].push_back({v + 2, 1});
		g[u + 2].push_back({v, 1});
	}
	int s, t;
	cin >> s >> t;
	s = (s - 1) * 3;
	t = (t - 1) * 3;

	vector<int> d(g.size(), 1e8);
	dijkstra(g, d, s);
	cout << (d[t] == 1e8 ? -1 : d[t] / 3) << endl;

	return 0;
}


Measured memory_bytes: 17792
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
  //  FI(); /// skip this line for compile
    int n;
    cin >> n;
    if(n<600) cout << 8 << endl;
    else if(n<800) cout << 7 << endl;
    else if(n<1000) cout << 6 << endl;
    else if(n<1200) cout << 5 << endl;
    else if(n<1400) cout << 4 << endl;
    else if(n<1600) cout << 3 << endl;
    else if(n<1800) cout << 2 << endl;
    else cout << 1 << endl;
    return 0;
}



Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <string>
#include <queue>

using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int H, W;   cin >> H >> W;
    vector<string> s(H);
    for (int i = 0; i < H; i++)
        cin >> s[i];

    vector<vector<int> > dist(H, vector<int>(W, -1));
    queue<pair<int, int> > que;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (s[i][j] == '#') {
                que.push(pair<int, int>(i, j));
                dist[i][j] = 0;
            }
        }
    }

    int ans = 0;
    while (!que.empty()) {
        pair<int, int> v = que.front();
        for (int i = 0; i < 4; i++) {
            int nx = v.first + dx[i];
            int ny = v.second + dy[i];

            if (nx < 0 || H <= nx || ny < 0 || W <= ny || s[nx][ny] == '#' || dist[nx][ny] != -1)
                continue;
            
            dist[nx][ny] = dist[v.first][v.second] + 1;
            ans = dist[nx][ny];
            que.push(pair<int, int>(nx, ny));
        }
        que.pop();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13568
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
    
    int A,B;
    cin >> A >> B;
    if (A >= 10 || B >= 10) {
        cout << -1 << endl;
    } else {
        cout << A * B << endl;
    }

    return 0;
}


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

int main()
{
  long long n, a, b;
  cin >> n >> a >> b;
  long long res = 0;
  res += n / (a + b) * a;
  res += min(a, n % (a + b));
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long A,B,C,K;
  cin>>A>>B>>C>>K;
  long long Af,Bf,Cf;
  for(int i=0;i<K;i++){
    Af=B+C;
    Bf=C+A;
    Cf=A+B;
    A=Af;
    B=Bf;
    C=Cf;
  }
  long long x=1;
  for(int i=0;i<18;i++)
    x*=10;
  if(A-B<=x && B-A<=x)
    cout<<A-B<<endl;
  else
    cout<<"Unfair"<<endl;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
int main() {
  char c[2][3];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c[i][j];
    }
  }
  cout << (c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0] ? "YES" : "NO");
}

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

int main()
{
    ll l, r;
    cin>>l>>r;
    if(r-l>2020){
        cout<<0<<endl;
        return 0;
    }
    ll ans=2018;
    for(ll i=l; i<=r; i++){
        for(ll j=i+1; j<=r; j++){
            ans=min(ans, i*j%2019);
        }
    }
  cout<<ans<<endl;
    return 0;
}

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

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

    string s;
    cin >> s;

    int ans = 0;
    REP(i, s.size()){
        if(s[i] == '+') ans++;
        else ans--;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256