akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
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);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/


int solve(int n, vector<vector<int> >& graph,int s,int t) {

	auto dist = make_v<int>(n, 3);
	fill_v(dist, -1);

	dist[s][0] = 0;

	queue<pii> que;//頂点，状態

	que.push(pii(s, 0));


	while (!que.empty()) {

		pii now = que.front();
		que.pop();
		int v = now.first;
		int flag = now.second;

		for (auto itr : graph[v]) {

			int next = (flag + 1) % 3;

			if (dist[itr][next] == -1) {
				dist[itr][next] = dist[v][flag] + 1;
				que.push(pii(itr, next));
			}
		}
	}

	if (dist[t][0] == -1) {
		return -1;
	}
	else
	{
		return dist[t][0] / 3;
	}
}


int main() {



	int n, m, s, t;
	cin >> n >> m;
	vector<vector<int> > graph(n + 10);
	
	for (int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		graph[u].push_back(v);
	}

	cin >> s >> t;
	s--;
	t--;

	cout << solve(n, graph, s, t) << endl;
	

	return 0;
}


Measured memory_bytes: 11136
#include<cstdio>
using namespace std;

int main() {
    int A, B, X;
    scanf("%d%d%d", &A, &B, &X);
    if(A <= X && X <= A+B) {
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
flag = "APPROVED"
for aa in a:
#     print(aa, flag)
    if aa%2 == 0:
        if aa%3 != 0:
            if aa%5 != 0:
                flag = "DENIED"
#                 print("a")
                break            
            
print(flag)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define erorp(x) cout<<#x<<"={"<<(x.F)<<" , "<<x.S<<"}"<<endl;
#define print(v,r) f(i,0,r) cout<<v[i]<<" "; cout<<endl;
#define is_bit(x,y) (x%(1<<(y+1))>=(1<<y))
#define eror(x) cout<<#x<<'='<<(x)<<endl;
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define Gett(x,y) scanf("%d%d",&x,&y);
#define f(i,a,b) for(int i=a;i<b;i++)
#define get(x) scanf("%I64d",&x);
#define All(x) x.begin(),x.end()
#define gett(x) scanf("%d",&x);
#define Add(x,y) x=(x+y)%p
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first

const int N=1e5+9;

int n,u,v,ans,mark[N],sub[N];
vector<int> g[N];

void dfs(int x,int par){
    sub[x]=1;
    f(i,0,g[x].size())
        if(g[x][i]!=par)
            dfs(g[x][i],x),sub[x]+=sub[g[x][i]];
    if(sub[x]&1) mark[x]++,mark[par]++;
}

int main(){
    cin>>n;
    f(i,1,n){
        Gett(u,v);
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(1,0);
    ans=1;
    if(n&1) ans=0;
    f(i,1,n+1)
        if(mark[i]!=1)
            ans=0;
    if(ans) cout<<"Second";
    else cout<<"First";
}

Measured memory_bytes: 10128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int> > Matrix;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    vector<int> sa(n-1);
    rep(i, n-1){
        sa[i] = h[i] - h[i+1];
    }

    int count = 0;
    int ans = 0;
    rep(i, n-1){
        if (sa[i] >= 0){
            count++;
        } else{
            ans = max(count, ans);
            count = 0;
        }
    }
    ans = max(ans, count);

    cout << ans << endl;
}

Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10 ** 8)

N, M = map(int, input().split())
graph = [dict() for _ in range(N)]

for i in range(M):
    x, y = map(int, input().split())
    graph[y - 1][x - 1] = 1

dp = [0 for _ in range(N)]


def dfs(u):
    if dp[u] != 0 or len(graph[u]) == 0:
        return dp[u]
    max_dis = 0
    for f in graph[u].keys():
        if max_dis < dfs(f) + 1:
            max_dis = dfs(f) + 1

    dp[u] = max_dis
    return dp[u]


for i in range(N):
    dfs(i)
print(max(dp))


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

int main(void){
    string s,t;
    cin >> s >> t;
    int count = 0;
    rep(i,3){
        if(s[i]==t[i]){
             count++;
        }
        
    }

    cout << count << endl;
}

Measured memory_bytes: 256
while True:
    H,W=map(int,input().split())
    if H==0 and W==0 :
        break
    for i in range(H) :
        for j in range(W) :
            if  i==0 or i==H-1 or j==0 or j == W-1 :
                print ("#",end="")
            else:
                print(".",end="")
        print()
    print()
    
    


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

#define ll long long
#define inf 0x3f3f3f3f 
#define il inline 

#define in1(a) a=read()
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)
#define out(a) printf( "%d" , a ) 
#define outn(a) out(a),putchar('\n')

#define I_int int 
inline I_int read() {

    I_int x = 0 , f = 1 ; char c = getchar() ;
    while( c < '0' || c > '9' ) {
        if( c == '-' ) f = -1 ;
        c = getchar() ;
    }
    while( c >= '0' && c <= '9' ) {
        x = (x << 1) + (x << 3) + c - 48 ;
        c = getchar() ;
    }
    return x * f ;
}
#undef I_int

using namespace std ;

#define N 100010

int n , m ;
int cnt[ N ] ;
struct node {
	int year , p , id ;
} a[ N ] ;

int ans[ N ][ 20 ] ;

bool cmp( node a , node b ) {
	return a.year < b.year ;
}

