akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

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

struct path_history {
	const vector<vector<Edge>>& g;
	vector<int> edges;

	path_history(const vector<vector<Edge>>& g) : g(g) {
		edges.reserve(64);
	}

	bool traverse(int from, int to, int parent = -1) {
		if (from == to) {
			return true;
		}
		for (auto e : g[from]) {
			if (e.to == parent) continue;
			if (traverse(e.to, to, from))
			{
				edges.push_back(e.id);
				return true;
			}
		}
		return false;
	}
};
struct IEP {
	ll solve(ll all, function<ll(ll)> getState) {
		ll sum = 0;
		rep(i, all) {
			ll element = getState(i);
			if (__builtin_popcountll(i) % 2 == 0) sum += element;
			else sum -= element;
		}
		return sum;
	}
};

int main(void)
{
	ll n;
	cin >> n;
	vector<vector<Edge>> g(n);
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].emplace_back(b, i);
		g[b].emplace_back(a, i);
	}
	ll m;
	cin >> m;
	vector<ll> state(m, 0);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;

		path_history h(g);
		h.traverse(a, b);
		for (ll e : h.edges) {
			state[i] |= (1LL << e);
		}
	}
	IEP p;
	ll ans = p.solve(1LL << m, [&](ll i) {
		ll mask = 0;
		rep(j, m) {
			if (i >> j & 1) {
				mask |= state[j];
			}
		}
		int white = __builtin_popcountll(mask);
		ll now = 1LL << (n - 1 - white);
		return now;
	});
	cout << ans << endl;

	return 0;


}


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

int main(){
    int t;
    cin >> t;
    int s,m;
    s = t%60;
    t /= 60;
    m = t%60;
    t /= 60;
    cout << t << ":" << m << ":" << s  << endl;
    return 0;
}



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

int gcd(int p,int q){
    if(p%q == 0){
        return q;
    }
        return gcd(q,p%q);
}

