akhauriyash/Code-Regression huggingface dataset:
#include <string.h>

#include <algorithm>
#include <cstdlib>  // abs() for integer
#include <iostream>

using namespace std;

int main(void) {

	int N;
	int L[100];

	cin >> N;
	for (int i = 0; i < N; i++) cin >> L[i];
	sort(L, L + N);//昇順でソート

	int ans = 0;

	for (int i = 0; i < N - 2; i++) {
		for (int j = i + 1; j < N - 1; j++) {
			for (int k = j + 1; k < N; k++) {

				//同じ長さの辺があればその時点で計算しない
				if (L[i] == L[j] || L[j] == L[k]) {

				}

				else {//三角形の成立条件
					if (L[i] + L[j] > L[k]) {
						ans++;
					}
				}


			}
		}
	}

	cout << ans << endl;
	return 0;
}

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

using namespace std;

const int N = 2e5 + 5;
const int M = 1e6 + 9;
const long long INF = 1e9 + 7;
const int SM = 1e3 + 4;
const double EPS = 3e-16;
const int K = 25;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    
    int n; cin >> n;
    vector<int> a(n), ans(n, 0);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        ans[a[i] - 1] = i + 1;
    }
    
    
    for(int i = 0; i < n; i++){
        cout << ans[i] << " ";
    }
    
    return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
int main(){
int n,m;
while(1){
scanf("%d%d",&n,&m);
if(n==0)return 0;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
printf("#");
}
printf("\n");
}
printf("\n");
}
}

