akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner sc = new Scanner(is);
        long X = sc.nextLong();

        for(long A = -200; A <= 200; A++) {
            for(long B = -200; B <= 200; B++) {
                if(A*A*A*A*A == X + B*B*B*B*B){
                    os.println(A + " " + B);
                    return;
                }
            }
        }
    }
}

Measured memory_bytes: 27044
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  if((b*10+c)%4 ==0 )
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}

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

#define REP(i,n) for(int (i)=0;i<(n);i++)
#define vi vector<int>

using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  n++;
  vi v(n, 1);

  int aka = 131072; // 2 ** 17
  v[1] = aka;
  int x, y;
  REP (i, m) {
    cin >> x >> y;
    if (aka & v[x])
    {
      v[x] == aka ? v[x] = 0 : v[x]--;
      v[y] < aka ? v[y] += aka : v[y]++;
    }
    else
    {
      v[x]--;
      v[y]++;
    }
  }

  int ans = 0;
  REP(i, n){
    ans += (aka <= v[i]);
  }
  cout << ans << endl;
  return 0;
}

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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

  

int main()
{
  ll x;
  cin >> x;

  for(ll a = -118; a <= 119; a++)
  {
    for(ll b = -118; b <= 119; b++)
    { 
      ll a5 = a*a*a*a*a;
      ll b5 = b*b*b*b*b;
      if(a5 - b5 == x)
      {
        cout << a << ' ' << b << endl;
        return 0;
      }
    }
  }

  return 0;
}

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

int MAX = 100000;
int n, k;
vector<int> w(MAX);

// 積載量pの時必要なトラックの台数
// int t(int p) {
//     int track = 0, sum = 0;
//     rep(i, n) {
//         if (w[i] > p) {
//             return 0;
//         }
//         if (sum + w[i] <= p) {
//             sum += w[i];
//         } else {
//             sum = w[i];
//             track++;
//         }
//     }
//     return ++track;
// }

// 積載量pのトラックk台で積める荷物の個数
int c(int p) {
    int item = 0;
    rep(i, k) {
        int sum = 0;
        while (sum + w[item] <= p) {
            sum += w[item];
            item++;
            if (item == n) return n;
        }
    }
    return item;
}

int main() {
    scanf("%d %d", &n, &k);
    int max_w = 0, sum_w = 0;
    rep(i, n) {
        scanf("%d", &w[i]);
        max_w = max(max_w, w[i]);
        sum_w += w[i];
    }
    int left = 0, right = sum_w;
    while (left <= right) {
        int mid = (left + right) / 2;
        if (c(mid) == n) {
            if (c(mid - 1) < n) {
                printf("%d\n", mid);
                break;
            } else {
                right = mid - 1;
            }
        } else if (c(mid) < n) {
            left = mid + 1;
        }
    }
    // for (int i = 0; i <= sum_w; i++) {
    //     // printf("%d %d\n", i, c(i));
    //     if (c(i) == n) {
    //         printf("%d\n", i);
    //         break;
    //     }
    // }
}


Measured memory_bytes: 3428
#include<stdio.h>
#include<string.h>
#define N 100000

int isEmpty(void);
void enqueue(int);
int dequeue(void);
int calc(void);

int time[N];
int head=0,tail=0;

int main(){
  
  int i;
  int n,q;
  int totaltime=0;
  char swap[10],s[N][10];
  
  scanf("%d%d",&n,&q);
  for(i=0;i<n;i++){
    scanf("%s%d",s[i],&time[i]);
    tail++;
  }
  while(isEmpty()!=1){
    if(time[head]<=q){
      totaltime+=dequeue();
      printf("%s %d\n",s[head-1],totaltime);
    }
    else{
      strcpy(swap,s[head]);
      strcpy(s[tail],swap);
      time[head]-=q;
      enqueue(dequeue());
      totaltime+=q;
    }
  }
  return 0;
}

int isEmpty(){
  if(head==tail) return 1;
  return 0;
}

void enqueue(int n){
  
  time[tail]=n;
  if(tail+1==N){
    tail=0;
  }
  else{
    tail++;
  }
}

int dequeue(){

  int n;

  n=time[head];
  if(head+1==N){
    head=0;
  }
  else{
    head++;
  }
  return n;
}