int main() {
	in1( n ) , in1( m ) ;
	for( int i = 1 ; i <= m ; i ++ ) {
		in1( a[ i ].p ) , in1( a[ i ].year ) ;
		a[ i ].id = i ;
	}
	sort( a + 1 , a + m + 1 , cmp ) ;
	for( int i = 1 ; i <= m ; i ++ ) {
		cnt[ a[ i ].p ] ++ ;
		int t[ 10 ] , t1[ 10 ] ;
		memset( t , 0 , sizeof( t ) ) ;
		memset( t1 , 0 , sizeof( t1 ) ) ; 
		int x = a[ i ].p , y = cnt[ a[ i ].p ] ;
		int l = 0 , l1 = 0 ;
		while( x ) { t[ ++ l ] = x % 10 ; x /= 10 ; }
		while( y ) { t1[ ++ l1 ] = y % 10 ; y /= 10 ; }
		int tot = 0 ;
		for( int j = 6 ; j ; j -- ) {
			ans[ a[ i ].id ][ ++ tot ] = t[ j ] ;
		}
		for( int j = 6 ; j ; j -- ) {
			ans[ a[ i ].id ][ ++ tot ] = t1[ j ] ;
		}
	}
	for( int i = 1 ; i <= m ; i ++ ) {
		for( int j = 1 ; j <= 12 ; j ++ ) printf( "%d" , ans[ i ][ j ] ) ;
		puts("");
	}
}

Measured memory_bytes: 10880
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  string s, t;
  cin >> s >> t;
  lli m = sz(s) + 2;
  fore (i,0,sz(s) - sz(t) + 1){
      lli c = 0;
      fore (j,i,i + sz(t)){
        if (t[j - i] != s[j]){
          c++;
        }
      }
      if (c < m){
        m = c;
      }
  }
  cout << m << ENDL;
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s,ans;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if (s.at(0)==s.at(1) && s.at(2) == s.at(3) && s.at(1) != s.at(2)) {
            ans = "Yes";
        }
        else if (s.at(0)==s.at(2) && s.at(1) == s.at(3) && s.at(0) != s.at(1)) {
            ans = "Yes";
        }
        else if (s.at(0)==s.at(3) && s.at(1) == s.at(2) && s.at(0) != s.at(1)) {
            ans = "Yes";
        }
        else
        {
            ans =  "No";
        }
                
            
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

// Manages Weighted Union-Find Forest.
class WeightedUnionFindForest {
  std::vector<int> parent_;
  std::vector<int> rank_;
  std::vector<int> size_;
  std::vector<int> weight_;

 public:
  // Initialize forest.
  // parent_[i]=i, rank_[i]=0, size_[i]=1, weight_[i]=0.
  WeightedUnionFindForest(const int n);
  // Get the number of the root of the node q.
  int Root(const int q);
  // Return true if the roots of x and y is same.
  bool IsSame(const int x, const int y);
  // Unite the tree x and tree y(weight is w).
  // If x and y already have been united, return false.
  // Weight(y)-Weight(x)=w
  bool Unite(int x, int y, int w);
  // Get the number of nodes which are the same group as node q.
  int Size(const int q);
  // Get the weight of node q.
  int Weight(const int q);
  // Get the weights' difference of node x and y(Weight(y)-Weight(x)).
  int Diff(const int x, const int y);
};

WeightedUnionFindForest::WeightedUnionFindForest(const int n) {
  parent_.resize(n);
  rank_.resize(n);
  size_.resize(n);
  weight_.resize(n);
  for (int i = 0; i < n; i++) {
    parent_[i] = i;
    rank_[i]   = 0;
    size_[i]   = 1;
    weight_[i] = 0;
  }
}
int WeightedUnionFindForest::Size(const int q) {
  return size_[Root(q)];
}
int WeightedUnionFindForest::Root(const int q) {
  if (parent_[q] == q) {
    return q;
  } else {
    const int r = Root(parent_[q]);
    weight_[q] += weight_[parent_[q]];
    return parent_[q] = r;
  }
}

bool WeightedUnionFindForest::IsSame(const int x, const int y) {
  return Root(x) == Root(y);
}

int WeightedUnionFindForest::Weight(const int q) {
  Root(q);  // compress path
  return weight_[q];
}
int WeightedUnionFindForest::Diff(const int x, const int y) {
  if (Root(x) != Root(y)) {
    cerr << "WeightedUnionFindForest: Error" << endl;
    cerr << "Roots of node x and y aren't same" << endl;
    return INT32_MAX;
  }
  return Weight(y) - Weight(x);
}

bool WeightedUnionFindForest::Unite(int x, int y, int w) {
  w += Weight(x);
  w -= Weight(y);
  x = Root(x);
  y = Root(y);

  if (x == y) return false;
  if (rank_[x] < rank_[y]) {
    weight_[x] = w * (-1);
    parent_[x] = y;
    size_[y] += size_[x];
    size_[x] = 0;

  } else {
    weight_[y] = w;
    parent_[y] = x;
    size_[x] += size_[y];
    size_[y] = 0;
    if (rank_[x] == rank_[y]) rank_[x]++;
  }
  return true;
}