int main(){
    string s; cin >> s;
    if(s=="ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3592
N = int(input())

rng = []
for i in range(N):
    X, L = map(int, input().split())
    rng.append((max(X-L, 0), X+L))

rng.sort(key=lambda x: x[1])

ans = 0
t = 0
for r in rng:
    if t <= r[0]:
        ans += 1
        t = r[1]
print(ans)


Measured memory_bytes: 18232
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int a , b ;
    cin >> a >> b ;
    string c ;
    cin >> c ;
    char f ; 
   
    bool flag = true ;
    for(int i = 0 ; i < a ; i++){
        f = c[i] ;
        if(f == '-'){
            flag = false ;
            
        }
    }

    f = c[a] ;
    if(f != '-'){
        flag = false ;
        
    }
    
    for(int i = 0 ; i < b ; i++){
        f = c[a + 1 + i] ;
        if(f == '-'){
            flag = false ;
           

        }
    }

   if(flag == false){
        cout << "No "<< endl;
   }else{
       cout <<"Yes " << endl;
   }

 
}

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

int main(){
    int n;
    cin >> n;
    vector<int> ans;
    rep(i,n){
        int a;
        cin >> a;
        if(i == 0) ans.push_back(a);
        else{
            auto it = ans.begin();
            if (i % 2 == 0) ans.push_back(a);
            else ans.insert(it, a);
        }
    }
    if (n % 2 == 0) rep(i,n) cout << ans[i] << " ";
    else rep(i,n) cout << ans[n-i-1] << " ";
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, K;
    cin >> N >> K;
    cout << !!(N % K) << endl;
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
typedef long long LL;
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second

using namespace std;

int main(){
	DRI(n);
	VI v(n);
	VI t1(100001);
	VI t2(100001);
	REP(i,n) {
		RI(v[i]);
		if (i%2) {t2[v[i]]++;}
		else {t1[v[i]]++;}
		}
	PII mt1={-1,0};
	PII m2t1={-1,0};
	PII mt2={-1,0};
	PII m2t2={-1,0};
	REPP(i,1,100001){
		if (t1[i]>mt1.F) {m2t1=mt1; mt1={t1[i],i};}
		else { if (t1[i]>m2t1.F) {m2t1={t1[i],i};}}
		if (t2[i]>mt2.F) {m2t2=mt2; mt2={t2[i],i};}
		else { if (t2[i]>m2t2.F) {m2t2={t2[i],i};}}
	}
	
	/*cout<<mt1.F<<" "<<mt1.S<<endl;
	cout<<m2t1.F<<" "<<m2t1.S<<endl;
	cout<<mt2.F<<" "<<mt2.S<<endl;
	cout<<m2t2.F<<" "<<m2t2.S<<endl;
	*/
	if (mt1.S!=mt2.S) { printf("%d\n",n-mt1.F-mt2.F);}
	else {
		int res=min(n-mt1.F-m2t2.F,n-mt2.F-m2t1.F);
		printf("%d\n",res);
	}
	
	
}


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

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

const int mod = 1e9+7;
const ll INF = 1e12;
const int MAX = 1e5;

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

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visit[MAX]; // 訪問の有無

int n, w; // 変数
struct item {int va, we;};
item items[100];
ll dp[100][MAX+1];

ll rec(int i, int j) { // 重さの総和jまでで品物iまでを選んだときの価値の総和の最大
    if (j < 0) return -INF;
    if (dp[i][j] != -1) return dp[i][j];
    if (i == 0) {
        if (items[i].we <= j) return dp[i][j] = items[i].va;
        else return dp[i][j] = 0;
    }
    ll x = rec(i-1, j);
    ll y = rec(i-1, j-items[i].we) + items[i].va;
    return dp[i][j] = max(x, y);
}

int main() {
// input
    cin >> n;
    cin >> w;
    rep(i, n) {
        cin >> items[i].we;
        cin >> items[i].va;
    }
// solve
    rep(i, n) {
        rep(j, w+1) {
            dp[i][j] = -1;
        }
    }
    ll ans = rec(n-1, w);
// output
    cout << ans << "\n";
}

Measured memory_bytes: 81648
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>



using namespace std;



int main()
{
	int n, p, wan, temoto[50];
	
	while (cin >> n >> p)
	{
		if (n == 0 && p == 0) break;
		
		//wan, temotoの初期化
		wan = p;
		for (int i=0; i<n; i++) temoto[i] = 0;
		
		for (int i=0; i<1000000; i++)
		{
			if (wan >= 2)
			{
				wan--;
				temoto[i % n]++;
			} else if (wan == 0) {
				wan = temoto[i % n];
				temoto[i % n] = 0;
			} else if (wan == 1) {
				bool flag = true;		//forの後trueならその人の勝ち
				for (int j=0; j<n; j++)
				{
					if (j == i % n) continue;
					if (temoto[j] != 0) flag = false;
				}
				if (flag)
				{
					cout << i % n << endl;
					break;
				} else {
					wan--;
					temoto[i % n]++;
				}
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;

void printVec(vi vec){
  if (vec.size()==0) return;
  cout << vec[0];
  for (int i=1; i<vec.size(); i++){
    cout << " " << vec[i];
  } cout << endl;
}

void solve(int n, int lmt, vi vec){
  if (n<1) return;
  for (int i=n; i; i--){
    if (i>lmt) continue;
    vec.push_back(i);
    if (i==n) printVec(vec);
    else solve(n-i, i, vec);
    vec.pop_back();
  }
}

int main(void){
  int n;
  while (true){
    cin >> n;
    if (n==0) break;
    solve(n, n, vi());
  }
  return 0;
}



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

int main()
{
  string s,t;
  cin>>s>>t;
  int cnt = 0;
  for (int i=0;i<s.size();i++)
  {
      if(s[i]!=t[i])
        cnt++;
  }
  cout<<cnt;
    return 0;
}


Measured memory_bytes: 3872
#include <stdio.h>

typedef struct{
    char design;
    int value;
}card;

void BubbleSort(card *,int);
void SelectionSort(card *,int);

int main() {
  int i,n,flag=0;
    card C[36],A[36];
    
    scanf("%d",&n);
    for(i = 0; i < n; i++) {
      scanf(" %c%d",&C[i].design,&C[i].value);
      A[i] = C[i];
    }
    
    BubbleSort(C,n);
    for(i = 0; i < n; i++) {
      printf("%c%d",C[i].design,C[i].value);
      if(i != n-1) printf(" ");
    }
    printf("\n");
    printf("Stable\n");
    
    SelectionSort(A,n);
    for(i = 0; i < n; i++) {
      printf("%c%d",A[i].design,A[i].value);
      if(i != n-1) printf(" ");
    }
    printf("\n");

    for(i = 0; i < n; i++) {
      if(C[i].design != A[i].design) flag = 1;
    }
    
    if(flag == 1) printf("Not stable\n");
    else printf("Stable\n");

    return 0;
}

void BubbleSort(card *C,int N)
{
  int i,j;
  card temp;
    for(i = 0; i <= N-1; i++) {
        for(j = N-1; j >= i+1; j--) {
            if(C[j].value < C[j-1].value) {
                temp = C[j];
                C[j] = C[j-1];
                C[j-1] = temp;
            }
        }
    }
}

void SelectionSort(card *C,int N)
{
  int i,j,minj;
  card temp;
    for(i = 0; i <= N-1; i++) {
        minj = i;
        for(j = i; j <= N-1; j++) {
            if(C[j].value < C[minj].value) {
                minj = j;
            }
        }
	temp = C[i];
	C[i] = C[minj];
	C[minj] = temp;
    }
}



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

int h, w;

map<char, int> cnt;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char c; cin >> c;
            cnt[c]++;
        }
    }
    
    vector<int> needed;
    for (int i = 0; i < ceil((double)h / 2); i++) {
        for (int j = 0; j < ceil((double)w / 2); j++) {
            int cnt = 4;
            if (h % 2 && i == h / 2) cnt /= 2;
            if (w % 2 && j == w / 2) cnt /= 2;
            needed.push_back(cnt);
        }
    }
    sort(needed.begin(), needed.end(), greater<int>());

    priority_queue<int, vector<int>> pq;
    for (auto i : cnt) {
        pq.push(i.second);
    }
    
    for (auto i : needed) {
        int v = pq.top();
        pq.pop();
        if (v < i) {
            cout << "No";
            return 0;
        } else {
            v -= i;
            if (v) pq.push(v);
        }
    }
    cout << "Yes";
}


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

int main(){
    int N, K;
    cin >> N >> K;
    vector<ll> X(N), Y(N);
    vector<ll> P(N), Q(N);
    for(int i=0;i<N;i++) cin >> X[i] >> Y[i], P[i] = X[i], Q[i] = Y[i];
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    ll ans = 1ll<<62;
    
    for (int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int a=i+1;a<N;a++){
                for (int b=j+1;b<N;b++){
                    ll x1 = X[i], x2 = X[a], y1 = Y[j], y2 = Y[b];
                    int cnt = 0;
                    for(int k=0;k<N;k++){
                        if (x1 <= P[k] && P[k] <= x2 && y1 <= Q[k] && Q[k] <= y2) cnt += 1;
                    }
                    if (cnt >= K) ans = min(ans, (x2-x1)*(y2-y1));
                }
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
  Graph data(3, vector<int>(3));
  for (int i = 0; i < 3;i++){
    for (int j = 0; j < 3;j++){
      cin >> data.at(i).at(j);
    }
  }
  ll n;
  cin >> n;
  rep(i,n){
    int a;
    cin >> a;
    rep(i, 3){
      rep(j, 3){
        if (a == data.at(i).at(j)){
          data.at(i).at(j) = 0;
        }
        else{
          continue;
        }
      }
    }
  }
  bool ans = false;
  rep(i,3){
    if (data.at(i).at(0) == 0 && data.at(i).at(1) == 0 && data.at(i).at(2) == 0){
      ans = true;
    }
    if(data.at(0).at(i)==0&&data.at(1).at(i)==0&&data.at(2).at(i)==0){
      ans = true;
    }
  }
  if(data.at(0).at(0)==0&&data.at(1).at(1)==0&&data.at(2).at(2)==0){
    ans = true;
  }
  else if(data.at(0).at(2)==0&&data.at(1).at(1)==0&&data.at(2).at(0)==0){
    ans = true;
  }
  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
int main()
{
	string s;
	cin >> s;
	
	bool flag = true;
	int n = s.size();
	rep(i, n) {
		if ((i + 1) % 2 == 1) {
			if (s[i] == 'L')  flag = false;
		}
		else {
			if (s[i] == 'R')  flag = false;
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;
const lint mod = 1e9 + 7;

typedef struct Segtree{
    int n = 1;
    vector<int> node;
    
    Segtree(int n_){
        while(n < n_) n *= 2;
        node.resize(2*n-1, 0);
    }
    
    void update(int a, int b, int i, int l, int r, int v){
        if(r<=a || b<=l) return;
        if(a<=l && r<=b){
            node[i] += v;
            return;
        }
        update(a, b, 2*i+1, l, (l+r)/2, v);
        update(a, b, 2*i+2, (l+r)/2, r, v);
    }
    
    int getval(int i){
        i += n-1;
        int ret = node[i];
        while(i){
            i = (i-1) / 2;
            ret += node[i];
        }
        return ret;
    }
}ST;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    pii p[n];
    rep(i, n){
        int l, r;
        scanf("%d%d", &l, &r);
        p[i] = make_pair(l, r);
    }
    sort(p, p+n, [](const pii &a, const pii &b){return a.se-a.fi < b.se-b.fi;});
    ST st(m+1);
    int cur = 0;
    For(i, 1, m+1){
        while(cur < n && p[cur].se-p[cur].fi+1 <= i){
            st.update(p[cur].fi, p[cur].se+1, 0, 0, st.n, 1);
            ++cur;
        }
        int ans = n - cur;
        for(int j=0; j<=m; j+=i) ans += st.getval(j);
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  ll sum = 0;
  rep(i, n){
    int in;
    cin >> in;
    sum += in-1;
  }
  cout << sum << endl;
  return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  int N, M;
  cin >> N >> M;
  int low = -inf, high = inf;
  while(M--) {
    int x, y;
    cin >> x >> y;
    chmax(low, x);
    chmin(high, y);
  }
  cout << max(0, high - low + 1) << endl;
}



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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  map<string, ll> m;
  rep(i, n) {
    string s;
    cin >> s;
    sort(all(s));
    m[s]++;
  }

  ll ans = 0;
  for (auto it = m.begin(); it != m.end(); it++) {
    ans += it->S * (it->S - 1) / 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 11136
#include <stdio.h>
int main (void){
int N;
int a=0;
scanf("%d",&N);
int p[100];
for(int i=0;i<N;i++){
    scanf("%d",&p[i]);
}
for(int i=0;i<N;i++){
    if(p[i]!=i+1){
       a=a+1; 
    }
}
if(a==2||a==0){
    printf("YES");
}else{
    printf("NO");

}
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  string s;cin>>s;
  for(int i = 0; n > i; i++){
    if(i+1 == k)cout << (char)(s[i] - ('A'-'a'));
    else cout << s[i];
   }
    cout << endl;
  }
    

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

    private static void q_1() {
        try (Scanner scan = new Scanner(System.in)) {
            int a = scan.nextInt();
            int b = scan.nextInt();

            System.out.println(b % a == 0 ? b + a : b - a);
        }
    }

    private static void q_2() {
        try (Scanner scan = new Scanner(System.in)) {
            int n = scan.nextInt(); // n人
            int m = scan.nextInt(); // m種類

            Map<Integer, Integer> a = new HashMap<>();
            for(int i=0; i<n; i++) {
                int k = scan.nextInt();
                for(int j=0; j<k; j++) {
                    int am = scan.nextInt();
                    if(a.get(am) == null) {
                        a.put(am, 1);
                    } else {
                        a.put(am, a.get(am) + 1);
                    }
                }
            }

            int cnt = 0;

            for (Integer val : a.values()) {
                if(val == n) {
                    cnt ++;
                }
            }

            System.out.println(cnt);

        }
    }
}


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

int main () {
  int A, B, K;
  cin >> A >> B >> K;
  for (int i = A; i <= min(A+K-1,B); i++) {
    cout << i << endl;
  }
  if (A+K < B-K+1) {
    for (int i = B-K+1; i <= B; i++) {
      cout << i << endl;
    }
  }
  else {
    for (int i = A+K; i <= B; i++) {
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	ll n, a[100001] = {}, b;
	cin >> n;
	REP(i, n+1) cin >> a[i];
	REP(i, n) {
		cin >> b;
		REP(j, 2){
			int kill = min(a[i+j] , b);
			a[i+j] -= kill;
			b -= kill;
			ans += kill;
		}
	}
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
typedef long long ll;

int main() {
    ll Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    ll min_one = min(4 * Q, min(2 * H, S));
    ll min_two = min(2 * min_one, D);
    if (N >= 2 && 2 * min_one > min_two) {
        cout << (N / 2) * min_two + min_one * (N % 2) << endl;
    }
    else {
        cout << N * min_one << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
cake = 4
dont = 7
max_kosuu_cake = N // cake
max_kosuu_dont = N // dont
ans = 'No'
for i in range(max_kosuu_cake+1):
    for j in range(max_kosuu_dont+1):
        if cake * i + dont * j == N:
            ans = 'Yes'
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
  int n;
  char S[100],T[100];
  scanf("%s%s",S,T);
  for(n=0;n<100;n++){
    if(S[n]=='\0'){
      printf("Yes\n");
      break;
    }
    else if(S[n]!=T[n]){
      printf("No\n");
      break;}
  }
  return 0;
}
  

Measured memory_bytes: 1636
#include<bits/stdc++.h>
using namespace std;
int ten[20][20],n;
long long cnt;
int main() 
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		double x;
		cin>>x;
		long long tmp=x*1e9+0.1;
		int two=0,five=0;
		while(!(tmp%2))
		{
			tmp/=2;
			two++;
		}
		while(!(tmp%5))
		{
			tmp/=5;
			five++;
		}
		if(two>18)two=18;
		if(five>18)five=18;
		for(int j=18-two;j<=18;j++)
			for(int k=18-five;k<=18;k++)
				cnt+=ten[j][k];
		ten[two][five]++;
	}
	cout<<cnt;
}

Measured memory_bytes: 3688
// AOJ 0070
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
typedef long long int integer;

const integer NMAX = 20, SMAX = 1000;
integer dp[NMAX][SMAX], factorial[NMAX]; 

void solve() {
  factorial[0] = 1;
  for (int i = 1; i <= 10; i++) {
    factorial[i] = i * factorial[i - 1];
  }

  int nums[10] = {0,1,2,3,4,5,6,7,8,9};
  do {
    integer sum = 0;
    REP(i, 10) {
      sum += nums[i] * (i + 1); 
      dp[i+1][sum]++;
    }
  } while (next_permutation(nums, nums + 10));
}

int main() {
  solve();
  
  int n, s;
  while (cin >> n >> s) {
    cout << dp[n][s] / factorial[10 - n] << endl;
  }
}

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

using namespace std;
int main(){
    int c,t,c1,t1;
    int C,T;
    pair<int,int> mejor;
    vector<pair<int,int>> x;
    cin >> c >> t;
    c1= c;
    t1 = t;
    for(int i = 0; i < c; i++){
        cin >> C >> T;
        x.push_back(make_pair(C,T));
    }
    mejor = x[0];
    for(int i = 0; i < x.size(); i++){
        if(x[i].first <= mejor.first){
            if(x[i].second <= t) mejor = x[i];
        }
        
    }

    if(mejor.second > t) cout << "TLE";
    else cout << mejor.first;
    return 0;
}


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

int main(){
	int N,L;
	cin>>N>>L;
	string S[N];
	string ans;
	for(int i=0;i<N;++i){
		cin>>S[i];
	}
	sort(S,S+N);
	for(int i=0;i<N;++i){
		ans+=S[i];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std; 
int main(){ 
    long long int i,n,c=0; 
    cin>>n;
    for (i=1; i<=n; i++) {  
        if(i%3==0)            
            continue; 
		else if(i%5==0)	
			continue;
		else if(i%15==0)
			continue;
		else
			c=c+i;				                 
    } 
    cout<<c;
    return 0; 
}

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

#############
# Libraries #
#############
import random
import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

D = int(input().strip())
C = list(map(int,input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

ans = 0
score = 0
last = [[-1] for i in range(26)]
schedule = []

for d in range(D):
  t = random.choice(range(26))
  last[t].append(d)
  score += S[d][t]
  schedule.append(t)

for i in range(26):
  last[i].append(D)
  for k in range(len(last[i])-1):
    g = last[i][k+1]-last[i][k]-1
    score -= C[i]*g*(g+1)//2

count = 2000000

while count:
  count -= 1
  prev = score
  d,q = random.choice(range(D)),random.choice(range(26))
  p = schedule[d]
  schedule[d] = q
  score -= S[d][p]
  score += S[d][q]
  
  pos = last[p].index(d)
  score -= C[p]*(last[p][pos]-last[p][pos-1])*(last[p][pos+1]-last[p][pos])
  last[p].remove(d)
  
  pos = bisect.bisect(last[q],d)
  score += C[q]*(d-last[q][pos-1])*(last[q][pos]-d)
  bisect.insort(last[q],d)
  if score<prev:
    score = prev
    bisect.insort(last[p],d)
    last[q].remove(d)
    schedule[d] = p
    
for i in schedule:
  print(i+1)


Measured memory_bytes: 84252
package main
 
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "sort"
)
 
var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n, _ = strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

type Node struct {
  Value int
  Index int
}
type Nodes []Node
func(N Nodes) Len() int { return len(N) }
func(N Nodes) Less(i, j int) bool { return N[i].Value < N[j].Value }
func(N Nodes) Swap(i, j int) { N[i], N[j] = N[j], N[i] }

func main() {
  N := NextInt()
  E := make([][]int, N)
  for i := range E {
    E[i] = make([]int, 0)
  }
  for i := 0; i < N - 1; i++ {
    AB := NextIntVec()
    E[AB[0] - 1] = append(E[AB[0] - 1], AB[1] - 1)
    E[AB[1] - 1] = append(E[AB[1] - 1], AB[0] - 1)
  }
  K := NextInt()
  V := make([][]int, N)
  for i := range V {
    V[i] = []int{-1, -1}
  }
  T := make([]Node, 0)
  for i := 0; i < K; i++ {
    VP := NextIntVec()
    V[VP[0] - 1] = []int{VP[1], VP[1]}
    T = append(T, Node{VP[1], VP[0] - 1})
  }
  sort.Sort(sort.Reverse(Nodes(T)))
  D := make([]int, N)
  Q := make([]int, N)
  Q[0] = T[0].Index
  D[Q[0]] = 1
  pos := 1
  ans := "Yes"
  for i := 0; i < N; i++ {
    q := Q[i]
    for _, adj := range E[q] {
      if D[adj] > 0 { continue }
      D[adj] = D[q] + 1
      Q[pos] = adj
      pos++
      if V[adj][0] < 0 {
        V[adj][0] = V[q][0] + 1
        V[adj][1] = V[q][1] - 1
        continue
      }
      if V[q][0] + 1 < V[adj][1] {
        ans = "No"
        break
      }
      if V[adj][0] < V[q][1] - 1 {
        ans = "No"
        break
      }
      if D[adj] % 2 == (V[Q[0]][0] - V[adj][0]) % 2 {
        ans = "No"
        break
      }
    }
  }
  if ans == "Yes" {
    for i := N - 1; i > -1; i-- {
      q := Q[i]
      for _, adj := range E[q] {
        if D[q] < D[adj] { continue }
        if V[q][0] + 1 < V[adj][1] {
          ans = "No"
          break
        }
        if V[adj][0] < V[q][1] - 1 {
          ans = "No"
          break
        }
        if V[q][0] + 1 < V[adj][0] {
          V[adj][0] = V[q][0] + 1
        }
        if V[adj][1] < V[q][1] - 1 {
          V[adj][1] = V[q][1] - 1
        }
      }
    }
    for i := 0; i < N; i++ {
      q := Q[i]
      for _, adj := range E[q] {
        if D[adj] < D[q] { continue }
        if V[q][0] + 1 < V[adj][0] {
          V[adj][0] = V[q][0] + 1
        }
        if V[adj][1] < V[q][1] - 1 {
          V[adj][1] = V[q][1] - 1
        }
      }
    }
  }
  Write(ans)
  if ans == "Yes" {
    for _, v := range V {
      Write(v[0])
    }
  }
  Output()
}

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

#define INF 1e9

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

    string st;
    int x;
    cin >> x;

    st = to_string(x);

    for (int i = 0; i < st.length(); i++){
        if (st[i] == '1') cout << '9';
        else cout << '1';
    }

    return 0;
}



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

int main(void){
    int n;
    cin>>n;
    vector<ll> v(n);
    rep(i, n) cin>>v[i];
    ll r=accumulate(v.begin(), v.end(), 0LL)-v[0];
    ll l=v[0];
    ll ans=abs(l-r);
    rep(i, n-2){
        l+=v[i+1];
        r-=v[i+1];
        ans=min(ans, abs(l-r));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e6+20;
const ll mod=1e9+7;
int n,k,d[N];
bool check(int x)
{
	while(x)
	{
		int r=x%10;
		if(d[r])
			return false;
		x/=10;
	}
	return true;
}
int main()
{
	while(cin>>n>>k)
	{
		int x;
		memset(d,0,sizeof(d));
		for(int i=1;i<=k;i++)
			cin>>x,d[x]=1;
		for(int i=n;;i++)
		{
			if(check(i))
			{
				cout<<i<<endl;
				break;
			}	
		}
	}
	return 0;
}

Measured memory_bytes: 8064
#include<iostream>
using namespace std;
int M,N;
int A[1<<17];
main()
{
	cin>>M>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	if(M==2)
	{
		int a1=0,a2=0;
		for(int i=0;i<N;i++)
		{
			if(A[i]==i%2+1)a1++;
			else a2++;
		}
		cout<<(a1<a2?a1:a2)<<endl;
		return 0;
	}
	int cnt=0;
	for(int i=1;i<N;i++)
	{
		if(A[i-1]==A[i])
		{
			A[i]=-1;
			cnt++;
		}
	}
	cout<<cnt<<endl;
}



Measured memory_bytes: 3504
def main():
    n, m, k = map(int, input().split())
    mod = 998244353
    comb = 1
    c = 0
    for i in range(k + 1):
        if i > 0:
            comb = comb * (n - i) * pow(i, mod - 2, mod) % mod
        c = (c + m * comb * pow(m - 1, n - 1 - i, mod)) % mod
    print(c)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9196
n=int(input())

def make_divisors(n):
    divisors = [0,0]
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors[0]=(i)
            divisors[1]=(n//i)
    return divisors

a=make_divisors(n)
print(a[0]+a[1]-2)


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

/*  */
int main() {
    int N;
    cin >> N;
    int h[N];
    rep(i, N) cin >> h[i];

    int maxHeight = 0;
    rep(i, N) {
        if(maxHeight < h[i]){
            maxHeight = h[i];
        }
    }

    int count = 0;
    int left, right;
    rep(nowHeight, maxHeight){

        left = -1;
        rep(j, N){
            if(h[j] > nowHeight && left == -1){
                left = j;
            }

            if(h[j] <= nowHeight && left != -1){
                right = j-1;
                count++;
                left = -1;
            }
            else if(j == N-1 && left != -1){
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}
#define N 2000004
ll fact[N] = {};

void init() {
	fact[0] = fact[1] = 1;
	for(ll i = 2; i < N; i++) {
		fact[i] = (fact[i-1]*i)%mod;
	}
}

ll calc(ll n,ll r){
	ll ans = fact[n];
	ll den = inv(fact[r]);
	den = (inv(fact[n-r])*den)%mod;
	ans = (ans * den)%mod;
	return ans;
}

int main() {
	int k;
	string s;
	cin >> k;
	cin >> s;
	int n = size(s);
	init();
	
	ll ans = 0;

	for(int i = 0; i <= k; i++) {
		ll curr = power_mod(26ll,i);
		curr = (curr * power_mod(25,k-i))%mod;
		curr = (curr * calc(k-i+n-1,n-1))%mod;
		ans = (ans + curr)%mod;	
	}

	cout << ans << endl;
}

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

using namespace std;
typedef unsigned long long ull;

int Happiness(ull yen){
	ull coin500, coin5, left;
	coin500 = yen / 500;
	left = yen - coin500 * 500;
	coin5 = left / 5;
	return coin500 * 1000 + coin5 * 5;
}

int main(void){
	ull yen, happy;

	cin >> yen;

	happy = Happiness(yen);

	cout << happy << endl;

	return 0;
}


Measured memory_bytes: 256
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n,c = readline() |> split |> parseMap
	a = Array{Int}(3,n)
	for i in 1:n
		a[:,i] = readline() |> split |> parseMap
	end
	b = Array{Int}(3,2*n)
	now = 1
	for i in 1:n
		b[1,now] = a[1,i]
		b[2,now] = a[3,i]
		b[3,now] = 0
		now += 1
		b[1,now] = a[2,i]
		b[2,now] = a[3,i]
		b[3,now] = 1
		now += 1
	end
	b = sortcols(b,by=x->(x[1],x[3]))
	count = 0
	k = zeros(Int,c)
	flg = zeros(Int,c)
	for i in 1:2*n
		if b[3,i] == 0
			k[b[2,i]] = 1
			flg[b[2,i]] = b[1,i]
			count = max(count,sum(k))
		elseif b[1,i] != flg[b[2,i]]
			k[b[2,i]] = 0
		end
	end
	println(count)
end
main()


Measured memory_bytes: 167456
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
candy = 0
for col in range(N):
    candy_tmp = sum(A1[0:col+1]) + sum(A2[col:N+1])
    candy = max(candy, candy_tmp)
print(candy)


Measured memory_bytes: 38512
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

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

	vector<vector<int>> s(m);
	for (int i = 0; i < m; i++) {
		int k;
		cin >> k;
		s[i].resize(k);

		for (auto &v : s[i]) {
			cin >> v;
			v--;
		}
	}

	vector<int> p(m);
	for (auto &v : p) {
		cin >> v;
	}

	int ans = 0;
	for (int bit = 0; bit < (1 << n); bit++) {
		bool isLight = true;
		for (int i = 0; i < m; i++) {
			int score = 0;
			for (auto v : s[i]) {
				if (bit & (1 << v)) {
					score++;
				}
			}

			score %= 2;
			if (score != p[i]) {
				isLight = false;
				break;
			}
		}

		if (isLight) {
			ans++;
		}
	}

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


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int x,y,ans=0;cin>>x>>y;
    if(x==1)ans+=300000;
    if(y==1)ans+=300000;
    if(x==2)ans+=200000;
    if(y==2)ans+=200000;
    if(x==3)ans+=100000;
    if(y==3)ans+=100000;
    if(x==1&&y==1)ans+=400000;
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int a =700;
    
    if(s.equals("ooo")){
      a = 1000;
    }else if(s.equals("oxo")||s.equals("oox")||s.equals("xoo")) {
      a = 900;
    } else if(s.equals("oxx")||s.equals("xxo")||s.equals("xox")){
      a = 800;
    }
    System.out.println(a);
  }
}

Measured memory_bytes: 35652
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;

int main(){
	int n;
    cin>>n;
    int cnt=0;
    bool flag=true;
    for(int i=11;i<=55555;i+=5){
        flag=true;
        for(int j=2;j<=i-1;j++){
            if(i%j==0){
                flag=false;
                break;
            }
        }
        if(flag){
            cnt++;
            OUT(i);
        }
        if(cnt>=n){
            break;
        }
    }
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int n;
vector<pii> line;
//place最後に使った対象,used使用済み
int func(int place,int used,int bp){
	if(used==bit(n)-1){
		return 0;
	}
	static vvector<int> dp(n,vector<int>(bit(n),-1));
	if(dp[place][used]>=0)return dp[place][used];
	int res = INF;
	vector<pii> nows;
	vector<int> bcnt(n+1,0);
	vector<int> fcnt(n,0);
	per(i,n){
		bcnt[i] = bcnt[i+1];
		if(bit(i)&used){
			++bcnt[i];
		}
	}
	rep(i,n){
		if(i){
			fcnt[i]=fcnt[i-1];
		}
		if(~used&bit(i)){
			++fcnt[i];
		}
	}
	for(int i=n-1;i>=0;--i){
		if(used&bit(i))continue;
		if((fcnt[i]+bcnt[i])&1){
			nows.emplace_back(line[i].first,i);
		}else{
			nows.emplace_back(line[i].second,i);
		}
	}
	rep(i,nows.size()){
		if(bp>nows[i].first)continue;
		chmin(res,nows.size()-i-1+func(nows[i].second,used|bit(nows[i].second),nows[i].first));
	}
	return dp[place][used] = res;
}

int main(){
	cin >> n;
	line.resize(n);
	foreach(i,line){
		cin >> i.first;
	}
	foreach(i,line){
		cin >> i.second;
	}
	int ans = func(0,0,-1);
	if(ans==INF){
		cout << -1 << endl;
	}else{
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 19712
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> a(N);
    REP(i, N) { cin >> a[i]; }
    //[left, right)
    vector<ll> ruisekiwa(N + 1, 0);
    for(int i = 1; i < N + 1; i++) {
        ruisekiwa[i] = ruisekiwa[i - 1] + a[i - 1];
    }
    vector<ll> v;
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N + 1; j++) {
            v.push_back(ruisekiwa[j] - ruisekiwa[i]);
        }
    }
    int n = v.size();
    vector<int> ok(n, 1);
    ll ans = 0;
    for(int d = 60; d >= 0; d--) {
        ll msk = 1LL << d;
        int cnt = 0;
        REP(i, n) {
            if(v[i] & msk and ok[i]) {
                cnt++;
            }
        }
        // cntが十分多い
        if(K <= cnt) {
            ans += msk;
            REP(i, n) {
                if(!(v[i] & msk) and ok[i]) {
                    // selectしない
                    ok[i] = 0;
                }
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main(int argc, char *argv[])
{
    
    
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int n,m;
    while (cin >> n >> m, n||m) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3164
#include <stdio.h>

int main() {
  int line, store1, store2;
  scanf("%d %d %d", &line, &store1, &store2);
  int distA = (line > store1) ? line - store1 : store1 - line;
  int distB = (line > store2) ? line - store2 : store2 - line;
  (distA < distB) ? puts("A") : puts("B");
  return 0;
}

Measured memory_bytes: 1648
import Control.Monad
import Data.List

solve :: [[Int]] -> Int -> Int -> Int
solve ([a, b]:xs) m sum 
  | m <= 0 = sum
  | m <= b = solve xs 0 (sum + m*a)
  | otherwise = solve xs (m - b) (sum + a * b)
solve [] 0 sum = sum
solve [] _ _ = error "hoge"


main = do
  [n, m] <- (map read) . words <$> getLine
  input  <- (replicateM n ((map read . words) <$> getLine) :: IO [[Int]])
  let 
    input' = sort input
  putStrLn $ show $ solve input' m 0 




Measured memory_bytes: 145788
N=int(input())
a=list(map(int,input().split()))
res=0
count=[0]*(10**5+2)
for i in range(N) :
  count[a[i]]+=1
for i in range(10**5) :
  x=count[i]+count[i+1]+count[i-1]
  res=max(res,x)
print(res)

Measured memory_bytes: 20832
#include <iostream>

using namespace std;

int main()
{
	int n;
	int R[200000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> R[i];
	}
	int minv = R[0];
	int maxv = R[1] - R[0];
	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	cout << maxv << endl;
	return 0;
}


Measured memory_bytes: 3848
import java.util.Scanner;

public class Main {
	static double dis[][];
	static double sum=0;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d[][] = new int[2][n];
		dis = new double[n][n];
		String s="";
		int p = 1;

		for(int i = 0; i < n; i++) {
			d[0][i] = sc.nextInt();
			d[1][i] = sc.nextInt();
			s = s + i;
			p *= i+1;
		}

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

				dis[i][j] = Math.sqrt(Math.pow(d[0][i] - d[0][j],2) +  Math.pow(d[1][i] - d[1][j], 2));

			}
		}

		permutation(s, "");

        System.out.println(sum/p);

        return;
    }

	public static void permutation(String q, String ans){
        // Base Case
        if(q.length() <= 1) {
        	String end = ans + q;
            for(int j = 0; j < end.length()-1; j++) {
            	sum += dis[end.charAt(j) - '0'][end.charAt(j+1) - '0'];
            }
        } else {
            for (int i = 0; i < q.length(); i++) {
                permutation(q.substring(0, i) + q.substring(i + 1),
                        ans + q.charAt(i));
            }
        }
    }
}



Measured memory_bytes: 43628
import math
s = list(input())
ans = [0] * len(s)
r = 1
l = 1
for i in range(len(s)-1):
  if s[i] == "R":
    if s[i+1] == "R":
      r += 1
    if s[i+1] == "L":
      ans[i] += math.ceil(r/2)
      ans[i+1] += math.floor(r/2)
      index = i
      r = 1
  if s[i] == "L":
    if s[i+1] == "R":
      ans[index] += math.floor(l/2)
      ans[index + 1] += math.ceil(l/2)
      l = 1
    if s[i+1] == "L":
      l += 1
ans[index] += math.floor(l/2)
ans[index + 1] += math.ceil(l/2)
for i in range(len(ans)-1):
  print(str(ans[i]) + " ", end="")
print(ans[-1])

Measured memory_bytes: 5680
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();
        if ((a < b) && (b < c)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}


Measured memory_bytes: 26248