Measured memory_bytes: 3084
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        $(writeln!(stderr(), "{} = {:?}", stringify!($arg), $arg).unwrap());*
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, M, Q) = read!(usize, usize, usize);
    let mut es = vec![vec![0; N + 1]; N + 1];

    let stdout = std::io::stdout();
    let mut outl = stdout.lock();

    let stdin = std::io::stdin();
    let mut inl = stdin.lock();
    let mut line = String::new();

    for _ in 0..M {
        line.clear();
        inl.read_line(&mut line).unwrap();
        let mut tt = line.split_whitespace().map(|w| w.parse().unwrap());

        let l: usize = tt.next().unwrap();
        let r: usize = tt.next().unwrap();

        es[l][r] += 1;
    }

    for e in es.iter_mut() {
        for i in 0..N {
            e[i + 1] += e[i];
        }
    }

    // O(Q)
    for _ in 0..Q {
        line.clear();
        inl.read_line(&mut line).unwrap();
        let mut tt = line.split_whitespace().map(|w| w.parse().unwrap());

        let p: usize = tt.next().unwrap();
        let q: usize = tt.next().unwrap();

        let mut k = 0;

        for x in p..q + 1 {
            k += es[x][q];
        }

        writeln!(outl, "{}", k).unwrap()
    }
}


Measured memory_bytes: 4988
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n, k, ans = INF;
    cin >> n >> k;
    
    vector<int> v(n);
    for (auto &x : v) cin >> x;
    sort(ALL(v));
    
    for (int i = k-1; i < n; ++i) ans = min(ans, v[i] - v[i-k+1]);
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int,int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 0;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for(int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for(int i = L; i != (int)R; --i)
#define IOS cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);

int main()
{
    IOS;
    deque<char> dq;
    string s;
    int q;
    bool r = false;
    cin >> s >> q;
    FOR(i, 0, s.size()) { dq.push_back(s[i]); }
    while(q--)
    {
        int a, b;
        char c;
        cin >> a;
        if(a == 1)
        {
            r = !r;
        }
        else
        {
            cin >> b >> c;
            if(r ^ (b & 1))
            {
                dq.push_front(c);
            }
            else
            {
                dq.push_back(c);
            }
        }
    }
    if(r)
    {
        while(!dq.empty()){
            cout << dq.back();
            dq.pop_back();
        }
    }
    else
    {
        while(!dq.empty()){
            cout << dq.front();
            dq.pop_front();
        }
    }
    cout << '\n';
}


Measured memory_bytes: 976
#include<bits/stdc++.h>
#define pb emplace_back
#define INF 1e9
#define N 210
using namespace std;
struct Info{int nu,ne,qu;}a[N*N];
int m,n,x,y,s,t,num=1,b[N],cur[N],an[N][N],li[N],di[N];
vector<int> c[N][N];
void jb(int x,int y){
	a[++num].nu=y;a[num].ne=b[x];b[x]=num;a[num].qu=1;
	a[++num].nu=x;a[num].ne=b[y];b[y]=num;a[num].qu=0;
}
int dinic(int x,int sh){
	if (x==t) return sh;
	int n1=0,n2;
	for (int y=cur[x];y;y=a[y].ne){
		cur[x]=y;
		if (di[a[y].nu]==di[x]+1&&a[y].qu){
			n2=dinic(a[y].nu,min(a[y].qu,sh-n1));
			n1+=n2;a[y].qu-=n2;a[y^1].qu+=n2;
			if (n1==sh) return n1;
		}
	}
	return n1;
}
bool bfs(){
	for (int i=1;i<=t;i++)di[i]=INF;
	int l=1,r=1;li[l]=s;di[s]=0;
	while (l<=r){
		for (int y=b[li[l]];y;y=a[y].ne)
			if (a[y].qu&&di[a[y].nu]==INF){di[a[y].nu]=di[li[l]]+1;li[++r]=a[y].nu;}
		l++;
	}
	return (di[t]!=INF);
}
int main(){
	cin>>n>>m;
	s=n+n+1,t=n+n+2;
	for (int i=1;i<=n;i++){jb(s,i);jb(i+n,t);}
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++){cin>>x;c[i][(x-1)/m+1].pb(x);jb(i,n+(x-1)/m+1);}
	for (int j=1;j<=m;j++){
		while (bfs()){for (int i=1;i<=t;i++)cur[i]=b[i];dinic(s,INF);}
		for (int i=1;i<=n;i++){
			a[i*2].qu=1;a[i*2+1].qu=0;
			a[(i+n)*2].qu=1;a[(i+n)*2+1].qu=0;
		}
		for (int i=3;i<=num;i+=2){
			if (a[i].qu){
				a[i].qu=0;y=a[i^1].nu-n;
				an[a[i].nu][j]=c[a[i].nu][y][c[a[i].nu][y].size()-1];
				c[a[i].nu][y].pop_back();
			}
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<m;j++)cout<<an[i][j]<<' ';
		cout<<an[i][m]<<endl;
	}
	for (int i=1;i<=m;i++){
		vector<int> no;no.clear();
		for (int j=1;j<=n;j++)no.pb(an[j][i]);
		sort(no.begin(),no.end());
		for (int j=1;j<=n;j++)an[j][i]=no[j-1];
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<m;j++)cout<<an[i][j]<<' ';
		cout<<an[i][m]<<endl;
	}
	return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  int l, r, ans = 0;
  for (int i=0; i<n; i++) {
    scanf("%d%d", &l, &r);
    ans += r-l+1;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.util.ArrayList;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        long N = Long.parseLong(str);
        ArrayList<Long> num = new ArrayList<>();
        long div;
        for (int i=1;i<Math.sqrt(N);i++){
            div = (long)(N-i)/i;
            if (N/div==N%div){
                num.add(div);
            }
        }
        long ans = 0;
        for (long n:num){
            ans += n;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i, n) cin >> l[i];
	sort(l.begin(), l.end());
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			int tmp = l[j] - l[i], tmp_ = l[i] + l[j];
			auto itr = lower_bound(l.begin(), l.end(), tmp + 1);
			int d = max(j + 1, (int)distance(l.begin(), itr) - 1);
			auto itr2 = lower_bound(l.begin(), l.end(), tmp_);
			int d2 = (int)distance(l.begin(), itr2) - 1;
			ans += max(0, d2 - d + 1);
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1e9 + 7;
using namespace std;
typedef long long ll;
 
map<ll, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(20);
	int n, m, k;
	cin >> n >> m >> k;
	bool ok = false;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			if (i * (m - j) + j * (n - i) == k) {
				ok = true;
				break;
			}
		}
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define GO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
const ll N = 2e5 + 2;
const ll Mod = 2520;