int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;

  WeightedUnionFindForest WUFF(n + 1);
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    if (WUFF.IsSame(l, r)) {
      if (WUFF.Diff(l, r) == d) {
        // no conflict
      } else {
        // conflict
        cout << "No" << endl;
        exit(0);
      }
    } else {
      WUFF.Unite(l, r, d);
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1920
import numpy as np
card = np.array([list(map(int,input().split())),\
                 list(map(int,input().split())),\
                 list(map(int,input().split()))])
N = int(input())
for i in range(N):
  card[card == int(input())] = 0
print('No' if str(np.all(card == 0, axis = 0)) == '[False False False]' and\
              str(np.all(card == 0, axis = 1)) == '[False False False]' and\
              sum(np.diag(card)) != 0 and\
			  sum(np.choose([2, 1, 0], card)) != 0 else 'Yes')

Measured memory_bytes: 12500
def answer(arr)
  min, max = 2, 2
  arr.reverse_each do |a|
    return -1 if max % a != 0 && max / a * a < min
    new_min = (min % a == 0) ? min : (min / a + 1) * a
    min, max = if new_min + a > max
                 [new_min, new_min + a - 1]
               else
                 [new_min, max / a * a + a - 1]
               end
  end
  return "#{min} #{max}"
end

_ = gets
a = gets.split.map(&:to_i)
puts answer(a)


Measured memory_bytes: 13188
(let ((s (read-line)))
  (princ (if (and (char= (char s 0) #\A)
                  (= (count #\C s :start 2 :end (1- (length s)) :test #'char=) 1)
                  (string= (remove-if #'lower-case-p (remove #\C (subseq s 1) :test #'char= :count 1)) ""))
             "AC"
             "WA")))

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

using namespace std;
typedef long long ll;

const int M = 1e9 + 7;

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    vector<ll> pos, neg;
    ll zer = 0, a;
    for (int i = 0; i < n; i++) {
        scanf("%lld", &a);
        if (a > 0) pos.push_back(a);
        else if (a < 0) neg.push_back(-a);
        else zer++;
    }
    if ((neg.size() / 2) * 2 + pos.size() >= k && (k % 2 == 0 || pos.size())) {
        // positive
        ll ans = 1;
        sort(pos.begin(), pos.end(), greater<>());
        sort(neg.begin(), neg.end(), greater<>());
        int pi = 0, ni = 0, cnt = 0;
        while (cnt < k) {
            bool tneg = (k - cnt >= 2) && (ni + 1 < neg.size());
            if (tneg && pi + 1 < pos.size()) {
                tneg = (pos[pi] * pos[pi + 1]) <= (neg[ni] * neg[ni + 1]);
            }
            if (tneg) {
                ans = ans * neg[ni] % M;
                ans = ans * neg[ni + 1] % M;
                ni += 2, cnt += 2;
            } else {
                ans = ans * pos[pi] % M;
                pi++, cnt++;
            }
        }
        cout << ans << "\n";
    } else if (zer) {
        // zero
        printf("0\n");
    } else {
        // negative, either all negative or k == n
        ll ans = 1;
        if (k == n) {
            for (auto e : pos) ans = ans * e % M;
            for (auto e : neg) ans = ans * e % M;
        } else {
            sort(neg.begin(), neg.end());
            for (int i = 0; i < k; i++) ans = ans * neg[i] % M;
        }
        ans = (M - ans) % M;
        cout << ans << "\n";
    }
}


Measured memory_bytes: 5636
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <map>
#include <cmath>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#include <unordered_map>
#include <vector>
#include <cmath>

class Factoriser
{
    std::vector<int> factors;

public:
    using map_type = std::unordered_map<int, int>;
    
    Factoriser(int N)
    {
        factors.resize(N+1, 0);
        int sqrN = static_cast<int>(std::sqrt(N));

        for (int i = 2; i <= sqrN; ++i)
        {
            if (factors[i] == 0)
            {
                for (int j = i * 2; j <= N; j += i)
                {
                    if (factors[j] == 0)
                    {
                        factors[j] = i;
                    }
                }
            }
        }
    }

    map_type Factorise(int M) const
    {
        map_type P;
        int mm = M;

        while (factors[mm])
        {
            ++P[factors[mm]];
            mm /= factors[mm];
        }

        if (mm >= 2) ++P[mm];
        return P;
    }
    
    bool IsPrime(int M) const
    {
        return factors[M] == 0;
    }
};

template<template <class ...> class MapT, class IntT>
MapT<IntT, int> factorise(IntT M)
{
    MapT<IntT, int> P;
    IntT mm = M;

    IntT sqrM = static_cast<IntT>(std::sqrt(M));
    IntT i = 2;
    while (i <= sqrM)
    {
        if (mm % i == 0)
        {
            ++P[i];
            mm /= i;
        }
        else
        {
            ++i;
        }
    }

    if (mm >= 2) ++P[mm];
    return P;
}

template<class IntT>
std::unordered_map<IntT, int> factorise_umap(IntT M)
{
    return factorise<std::unordered_map, IntT>(M);
}


///////////////////////////////////////////////////

bool contains_dfs(const vi &kusi, int a, int cur, Factoriser::map_type::const_iterator it, Factoriser::map_type::const_iterator last)
{
    if (cur == a) return false;
    if (it == last)  return kusi[cur] > 0;

    auto [p, m] = *it++;
    for (int i = 0; i <= m; ++i)
    {
        bool r = contains_dfs(kusi, a, cur, it, last);
        if (r) return true;
        cur *= p;
    }
    return false;
}

bool contains(const vi &kusi, int a, const Factoriser &fac)
{
    auto plist = fac.Factorise(a);
    return contains_dfs(kusi, a, 1, plist.begin(), plist.end());
}

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

    constexpr int MAX_A = 1000000;
    vi kusi(MAX_A+1, 0);
    for (auto [a, i] : A)
        kusi[a] = i;
        
    Factoriser fac(MAX_A);

    int ans = 0;
    if (kusi[1] > 1)
    {
        ans = 0;
    }
    else if (kusi[1] == 1)
    {
        ans = 1;
    }
    else
    {
        for (auto [a, i] : A)
        {
            if (i == 1 && !contains(kusi, a, fac)) ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 20412
#include<bits/stdc++.h>
using namespace std;
int main(){
	int w,h,n,x[105],y[105],a[105];
	int s1=0,s2,s3=0,s4;
	cin>>w>>h>>n;
	s2=w;
	s4=h; 
	for(int i=1;i<=n;i++)
	{
		cin>>x[i]>>y[i]>>a[i];
		if(a[i]==1&&s1<x[i])
		{
			s1=x[i];
		}
		if(a[i]==2&&s2>x[i])
		{
			s2=x[i];
		}
		if(a[i]==3&&s3<y[i]) 
		{
		    s3=y[i];
		}
		if(a[i]==4&&s4>y[i])
		{
			s4=y[i];
	    }
	}
	w=s2;
	w=w-s1;
	h=s4;
	h=h-s3;
	if(w<=0||h<=0) cout<<0;
	else cout<<w*h; 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
 int main(){
int x1 , x2 , x3 , x4 , x5 ;
cin>>x1>>x2>>x3>>x4>>x5;
if(x1 == 0)
{
    cout<<'1'<<endl;
}
else if(x2 == 0)
{
    cout<<'2'<<endl;
}
else if(x3 == 0)
{
    cout<<'3'<<endl;
}
else if(x4 == 0)
{
    cout<<'4'<<endl;
}
else if(x5 == 0)
{
    cout<<'5'<<endl;
}
 return 0;}


Measured memory_bytes: 3476
N = int(input()) 
A = [] 
import itertools
import math
for i in range(N): 
    A.append(list(map(int, input().split()))) 
B = 0 
C = 0
for i in itertools.permutations(range(N)):
    B +=1
    a0 = A[i[0]]
    for j in range(N-1):
        a1 = A[i[j+1]]
        r = (a1[1]-a0[1])**2+(a1[0]-a0[0])**2
        C += math.sqrt(r)
        a0 = a1
print ( C / B )       

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

using namespace std;

string s;
int n;

int wst[300002];
int wdr[300002];
int est[300002];
int edr[300002];

int main()
{
    cin >> n;
    cin >> s;

    int i;
    for(i = 1; i <= n; i ++)
        wst[i] = wst[i - 1] + (s[i - 1] == 'W');

    for(i = 1; i <= n; i ++)
        est[i] = est[i - 1] + (s[i - 1] == 'E');

    for(i = n; i >= 1; i --)
        edr[i] = edr[i + 1] + (s[i - 1] == 'E');

    for(i = n; i >= 1; i --)
        wdr[i] = wdr[i + 1] + (s[i - 1] == 'W');

    int rez = n + 1;
    for(i = 1; i <= n; i ++)
    {
        rez = min(rez, wst[i - 1] + edr[i + 1]);
    }

    cout << rez << "\n";

    return 0;
}


Measured memory_bytes: 5380
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(void){
    string S, T;
    cin >> S >> T;
    if(S.length() + 1 == T.length()){
        for(int i = 0; i < S.length(); i++){
            if(S[i] != T[i]) break;
            if(i == S.length() - 1){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAXN 100000
int n,x;
int A,G;
int gcd(int m,int n)
{
    while(m>0)
    {int c=n%m;n=m,m=c;}
    return n;
}
int main()
{
    scanf("%d%d",&n,&x);
    scanf("%d",&A);
    G=abs(x-A);
    for(int i=2;i<=n;i++){scanf("%d",&A);G=gcd(G,abs(x-A));}
    printf("%d",G);
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

bool isYYMM(string s){
    if(s.substr(2)=="00") return false;
    return s.substr(2)<="12";
}

bool isMMYY(string s){
    if(s.substr(0,2)=="00") return false;
    return s.substr(0,2)<="12";
}

void solve() {
    //const i64 mod = 1'000'000'007;
    const string amb="AMBIGUOUS",na="NA";

    string S;
    cin >> S;

    if(isYYMM(S) and isMMYY(S)){
        cout << amb << endl;
        return;
    }

    if(isYYMM(S)){
        cout << "YYMM" << endl;
        return;
    }

    if(isMMYY(S)){
        cout << "MMYY" << endl;
        return;
    }

    cout << na << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
r,c = map(int, input().split())
a=[]
sum1=[]
for i in range(r):
    a.append(list(map(int, input().split())))

for i in range(r):
    sum=0
    for j in range(c):
        print(a[i][j],end=' ')
        sum+=a[i][j]
        if i==0:
            sum1.append(a[i][j])
        else:
            sum1[j]+=a[i][j]
        if j==c-1:
            print(sum)
            if i==0:
                sum1.append(sum)
            else:
                sum1[c]+=sum
for i in range(c+1):
    if i!=c:
        print(sum1[i],end=' ')
    else:
        print(sum1[i])


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

using namespace std;

#define ll long long
#define lop(b) for(int i = 1; i <= b; i++)

const int N = 1e5+4, K = 1e2+2;
const ll inf = 1e16;
int h[N], n, k;
ll dp[K][N];

ll f(int j, int t)
{
    if(j > n)
        return inf;

    if(dp[t][j] != -1)
        return dp[t][j];

    ll ans = inf;

    lop(k) ans = min(ans, f(j + i, i));

    if(ans == inf)
        ans = 0;

    return dp[t][j] = abs(h[j] - h[j - t]) + ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> k;

    lop(n)
        cin >> h[i];

    memset(dp, -1, sizeof dp);

    cout << f(1, 0) << '\n';

    return 0;
}


Measured memory_bytes: 88336
#include <iostream>
#include <map>

int main() {
  using namespace std;
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  map<int, int> cnt;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    cnt[a]++;
    if (n % 2 == a % 2 || cnt[a] > 2) {
      cout << 0 << endl;
      return 0;
    }
  }
  if (n % 2 && cnt[0] == 2) {
    cout << 0 << endl;
    return 0;
  }
  constexpr int M = 1e9 + 7;
  int result = 1;
  for (int i = 0; i < n / 2; i++) {
    result *= 2;
    result %= M;
  }
  cout << result << endl;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll MOD = 1e9 + 7;

vector<vector<ll>> dp(1e5 + 10, vector<ll>(3, 0));
int main() {
  ll N;
  cin >> N;
  for (ll i = 0; i < N; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    dp[i+1][0] = max(dp[i][1], dp[i][2]) + a;
    dp[i+1][1] = max(dp[i][2], dp[i][0]) + b;
    dp[i+1][2] = max(dp[i][0], dp[i][1]) + c;
  }
  cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
  return 0;
}

Measured memory_bytes: 5760
package main

import "fmt"

func main() {

	var n, k int
	fmt.Scan(&n, &k)

	var v = make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&v[i])
	}

	result := 0
	for _, val := range v {
		if val >= k {
			result++
		}
	}

	fmt.Println(result)
}

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

template <typename T>
struct MonotoneQueue {
    std::deque<T> q, m;

    void push(const T &x) {
        q.push_back(x);
        while (!m.empty() && m.back() < x) m.pop_back();
        m.push_back(x);
    }

    void pop() {
        T x = q.front();
        q.pop_front();
        if (x == m.front()) m.pop_front();
    }

    size_t size() {
        return q.size();
    }

    T top() {
        return m.front();
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
 
    int n;
    cin >> n;
 
    int *h = new int [n + 1];
    for (int i = 1; i <= n; ++i) cin >> h[i];
 
    int l = 1, r = 1, res = 0;
    while (r <= n) {
        while (r < n && h[r] >= h[r + 1]) ++r;
        res = max(res, r - l);
        if (l == r) l = ++r;
        else l = r;
    }

    cout << res << '\n';
}

Measured memory_bytes: 640
// AtCoder Beginner Contest 070
// D - Transit Tree Path

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;


const int MAX_N = 100000;

int N;
int Q, K;
vector<pli> G[MAX_N + 1];
ll d[MAX_N + 1];

void dfs(int v, ll dep = 0, int p = -1) {
    d[v] = dep;
    for (pli &e : G[v]) {
        if (e.second == p) {
            continue;
        }
        dfs(e.second, dep + e.first, v);
    }
}

int main() {

    int a, b, x, y;
    ll c;

    cin >> N;
    for (int i = 0; i < N - 1; i++) {
        cin >> a >> b >> c;
        G[a].push_back(pli(c, b));
        G[b].push_back(pli(c, a));
    }

    cin >> Q >> K;
    dfs(K);
    for (int i = 0; i < Q; i++) {
        cin >> x >> y;
        cout << d[x] + d[y] << endl;
    }


    return 0;

}





Measured memory_bytes: 14336
#include <stdio.h>

int main(void) {
	int n;
	scanf("%d", &n);

	bool flag = false;
	while (n) {
		if (n % 10 == 7)
			flag = true;
		n /= 10;
	}

	if (flag) {
		printf("Yes\n");
	}
	else
		printf("No\n");
}

Measured memory_bytes: 1664
s=input()
n=len(s)
ans=0
for i in range(1<<(n-1)):
    f=s[0]
    for j in range(n-1):
        if (1<<j)&i:
            f+='+'
        f+=s[j+1]
    ans+=sum(map(int,f.split('+')))
print(ans)

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		if(num == 3 || num == 5 || num == 7 ) System.out.println("YES");
		else System.out.println("NO");

	}
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll h,w,n;
  cin >> h >> w >> n;
  ll r,c;
  cin >> r >> c;
  r--;
  c--;
  string s,t;
  cin >> s >> t;
  ll cursor;
  // push R
  cursor = c;
  REP(i,n){
    if(s[i]=='R') cursor++;
    if(cursor>=w){
      cout << "NO" << endl;
      return 0;
    }
    if(t[i]=='L' && cursor>0) cursor--;
  }
  // push L
  cursor = c;
  REP(i,n){
    if(s[i]=='L') cursor--;
    if(cursor<0){
      cout << "NO" << endl;
      return 0;
    }
    if(t[i]=='R' && cursor<w-1) cursor++;
  }
  // push U
  cursor = r;
  REP(i,n){
    if(s[i]=='U') cursor--;
    if(cursor<0){
      cout << "NO" << endl;
      return 0;
    }
    if(t[i]=='D' && cursor<h-1) cursor++;
  }
  // push D
  cursor = r;
  REP(i,n){
    if(s[i]=='D') cursor++;
    if(cursor>=h){
      cout << "NO" << endl;
      return 0;
    }
    if(t[i]=='U' && cursor>0) cursor--;
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 776
#include<iostream>
#include<algorithm>
#include<math.h>

 using namespace std;
 int main(){
  int n;
  cin >> n;
  int k;
  int T[100001];
  for (int i=1;i<=100000;i++){
    T[i]=i;
  }
  for(int j=1;j<=7;j++){
    k=pow(6,j);
    for (int i=k;i<=100000;i++){
      T[i]=min(T[i],T[i-k]+1);
  }
  }
  for(int j=1;j<=6;j++){
    k=pow(9,j);
    for (int i=k;i<=100000;i++){
      T[i]=min(T[i],T[i-k]+1);
  }
  }

  cout << T[n] << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
long N, i, j, w; cin >> N; long a[N], sum[N][N]={}, ans[N][N]={};
for(i=0; i<N; i++){ cin >> sum[i][i]; if(i){ sum[0][i]=sum[0][i-1]+sum[i][i]; } }
for(i=1; i<N-1; i++){ for(j=i+1; j<N; j++){ sum[i][j]=sum[0][j]-sum[0][i-1]; } }

for(w=1; w<N; w++){
for(i=0; i<N-w; i++){
for(ans[i][i+w]=1e16, j=0; j<w; j++){ 
  ans[i][i+w]=min(ans[i][i+w], ans[i][i+j]+ans[i+j+1][i+w]+sum[i][i+w]); 
}
}  
}
cout << ans[0][N-1] << "\n";
}

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

#define ll long long
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;


int main() {
    int N;
    cin >> N;
    int a[1000000];
    for(int i=0;i<3*N;i++){
        cin >> a[i]; 
    }
    sort(a,a+3*N,greater<int>());
    ll sum =0;
    for (int j=0;j<N;j++){
        sum += a[2*j+1];
    }
   cout << sum << endl;
}


Measured memory_bytes: 3456
#include <iostream>
     
     
     
    int main(){
      
     	int A, B, C;
      	std::cin>>A>>B>>C;
      	int sum = A + B + C;
      
      	if (sum >= 22)
          	std::cout<<"bust";
      	else
          	std::cout<<"win";
      	
      
      
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N1,N2,N3,N4; cin>>N1>>N2>>N3>>N4;
  vector<int> a{N1,N2,N3,N4};
  sort(a.begin(),a.end());
  if(a.at(0)==1 && a.at(1)==4 && a.at(2)==7 && a.at(3)==9) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
c = abs(a-b)
if c % 2 != 0:
  print("IMPOSSIBLE")
else:
  ka1 = a - (c // 2)
  ka2 = a + (c // 2)
  kb1 = b - (c // 2)
  kb2 = b + (c // 2)
  if ka1 == kb1:
    print(kb1)
  if ka1 == kb2:
    print(kb2)
  if ka2 == kb1:
    print(kb1)
  if ka2 == kb2:
    print(kb2)

Measured memory_bytes: 3064
N, M = map(int, input().split())
SCs = [list(map(int, input().split())) for i in range(M)]

def main():
    ze = [None] * N
    
    for s, c in SCs:
        if ze[s-1] is not None and ze[s-1] != c:
            print(-1)
            return
        ze[s-1] = c
    
    if ze[0] == 0:
        if N == 1:
            print(0)
            return
        else:
            print(-1)    
            return

    if ze[0] is None and N != 1:
        ze[0] = 1
    

    ze = [0 if z is None else z for z in ze]

    print("".join([str(i) for i in ze]))

main()

Measured memory_bytes: 3064
h, w, k = gets.split.map(&:to_i)

s = h.times.map {gets.chomp}

dp = Array.new(h+1) {Array.new(w+1, 0)}
h.times do |i|
    w.times do |j|
        dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]
        dp[i][j] += 1 if s[i][j] == "1"
    end
end

ans = h + w + 1
(2**(h-1)).times do |i|
    i = Array.new(h-1) {|x| i[x] == 1 ? x : nil}.compact
    t = i.size
    i.unshift(-1)
    i << h - 1

    wp = -1
    w.times do |j|
        if i.each_cons(2).any?{|a,b| dp[b][j] - dp[a][j] - dp[b][wp] + dp[a][wp] > k}
            if wp + 1 == j
                t = h + w + 1
                break
            else
                t += 1
                wp = j - 1
                redo
            end
        end
    end

    ans = t if ans > t
end

puts ans

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

#define ll long long int
#define loop(a,b,c) for(ll a=b; a<c; a++)
#define eloop(a,b,c) for(ll a=b; a<=c; a++)
#define nl prllf("\n");

using namespace std;

ll gcd(ll a, ll b){
    if(a==0) return b;
    if(a==1) return 1;
    else
        return gcd(b%a, a);
}

int main(){
    ll T = 1; //cin >> T;
    while(T--){
        ll n; cin >> n; 
      //  vector<ll> v(n);
        ll sum =0;
        eloop(i,1,n){
            eloop(j,1,n){
                eloop(k,1,n){
                    ll t = gcd(j,k);
                    t= gcd(i, t);
                    sum += t;
                }
            }
            

        }
        cout << sum << endl;
       

        
        
        

    }
    return 0;
}
/*

*/

Measured memory_bytes: 3592
n = int(input())
a = 0
b = 0
ans = 10**9
for i in range(1,n):
    a = i
    b = n-i
    ans_a = 0
    ans_b = 0
    a = list(str(a))
    b = list(str(b))
    for i in range(len(a)):
        ans_a += int(a[i])
    for i in range(len(b)):
        ans_b += int(b[i])
    ans = min(ans,ans_a+ans_b)
print(ans)

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

int main() {
  	int A,B,X;
  	cin >> A >> B >> X;
  	double theta=0;
  	if(X!=0){
  	if(X > double(A*A*B*0.5)){
		theta = double(atan2(2*B*A*A-2*X,A*A*A));
	}else{
  		theta = double(atan(double(A*B*B*0.5/X)));
	}
      cout << std::setprecision(9) << theta*180/M_PI <<endl;
    }else{
      cout << 90 <<endl;
    }
}
	

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	private void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int K = in.nextInt();
		
		double total = 0;
		for(int i=N; i>=1; i--) {
			total += Math.pow(0.5,countHead(i,K));
		}
		System.out.println(total/N);
	}
	
	private int countHead(int start, int target) {
		int count = 0;
		while(target > start) {
			start = start*2;
			count ++;
		}
		return count;
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define all(t) (t).begin(),(t).end()
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


int main(){
	ll n,m,ans=0;
	cin >> n >> m;
	priority_queue<ll> v;
	ll a[100010];
	FOR(i,n){
		cin >> a[i];
		v.push(a[i]);
	}

	FOR(i,m){
		ll x=v.top();v.pop();
		v.push(x/2);
	}

	while(!v.empty()){
		ans+=v.top();
		v.pop();
	}	
	cout << ans << endl;



}

Measured memory_bytes: 1912
#include <bits/stdc++.h>
using namespace std;
struct rest
{
	string name;
	int score,number;
}memory[111];
bool cmp(rest x,rest y)
{
	if (x.name!=y.name) return x.name<y.name;
	else return x.score>y.score;
}
int main()
{
	int n;
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>memory[i].name>>memory[i].score;
		memory[i].number=i;
	}
	sort(memory+1,memory+n+1,cmp);
	for (int i=1;i<=n;i++)
	{
		cout<<memory[i].number<<endl; 
	}
	return 0; 
} 

Measured memory_bytes: 256
<?php
list($s) = strs();
$n = strlen($s);
$ans = $cntB = 0;
for ($i = 0; $i < $n; ++$i) {
    if ($s[$i] === 'B') {
        $ans -= $i;
        ++$cntB;
    }
}
$ans += ($n - 1 + ($n - $cntB)) * $cntB / 2;
echo $ans;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}

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

int main() {
    string s;
    cin >> s;
    if(s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi"){
            cout << "Yes";
        } else {
            cout << "No";
        }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int dp[101][100001];
int v[101], w[101];
int main(){
      int n, W;
      cin>>n>>W;

      for(int i=0; i<n; i++)
            cin>>w[i+1]>>v[i+1];
      
      for(int i=0; i<=W; i++)
      for(int j=0; j<=n; j++)
      {
            dp[j][i]=-1;
            if(i==0 || j==0)dp[j][i]=0;
      }

      for(int i=1; i<=n; i++)
      {
            for(int w1=1; w1<=W; w1++){
                  dp[i][w1]=dp[i-1][w1];
                  if(w[i]<=w1)
                  dp[i][w1]=max(dp[i][w1], dp[i-1][w1-w[i]]+v[i]);
            }
      }
      cout<<dp[n][W]<<'\n';
}

Measured memory_bytes: 82520
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
#define mod 200003
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using vvb=vector<vector<bool>>;
using vb= vector<bool>;
ll f(ll a,ll b,ll p){
	if(b==0) return 1;
	if(b%2==0){
		ll t=f(a,b/2,p);
		return t*t%p;
	}
	return a*(f(a,b-1,p))%p;
} 

//__builtin_popcount()
signed main(){
	string s; cin>>s;
	int n=s.size();
	ll ans=0;
	string memo;
	while(!s.empty()){
		int m=s.size();
		string t; t.push_back(s[s.size()-1]);
		s.pop_back();
		if(m==1){
			ans+=(memo!=t);
			continue;
		}
		if(memo!=t){
			memo=t;
			ans++;
			continue;
		}
		else{
			t.push_back(s[s.size()-1]);
			s.pop_back();
			memo=t;
			ans++;
		}
	}
	cout<<ans<<endl;

	


	return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <deque>
#include <iomanip>
#include <bitset>
#include <complex>
#include <sstream>
#include <algorithm>
#include <limits>
#include <cmath>
#include <utility>
#include <tuple>
using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr int mod = 1e9+7;
constexpr ld eps = 1e-10;
constexpr ld pi = acos(-1.0);

#define DUMP(a) cout << #a << ": " << (a) << endl


int main() {
    string s;
    string s2 = "CODEFESTIVAL2016";
    cin >> s;
    int res=0;
    for(int i=0; i<s.size(); ++i) {
        if(s[i] != s2[i]) {
            res++;
        }
    }
    cout << res << endl;
}



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

		int N = sc.nextInt();	
		long T = sc.nextLong();	
		long[] t = new long[N];
		for( int i=0; i<N; i++ ){
			t[i] = sc.nextLong();
		}
		long ans = 0;
		for( int i=1; i<N; i++ ){
			if( t[i]-t[i-1]<=T ){
				ans+=t[i]-t[i-1];
			}else{
				ans+=T;
			}
		}
		System.out.println(ans+T);
	}
}


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


      int main()
      {


           ios_base::sync_with_stdio(false);
           cin.tie(NULL);
         /* #ifndef ONLINE_JUDGE
              freopen("input.txt","r",stdin);
              freopen("output.txt","w",stdout);
          #endif*/
      map<string,int>nish;
      int count;
      cin>>count;
      for(int i=0;i<count;i++)
      {
        string temp;
        cin>>temp;
        sort(temp.begin(),temp.end());
        nish[temp]++;
      }

      long long int ans=0;
      for(auto it:nish)
      {
        long long int total=it.second;
        total=(1LL*total*(total-1))/2;

        ans+=total;
      }

      cout<<ans<<endl;
      return 0;


      }

Measured memory_bytes: 11396
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

ll x, y;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> x >> y;
    int ans = 0;
    while (x <= y) ans++, x *= 2;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cstdlib>  // abs() for integer
#include <math.h>     // math.h をインクルードする！
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    if (a + b <= 2 * c) {
        cout << a * x + b * y << endl;
        return 0;
    }
    else {
        int money_1 = c * 2 * min(x, y);
        if (x == y) {
            cout << money_1 << endl;
            return 0;
        }

        else if (x > y && a < 2 * c) {
            cout << money_1 + a * (x - y) << endl;
            return 0;
        }

        else if(x < y && b < 2 * c) {
            cout << money_1 + b * (y - x) << endl;
            return 0;
        }

        else {
            cout << money_1 + c * 2 * abs(x - y) << endl;
            return 0;
        }
    }
    // cout << x << ' ' << y << endl;
}

Measured memory_bytes: 256
// I look at my watch
// it say nine twenty-five
// And I think oh God
// I'm still alive
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;

const int N=1e5+100;
vector<ii>gfo[N];
bool vst[N];
int d[N];
vector<int>ts;

void toposort(int u){
	vst[u]=true;
	for(ii v:gfo[u])
		if(!vst[v.ff])toposort(v.ff);
	ts.pb(u);
}

bool dfs(int u,int val){
	vst[u]=true;
	bool ctm=false;
	for(ii v:gfo[u]){
		if(d[v.ff]==-1)d[v.ff]=d[u]+v.ss;
		else{
			if(d[v.ff]!=d[u]+v.ss)return true;
		}
		if(!vst[v.ff])ctm|=dfs(v.ff,d[u]+v.ss);
	}
	return ctm;
}

int main(){	
	int n,m;cin>>n>>m;	
	For(i,0,m){
		int l,r,d;cin>>l>>r>>d;
		l--,r--;
		gfo[l].pb({r,d});
	}
	bool find=false;
	For(i,0,n)if(!vst[i])toposort(i);
	reverse(all(ts));
	memset(vst,false,sizeof(vst));
	memset(d,-1,sizeof(d));
	for(int u:ts)if(!vst[u]){
		d[u]=0;
		find|=dfs(u,0);
	}
	if(find)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	
	return 0;
}


Measured memory_bytes: 11384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define N 1000005
typedef long long int ll;
// int n,m;
// vector<int> adj[mx];

//---dfs--
// bool visited[mx];
// vector<int> val(n,0);

// void dfs(int s, int & cnt_vert, int & cnt_edge){
// 	assert(!visited[s]);
// 	visited[s]=true;
// 	++cnt_vert;
// 	cnt_edge+=adj[s].size();
// 	for(int b:adj[s]){
// 		if(!visited[b]){
// 			dfs(b,cnt_vert,cnt_edge);
// 		}
// 	}
// }
//---dfs---

//---primes---
// vector<bool> prime(N,true);
// int spf[N];

// void calc(){
// 	for(int i=2;i<1e4;i++){
// 		if(!prime[i]) continue;
// 		spf[i]=i;
// 		for(int j=i*i;j<N;j+=i){
// 			prime[j]=false;
// 			spf[j]=i;
// 		}
// 	}
// 	for(int i=2;i<N;i++){
// 		if(!spf[i]) spf[i]=i;
// 	}
// }

// vector<pair<int,int>> getp(int x){
// 	int curr=x;
// 	vector<pair<int,int>> ans;
// 	while(curr>1){
// 		int a=spf[curr];
// 		int count=0;
// 		while(curr%a==0){ curr/=a; count++;}
// 		ans.push_back(make_pair(a,count));
// 	}
// 	return ans;
// }

// bool ispr(int n) {
//     for (int i=2;i*i<=n;++i){
//         if(n%i==0){
//             return false;
//         }
//     }
//     return true;
// }
//---primes---

//---segment_tree---
// int upd(int t,int val,int l,int r,int y, int z){
// 	if(y<l||y>r) return tr[val];
// 	if(l==r) return tr[val]=z;
// 	int s=(l+r)/2;
// 	upd(t^1,2*val+1,l,s,y,z);
// 	upd(t^1,2*val+2,s+1,r,y,z);
// 	if(t) tr[val]=tr[2*val+1]|tr[2*val+2];
// 	else tr[val]=tr[2*val+1]^tr[2*val+2];
// 	return tr[val];
// }
//int query(){}
//---segment_tree---

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int t=1;
	//cin>>t;
	while(t--){
		int x;
		cin>>x;
		int k=1;
		for(k;k<=360;k++){
			if((k*x)%360==0) break; 
		}
		cout<<k<<"\n";
	}
}


Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll int
#define rep(i,a,N) for(int (i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for(int (i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define pb(b) push_back(b) 
#define all(a) a.begin(),a.end()
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define llpvec vector<pair<ll,ll>>
#define size_(a,b) (a,vector<ll>(b))
#define S 21
////////////////////////////////////////////////////////////
ll n,x,y,mx=0;
llvec g; 
llpvec pairs;
vector<ll> cnt;
map<pair<ll,ll>,ll> color;
void bfs(ll a,ll b,ll c){
 ll ed=g[a].size(),d=0;
 color[{b,a}]=c;
 rep(i,0,ed){
  if(i+1==c)++d;
  bfs(g[a][i],a,i+d+1);
 }
}

int main(){
 cin>>n;
 g.resize(n+1);
 cnt.assign(n+1,0);
 rep(i,0,n-1){
  cin>>x>>y;
  g[x].pb(y);
  pairs.pb(pair(x,y));
  ++cnt[x];++cnt[y];
  mx=max(cnt[x],mx);
 }
 cout<<mx<<endl;
 bfs(1,0,0);
 rep(i,0,n-1){
  pair<ll,ll>p=pairs[i];
  cout<<color[p]<<endl;
 }
return 0;}

Measured memory_bytes: 15040
#include<stdio.h>

int main(void){
  int input[4][13],i,n,card=0,j,v=0;
  char c,mark[5] ={'S','H','C','D','\0'};

  
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      input[i][j]=0;
    }
  }


  scanf("%d\n",&n);

  for(i=0;i<n;i++){
    scanf("%c %d\n",&c,&card);
    for(j=0;j<5;j++){
      if(mark[j]==c){
	input[j][card-1]=1;
      }
    }
  }

  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      if(input[i][j]==0){
	printf("%c %d\n",mark[i],j+1);
      }
    }
  }
}
	
      



Measured memory_bytes: 2096