Measured memory_bytes: 2600
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        
        long L = sc.nextLong();
        long R = sc.nextLong();
        
        long tmp = L / 2019;
        if(tmp > 0){
            L = L - (2019 * tmp);
            R = R - (2019 * tmp);
        }

        long min = Integer.MAX_VALUE;
        if(R - L < 2019){
            for(long i = L; i < R; i++){
                for(long j = i+1; j <= R; j++){
                    min = Math.min(min,(i * j) % 2019);
                }
            }
        }else{
            min = 0;
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
        using namespace std;
         
        int main() {
            int n; cin >> n;
            int l[201];
            for(int i=0; i<2*n; i++) cin >> l[i];
            sort(l, l+2*n);
             
            int ret = 0;
            for(int i=0; i<n; i++) ret += min(l[2*i], l[2*i+1]);
            cout << ret << endl;
        }

Measured memory_bytes: 256
#line 1 "cumulative_sum.test.cpp"
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/solutions/problem/0022/review/4031365/toof/C++14"

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

#line 1 "../cumulative_sum.cpp"
template<class T>
struct CumulativeSum {
  vector<T> v;

  CumulativeSum(size_t n) : v(n+1) {};
  CumulativeSum(vector<T> v_) {
    v.resize(v_.size()+1);
    for (size_t i = 0; i < v_.size(); i++) v[i+1] = v_[i];
  };

  void add(size_t i, T x) {
    v[i+1] += x;
  }

  // O(N)
  void build() {
    for (size_t i = 0; i < v.size()-1; i++)
      v[i+1] += v[i];
  }

  // O(1) sum [l, r]
  T sum(size_t l, size_t r) const {
    return l == 0 ? v[r+1] : v[r+1]-v[l];
  }

  // O(1) sum [0, r]
  T sum(size_t r) const {
    return v[r+1];
  }

  T& operator[](size_t i) {
    return v[i];
  }

  const T& operator[](size_t i) const {
    return v[i];
  }
};
#line 15 "cumulative_sum.test.cpp"

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

  while (true) {
    ll n;
    cin >> n;
    if (n == 0) break;

    vector<ll> v(n);
    rep(i, n) {
      cin >> v[i];
    }

    CumulativeSum<ll> c(v);
    c.build();

    ll ans = -1e10;
    rep(i, n) {
      for (ll j = i; j < n; j++) {
        cmax(ans, c.sum(i, j));
      }
    }
    cout << ans << endl;
  }
}



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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (ll)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll digsum(ll n){
    ll sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

int main()
{
    ll n;
    cin >> n;
    cout << pow(n, 3) << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
Time = 0
t = [0]
xy = [[0, 0]]
judge = 'Yes'

for i in range(N):
    tt, x, y = map(int, input().split())
    t.append(tt)
    xy.append([x, y])

for i in range(N):
    diff_xy = abs(xy[i + 1][0] - xy[i][0]) + abs(xy[i + 1][1] - xy[i][1])
    diff_t = t[i + 1] - t[i]
    
    if (diff_t < diff_xy or (diff_t - diff_xy) % 2 != 0):
        judge = 'No'
    
print(judge)

Measured memory_bytes: 20340
while True:
    n = int(input())
    if n == 0:
        break
    arr = [[0] * n] * n
    for i in range(n):
        arr[i] = list(map(int,input().split()))

    for i in range(n):
        tmp = 0
        for j in range(n):
            tmp += arr[i][j]
        arr[i].append(tmp)

    last_line = []
    for j in range(n):
        tmp = 0
        for i in range(n):
            tmp += arr[i][j]
        last_line.append(tmp)

    tmp = 0
    for i in range(n):
        tmp += last_line[i]
    last_line.append(tmp)

    for i in range(len(arr[i])-1):
        for j in range(len(arr[i])):
            print('{0:5d}'.format(arr[i][j]),end = '')
        print('')
    for i in range(len(last_line)):
        print('{0:5d}'.format(last_line[i]),end = '')
    print('')

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

using namespace std;

int main() {
  vector<vector<int>> c(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c[i][j];
    }
  }

  string ans = "Yes";
  int b10 = c[0][1] - c[0][0];
  int b21 = c[0][2] - c[0][1];

  for (int i = 0; i < 3; i++) {
    int d1 = c[i][1] - c[i][0];
    int d2 = c[i][2] - c[i][1];

    if (d1 != b10 || d2 != b21) ans = "No";
  }

  int a10 = c[1][0] - c[0][0];
  int a21 = c[2][0] - c[1][0];

  for (int j = 0; j < 3; j++) {
    int d1 = c[1][j] - c[0][j];
    int d2 = c[2][j] - c[1][j];

    if (d1 != a10 || d2 != a21) ans = "No";
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
N=input()
a=list(map(int,input().split()))	
c = 0
cmax = 0
for (i,j) in zip(a[:-1],a[1:]):
	if j <= i:
		c += 1
	else:
		cmax = c if cmax < c else cmax
		c = 0
cmax = c if cmax < c else cmax
print(cmax)
	

Measured memory_bytes: 63856
#include <bits/stdc++.h>
    using namespace std;
    #define int long long
    typedef int ll;
    typedef long double ld;
    const ll N = 55;
    char en = '\n';
    ll inf = 1e16;
    ll mod = 1e9 + 7;
    ll power(ll x, ll n, ll mod) {
      ll res = 1;
      x %= mod;
      while (n) {
        if (n & 1)
          res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
      }
      return res;
    }
     
    ll n;
    ll edges[N][2];
    ll depth[N];
    vector<ll> adj[N];
     
    vector<ll> values[N];
     
    vector<ll> dfs(ll curr, ll prev1 = -1, ll depth1 = 0) {
     
      depth[curr] = depth1;
      vector<ll> children;
      children.push_back(curr);
      for (ll &x : adj[curr]) {
        if (x != prev1) {
          vector<ll> childx = dfs(x, curr, depth1 + 1);
          for (ll &y : childx)
            children.push_back(y);
        }
      }
     
      values[curr] = children;
      return children;
    }
     
    ll op[N][2];
    ll m;
     
    ll maskOp[N];
     
    ll dp[N][1 << 20];
    ll recur(ll edge, ll mask) {
     
      if (edge == n) {
        return mask == ((1 << m) - 1);
      }
      ll &ans = dp[edge][mask];
      if (ans != -1)
        return ans;
     
      ans = recur(edge + 1, mask) + recur(edge + 1, mask | (maskOp[edge]));
      return ans;
    }
     
    int32_t main() {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
     
      cin >> n;
      for (ll i = 1; i < n; i++) {
        cin >> edges[i][0] >> edges[i][1];
     
        adj[edges[i][0]].push_back(edges[i][1]);
        adj[edges[i][1]].push_back(edges[i][0]);
      }
     
      dfs(1);
     
      cin >> m;
      for (ll i = 0; i < m; i++)
        cin >> op[i][0] >> op[i][1];
     
      for (ll i = 1; i < n; i++) {
        ll u = edges[i][0], v = edges[i][1];
     
        if (depth[u] < depth[v])
          swap(u, v);
     
        ll mask = 0;
        for (ll j = 0; j < m; j++) {
          ll a = op[j][0];
          ll b = op[j][1];
     
          ll cnt = 0;
          if (find(values[u].begin(), values[u].end(), a) != values[u].end())
            cnt++;
     
          if (find(values[u].begin(), values[u].end(), b) != values[u].end())
            cnt++;
     
          if (cnt == 1) {
            mask |= (1 << j);
          }
        }
        maskOp[i] = mask;
      }
     
      memset(dp, -1, sizeof(dp));
      cout << recur(1, 0) << en;
     
      return 0;
    }

Measured memory_bytes: 450816
n, m = list(map(int, input().split()))
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = list(map(int, input().split()))
c = [0] * m
d = [0] * m
for j in range(m):
    c[j], d[j] = list(map(int, input().split()))

for i in range(n):
    distance = []
    minDistance = 10 ** 16
    checkPoint = 1
    for j in range(m):
        distance.append(abs(a[i] - c[j]) + abs(b[i] - d[j]))
        if minDistance > distance[j]:
            minDistance = distance[j]
            checkPoint = j + 1
    print(checkPoint)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  int64_t a, b, c;
  cin >> a >> b >> c;

  const int64_t d = c - a - b;
  if (d < 0) {
    cout << "No" << endl;
  } else {
    cout << (4 * a * b < d * d ? "Yes" : "No") << endl;
  }
  return 0;
}

Measured memory_bytes: 3644
import sys
input = sys.stdin.buffer.readline


class UnionFind:
    """素集合を木構造として管理する。"""
    def __init__(self, n):
        self.parent = [-1] * n
        self.n = n
        self.cnt = n

    def root(self, x):
        """要素xの代表元を求める。O(α(N))"""
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]

    def merge(self, x, y):
        """要素xを含む集合と要素yを含む集合を併合する。O(α(N))"""
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.parent[x] > self.parent[y]:
            x, y = y, x
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        self.cnt -= 1
        return True

    def is_same(self, x, y):
        """要素x, yが同じ集合に属するかどうかを求める。O(α(N))"""
        return self.root(x) == self.root(y)

    def size(self, x):
        """要素xを含む集合の要素数を求める。O(α(N))"""
        return -self.parent[self.root(x)]

    def count(self):
        """集合の個数を求める。O(1)"""
        return self.cnt

    def groups(self):
        """集合を列挙する。list[list[int]]で返す。O(N)"""
        res = [[] for _ in range(self.n)]
        for i in range(self.n):
            res[self.root(i)].append(i)
        return [grp for grp in res if grp]


n, q = map(int, input().split())
queries = [list(map(int, input().split())) for _ in range(q)]


uf = UnionFind(n)
for flag, u, v in queries:
    if flag:
        print(int(uf.is_same(u, v)))
    else:
        uf.merge(u, v)

Measured memory_bytes: 110656
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

string s, t, u;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (s == u)
        printf("%d %d\n", a-1, b);
    else
        printf("%d %d\n", a, b-1);

    return 0;
}