int main()
{
	GO;
	ll x, n;
	cin >> x >> n;
	set<ll> s;
	while (n--)
	{
		ll y; cin >> y;
		s.insert(y);
	}
	for(int i=0;;i++)
		if (!s.count(x - i))
		{
			cout << x - i << endl;
			return 0;
		}
		else if (!s.count(x + i))
		{
			cout << x + i << endl; return 0;
		}
	return 0;
}

Measured memory_bytes: 3664
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    S = input().strip()

    ans = 0
    f = False
    for i, s in enumerate(S):
        if f:
            ans += 9
        elif i == len(S) - 1:
            ans += int(S[i])
        else:
            if S[i + 1] != "9":
                f = True
                ans += int(S[i]) - 1
            else:
                ans += int(S[i])

    print(ans)

    
    

if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 

int main(){
    fastio
    int n ; 
    cin >> n ; 
    double sum = 0 ;
    for(int i=0;i<n;i++){
    	int x ; 
    	cin >> x ;
    	sum += 1.0 / x ; 
    }
    cout << fixed << setprecision(12) << 1.0 / sum << endl;
    return 0 ;
}


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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
  Edge(int src, int dst) :
    src(src), dst(dst) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool augment(const Graph& g, int u,
    vector<int>& matchTo, vector<bool>& visited) {
  if (u < 0) return true;
  FOR(e, g[u]) if (!visited[e->dst]) {
    visited[e->dst] = true;
    if (augment(g, matchTo[e->dst], matchTo, visited)) {
      matchTo[e->src] = e->dst;
      matchTo[e->dst] = e->src;
      return true;
    }
  }
  return false;
}
int bipartiteMatching(const Graph& g, int L, Edges& matching) {
  const int n = g.size();
  vector<int> matchTo(n, -1);
  int match = 0;
  REP(u, L) {
    vector<bool> visited(n);
    if (augment(g, u, matchTo, visited)) ++match;
  }
  REP(u, L) if (matchTo[u] >= 0) // make explicit matching
    matching.push_back( Edge(u, matchTo[u]) );
  return match;
}
int main(){
	int n;
	cin >> n;
	
	Graph g(n+31);
	for(int i = 0 ; i < n ; i++){
		
		int a,b;
		cin >> a >> b;
		for(int j = a ; j <= b ; j++){	
			g[i].push_back(Edge(i,n+j-1));
			g[n+j-1].push_back(Edge(n+j-1,i));
		}
	}
	
	Edges dummy;
	long long ans = 31 * 50 + bipartiteMatching(g,n,dummy) * 50;
	cout << ans << endl;
	
}

Measured memory_bytes: 1232
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
char s[100001];
int main() {
	scanf("%s",s);
	int len=strlen(s);
	bool judge=0;
	for (int i=0;i<len-1;i++)
		if (s[i]=='A'&&s[i+1]=='C') {
			judge=1;
			break;
		}
	if (judge) printf("Yes\n");
		else printf("No\n");
	return 0;
}

Measured memory_bytes: 384
use proconio::{input, fastout};

fn gcd(a: usize, b: usize) -> usize {
    if a % b == 0 {
        b
    } else {
        gcd(b, a%b)
    }

}

#[fastout]
fn main() {
    input! {
        k : usize,
    }

    let mut ans = 0;
    for a in 1..=k {
        for b in 1..=k {
            for c in 1..=k {
                ans += gcd(c, gcd(a, b));
            }
        }
    }


    println!("{}", ans);

}

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

// DAME: グラフ連結判定 DFS

