akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, n) for (size_t i = 0; i < (n); i++)
#define REP(n) FOR(i, n)
#define cinv(v, n) REP(n) {cin>>(v)[i];}
#define nvec(T, v, n) vector<T> v(n); cinv(v, n)
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define GCD(v) gcd(ALL(v), 0l)

template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}


int main(){
  int n,y;
  cin>>n>>y;
  y-=1000*n;
  for (size_t i = 0; i <= y/9000; i++) { /*i:mannsatu*/
    int y2=y-9000*i;
    if(y2%4000==0&&y2/4000<=n-i){
      cout<<i<<" "<<y2/4000<<" "<<n-i-y2/4000;
      return 0;
    }
  }
  cout<<"-1 -1 -1";
}






/* きょむ〜 */

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,M;
const int INFTY = 99999; 
vector<list<int>> G;
vector<int> dis;
bool POSSIBLE = false;

void print_list(list<int> list){
  for(auto itr = list.begin(); itr != list.end(); itr++){
    cout << *itr << ' ';
  }
}
void bfs(){
  queue<int> q;
  dis.at(0) = 0;
  q.push(0);
  int u;
  list<int> list;
  while(!q.empty()){
    u = q.front(); q.pop();
    list = G.at(u);
    if(dis.at(u) <= 2 && u == N - 1){
      POSSIBLE = true;
      return;
    }
    for(auto itr = ++list.begin(); itr != list.end(); ++itr){
      if(dis.at(*itr) == INFTY){
        q.push(*itr);
        dis.at(*itr) = dis.at(u) + 1;
      }
    }
  }
}