Measured memory_bytes: 256
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

// fn read<T: std::str::FromStr>() -> T {
//     let mut s = String::new();
//     std::io::stdin().read_line(&mut s).ok();
//     s.trim().parse().ok().unwrap()
// }

fn main() {
    loop{
        let v:Vec<i32> = read_vec();
        if v[0] == 0 && v[1] == 0 {
            break;
        }

        for i in 0..v[0] {
            for j in 0..v[1] {
                if (i + j) % 2 == 0 {
                    print!("#");
                } else {
                    print!(".")
                }
                // print!("{}", i + j);
            }
            println!("");
        }
        println!("");
    }
}


Measured memory_bytes: 5032
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int r;
int main()
{
	scanf("%d",&r);
	if(r<1200)
	{
		printf("ABC");
		return 0;
	}
	if(r<2800)
	{
		printf("ARC");
		return 0;
	}
	printf("AGC");
	//return 0;
}

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

typedef complex<double> P;

#define X real()
#define Y imag()

const double eps=1e-8;
const double inf=1e12;

namespace std{
  bool operator<(const P& a,const P& b){
    return abs(a.X-b.X)<eps?a.Y<b.Y:a.X<b.X;
  }
}

double cross(P a,P b){return (conj(a)*b).Y; }
double dot(P a,P b){return (conj(a)*b).X; }

struct L : public vector<P>
{
  L(const P& a,const P& b){
    push_back(a);
    push_back(b);
  }
};

struct C
{
  P p; double r;
  C(const P& p,double r):p(p),r(r){}
};

int ccw(P a,P b,P c){
  b=b-a; c=c-a;
  if(cross(b,c)>0)return +1;
  if(cross(b,c)<0)return -1;
  if(dot(b,c)>0)return +2;
  if(norm(b)>norm(c))return -2;
  return 0;
}

bool intersectSS(L s,L t){
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1])<=0&&ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1])<=0;
}

pair<P,P> crosspointCC(C c1,C c2){
  P p1=c1.p,p2=c2.p;
  double r1=c1.r,r2=c2.r;
  P A=conj(p2-p1),B=(r2*r2-r1*r1-(p2-p1)*conj(p2-p1)),C=r1*r1*(p2-p1);
  P D1=B*B-(double)4.0*A*C;
  P z1=(-B+sqrt(D1))/((double)2.0*A)+p1,z2=(-B-sqrt(D1))/((double)2.0*A)+p1;
  if(z2<z1)swap(z1,z2);
  return pair<P,P>(z1,z2);
}

int n;
double dist[222][222];
vector<C> cs;
vector<L> ls;
vector<P> ps;

int main(void) {
  while(1) {
    cin>>n;
    if(n==0)break;
    cs.clear(); ps.clear(); ls.clear();
    rep(i,n){
      double x,y,r;
      cin>>x>>y>>r;
      cs.push_back(C(P(x,y),r));
    }
    ps.push_back(cs[0].p);
    rep(i,n-1){
      pair<P,P> cp=crosspointCC(cs[i],cs[i+1]);
      ps.push_back(cp.first); ps.push_back(cp.second);
      ls.push_back(L(cp.first,cp.second));
    }
    ps.push_back(cs[n-1].p);
    int m=ps.size();
    int lsize=ls.size();
    rep(i,222)rep(j,222)dist[i][j]=i==j?0:inf;
    rep(i,m)repl(j,i+1,m){
      L tmp=L(ps[i],ps[j]);
      bool ok=true;
      repl(k,(i+1)/2,min(lsize,(j-1)/2)){
        if(!intersectSS(tmp,ls[k]))ok=false;
      }
      if(ok){
        dist[i][j]=min(dist[i][j],abs(ps[i]-ps[j]));
      }
    }
    /*
    rep(i,m)rep(j,m){
      printf("%.3f %c", dist[i][j]==inf?-1:dist[i][j],j==m-1?'\n':'\t');
    }*/
    rep(k,m)rep(i,m)rep(j,m)dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
    printf("%.10f\n", dist[0][m-1]);
  }
  return 0;
}