/*
    連結判定
        1. 全ての頂点を未訪問にする
        2. 任意の１つの頂点からDFS
        3. 全ての頂点が訪問済みになるならば連結であり、そうでない場合は非連結

    橋判定
        各辺をグラフから取り除いてグラフが連結であるかを判定して非連結となる場合を数える
*/

// 隣接行列表現
const int limit=50;
int n,m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v){
    visited[v] = true;
    for(int v2=0; v2<n; ++v2){
        if(graph[v][v2]==false) continue;
        if(visited[v2]) continue;
        dfs(v2);
    }
}

int main() {
    cin >> n >> m;
    for(int i=0; i<m; ++i){
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    int ans = 0;

    for(int i=0; i<m; ++i){
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

        for(int j=0; j<n; ++j){
            visited[j] = false;
        }

        dfs(0);

        bool bridge = false;
        for(int j=0; j<n; ++j){
            if(visited[j]==false) bridge = true;
        }

        if(bridge) ans += 1;

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll);

int N, a[110];
vector<int> v;
bool used[110];

signed main(){
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> a[i];
    }
    int M = N;
    while(M--){
        int now = 0;
        bool con = false;
        for(int i = 1; i <= N; i++){
            if(!used[i]){
                now++;
                if(a[i] > now){
                    printf("-1\n");
                    return 0;
                }
                else if(a[i] == now){
                    bool flag = true;
                    int pos = now;
                    for(int j = i + 1; j <= N; j++){
                        if(!used[j]){
                            pos++;
                            if(a[j] >= pos)flag = false;
                        }
                    }
                    if(flag){
                        used[i] = true;
                        v.push_back(a[i]);
                        con = true;
                        break;
                    }
                }
            }
        }
        if(!con){
            printf("-1\n");
            return 0;
        }
    }
    reverse(v.begin(), v.end());
    for(int i = 0; i < N; i++){
        cout << v[i] << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int h,w,i,j,k,mf,ans=0;
  string s;
  vector<string> g;
  cin >> h >> w;
  vector<vector<int>> m(h,vector<int>(w,0));
  for (i=0;i<h;i++){
    cin >> s;
    g.push_back(s);
  }
  for (i=0;i<h;i++){
    mf=0;
    for (j=0;j<w;j++) if (g.at(i).at(j)=='#'){
      for (k=mf;k<j;k++) m.at(i).at(k)=j-mf;
      mf=j+1;
    }
    for (k=mf;k<w;k++) m.at(i).at(k)=w-mf;
  }
  for (j=0;j<w;j++){
    mf=0;
    for (i=0;i<h;i++) if (g.at(i).at(j)=='#'){
      for (k=mf;k<i;k++) m.at(k).at(j)+=i-mf;
      mf=i+1;
    }
    for (k=mf;k<h;k++) m.at(k).at(j)+=h-mf;
  }
  for (i=0;i<h;i++){
    for (j=0;j<w;j++){
      if (ans<m.at(i).at(j)-1) ans=m.at(i).at(j)-1;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n,m;
  cin>>n>>m;
  int a[n];
  for(int i=0; i<n; i++) cin>>a[i];

  int sum=0;
  for(int i=0; i<n; i++) sum+=a[i];

  sort(a, a+n, greater<int>());

  if(a[m-1]>=double(sum)/(4*m)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
  // 入力
  int r, D, x2000;
  cin >> r >> D >> x2000;
  
  int i = 1;
  int p = x2000;
  while (i <= 10) {
    int n = r * p - D;
    cout << n << endl;
    p = n;
    i++;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int n;

    cin >> n;

    vector<int> v(n);
    int cnt = 0;
    int cnt_two = 0;

    for(int i = 0; i < n; i++) {
        cin >> v[i];
        if(v[i] % 4 == 0)
            cnt++;
        if(v[i] % 4 == 2)
            cnt_two++;
    }

    // cout << cnt << endl;
    // cout << cnt_two << endl;

    if(cnt >= (n - cnt_two + (cnt_two != 0)) / 2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 888
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		String x = "";
		try {
			while ((x = in.readLine()) != null) {
				String[] ab = x.split(" ");
				int a = Integer.parseInt(ab[0]);
				int b = Integer.parseInt(ab[1]);
				String str = String.valueOf(a + b);
				System.out.println(str.length());
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24304
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	map<int,int> m;
	int n,a;cin>>n;
	rep(i,n) {cin>>a;m[a]++;}
	int ans=0;
	for(auto i=m.begin(); i!=m.end(); i++) ans+=(i->second)%2;
	cout<<ans<<endl;
}


Measured memory_bytes: 4992
n = int(input())
l = ["a","b","c","d","e","f","g","h","i","j"]
i = 0
def st(s,n,k,m):
  if k == n:
    print(s)
    return
  for i in range(m):
    st(s+l[i],n,k+1,m)
  st(s+l[m],n,k+1,m+1)
st("a",n,1,1)

Measured memory_bytes: 58200
#include<iostream>
using namespace std;
int main()
{
	char c[4];
	int n[4];
	for(int i=0;i<4;i++)
	{
		cin>>c[i];
		n[i]=c[i]-'0';
	}
	int ans=n[0];
    if(ans+n[1]+n[2]+n[3]==7)
    {
    	cout<<n[0]<<'+'<<n[1]<<'+'<<n[2]<<'+'<<n[3];
    	
	}
	else
	if(ans+n[1]+n[2]-n[3]==7)
    {
    	cout<<n[0]<<'+'<<n[1]<<'+'<<n[2]<<'-'<<n[3];
    	
	}
	else
	if(ans+n[1]-n[2]+n[3]==7)
    {
    	cout<<n[0]<<'+'<<n[1]<<'-'<<n[2]<<'+'<<n[3];
    	
	}
	else
	if(ans+n[1]-n[2]-n[3]==7)
    {
    	cout<<n[0]<<'+'<<n[1]<<'-'<<n[2]<<'-'<<n[3];
    	
	}
	else
	if(ans-n[1]+n[2]+n[3]==7)
    {
    	cout<<n[0]<<'-'<<n[1]<<'+'<<n[2]<<'+'<<n[3];
    	
	}
	else
	if(ans-n[1]-n[2]+n[3]==7)
    {
    	cout<<n[0]<<'-'<<n[1]<<'-'<<n[2]<<'+'<<n[3];
    
	}
	else
	if(ans-n[1]+n[2]-n[3]==7)
    {
    	cout<<n[0]<<'-'<<n[1]<<'+'<<n[2]<<'-'<<n[3];
    	
	}
	else
	if(ans-n[1]-n[2]-n[3]==7)
    {
    	cout<<n[0]<<'-'<<n[1]<<'-'<<n[2]<<'-'<<n[3];
    	
	}
	cout<<'='<<7;
}

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

int a[60];
int N;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	vector<int> num;
	map<int, int> cnt;
	for (int i = 0; i < N; i++) {
		cnt[a[i]]++;
	}

	if (cnt[-2] % 2 == 1) {

		if (cnt[-1] > 0) {
			for (int i = 0; i < N; i++) {
				if (a[i] == -1) {
					num.push_back(i + 1);
					break;
				}
			}
			for (int i = 0; i < N; i++) {
				if (a[i] == -2 || a[i]==2) {
					num.push_back(i + 1);
				}
			}
		}
		else {
			int cnt2 = 0;
			for (int i = 0; i < N; i++) {
				if (a[i] == -2 || a[i] == 2) {
					if (a[i] == -2 && cnt[-2] == cnt2 + 1) {
						continue;
					}
					if (a[i] == -2) {
						cnt2++;
					}
					num.push_back(i + 1);
				}
			}
		}
	}
	else {
		for (int i = 0; i < N; i++) {
			if (a[i] == -2 || a[i] == 2) {
				num.push_back(i + 1);
			}
		}
	}

	sort(num.begin(), num.end());
	cout << num.size() << endl;

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

	return 0;
}


Measured memory_bytes: 3160
#include<stdio.h>
int main(void){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(W<x+r||H<y+r||0>x+r||0>y+r||x<0||y<0){
		printf("No\n");
	}else if(W>=x+r&&H>=y+r&&0<=x+r&&0<=y+r){
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include<cstdio>

typedef long long ll;
ll ans=1e18;

void uans(ll a,ll b,ll c)
{
	ll s=0;
	if((a>b?a-b:b-a)>s)s=(a>b?a-b:b-a);
	if((a>c?a-c:c-a)>s)s=(a>c?a-c:c-a);
	if((c>b?c-b:b-c)>s)s=(c>b?c-b:b-c);
	if(s<ans)ans=s;
}

void work(int n,int m)
{
	int i;ll a,b,c;
	for(i=1;i<m;i++)
	{
		a=(ll)n*(m-i);
		b=(ll)n/2*i;
		c=(n+1ll)/2*i;
		uans(a,b,c);
	}
}

int main()
{
	int n,m;scanf("%d%d",&n,&m);
	if(n%3==0||m%3==0)return puts("0"),0;
	ans=n<m?n:m,work(n,m);
	if(n!=m)work(m,n);
	printf("%lld\n",ans);
}

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

#define MaxN 3000005
#define INF 2140000000
#define MOD 998244353

using namespace std;

long long N,A,B,K,Ans,fact[MaxN];

long long LogPow(long long base,long long exp)
{
    long long act=1;
    for(int i=0;i<31;i++)
    {
        if(exp&(1LL<<i))
            act=act*base%MOD;
        base=base*base%MOD;
    }
    return act;
}

long long Comb(long long n,long long k)
{
    if(k>n||k<0)return 0;
    return fact[n]*LogPow(fact[k],MOD-2)%MOD*LogPow(fact[n-k],MOD-2)%MOD;
}

int main()
{
    scanf("%d%d%d%lld",&N,&A,&B,&K);

    fact[0]=1;
    for(int i=1;i<=N;i++)
        fact[i]=fact[i-1]*i%MOD;
    for(int i=0;i<=N;i++)
        if((K-A*i)%B==0)
                Ans=(Ans+Comb(N,i)*Comb(N,(K-A*i)/B)%MOD)%MOD;
    printf("%lld",Ans);

    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	char c;
	cin >> c;
	if(c >= 'A' && c <= 'Z')
		cout << "A" << endl;
	else cout << "a" << endl;
	return 0;
}



Measured memory_bytes: 3600
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>
#include <complex>
using namespace std;

typedef complex<int> pint;
typedef const pint &refpint;
typedef pair<double,bool> pdb;


#define INF 1e99

int cross(refpint a, refpint b){
	return a.real() * b.imag() - a.imag() * b.real();
}

double intersect(refpint a, refpint dif1, refpint f, refpint dif2){
	int A_ = cross(dif1, -dif2);
	if( A_ == 0.0 ) return INF;
	double A = A_;
	
	pint ddif = f - a;
	double t = cross(ddif, -dif2) / A;
	double s = cross(dif1, ddif) / A;
	
	if(t >= 0.0 && t <= 1.0 && s >= 0.0 && s <= 1.0){
		return t;
	}
	return INF;
}


int main(){
	int dataset;
	for(scanf("%d", &dataset); dataset--; ){
		pint a, b, from, to, dif1, dif2;
		int n, o, l, x1, x2, y1, y2;
		vector<pdb> ts;

		scanf("%d%d%d%d%d", &x1, &y1, &x2, &y2, &n);
		a = pint(x1, y1);
		b = pint(x2, y2);
		dif1 = b - a;

		ts.reserve(n);

		for(int i = 0; i < n; ++i){
			scanf("%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &o, &l);
			from = pint(x1, y1);
			to = pint(x2, y2);
			dif2 = to - from;

			double t = intersect(a, dif1, from, dif2);
			if( t != INF ){
				ts.push_back( pdb(t, o != l) );
			}
		}
		
		sort(ts.begin(), ts.end());
		int res = 0;
		for(int i = 1; i < ts.size(); ++i){
			if(ts[i-1].second != ts[i].second){
				++res;
			}
		}
		printf("%d\n", res);
	}
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

const int SZ=1<<18;
vector<pair<int,int>> E[200001];
vector<tuple<int,int,int>> P;
vector<int> x, query;
int tree[2*SZ];

void add_tree(int n, int v)
{
	for(tree[n+=SZ]+=v;n>>=1;) tree[n]=tree[2*n]+tree[2*n+1];
}

int solve()
{
	int bit=1, s=0, e=SZ-1;
	while(s<e) {
		int m=(s+e)>>1;
		if(tree[2*bit]) {
			e=m;
			bit=2*bit;
		}
		else {
			s=m+1;
			bit=2*bit+1;
		}
	}
	return s;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, Q;
	cin>>N>>Q;
	P.resize(N);
	for(int i=0;i<N;i++) {
		int S, T, X;
		cin>>S>>T>>X;
		P[i]=make_tuple(S-X,T-X-1,X);
		x.push_back(X);
	}
	query.resize(Q);
	for(int i=0;i<Q;i++) cin>>query[i];
	sort(x.begin(),x.end());
	x.resize(unique(x.begin(),x.end())-x.begin());
	for(int i=0;i<N;i++) {
		int S, T, X;
		tie(S,T,X)=P[i];
		S=lower_bound(query.begin(),query.end(),S)-query.begin();
		T=upper_bound(query.begin(),query.end(),T)-query.begin();
		X=lower_bound(x.begin(),x.end(),X)-x.begin();
		E[S].emplace_back(X,1);
		E[T].emplace_back(X,-1);
	}
	for(int i=0;i<Q;i++) {
		for(auto e: E[i]) add_tree(e.first,e.second);
		if(tree[1]==0) cout<<"-1\n";
		else cout<<x[solve()]<<'\n';
	}
	return 0;
}

Measured memory_bytes: 19316
import itertools

s=input()
l=len(s)

cand=("+"," ")

ans=0

for i in itertools.product(cand,repeat=l-1):
	siki=s[0]
	for j in range(len(i)):
		if i[j]=="+":
			siki=siki+i[j]+s[j+1]
		else:
			siki=siki+s[j+1]
	ans+=eval(siki)
  
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

#define no cout << "No" << endl; exit(0)

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    cins(all(A));
    vector<int> A_sorted = A;
    sort(all(A_sorted));
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans += (i ^ (lower_bound(all(A_sorted), A[i])) - A_sorted.begin()) % 2;
    }
    cout << ans / 2 << endl;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	a := scanInts(3)
	sort.Ints(a)
	fmt.Fprintln(wr, a[2]*10+a[1]+a[0])
}


Measured memory_bytes: 1776
#include<iostream> 
#include<vector> 
#include<algorithm> 
using namespace std; 
#define lld long long int
#define X 1000000007
#define fast();  ios_base::sync_with_stdio(false); cin.tie(0);
# define rec(i,n) for(int i=0;i<n;i++) 
#define w(t) int t; cin>>t; while(t--)
int main()
{
    fast(); 
    lld n,m,x; 
    cin>>n>>m; 
    rec(i,m) 
    { cin>>x; 
       n=n-x; 
    }
    if(n<0) 
     n=-1; 
    cout<<n<<endl; 
	return 0;
}

Measured memory_bytes: 3644
while True:
    a, op, b = raw_input().split()
    if "?" == op:
        break
    a = int( a )
    b = int( b )
    if "+" == op:
        print a+b
    elif "-" == op:
        print a-b
    elif "*" == op:
        print a*b
    elif "/" == op:
        print a/b

Measured memory_bytes: 6428
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    n,k = mi()
    a = li()
    a = list(reversed(sorted(a)))
    ans = 0
    for i in range(k,n):
        ans+=a[i]
    print(ans)



main()


Measured memory_bytes: 27700
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

n = inp()
dp = [[0]*3 for i in range(n)]
a,b,c = [],[],[]
for _ in range(n):
    aa,bb,cc = ip()
    a.append(aa)
    b.append(bb)
    c.append(cc)
dp[0] = [a[0],b[0],c[0]]
for i in range(1,n):
    dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2])
    dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2])
    dp[i][2] = c[i] + max(dp[i-1][0],dp[i-1][1])
print(max(dp[-1]))


Measured memory_bytes: 98016
#include<iostream>
using namespace std;
int main(){
  int t,bell;
  while(1){
    t=0;
    cin >> bell;
    if(bell==0){
      break;
    }
    while(bell!=1){
      t++;
      if(bell%2==0){
	bell/=2;
      }
      else{
	bell*=3;
	bell++;
      }
    }
    cout << t << endl;
  }
}

Measured memory_bytes: 1160
function main(input) {
    var args = input.trim().split("\n");
    var N = parseInt(args[0]);
    var Ss = args.filter((v, i) => i !== 0);

    var resultMap = Ss.map((v) => {
        var sorted = v.split("").sort();
        return sorted.join("");
    }).reduce((accumulator, currentValue) => {
        accumulator[currentValue] = !!accumulator[currentValue] ? accumulator[currentValue] + 1 : 1;
        return accumulator;
    }, {});

    var result = Object.keys(resultMap).filter((v) => {
        return resultMap[v] > 1
    }).reduce((accumulator, currentValue) => {
        var base = resultMap[currentValue] - 1;
        var value = 0;
        while(base > 0) {
            value += base;
            base--;
        }

        return accumulator + value
    }, 0);

    console.log(result);
}

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

Measured memory_bytes: 61696
#include<cstdio>
using namespace std;
int main(){
    int a,b,c,cnt=0;
    scanf("%d%d%d",&a,&b,&c);
    for(int i=a;i<=b;i++){
        if(c%i==0)
            cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}



Measured memory_bytes: 2700
import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり整数
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

N行M列の初期化
dp = [[INF] * M for i in range(N)]

'''

H, W  = map(int, input().split())

S = []
for i in range(H):
    s = list(map(str,input().split()))
    S.append(s)


for w in range(W):
    for h in range(H):
        if S[h][w] == "snuke":
            print("{}{}".format(chr(ord("A")+w), h+1))
            sys.exit()




Measured memory_bytes: 5116
#include<iostream>
#include<algorithm>

using namespace std;

#define REP(s,e) for(int i=(s);i<(e);i++)

int main(){
    string A,B;

    cin>>A>>B;
    
    if(A=="H") cout<<B<<endl;
    else if(B=="H") cout<<"D"<<endl;
    else cout<<"H"<<endl;
}


Measured memory_bytes: 888
n = int(input())
t = [[0 for j in range(10)] for i in range(10)]
for i in range(1,n+1):
    s = str(i)
    t[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += t[i][j]*t[j][i]
print(ans)

Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define mp make_pair
#define pb push_back
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)  ((a)*((b)/gcd(a,b)))
#define pi 3.14159265358979323846
#define mod 1000000007
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;
	
//	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	#endif
	
	string s;
	cin>>s;
	int sum=0;
	for(int i=0;i<s.length();i++)
	{
		sum+=(s[i]-'0');
	}
	if(sum%9==0)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
#define INF (1e9)
#define H 205
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;

priority_queue<P1,vector<P1>,greater<P1> > q;
int h,w,sy,sx;
string s[H];
int d[H][H];

int dijkstra(){
  int dy[4]={-1,0,1,0};
  int dx[4]={0,1,0,-1};
  while(!q.empty()){
    P1 t=q.top(); q.pop();
    int y=t.second.first;
    int x=t.second.second;
    int cost=t.first;
    if(d[y][x]<cost)continue;
    if(s[y][x]=='%')return cost;
    for(int i=0;i<4;i++){
      int ny=y+dy[i],nx=x+dx[i];
      if(ny<0||nx<0||h<=ny||w<=nx)continue;
      if(s[ny][nx]=='#')continue;
      if(d[ny][nx]>cost+1){
	d[ny][nx]=cost+1;
	q.push(P1(cost+1,P(ny,nx)));
      }
    }
  }
  return INF;
}

int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++){
    cin>>s[i];
    for(int j=0;j<w;j++){
      d[i][j]=INF;
      if(s[i][j]=='@')sy=i,sx=j;
      if(s[i][j]=='$'){
	q.push(P1(0,P(i,j)));
	d[i][j]=0;
      }
    }
  }
  int comp=dijkstra();
  while(!q.empty())q.pop();
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      d[i][j]=INF;
  q.push(P1(0,P(sy,sx)));
  d[sy][sx]=0;
  int r=dijkstra();
  if(r<comp)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

int main(){
    int x,y;
    cin >> x >> y;
    for(int i = 0; i <= x; i++){
        if(2*i + ((x-i)*4) == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
}


Measured memory_bytes: 3580
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int x;
        if(a>b){
            x=b;
            b=a;
            a=x;
        }
        if(a>c){
            x=c;
            c=a;
            a=x;
        }
        if(b>c){
            x=c;
            c=b;
            b=x;
        }
                System.out.printf("%d %d %d\n", a, b, c);
    }}



Measured memory_bytes: 26336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
using ll = long long;
typedef pair<int, int> P;

int main(){
    int n,x=0;
    cin>>n;
    vector<int> dat(n);
    rep(i,n){
        cin>>dat[i];
        x=x^dat[i];
    }
    rep(i,n){
        int ans=dat[i]^x;
        cout<<ans<<" ";
    }
    return 0;
}

Measured memory_bytes: 3976
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int n,a[2][100],s=0,ma;
    cin>>n;
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++)cin>>a[i][j];
    }
    s+=a[0][0];
    for(int i=0;i<n;i++)s+=a[1][i];
    ma=s;
    
    for(int i=1;i<n;i++){
        s+=a[0][i];
        s-=a[1][i-1];
        ma=max(ma,s);
    }
    cout<<ma<<endl;
    return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def gcd_n(a, n):
    ans = a[0]
    for i in range(1, n):
        ans = gcd(ans, a[i])
    return ans


def main():
    N, X = MI()
    x = LI()
    x.append(X)
    x.sort()
    d = []

    for i in range(1, N+1):
        d.append(x[i] - x[i-1])

    print(gcd_n(d, len(d)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 88272
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
  if (p[i-1]<p[i] and p[i]<=p[i+1])or(p[i+1]<p[i] and p[i]<=p[i-1]):
    #print(i,p[i])
    ans+=1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
#define EPS (1e-10)
int main(){
    double x1, y1, x2, y2, xq, yq;

    while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq ,&yq)){
	double a = y1 - y2;
	double b = - x1 + x2;
	double c = -(a*x1 + b*y1);
	double dis = abs(a * xq + b * yq + c) / hypot(a, b);
	double xa = xq + 2 * dis * (y1 - y2) / hypot(x1 - x2, y1 - y2), xb = xq - 2 * dis * (y1 - y2) / hypot(x1 - x2, y1 - y2);
	double ya = yq + 2 * dis * (x2 - x1) / hypot(x1 - x2, y1 - y2), yb = yq - 2 * dis * (x2 - x1) / hypot(x1 - x2, y1 - y2);
	double disa = abs(a * xa + b * ya + c) / hypot(a, b);
	if(abs(dis - disa) < EPS){
	    printf("%.9lf %.9lf\n", xa, ya);
	}
	else{
	    printf("%.9lf %.9lf\n", xb, yb);
	}
    }
    return 0;
}

Measured memory_bytes: 1256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::collections::HashMap;

fn main() {
    let n: usize = read();
    let mut a: Vec<String> = vec![];
    let mut map: HashMap<String, bool> = HashMap::new();

    for _ in 0..n {
        a.push(read());
    }

    let mut prev: char = '?';

    for i in 0..a.len() {
        // println!("{}", prev);
        if i != 0 && a[i].chars().nth(0).unwrap() != prev {
            println!("No");
            return;
        }
        if map.contains_key(&a[i]) {
            println!("No");
            return;
        }
        let ac = a[i].clone();
        map.insert(ac, true);
        prev = a[i].chars().last().unwrap();
    }
    println!("Yes");
}


Measured memory_bytes: 4352