int main(){
  cin >> N >> M;
  G = vector<list<int>>(N);
  dis = vector<int>(N,INFTY);
  for(int i = 0; i < N; i++){
    G.at(i).push_back(i);
  }
  for(int i = 0; i < M; i++){
    int a,b; cin >> a >> b;
    a--;
    b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  /*for(int i = 0; i < N; i++){
    Print_list(G.at(i));
    cout << endl;
  }*/
  bfs();
  if(POSSIBLE) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}


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

int main() {    
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i,n) {
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }

    int ans = 1e9;
    rep(i,1<<n) {
        vector<int> y(m, 0);
        int sum = 0;
        rep(j,n) {
            if((i>>j)%2) {
                rep(k,m) y[k] += a[j][k];
                sum += c[j];
            }
        }
        bool flag = true;
        rep(j,m) if(y[j] < x) flag = false;
        if(flag) ans = min(ans, sum);
    }
    if(ans == 1e9) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

vec div(int n) {
    vec r(2);
    r[1] = ((n % 2) + 2) % 2;
    if (n < 0) {
        if (r[1] % 2) {
            r[0] = abs(n-1) / 2;
        }
        else {
            r[0] = abs(n) / 2;
        }
    }
    else {
        r[0] = n / 2;
        r[0] = -r[0];
    }
    return r;
}

int main() {
    int n;
    cin >> n;
    if (n == 0) {
        cout << 0 << endl;
        exit(0);
    }

    string res = "";

    while (n != 1 && n != 0) {
        auto re = div(n);
        int q = re[0], r = re[1];
        n = q;
        res += to_string(r);
        if (q == 1) res += to_string(q);
    }

    reverse(all(res));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
//桁
int kt(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a;
  cin>>a;
  vector<int> b(a);
  rep(i,a)
    cin>>b[i];
  int c=0;
  int d=0;
  rep(i,a){
  rep(j,a){
  c+=b[i]*b[j];
  }
  }
   rep(i,a)
   d+=b[i]*b[i]; 
            cout<<(c-d)/2;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main (){
  int a, b, t;
  int i;
  int count = 0;
  
  cin >> a >> b >> t;

  i = 0;
  i += a;
  while(i<t+0.5){
    count += b;
    i += a;
  }

  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
constexpr int mod = 1e9+7;

bool grid[1010][1010];
int dp[1010][1010];

int main(){
  int h, w;
  char prop;
  cin>>h>>w;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin>>prop;
      if(prop=='#')
        grid[i][j]=0;
      else grid[i][j]=1;
    }
  }
  for(int i = 0; i < h && grid[i][0]; i++)
    dp[i][0] = 1;
  for(int j = 0; j < w && grid[0][j]; j++)
    dp[0][j] = 1;

  for(int i = 1; i < h; i++){
    for(int j = 1; j < w; j++){
      if(grid[i][j])
        dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
      else
        dp[i][j] = 0;
    }
  }
  cout << dp[h-1][w-1] << "\n";
  return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i, r, n) for (ll i = (ll)(n - 1); i >= r; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T>
T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T>
T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

ll d[4][4];

int main()
{
    REP(i, 3)
    {
        REP(j, 3)
        {
            cin >> d[i + 1][j + 1];
        }
    }
    ll a1, a2, a3, b1, b2, b3;
    REP(i, 101)
    {
        a1 = i;
        b1 = d[1][1] - a1;
        a2 = d[2][1] - b1;
        b2 = d[2][2] - a2;
        a3 = d[3][2] - b2;
        b3 = d[3][3] - a3;
        if (a1 >= 0 && a2 >= 0 && a3 >= 0 && b1 >= 0 && b2 >= 0 && b3 >= 0&&a1+b2==d[1][2]&&a1+b3==d[1][3]&&a2+b3==d[2][3]&&a3+b1==d[3][1]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    println( n * n * n)
    return 0;
}

Measured memory_bytes: 3572
#include<cstdio>
int main(){
	int n;
	int a[51];
	scanf("%d",&n);
	int res = 0;
	for(int i = 0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i = 0;i<n;i++){
		for(int j = i;j<n;j++){
			if(i!=j){
				int t = a[i]*a[j];
				res += t;
			}
		}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 128
/*input
32
29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define int long long
#define MAX 100090
#define INF 0x3f3f3f3f
#define mod 1000000007LL

int n , x[MAX] , gi[MAX] , ni[MAX] , ans[MAX] , use[MAX];
int C(int a , int b){
    if(a < b) return 0;
    return gi[a] * ni[b] % mod * ni[a - b] % mod;
}
int32_t main(){
    IOS;
    gi[0] = ni[0] = ni[1] = 1;
    REP(i , 1 , MAX) gi[i] = gi[i - 1] * i % mod;
    REP(i , 2 , MAX) ni[i] = ni[mod % i] * (mod - mod / i) % mod;
    REP(i , 2 , MAX) ni[i] = ni[i] * ni[i - 1] % mod;

    int d;
    cin >> n , n ++;
    REP(i , 1 , n + 1) cin >> x[i];
    REP(i , 1 , n + 1) 
        if(use[x[i]]) d = i - use[x[i]] + 1;
        else use[x[i]] = i;

    REP(i , 1 , n + 1) ans[i] = C(n , i);
    REP(i , 1 , n + 1) ans[i] -= C(n - d , i - 1);
    REP(i , 1 , n + 1) ans[i] = (ans[i] % mod + mod) % mod;
    REP(i , 1 , n + 1) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 5120
import sys
import itertools
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    a = [v % m for v in list(itertools.accumulate(a))]
    cnt = a.count(0)
    d = collections.defaultdict(int)
    for v in a:
        cnt += d[v]
        d[v] += 1
    print(cnt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 56816
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

template <class E>
using Graph = vector<vector<E>>;

struct Edge {
    int to, cost;
    Edge(int to, int cost): to(to), cost(cost) {}
};

template <class E>
void addEdge(Graph<E>& graph, int from, int to, int cost) {
    graph[from].push_back(E(to, cost));
    graph[to].push_back(E(from, cost));
}



int main() {
    int n; cin >> n;
    Graph<Edge> g(n);
    rep(i, n-1) {
        int u, v, w; cin >> u >> v >> w;
        addEdge(g, u-1, v-1, w % 2);
    }

    vector<int> cost(n, 0);
    vector<bool> visit(n, false);
    queue<int> q;
    q.push(0);
    while(!q.empty()) {
        int i = q.front(); q.pop();
        for(Edge e: g[i]) {
            if(!visit[e.to]) {
                visit[e.to] = true;
                q.push(e.to);
                cost[e.to] = cost[i] + e.cost;
            }
        }
    }

    rep(i, n) {
        cout << cost[i] % 2 << endl;
    }
    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    set<int> st;
    rep(i, 3)
    {
        int a;
        cin >> a;
        st.insert(a);
    }

    OP(st.size());

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int n;
	int l[1000];
	int r[1000];
	int ans=0;
	
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>l[i]>>r[i];
		ans += (r[i]-l[i]+1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
typedef long long int ll;
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<m;j++) 
#define pb push_back 
#define mp make_pair 
#define sc second 
#define f first 
#define kek cout<<"\n" 
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
const ll MOD = 1e9 + 7;
const int N = 1005;
const ll INF = 1e9;
using namespace std;
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	char c;
	cin >> c;
	cout << char(c + 1);
	return 0;
 
 
}

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

int main() {
  int N, K, a;
  cin >> N >> K;
  
  for (int i = 0; ;i++) {
    if(pow(K, i) > N) {
      a = i;
      break;
    }
  }
  cout << a << endl;
}

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

typedef pair<int,int> pii;
const int N = 1e5;

int n;
map<pii,int> idx;
vector<int> adj[N+5];
int ans[N+5];

int lstidx[N+5];
int atas[N+5];

void dfs(int x, int p=-1){
	for(int i=0;i<adj[x].size();i++){
		int nx = adj[x][i];
		if(nx == p) continue;
		if(lstidx[x] == atas[x]) lstidx[x]++;
		atas[nx] = lstidx[x];
		int u = x;
		int v = nx;
		if(u > v) swap(u,v);
		ans[idx[make_pair(u,v)]] = lstidx[x];
		lstidx[x]++;
		dfs(nx,x);
	}
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		adj[u].push_back(v);
		adj[v].push_back(u);
		idx[make_pair(u,v)] = i;
	}
	int maksi = 0;
	for(int i=1;i<=n;i++){
		maksi = max(maksi,(int)adj[i].size());
		lstidx[i] = 1;
	}
	printf("%d\n",maksi);
	dfs(1);
	for(int i=1;i<n;i++){
		printf("%d\n",ans[i]);
	}
	return 0;
}


Measured memory_bytes: 16128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new java.util.Scanner(System.in);

		InputStreamReader input = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(input);

		StringBuilder sb = new StringBuilder();

		while (true) {
			int n = Integer.parseInt(br.readLine());
			if (n==0) break;
			int[] s = new int[n];

			String[] dataset = br.readLine().split(" ");

			for (int i = 0; i < n; i++) {
				s[i] = Integer.parseInt(dataset[i]);
			}
			int goukei = 0;

			for (int i : s) {
				goukei += i;
			}
			double m = (double)goukei / (double)n;

			double alfa2 = 0.0;

			for (int i : s) {
				alfa2 += (i - m) * (i - m);
			}

			alfa2 = alfa2 / n;

			double alfa = Math.sqrt(alfa2);
			System.out.println(alfa);
		}
	}

}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;


// https://qiita.com/ta-ka/items/a023a11efe17ab097433
struct Edge {
    ll to, cost;
};
vector<vector<Edge>> edges;

void insertTowWay(ll from, ll to, ll cost) {
    edges[from].push_back({to, cost});
    edges[to].push_back({from, cost});
}

class Dijkstra {
    ll vector_count;

    vector<ll> distances;

public:
    Dijkstra(ll n) {
        vector_count = n;
        distances.resize(n, INF);
    }


    void dijkstra(ll k) {
        distances[k] = 0;  // 始点sへの最短距離は0

        priority_queue<P, vector<P>, greater<P>> que;  // 距離が小さい順に取り出せるようgreater<P>を指定
        que.push(P(0, k));
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;  // 更新した頂点の中で距離が最小の頂点v
            if (distances[v] < p.first) {
                continue;
            }
            for (auto e : edges[v]) {  // 頂点vから出る辺eを走査
                if (distances[e.to] > distances[v] + e.cost) {
                    distances[e.to] = distances[v] + e.cost;
                    que.push(P(distances[e.to], e.to));
                }
            }
        }
    }

    ll calcDistance(ll to) {
        return distances[to];
    }

};


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


    vector<Dijkstra> dijkstra_list;
    rep(i, n) {
        Dijkstra d(n);
        dijkstra_list.push_back(d);
    }


    edges.resize(n);
    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        insertTowWay(a, b, c);
    }

    rep(i, n) {
        dijkstra_list[i].dijkstra(i);
    }

    int ans = 0;

    for (int i = 0; i < n; i++) {
        vector<Edge> es = edges[i];
        for (Edge e : es) {
            ll cost = dijkstra_list[i].calcDistance(e.to);
            if (cost < e.cost) {
                ans++;
            }
        }
    }

    cout << (ans / 2) << endl;

}

Measured memory_bytes: 384
#include<stdio.h>

#include  <stdio.h>

void QSort(long x[ ], int left, int right);
void Swap(long x[ ], int i, int j);

  /* クイックソートを行う */
void QSort(long x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */

    pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

    while (1) {                    /* 無限ループ */

        while (x[i] < pivot)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */

        while (pivot < x[j])       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */

        Swap(x, i, j);             /* x[i] と x[j]を交換 */
        i++;                       /* 次のデータ */
        j--;
    }

    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(x, left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(x, j + 1, right);    /* 右の配列を Q ソートする */
}

  /* 配列の要素を交換する */
void Swap(long x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

int ls(long x[],int n,long key){
  int left=0,right=n-1,mid;
  mid=(left+right)/2;
  while((mid!=left+1||right!=mid+1)&&left!=mid){
    if(x[mid]<key) left=mid;
    else right=mid+1;
    mid=(left+right)/2;
  }
  if(x[left]>=key) return left;
  else if(x[mid]>=key) return mid;
  else if(x[right]>=key) return right;
  return n;
}

int main(){
  int i,n,j,k;
  long a[100000],b[100000],c[100000],ca,cc,ans;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
  }
  for(i=0;i<n;i++){
    scanf("%ld",&b[i]);
  }
  for(i=0;i<n;i++){
    scanf("%ld",&c[i]);
  }
  QSort(a, 0, n - 1);
  QSort(c, 0, n - 1);
  for(i=0;i<n;i++){
    ca=ls(a,n,b[i]);
    cc=ls(c,n,b[i]+1);
    ans+=(long)ca*(n-cc);
  }
  printf("%ld\n",ans);
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
const int M = 100005 ;
using namespace std ;
int n ;
int a[M] ;
long long Ans ;
inline long long Solve(int x){
	int tim = 0 ;
	while(x%2==0){
		x >>=1;
		++tim ;
	}
	return tim ;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
	    scanf("%d",&a[i]);
	    Ans += Solve(a[i]) ;
	}
	cout<<Ans<<endl ;
	return 0 ;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == 5 && b == 5 && c == 7 || a == 5 && b == 7 && c == 5 || a == 7 && b == 5 && c == 5)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <cmath>
#include <tuple>
#include <algorithm>
#include <ctime>
#include <map>
#include <fstream>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;


const long long MOD = static_cast<long long>(1e9+7);
const long long INFINITE = static_cast<long long>(1e16);
const bool IS_DEBUG = false;



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int H,W,M;
    cin>>H>>W>>M;
    map<int,int> perCol;
    map<int,int> perRow;
    map<int,set<int> > mRow;
    for(int c=0;c<M;c++) {
        int h,w;
        cin>>h>>w;
        perCol[w]++;
        perRow[h]++;
        mRow[h].insert(w);
    }
    vector<pair<int,int> > v1;
    for(auto z:perRow) {
        v1.push_back(make_pair(z.second,z.first));
    }
    sort(v1.rbegin(),v1.rend());

    vector<pair<int,int> > v2;
    for(auto z:perCol) {
        v2.push_back(make_pair(z.second,z.first));
    }
    sort(v2.rbegin(),v2.rend());
    int countMaxi = 0;
    for(int c=0;c<v2.size();c++) {
        if(v2[c].first == v2[0].first) countMaxi++;
    }
    int res = 0;
    for(auto z:v1) {
        int count2Maxi = 0;
        for(auto y:mRow[z.second]) {
            if(perCol[y] == v2[0].first) {
                count2Maxi++;
            }
        }
        if(count2Maxi == countMaxi) {
            res = max(res, z.first+v2[0].first-1);
        } else {
            res = max(res, z.first+v2[0].first);
        }
    }
    cout<<res;
}


Measured memory_bytes: 81924
N = int(input())
X = list(map(int,input().split()))

candidates = []
for p in range(min(X), max(X)+1):
    #x=pで開催するとき
    #print(p)
    c = sum([(x - p)**2 for x in X])
    candidates.append(c)

print(min(candidates))

Measured memory_bytes: 3064
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <functional>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define MAX_DWORD				(0xFFFFFFFF)
#define	MAX_SDWORD				((SDWORD)0x7FFFFFFF)
#define	MIN_SDWORD				((SDWORD)0x80000000)
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define	MIN_QWORD				((QWORD)0x0000000000000000)
#define	MAX_SQWORD				((SQWORD)0x7FFFFFFFFFFFFFFF)
#define	MIN_SQWORD				((SQWORD)0x8000000000000000)
#define M_PI					3.14159265358979323846

typedef long					SDWORD;
typedef long long				SQWORD;
typedef unsigned long			DWORD;
typedef unsigned long long int	QWORD;
typedef pair<int, int>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
#define N_MAX	(200 * 1000)
#define K_MAX	(10)
#define M_MAX	(10)
#define H_MAX	(1000)
#define W_MAX	(1000)

int main()
{
	int A, B;
	cin >> A >> B;
	
	if (A % 3 == 0) {
		cout << "Possible";
	} else if (B % 3 == 0) {
		cout << "Possible";
	} else if ((A + B) % 3 == 0) {
		cout << "Possible";
	} else {
		cout << "Impossible";
	}

	cout << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {

	  // argumentの取得
	  Scanner s = new Scanner(System.in);
      double N = s.nextInt();
      
      
	  // 戻り値の返却
      // N % 108だと値が変わって動かない。。後で調べる
      if ((N * 100 % 108) == 0) {
        System.out.println(String.format("%.0f",N/1.08));
      } else {
        // 元に戻るか判定
        // Nを1.08で割る
        double tempA = Math.floor(N/1.08);
        
         // ↑に1.08をかけて、小数点を捨ててもとに戻ればOK
        double tempB = Math.floor((Math.floor(tempA +1) * 1.08));
        //System.out.println(tempA);
        //System.out.println(tempB);
        
        if (N == tempB) {
          //System.out.println(Math.floor(tempA +2));
          System.out.println(String.format("%.0f",Math.floor(tempA +1)));
          //String.format("%.2f", b)
        } else {
          System.out.println(":(");
        }
       
      }
	
	} 
}

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

using namespace std;

#define int ll
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;

vi e[120000], d(120000);
vi g[120000], cnt(120000);
vb vis(120000);

signed main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr); 
    cerr.tie(nullptr);    

    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; ++i){
        int u, v;
        cin >> u >> v;

        e[u].push_back(v);
        g[v].push_back(u);
    }

    queue<int> q;
    for (int i = 1; i <= n; ++i){
        int l = e[i].size();

        if (!l){
            q.push(i);
        }
    }

    int sol = 0;
    while (!q.empty()){
        int c = q.front();
        q.pop();
        sol = max(sol, d[c]);

        for (auto& i : g[c]){
            ++cnt[i];
        }

        for (auto& i : g[c]){
            int l = e[i].size();
            if (cnt[i] == l){
                q.push(i);
            }
            d[i] = max(d[i], d[c] + 1);
        }
    }

    cout << sol << '\n';
}

Measured memory_bytes: 14080
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();

		if (a < b) {
			if (b < c) {
				System.out.println("No");
			} else if (c < a) {
				System.out.println("No");
			} else {
				System.out.println("Yes");
			}
		} else {
			if (a < c) {
				System.out.println("No");
			} else if (c < b) {
				System.out.println("No");
			} else {
				System.out.println("Yes");
			}
		}
		scanner.close();

	}
}

Measured memory_bytes: 21844
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009

char ans[1001];
char re[1001];

void reverse(int x, int y){
	f(i, y - x + 1)re[i] = ans[x + i];
	f(i, y - x + 1)ans[y - i] = re[i];
}



int main(void){
	char a[10];
	f(i, 1001){
		ans[i] = 0;
	}
	int n, m;
	int x, y;
	scanf("%s", ans);
	scanf("%d", &n);
	f(i,n){
		scanf("%s", a);
		if (a[2] == 'i'){
			scanf("%d %d", &x, &y);
			for (int i = x; i < y + 1; i++)printf("%c", ans[i]);
			printf("\n");
		}
		else if (a[2] == 'v'){
			scanf("%d %d", &x, &y);
			reverse(x,y);
		}
		else{
			scanf("%d %d", &x, &y);
			scanf("%s", re);
			for (int i = x; i < y + 1; i++)ans[i] = re[i - x];
		}
	}

	return 0;
}

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



int main() {
	string S;
	cin >> S;

	int A = S[0] - '0';
	int B = S[1] - '0';
	int C = S[2] - '0';
	int D = S[3] - '0';

	if (A + B + C + D == 7) cout << A << '+' << B <<'+'<<C<<'+'<<D<<'='<<A+B+C+D << endl;
	else if (A - B + C + D == 7) cout << A<<'-'<<B<<'+'<<C<<'+'<<D<<'='<<A-B+C+D << endl;
	else if (A + B - C + D == 7) cout << A<<'+' <<B<<'-'<<C<<'+'<<D<<'='<< A + B - C + D << endl;
	else if (A + B + C - D == 7) cout << A<<'+'<<B<<'+'<<C<<'-'<<D<<'='<< A + B + C - D << endl;
	else if (A - B - C + D == 7) cout << A<<'-'<<B<<'-'<<C<<'+'<<D<<'='<<A-B-C+D << endl;
	else if (A + B - C - D == 7) cout << A<<'+'<<B<<'-'<<C<<'-'<<D<<'='<< A + B - C - D << endl;
	else if (A - B + C - D == 7) cout << A<<'-'<<B<<'+'<<C<<'-'<<D<<'='<<  A - B + C - D<< endl;
	else if (A - B - C - D == 7) cout << A<<'-'<<B<<'-'<<C<<'-'<<D<<'='<< A - B - C - D << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cctype>
#include <ctime>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define eps 1e-9
#define SZ(x) ((int)x.size())
#define x first
#define y second

typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 1e6;
int n, m, a, b, edge = 0, cnt1 = 0, cnt2 = 0;
int head[maxn], to[maxn], Next[maxn], color[maxn];
bool flag = true;

void add_edge(int u, int v) {
    to[edge] = v; Next[edge] = head[u]; head[u] = edge++;
}
void dfs(int u, int k) {
    if (k == 1) { ++cnt1; } else { ++cnt2; } color[u] = k; int v;
    for (int i = head[u]; i != -1; i = Next[i]) {
        v = to[i];
        if (color[v]) {
            if (color[v] == color[u]) { flag = false; } continue;
        }
        dfs(v, 3 - k);
    }
}

int main() {
#ifdef __AiR_H
    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif // __AiR_H
    memset(head, -1, sizeof(head)); scanf("%d %d", &n, &m); ll ans;
    for (int i = 0; i < m; ++i) {
        scanf("%d %d", &a, &b); add_edge(a, b); add_edge(b, a);
    }
    dfs(1, 1);
    if (flag) { ans = 1ll * cnt1 * cnt2 - m; }
    else { ans = 1ll * n * (n - 1) / 2 - m; }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 14976
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI A(N);
	REP(i, N)cin >> A[i];
	int k = 1;
	int ans = 0;
	REP(i, N) {
		if (A[i] != k) {
			ans++;
		}
		else k++;
	}
	if (ans == N)ans = -1;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
#define N 100005
typedef long long ll;
int a[N],b[N],pp[N],minm[N],pos[N],n,m,tot,num;
bool vis[N];
ll ans;
int find(int x){return x==pp[x]?x:pp[x]=find(pp[x]);}
int main()
{
	scanf("%d%d",&n,&m);
	rep(i,n)pp[i]=i;
	rep(i,n)scanf("%d",&a[i]);
	int x,y;
	rep(i,m){
		scanf("%d%d",&x,&y),++x,++y;
		pp[find(x)]=find(y);
	}
	rep(i,n)minm[i]=1e9+1;
	rep(i,n){
		int u=find(i);
		if(!vis[u])num++;vis[u]=1;
		if(minm[u]>a[i]){pos[u]=i;minm[u]=a[i];}
	}
	rep(i,n){
		int u=find(i);
		if(pos[u]==i)ans+=a[i];
		else b[++tot]=a[i];
	}
	if(num==1){puts("0");return 0;}
	if(tot<num-2){puts("Impossible");return 0;}
	sort(b+1,b+tot+1);
	rep(i,num-2)ans+=b[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2176
use std::cmp;
use std::collections::BTreeMap;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: i64 = sc.read();
    let x: i64 = sc.read();
    let d: i64 = sc.read();
    if d == 0 {
        if x == 0 {
            println!("{}", 1);
        } else {
            println!("{}", n + 1);
        }
        return;
    }

    let mut ans = BTreeMap::new();
    let (x, d) = if d < 0 { (-x, -d) } else { (x, d) };
    for k in 0..(n + 1) {
        let from = (k - 1) * k / 2;
        let to = ((n - k) + (n - 1)) * k / 2;

        let min = k * x + from * d;
        let max = k * x + to * d;

        let m = min % d;
        let m = if m < 0 { m + d } else { m };
        ans.entry(m).or_insert(Vec::new()).push((min, max));
    }

    let mut sum = 0;
    for (_, mut ans) in ans.into_iter() {
        ans.sort();
        let mut count = 0;
        let (mut cur_min, mut cur_max) = ans[0];
        for i in 1..ans.len() {
            let (min, max) = ans[i];
            if cur_max < min {
                count += (cur_max - cur_min) / d + 1;
                cur_min = min;
                cur_max = max;
            } else {
                cur_max = cmp::max(cur_max, max);
            }
        }

        count += (cur_max - cur_min) / d + 1;
        sum += count;
    }
    println!("{}", sum);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 37116
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]

direction = True
here = 0
answer = []
for i in range(H):
    if direction:
        while here < W:
            if here == W - 1:
                if i == H - 1:
                    break
                if a[i][here] % 2 == 1:
                    a[i][here] -= 1
                    a[i + 1][here] += 1
                    answer.append([i, here, i + 1, here])
                direction = False
                break
            if a[i][here] % 2 == 1:
                a[i][here] -= 1
                a[i][here + 1] += 1
                answer.append([i, here, i, here + 1])
                here += 1
            else:
                here += 1
    else:
        while -1 < here:
            if here == 0:
                if i == H - 1:
                    break
                if a[i][here] % 2 == 1:
                    a[i][here] -= 1
                    a[i + 1][here] += 1
                    answer.append([i, here, i + 1, here])
                direction = True
                break
            if a[i][here] % 2 == 1:
                a[i][here] -= 1
                a[i][here - 1] += 1
                answer.append([i, here, i, here - 1])
                here -= 1
            else:
                here -= 1

print(len(answer))
for i in answer:
    print(' '.join(map(str, [j + 1 for j in i])))

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

#define INF (1 << 30)
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

template <typename T>
T v1sum(vector<T> vec){
    T ret = 0;
    for(int i = 0; i < vec.size(); i++) ret += vec[i];
    return ret;
}
template <typename T>
vector<T> v1sort(vector<T> vec, bool min_to_max=true){
    sort(vec.begin(), vec.end(), [min_to_max](const T a, const T b){return (min_to_max == true) ? (a < b) : (b < a);});
    return vec;
}
template <typename T>
void v1show(vector<T> vec){
    for(int i = 0; i < vec.size(); i++){
        cout << vec[i] << " ";
    }
    cout << endl;
}
template <typename T>
vector<vector<T> > v2init(int y_len, int x_len, T padding){
    vector<vector<T> > vec(y_len, vector<T>(x_len, padding));
    return vec;
}
template <typename T>
vector<vector<T> > v2sort(vector<vector<T> > vec, int index){
    sort(vec.begin(), vec.end(), [index](const vector <T>  a, const vector <T> b){return (a[index] > b[index]);});
    return vec;
}
template <typename T>
void v2show(vector<vector<T> > vec){
    for(int i = 0; i < vec.size(); i++){
        for(int j = 0; j < vec[0].size(); j++){
            cout << vec[i][j] << " ";
        }
        cout << endl;
    }
}
template <typename T>
ll v2sum(vector<vector<T>> vec){
    ll ans = 0;
    for (int i = 0; i < vec.size(); i++){
        for (int j = 0; j < vec[0].size(); j++){
            ans += vec[i][j];
        }
    }
    return ans;
}
template <typename T, typename S>
vector<vector<T> > banpei(vector<vector<T> > vec, S padding){
    vector<vector<T> > ret = v2init<T>(vec.size()+2, vec[0].size()+2, vec[0][0]);
    for (int i = 0; i < vec.size()+2; i++){
        for (int j = 0; j < vec[0].size()+2; j++){
            if((i == 0) || (j == 0) || (i == vec.size()+1) || (j == vec[0].size()+1)){
                ret[i][j] = padding;
            }else{
                ret[i][j] = vec[i-1][j-1];
            }
        }
    }
    return ret;
}
int main(){
    int n;
    cin >> n;
    unordered_map<string, ll> mp;
    ll ans = 0;
    for(int i = 0; i < n; i++) 
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        ans += mp[s];
        mp[s]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10660
#include <cstdio>
using namespace std;
int n;
int a[102];
int main() {
	int a;
	int ans;
	int max, min;
	scanf("%d", &n);
	scanf("%d", &a);
	max = min = a;
	for (int i = 0; i < n-1; i++) {
		int m;
		scanf("%d", &m);
		if(m<min)min=m;
		if (m > max)max = m;
	}

	ans = max - min;
	printf("%d\n", ans);
}

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

class Program
{
    static void Main(string[] args)
    {
        var M = sc.ReadInt();
        var D = sc.ReadInt();
        var ans = 0;
        for (int i = 1; i <= M; i++)
        {
            for (int j = 10; j <= D; j++)
            {
                var d1 = j % 10;
                var d10 = (j - d1) / 10;
                if (d1 >= 2 && d10 >= 2 && d1 * d10 == i)
                {
                    ans++;
                }
            }
        }
        Console.WriteLine(ans);
    }

    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 13140
n,m = map(int,input().split())
h = list(map(int,input().split()))
ab = [[] for i in range(n)]

for i in range(m):
    x1, y1 = [int(i) for i in input().split()]
    ab[x1-1].append(y1-1)
    ab[y1-1].append(x1-1)

ans = 0

for i in range(n):
    ok = 1
    for j in range(len(ab[i])):
        #print(i)
        if h[i] >h[ab[i][j]]:
            continue
        else:
            ok = 0
            break

    if ok == 1:
        #print(i)
        ans += 1

print(ans)


Measured memory_bytes: 92412
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   int a,b;
   cin >> a >> b;
   int ans = 0;
   for(int i=a;i<=b;i++){
    string s = to_string(i);
    string t = s;
    reverse(s.begin(),s.end());
    if(s==t)
    ans++;
	}
   cout << ans << endl;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
 
import bisect
 
n,q = na()
s = ns()
x = []
 
for r in range(len(s)-1):
  if s[r] == 'A':
    if s[r+1] == 'C':
      x.append(r)
 
for i in range(q):
  l,r = na()
  b = bisect.bisect_left(x,l-1)
  a = bisect.bisect_right(x,r-2)
  c = a-b if a-b>0 else 0
  print(c)

Measured memory_bytes: 6044
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
//#define INF 1100000000000000000LL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main() {
	ll N;
	cin>>N;
	ll i;
	for(i=0;i*i<=N;i++);
	i--;
	cout<<i*i<<endl;
    return 0;
}

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

using namespace std;

bool Judge(vector<int> a, vector<int> b, int d){
    int sq_sum = 0;
    for (int i = 0;i < d;i++)
        sq_sum += (int)pow(a[i] - b[i], 2.0);
    return sq_sum == (int)pow((int)sqrt(sq_sum), 2.0);
}

signed main(){
    int n,d;
    cin >> n >> d;
    vector<vector<int>> xs(n);
    for (int i = 0;i < n;i++){
        vector<int> x(d);
        for (int j = 0;j < d;j++)
            cin >> x[j];
        xs[i] = x;
    }

    int ans = 0;
    for (int i = 0;i < n;i++)
        for (int j = i + 1;j < n;j++)
            if (Judge(xs[i],xs[j],d))
                ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val inputCount = readLine()!!.toInt()
    var (ansT, ansA) = listOf(1L, 1L)
    (1..inputCount).forEach {
        val (t, a) = readLine()!!.split(" ").map { it.toLong() }
        val start = Math.max(ansT/t, ansA/a)
        for (i in (start..(ansT+ansA))) {
            if(t*i>=ansT && a*i>=ansA) {
                ansT = t*i
                ansA = a*i
                break
            }
        }
    }
    println(ansA+ansT)
}



Measured memory_bytes: 37920
open System
open System.Runtime.InteropServices

let read() = Console.ReadLine() |> int

let N = read()
let A = 
    let t = Array.zeroCreate 2
    for i in 0..1 do 
        t.[i] <- Console.ReadLine().Split()
                 |> Array.map(int)
    t

let dp = Array2D.zeroCreate 2 N
dp.[0,N-1] <- A.[0].[N-1] + A.[1].[N-1]
dp.[1,N-1] <- A.[1].[N-1]
for i in (N-2)..(-1)..0 do 
    dp.[1,i] <- A.[1].[i] + dp.[1,i+1]
    dp.[0,i] <- A.[0].[i] + max dp.[0,i+1] dp.[1,i]

dp.[0,0]
|> printfn "%i" 


Measured memory_bytes: 11996
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int maxn=1e5+233;
int n,m;
int a[maxn];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int a[5],k;
	for(int i=0;i<5;i++)cin>>a[i];
	cin>>k;
	int dd=0;
	for(int i=0;i<5;i++){
		for(int j=i+1;j<5;j++){
			dd=max(dd,abs(a[j]-a[i]));
		}
	}
	if(dd>k)cout<<":("<<endl;
	else	cout<<"Yay!"<<endl;
    return 0;
}


Measured memory_bytes: 256