Measured memory_bytes: 3656
#include "iostream"
#include "vector"
#include<algorithm>
using namespace std;
 void solve() {
    int K, N; cin >> K >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    
    vector<int> d(N+1);
    for (int i = 1; i < N; i++) {
        d[i] = A[i] - A[i-1];
    }
    d[N] = K - (A[N-1] - A[0]);
 
    sort(d.begin(), d.end());
 
    int ans = K - d[N];
 
    cout << ans << endl;
}
 
 
int main() {
    solve();
    return 0;
}


Measured memory_bytes: 1792
// abc150_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#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 REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

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

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    REP(i, N) {
        cin >> A[i]; A[i] /= 2;
    }

    ll lcm=0;
    REP(i, N){
        if (i == 0){
            lcm = A[i];
        } else {
            ll d = gcd(lcm, A[i]);
            lcm = A[i] * lcm / d;
        }
    }
//    print(lcm);

    bool x = true;
    REP(i, N){
        if ( (lcm / A[i]) % 2 == 0){
            x = false;
            break;
        }
    }

    ll ans;
    if (x) {
        ans = (M + lcm) / (2 * lcm);
    } else {
        ans = 0;
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;



int main() {
    ios_base::sync_with_stdio(false); 

    ll x;
    cin >> x;
    vector<ll> p(1000);
    rep(i,1000) p[i]=pow(i,5);
    rep(i,1000) {
        repr(j,i,1000) {
            if (x==p[i]+p[j]) {
                cout << i << ' ' << -j << endl;
                break;
            } else if (x==p[j]-p[i]) {
                cout << j << ' ' << i << endl;
                break;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 4092
#include <stdio.h>

int main(void)
{
	int a =0;
	int b =0;
	int c =0;
	scanf("%d%d%d",&a,&b,&c);
	if(a < b && b < c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<cat> A(N);
	for(int i = 0; i < N; i++) cin >> A[i];
	vector< vector<cat> > muls_r(N+1, vector<cat>(16, 0));
	for(int i = 0; i <= 15; i++) muls_r[N-1][i] = i;
	for(int i = N-2; i >= 0; i--) for(int j = 0; j <= 15; j++) {
		cat x = A[i]<<(2*j);
		bool ok = false;
		for(int k = 0; k <= 15; k++) if((A[i+1]<<(2*k)) >= x) {
			muls_r[i][j] = muls_r[i+1][k] + j;
			ok = true;
			break;
		}
		if(!ok) muls_r[i][j] = muls_r[i][j-1] + N-i;
	}
	vector< vector<cat> > muls_l(N+1, vector<cat>(16, 0));
	for(int i = 0; i <= 15; i++) muls_l[1][i] = i;
	for(int i = 2; i <= N; i++) for(int j = 0; j <= 15; j++) {
		cat x = A[i-1]<<(2*j);
		bool ok = false;
		for(int k = 0; k <= 15; k++) if((A[i-2]<<(2*k)) >= x) {
			muls_l[i][j] = muls_l[i-1][k] + j;
			ok = true;
			break;
		}
		if(!ok) muls_l[i][j] = muls_l[i][j-1] + i;
	}
	cat ans = OVER9000;
	for(int i = 0; i <= N; i++) ans = min(ans, i + 2 * muls_r[i][0] + 2 * muls_l[i][0]);
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 67456
# 初期入力
import sys
input = sys.stdin.readline
L,R = (int(x) for x in input().split())

mod_L =L %2019
mod_R =R %2019
ans =0
xx=[]
if 2018 <= R -L:
    ans =0
elif mod_R < mod_L:
    ans =0
elif mod_L==0 :
    ans =0
else:
    for i in range(L,R):
        for j in range(i+1,R+1):
            x =i*j %2019
            xx.append(x)
    ans =min(xx)
print(ans)

Measured memory_bytes: 75432
#include <bits/stdc++.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;
int main(){
	IOS;
	string s,t,u;
	int a,b;
	cin>>s>>t;
	cin>>a>>b;
	cin>>u;
	if(u==s)
	cout<<--a<<" "<<b;
	else
	cout<<a<<" "<<--b;
	
	
	
	}

Measured memory_bytes: 3568
#include <stdio.h>
#define N 101
 
int main(){
  int t[N][N], k[N + 1][N + 1];
  int n, i, j;
 
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d%d", &t[i][0], &t[i][1]);
    for(j = 2; j < 2 + t[i][1]; j++){
      scanf("%d", &t[i][j]);
    }
  }
 
  for(i = 0; i < n; i++){
    for(j = 2; j < 2 + t[i][1]; j++){
      k[ t[i][0] ][ t[i][j] ] = 1;
    }
  }
 
 
  for(i = 1; i < n + 1; i++){
    for(j = 1; j < n ; j++){
      printf("%d ", k[i][j]);
    }
    printf("%d\n", k[i][j]);
  }
 
  return 0;
}

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

int main () {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int ans = 50;
  for (int i = 0; i < N; i++) {
    int count = 0;
    while (A.at(i)%2 == 0) {
      count++;
      A.at(i) /= 2;
    }
    ans = min(ans,count);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	ss := strings.Split(s, "")
	tt := strings.Split(t, "")
	sort.Strings(ss)
	sort.Sort(sort.Reverse(sort.StringSlice(tt)))

	if strings.Join(ss, "") < strings.Join(tt, "") {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
int main()
{
    string s;
    cin>>s;
    ll freq[200]={0};
    ll n=s.length();
    ll ans=1;
    freq[s[0]]++;
    for(ll i=1;i<n;i++)
    {
        ans+=i-freq[s[i]];
        freq[s[i]]++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640
public class Main{public static void main(String[] args){java.util.Scanner s=new java.util.Scanner(System.in);int[]m={0,1,2,3,5,7,8,9};while(true){int n=s.nextInt();if(n==0)return;char[]c=Integer.toOctalString(n).toCharArray();for(n=0;n<c.length;n++)System.out.print(m[c[n]-'0']);System.out.println();	}}}

Measured memory_bytes: 60504
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
    cin>>n>>k;
    ll a[n+1],vis[n+1]={0};
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        vis[i]=0;
    }
    
    i=1;
    vector<ll>v;
    v.pb(1);
    
    while(vis[a[i]]==0 && k>0)
    {
        vis[i]=1;
        v.pb(a[i]);
        i=a[i];
        k--;
    }
    if(k==0)
    {
        cout<<i;
        return;
    }
    int start=a[i];
    int end=i;
    if(start==end)
    {
        cout<<start;
        return;
    }
    int seen=0;
    int c=0;
    int ind1=-1,ind2=-1;
    
    for(i=0;i<v.size();i++)
    {
        
        if(v[i]==start)
        {
            seen=1;
            ind1=i;
        }
        if(seen==1)
        {
  
            c++;
        }
        
    }


    k=(k-1)%c;
  
    for(i=ind1;i<v.size();i++)
    {
        
        if(k==0)
        {
            cout<<v[i];
            break;
        }
        k--;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 8344
#include <iostream>
#include <cstdio>
using namespace std;
int counter;
int gcd(int a, int b){  
    if (b == 0)
    return a;    
    counter++;      
    return gcd(b, a%b);  
}
int main(void){ 
    int a, b, x;    
    while(cin>>a>>b){      
        if(a < b){         
            x = a;         
            a = b;        
            b = x;       
            }     
            if(a == 0 && b == 0)
            return 0;       
            counter = 0;    
            cout<<gcd(a,b)<<" ";
            cout<<counter<<endl;   
            }    
            return 0;
    
}



Measured memory_bytes: 3092
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
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; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll h, w; cin >> h >> w;
    vector<string> s(h);
    REP(i, h) cin >> s[i];

    vector<vector<ll>> rr(h, vector<ll>(w, -1));
    vector<vector<ll>> rc(h, vector<ll>(w, -1));

    REP(i, h) {
        ll l = 0, r = 0; // [l,r) ga '.'
        while (l < w) {
            while (l < w && s[i][l] != '.') l++;
            if (!(l < w)) break;
            r = l;
            while (r < w && s[i][r] == '.') r++;
            
            for (ll j = l; j < r; j++) {
                rc[i][j] = r - l;
            }

            l = r;
        }
    }

    REP(j, w) {
        ll l = 0, r = 0; // [l,r) ga '.'
        while (l < h) {
            while (l < h && s[l][j] != '.') l++;
            if (!(l < h)) break;
            r = l;
            while (r < h && s[r][j] == '.') r++;
            
            for (ll i = l; i < r; i++) {
                rr[i][j] = r - l;
            }

            l = r;
        }
    }

    ll ans = 0;
    REP(i, h) REP(j, w) if (s[i][j] == '.') {
        chmax(ans, rr[i][j] + rc[i][j] - 1);
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 67072
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    x, y = LI()
    d = {1: 0, 2: 2, 3: 0, 4: 1, 5: 0, 6: 1, 7: 0, 8: 0, 9: 1, 10: 0, 11: 1, 12: 0}

    if d[x] == d[y]:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()


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

int main(){
  int N, M;
  cin >> N >> M;
  if(M%N==0){
    cout << M/N << endl;
    return 0;
  }
  for(int ans=M/N; ans>=1; ans--){
    int x = M-ans*(N-1);
    if(x%ans==0){
      cout << ans << endl;
      return 0;
    }
  }
  return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int64_t x,y; cin>>x>>y;
	int ans=0;
	while(x<=y){
		x*=2;
		++ans;
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3640
//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

signed main(){
  int x;
  cin >> x;
  if (x == 0) cout << 1;
  else cout << 0;
}

Measured memory_bytes: 3600
import numpy as np
N = int(input())

items = []
for n in range(N):
    s,p = input().split()
    items.append([n+1,s,int(p)])

itm = sorted(
    items,
    key = lambda x: (x[1],-x[2])
)

for i in range(N):
    print(itm[i][0])

Measured memory_bytes: 21760
#include <stdio.h>
int main(void)
{
	int a;
	int b;
	int c;
	int d;
	int x;
	int y;
	int z;
	scanf("%d\n%d\n%d\n%d\n",&a,&b,&c,&d);
	z=a+b+c+d;
	x=z/60;
	y=z%60;
	printf("%d\n%d\n",x,y);
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>

int main()
{
	int data_count = 0;
	while ((std::cin >> data_count) && (data_count > 0)) {
		std::vector<long> dataset;
		for (int i = 0; i < data_count; ++i) {
			int data = 0;
			std::cin >> data;
			dataset.push_back(data);
		}

		long max_sum = dataset[0];
		for (int i = 0; i < data_count; ++i) {
			long current_sum = 0;
			long max_current_sum = dataset[i];
			for (int j = i; j < data_count; ++j) {
				current_sum += dataset[j];
				if (max_current_sum < current_sum) {
					max_current_sum = current_sum;
				}
			}
			if (max_sum < max_current_sum) {
				max_sum = max_current_sum;
			}
		}
		std::cout << max_sum << std::endl;
	}

	return 0;
}

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

int main() {
	ll a, b, n;
	cin >> a >> b >> n;
	ll ans = 0;
	
	if(n >= b) {
		ll s = a * (b-1) / b;
		ll t = (b-1) / b;
		ans = s - a * t;
	} else {
		for(ll x = n; x > max(0LL, n-100100100); x--) {
			ll s = a * x / b;
			ll t = x / b;
			ll now = s - a * t;
			ans = max(ans, now);
			// printf("%lld:: s:%lld, t%lld, now:%lld:\n",x, s, t, now);
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    vector<ll> A;
    ll money = 1000;
    ll stock = 0;
    for(int i = 0;i < N;i++){
        ll _a;cin>>_a;
        A.push_back(_a);
    }
    if(A[0] < A[1]){
        ll num = money / A[0];
        money -= num * A[0];
        stock += num;
    }
    for(int i = 1;i < N-1;i++){
        // cout<<money<<" " << stock << endl;
        // cout<<A[i-1] <<" " <<A[i] <<" " <<A[i+1]<<endl;;
        if(A[i-1] <= A[i] && A[i] > A[i+1] ){
            money += stock * A[i];
            stock = 0;
        }else if(A[i-1] >= A[i] && A[i] < A[i+1]){
            ll num = money / A[i];
            money -= num * A[i];
            stock += num;
        }
    }
    money += stock * A[N-1];
    stock = 0;
    cout<<money<<endl;
}

Measured memory_bytes: 3628
def resolve():
    (N, X) = list(map(int, input().split(" ")))
    Ls = list(map(int, input().split(" ")))
    cur = 0
    cnt = 0
    Ls.insert(0, 0)
    for l in Ls:
        cur += l
        if cur > X:
            print(cnt)
            break
        cnt += 1

    else:
        print(cnt)

    

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;

signed main() 
{
    int x1,y1,x2,y2,x3,y3,x4,y4; 
    cin >> x1 >> y1 >> x2 >> y2; 

    x3 = x2 +(y1-y2);
    y3 = y2 -(x1-x2);

    x4 = x3 + x1-x2;
    y4 = y3 + y1-y2;

    cout << x3 << " " << y3 <<" " << x4 << " " << y4; 
    return 0;
}


Measured memory_bytes: 3600
// VABC049_D
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define pll pair<ll, ll>

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

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

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

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

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

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

template <class T>
void printVec(vector <T> &vec) {
    size_t len = vec.size();
    REP(i, len) {
        if (i) cout << " ";
        cout << vec[i];
    }
    cout << "\n";
}

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, K, L, p, q;
    cin >> N >> K >> L;
    vector<ll> res(N, 1);
    UnionFind Road(N), Rail(N);
    REP(i, K) {
        cin >> p >> q; --p; --q;
        Road.merge(p, q);
    }
    
    REP(i, L) {
        cin >> p >> q; --p; --q;
        Rail.merge(p, q);
    }
    
    // 道路でも電車でも連結してる
    // 根が同じ
    map<pll, ll> mp;
    REP(i, N) mp[{Road.root(i), Rail.root(i)}]++;
    REP(i, N) cout << mp[{Road.root(i), Rail.root(i)}] << " ";
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 19712
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#include<queue>
using namespace std;
int main() {
	int n, a[100010], b[100010] = {}, max = -1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == 0) {
			b[0]++;
			b[1]++;
			continue;
		}
		b[a[i] - 1]++;
		b[a[i]]++;
		b[a[i] + 1]++;
	}
	for (int i = 0; i < 100010; i++) {
		if (max < b[i])max = b[i];
	}
	cout << max << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

class Main {
	public static void main(String... args) {
		int N = IN.nextInt();
		long[] A = new long[N + 1];
		for (int i = 1; i <= N; i++) {
			A[i] = IN.nextLong() + A[i - 1];
		}

		int iP = 1;
		int iR = 3;
		long ans = calc(1, 2, 3, A);
		for (int iQ = 2; iQ <= N - 2; iQ++) {
			while (canMoveNext(1, iQ, iP, A)) {
				iP += 1;
			}
			while (canMoveNext(iQ + 1, N, iR, A)) {
				iR += 1;
			}
			long tmp = calc(iP, iQ, iR, A);
			if (tmp < ans) {
				ans = tmp;
			}
		}
		puts(ans);
		flush();
	}

	static long calc(int iP, int iQ, int iR, long[] A) {
		long[] ss = {A[iP], A[iQ] - A[iP], A[iR] - A[iQ], A[A.length - 1] - A[iR]};
		long max = 0;
		long min = Long.MAX_VALUE;
		for (long x: ss) {
			if (max < x) max = x;
			if (x < min) min = x;
		}
		return max - min;
	}

	static boolean canMoveNext(int s, int f, int i, long[] A) {
		if (i + 1 == f) {
			return false;
		} else {
			return (Math.abs(2 * A[i + 1] - A[f] - A[s - 1]) <
					Math.abs(2 * A[i] - A[f] - A[s - 1]));
		}
	}

	static final Scanner IN = new Scanner(System.in);
	static final PrintWriter OUT = new PrintWriter(System.out);
	static <T> void puts(T arg) { OUT.println(arg); }
	static void flush() { OUT.flush(); }
}


Measured memory_bytes: 91964
import itertools

N, M = map(int, input().split())
s, c = [], []
for _ in range(M):
	ts,tc = map(int ,input().split())
	s.append(ts)
	c.append(tc)

ans = 10**10
for p in itertools.product(range(10), repeat=N):
	if N >= 2 and p[0] == 0:
		continue


	cond = 0
	for i in range(M):
		ind = s[i]-1
		num = c[i]

		if p[ind] != num:
			cond = 1
			break

	if cond:
		continue
	else:
		ans = min(ans, int(''.join(list(map(str, p)))))

if ans == 10**10:
	print(-1)
else:
	print(ans)


Measured memory_bytes: 3444
n = int(input())
S = [input() for i in range(n)]
AB = []
for i in range(n):
    a, b = 0, 0
    for c in S[i]:
        if c == '(':
            b += 1
        if c == ')':
            if b > 0:
                b -= 1
            else:
                a += 1
    AB.append((a, b))
AB0 = [(a, b) for a, b in AB if -a + b >= 0]
AB1 = [(a, b) for a, b in AB if -a + b < 0]
AB0.sort()
AB1.sort(key=lambda x: -x[1])
AB = AB0 + AB1
x = 0
for a, b in AB:
    x -= a
    if x < 0:
        print('No')
        exit()
    x += b
if x == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 167292
/*
THE BEST IS YET TO COME
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define r(i,s,l) for(int i=s;i<l;i++)
#define mod 1000000007
#define INT_BITS 32
#define ld long double
#define pp pair<long long,long long>
#define ss second
#define ff first
#define N 2000005
#define all(a) a.begin(),a.end()
#define pb push_back
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

int main(){
    fast();
    int n;
    cin>>n;
    string s;
    unordered_map<string,int> mp;
    r(i,0,n)
    {
        string s;
        cin>>s;
        sort(all(s));
        mp[s]++;
    }
    ll ct=0;
    for(auto i=mp.begin();i!=mp.end();i++)
    {
        ll x=i->second;
        ct+= (x*(x-1))/2;
    }
    cout<<ct;
	return 0;
}


Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000001

template <typename T>
struct CHT{
	deque<pair<T,T>> D;
	void add(T a,T b){
		while(true){
			if(D.size()<=1){
				D.emplace_back(a,b);
				break;
			}
			T a3 = a,b3 = b,a2 = D.back().first,b2 = D.back().second;
			D.pop_back();
			T a1 = D.back().first,b1 = D.back().second;
			D.pop_back();
			
			if((a2-a1)*(b3-b2)>=(b2-b1)*(a3-a2)){
				D.emplace_back(a1,b1);
				continue;
			}
			else{
				D.emplace_back(a1,b1);
				D.emplace_back(a2,b2);
				D.emplace_back(a3,b3);
				break;
			}
		}
	}

	T query(T x){
		while(true){
			if(D.size()<=1)break;
			T a1 = D.front().first,b1 = D.front().second;
			D.pop_front();
			T a2 = D.front().first,b2 = D.front().second;
			if(a1*x+b1>=a2*x+b2){
				continue;
			}
			else{
				D.emplace_front(a1,b1);
				break;
			}
		}
		
		return D.front().first*x +	D.front().second;
	}
};

int main(){
	
	int N;
	cin>>N;
	
	long long C;
	cin>>C;
	
	vector<long long> h(N);
	for(int i=0;i<N;i++)cin>>h[i];
	
	CHT<long long> cht;
	
	vector<long long> dp(N,Inf);
	
	for(int i=0;i<N;i++){
		if(i==0){
			dp[i] = 0;
		}
		else{
			dp[i] = h[i]*h[i] + cht.query(h[i]);
		}
		cht.add(-2*h[i],h[i]*h[i]+C+dp[i]);
	}
	
	cout<<dp.back()<<endl;
		
	return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct node {
	int to, cost, ticket;

	node(int to, int cost) : to(to), cost(cost) { this -> ticket = 0; }
	node(int to, int cost, int ticket) : to(to), cost(cost), ticket(ticket) { }
	node() { this -> to = this -> cost = this -> ticket = 0; }
};

bool operator < (const node &a, const node &b) {
	return a.cost < b.cost;
}

bool operator > (const node &a, const node &b) {
	return a.cost > b.cost;
}

int main() {
	int c, n, m, s, d;
	while (cin >> c >> n >> m >> s >> d, c || n || m || s || d) {
		--s, --d;

		vector< vector<node> > v(n);
		for (int i = 0; i < m; ++i) {
			int a, b, f; cin >> a >> b >> f;
			--a, --b;
			v[a].push_back( node(b, f) );
			v[b].push_back( node(a, f) );
		}

		int rest = c;
		vector< vector<int> > cost(n, vector<int>(c+1, -1));
		vector<bool> used(n, -1);
		priority_queue< node, vector<node>, greater<node> > que; que.push( node(s, 0, c) );
		while ( !que.empty() ) {
			node next = que.top(); que.pop();

			if (cost[next.to][next.ticket] >= 0) continue;
			cost[next.to][next.ticket] = next.cost;

			if (next.to == d) {
				cout << next.cost << endl;
				break;
			}

			for (int i = 0; i < v[next.to].size(); ++i) {
				que.push( node(v[next.to][i].to, next.cost + v[next.to][i].cost, next.ticket) );
				if (next.ticket) que.push( node(v[next.to][i].to, next.cost + v[next.to][i].cost/2, next.ticket-1) );
			}
		}
	}
}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N; cin >> N;
    ll res = 0;
    if (N%2==0) {
        N /= 2;
        ll d = 5;
        REP(i,25){
            res += N/d;
            d *= 5;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
a = list(map(int,input().split()))

j=1
ans=0
tmp=0
for i in range(0,N):
  if a[i]==j:
    ans += i-tmp
    tmp = i+1
    j += 1
#print(i,j,ans,tmp)

if ans==0 and tmp==N:
  print(ans)
elif ans==0 and j==1:
  print(-1)
elif N>tmp:
  print(ans+(N-tmp))
else:
  print(ans)

Measured memory_bytes: 26268
from itertools import combinations

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i, j in combinations(xy, 2):
    ans += ((i[0] - j[0]) ** 2 + (i[1] - j[1]) ** 2) ** 0.5
print(ans * 2 / n)

Measured memory_bytes: 9324
#include <stdio.h>
int arr[200001];
int cnt[200001];
int main(){
	int N;scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",arr+i);
		cnt[arr[i]]++;
	}
	long long sum = 0;
	for(int i=1;i<=N;i++) sum += 1LL*cnt[i]*(cnt[i]-1)/2;
	for(int i=0;i<N;i++){
		printf("%lld\n",sum-1LL*cnt[arr[i]]*(cnt[arr[i]]-1)/2+1LL*(cnt[arr[i]]-1)*(cnt[arr[i]]-2)/2);
	}
}

Measured memory_bytes: 3584
import java.io.*;
import java.util.*;


public class Main {
    static ArrayList<Integer>[] graph;
    static TreeMap<Long,Long> valTime = new TreeMap<>();
    public static void main(String[] args) throws Exception {
        //Scanner sc = new Scanner(System.in);
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] buf = reader.readLine().split(" ");
        int n = Integer.parseInt(buf[0]), m = Integer.parseInt(buf[1]);
        buf = reader.readLine().split(" ");
        for(String w:buf){
            long cur = Long.parseLong(w);
            putHelp(cur,1);
        }
        for(int i=0;i<m;i++){
            buf = reader.readLine().split(" ");
            long b = Long.parseLong(buf[0]), c = Long.parseLong(buf[1]);
            putHelp(c,b);
        }
        long cnt = 0,ans = 0;
        while(cnt<n){
            Map.Entry<Long,Long> cur = valTime.pollLastEntry();
            long val = cur.getKey(), time = cur.getValue();
            long toadd = Math.min(time,n-cnt);
            ans += toadd*val;
            cnt += toadd;
        }
        System.out.println(ans);


    }
    static void putHelp(long val, long time){
        if(!valTime.containsKey(val)) valTime.put(val,time);
        else valTime.put(val,valTime.get(val)+time);
    }
}



Measured memory_bytes: 79032
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const bool ready = []() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

set<int> fact(int i) {
    set<int> ans;
    for(int j=2; j*j<=i; j++) {
        while(i%j==0) {
            ans.insert(j);
            i/=j;
        }
    }
    if(i!=1)
        ans.insert(i);
    return ans;
}

void solve() {
    cini(n);
    cinai(a,n);

    int g=a[0];
    int pairwise=true;
    set<int> allf;
    for(int i=0; i<n; i++) {
        if(i>0)
            g=gcd(g,a[i]);

        if(pairwise) {
            set<int> f=fact(a[i]);
            for(int j : f) {
                if(allf.count(j)>0)
                    pairwise=false;
                allf.insert(j);
            }
        }
    }
    if(pairwise)
        cout<<"pairwise coprime"<<endl;
    else if(g==1)
        cout<<"setwise coprime"<<endl;
    else
        cout<<"not coprime"<<endl;

}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


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



int main()
{
    string n;
    cin >> n;
    for (int i = 0; i < n.length(); i++)
    {
        if(n[i] == '7')
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";

    return 0;
}

Measured memory_bytes: 3596