akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort((x).rbegin(),(x).rend())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
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;}
// clang-format on

void solve(long long K) {
  ll ans = 0;
  rep1(a, K) {
    rep1(b, K) {
      rep1(c, K) {
        ll g = gcd(a, gcd(b, c));
        ans += g;
      }
    }
  }
  ANS(ans);
}

// clang-format off
int main() {
  long long K;
  scanf("%lld",&K);
  solve(K);
  return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    int N, M; cin >> N >> M;
    int num = 0;
    rep(i, M) {
        int A; cin >> A;
        num += A;
    }
    if (N - num >= 0) {
        cout << N - num << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
import heapq

n, m = [int(v) for v in input().split(' ')]

links = []
for i in range(n):
    links.append([])

for i in range(m):
    l, r, c = [int(v) for v in input().split(' ')]
    l -= 1
    r -= 1
    links[r].append((l, c))

h = []
heapq.heappush(h, (0, n-1))
closed = 0
while len(h) > 0:
    c0, n0 = heapq.heappop(h)
    if (closed & (1 << n0)) != 0:
        continue
    closed |= (1 << n0)
    if n0 == 0:
        print(c0)
        exit()

    for n1, c1 in links[n0]:
        if (closed & (1 << n1)) != 0:
            continue
        heapq.heappush(h, (c0 + c1, n1))

    n2 = n0 + 1
    if n2 < n:
        if (closed & (1 << n2)) == 0:
            heapq.heappush(h, (c0, n2))

print("-1")

Measured memory_bytes: 31788
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
 
signed main(){
 
	lli n;
	cin>>n;
 
	/*iまで何個あるか?*/
	lli data[10000];
	REP(i,0,10000)data[i]=0;
 
	vector<lli> l(n);
 
	REP(i,0,n){
		cin>>l[i];
		data[l[i]]++;
	}

	REP(i,1,10000)data[i] += data[i-1];
	sort(l.begin(),l.end());
 
	lli sum = 0;
	
	for(lli i=n-1;i>=0;i--){
		for(lli j=i-1;j>=0;j--){
			auto itr = lower_bound(l.begin(),l.end(),l[i]+l[j]);
			lli ng = distance(itr,l.end());
			sum += (n-1-i)-ng;
		}
	}
 
	cout<<sum<<endl;
 
 
	return 0;
}

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

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  rep(i,a) cin >> p[i];
  rep(i,b) cin >> q[i];
  rep(i,c) cin >> r[i];
  sort(rrng(p));
  sort(rrng(q));
  r.insert(r.end(), p.begin(), p.begin() + x);
  r.insert(r.end(), q.begin(), q.begin() + y);
  sort(rrng(r));
  ll ans = 0;
  rep(i,x+y) ans += r[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2808
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        int c = sc.nextInt();
        int d = sc.nextInt();

        long ans = f(b, c, d) - f(a - 1, c, d);
        System.out.println(ans);
    }

    static long f(long x, long c, long d) {
        long ret = x; // これが全体数
        ret -= (x / c); // Cで割れる数を減らす
        ret -= (x / d); // Dで割れる数を減らす
        ret += x / lcm(c, d); // CとDで重複して減らした数を加算する
        return ret;
    }

    static long lcm(long a, long b) {
        // 最小公倍数
        return (a * b) / gcd(a, b);
    }

    static long gcd(long a, long b) {
        // 最大公約数
        return b == 0 ? a : gcd(b, a % b);
    }
}


Measured memory_bytes: 22100
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int aa=0,bb=0,i,j,count=0;
    int c[200]={};
    
    for(i=0;i<200;i++){
        if(scanf("%d %d",&aa,&bb) != 2){
            break;
        }
        c[i]=aa+bb;
    }
    for(j=0;j<i;j++){
        count=0;
        while(c[j]!=0){
            c[j]=c[j]/10;
            count++;
        }
        printf("%d\n",count);
    }
    return 0;
}


Measured memory_bytes: 2076
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int []s = new int [m];
		int []p = new int [m];
		
		for(int i = 0; i<m ; i++) {
			int k = sc.nextInt();
			for(int j = 0; j < k; j++) {
				int ss = sc.nextInt();
				s[i] += Math.pow(2, ss - 1);
			}
	      }
		for(int i = 0 ; i< m ; i++) {
			p[i] = sc.nextInt();
		}
		
		int N = (int) Math.pow(2, n);
		int ans = 0;
		
		for(int i = 0; i < N ; i++) {
			boolean light = true;
			for(int j = 0; j < m ; j ++) {
				int amp = i & s[j];
				if((Integer.bitCount(amp)%2) != p[j] ) {
					light = false;
				}
			}
			if(light)
				ans++;
		
		}
		System.out.println(ans);
  
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0) val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator - () const noexcept {
return val ? MOD - val : 0;
}
constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
constexpr Fp& operator += (const Fp& r) noexcept {
val += r.val;
if (val >= MOD) val -= MOD;
return *this;
}
constexpr Fp& operator -= (const Fp& r) noexcept {
val -= r.val;
if (val < 0) val += MOD;
return *this;
}
constexpr Fp& operator *= (const Fp& r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp& operator /= (const Fp& r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
val = val * u % MOD;
if (val < 0) val += MOD;
return *this;
}
constexpr bool operator == (const Fp& r) const noexcept {
return this->val == r.val;
}
constexpr bool operator != (const Fp& r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0) return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

// 愚直計算による二項係数計算
mint com(long long n, long long r) {
mint res = 1;
for (long long i = 0; i < r; ++i) {
res *= (n-i);
res /= (i+1);
}
return res;
}

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

ll X,Y;
cin >> X >> Y;
if( (X+Y) % 3 != 0 ) {
    cout << 0 << endl;
    return 0;
}
ll K = (X + Y) / 3;
if( X < K || X > 2*K ) {
    cout << 0 << endl;
    return 0;
}
mint ans = com(K, X-K);
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
using namespace std;
int D, E;
int main() {
	while (true) {
		cin >> D >> E; if (D == 0)break;
		long double minx = 1e+300;
		for (int i = 0; i <= D; i++) {
			int X = i, Y = D - i;
			minx = min(minx, fabsl(1.0*E - sqrt(1.0*X*X + 1.0*Y*Y)));
		}
		cout << fixed << setprecision(14) << minx << endl;
	}
	return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep1(i, n) for (ll i = 1; i < n; i++)
using P = pair<ll, ll>;

int main()
{
    ll n, a, b;
    cin >> n;
    ll p[n];
    rep(i, n) cin >> p[i];
    rep(i, n - 2)
    {
        if (p[i] > p[i + 1])
        {
            for (ll j = i + 1; j < n - 1; j++)
            {
                if (p[j] > p[j + 1])
                {
                    ll tmp = p[i];
                    p[i] = p[j + 1];
                    p[j + 1] = tmp;
                }
            }
        }
    }
    rep(i, n - 1)
    {
        if (p[i] > p[i + 1])
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    // rep(i, n) cout << p[i];
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
char change1(char a){
  if('A'<=a && a<='Z')
    return a;
  else
    return a+'A'-'a';
}
char change2(char a){
  if('a'<=a && a<='z')
    return a;
  else
    return a+'a'-'A';
}
int main(){
  while(1){
    string name,type;
    vector<string> word;
    cin >> name >> type;
    if(type=="X") break;
    int st = 0;
    name += "_";
    for(int i=1;i<(int)name.size();i++){
      if(name[i]=='_'){
	word.push_back(name.substr(st,i-st));
	st = i+1;
      } else if('A'<=name[i] && name[i]<='Z'){
	word.push_back(name.substr(st,i-st));
	st = i;
      }
    }
    if(type=="L"){
      for(int i=0;i<(int)word.size();i++){
	if(i==0) word[i][0]=change2(word[i][0]);
	else word[i][0]=change1(word[i][0]);
	cout << word[i];
      }
    } else if(type=="U"){
      for(int i=0;i<(int)word.size();i++){
	word[i][0]=change1(word[i][0]);
	cout << word[i];
      }
    } else {
      for(int i=0;i<(int)word.size();i++){
	word[i][0]=change2(word[i][0]);
	cout << word[i];
	if(i!=(int)word.size()-1) cout << "_";
      }
    }
    cout << endl;
  }
}

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

int main(){
  int N, M;
  cin >> N >> M;
  
  string a=to_string(N);
  string b=to_string(M);
  a+=b;
  int x=stoi(a);
  double sq=sqrt(x);
  int in=floor(sq);
  if(sq==in) cout<< "Yes"<<endl;
  else cout << "No" <<endl;
}

Measured memory_bytes: 256
debug = 0
"""
N: state num
M: city num
"""


if debug:
    N = 2
    m = 10
else:
    (N, M) = list(map(int, input().split()))

if debug:
    p_y_list = [
        [1, 30]
        ,[1, 20]
        ,[1, 10]
        ,[1, 3]
        ,[2, 63]
        ,[2, 33]
        ,[2, 23]
        ,[3, 21]
        ,[3, 7]
    ]

city_id_list = []
for num, z in enumerate(range(M)):
# for num, (P, Y) in enumerate(p_y_list):
    
    if not debug:
        (P, Y) = list(map(int, input().split()))

    city_id_list.append([Y, P, num])
    
city_id_list = sorted( city_id_list, key= lambda x: x[0])

state_cnt = {}
tmp_list = []
for (Y, P, num) in city_id_list:
    
    if P not in state_cnt.keys():
        state_cnt[P] = 1
    elif P in state_cnt.keys():
        state_cnt[P] += 1
        
    tmp_id = str(P).zfill(6) + str(state_cnt[P]).zfill(6)
    
    tmp_list.append([num, tmp_id])
    
for cid in sorted(tmp_list, key=lambda x: x[0]):
    print(cid[1])

Measured memory_bytes: 49536
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

int main(void){
  vector<ll> a(3);
  for (int i = 0; i < 3; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  
  if (a[0] + a[1] == a[2])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    
  
  

  return 0;
}


Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 
 
void solve(){
    ll n;
    cin>>n;
    ll a=0,ans=1;
    rep2(i,1,n+1){
        ll c=0,x=i;
        while(x%2==0){
            x/=2;
            c++;
        }
        if(chmax(a,c)) ans=i;
    }
    cout<<ans<<endl;
 
} 
 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    ll Q=1;
    // cin>>Q;
    rep(_,Q){
 
        solve();
 
    }
   
 
 
    return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
  static inline int64 Normalize(int64 x) {
    if (0 <= x && x < P) return x; x %= P; if (x < 0) x += P; return x;
  }
 public:
  FiniteField(int64 x) : x(Normalize(x)) {}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

ostream& operator<<(ostream& s, const FiniteField& v) { s << v.Value(); return s; }

FiniteField Power(FiniteField x, int p) {
  if (p < 0) return FiniteField(1) / Power(x, -p);
  FiniteField value = 1;
  while (p) {
    if (p % 2) value *= x;
    x *= x;
    p /= 2;
  }
  return value;
}

template<typename T>
vector<vector<vector<T>>>
Make3DVector(int d1, int d2, int d3, T default_value) {
  return vector<vector<vector<T>>>(
      d1, vector<vector<T>>(d2, vector<T>(d3, default_value)));
}

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

  int64 n;
  cin >> n;

  map<int64, FiniteField> dp;
  function<FiniteField(int64)> solve_dp_fn = [&](int64 x) -> FiniteField {
    if (dp.find(x) != dp.end()) {
      return dp[x];
    }
    if (x == 0) return 1;
    if (x == 1) return 2;
    auto v = solve_dp_fn((x - 2) / 2) + solve_dp_fn((x - 1) / 2) + solve_dp_fn(x / 2);
    dp[x] = v;
    return v;
  };
  cout << solve_dp_fn(n) << endl;
  // cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int HMOD = 1e6 + 3;

LL gen_ha(int ori[])
{
	LL ret = 0;
	rep(i, 4) ret = ret * 1000 + ori[i];
	return ret;
}

LL min_rep(int ori[], int& cnt)
{
	LL ret = INF;
	rep(i, 4) {
		ret = min(ret, gen_ha(ori));
		rotate(ori, ori + 1, ori + 4);
	}
	cnt = 0;
	rep(i, 4) {
		if(gen_ha(ori) == ret) cnt ++;
		rotate(ori, ori + 1, ori + 4);
	}
	return ret;
}

int n, c[405][4];
LL ha[405];
int hcnt[405];
vector<LL> hv[1000005];

LL tha[4];
int thcnt[405];
int tmp[4];
int fa[4], cnt[4];
LL solve(int id0, int id1)
{
	rep(i, 4) {
		tmp[0] = c[id0][i];
		tmp[1] = c[id0][i + 1 & 3];
		tmp[2] = c[id1][i + 1 & 3];
		tmp[3] = c[id1][i];
		tha[i] = min_rep(tmp, thcnt[i]);
	}
	
	rep(i, 4) fa[i] = i;
	rep(i, 4) rep(j, i)
	if(tha[i] == tha[j]) {
		fa[i] = j;
		break;
	}
	rep(i, 4) cnt[i] = 0;
	rep(i, 4) cnt[fa[i]] ++;
	
	LL ans = 1;
	rep(i, 4) {
		int tot = 0;
		vector<LL>& cur = hv[tha[i] % HMOD];
		rep(j, cur.size()) if(cur[j] == tha[i]) tot ++;
		if(ha[id1] == tha[i]) tot --;
		rep(j, cnt[i]) ans *= tot - j;
		rep(j, cnt[i]) ans *= thcnt[i];
	}
	return ans;
}

int main()
{
	scanf("%d", &n);
	rep(i, n) {
		rep(j, 4) scanf("%d", &c[i][j]);
		ha[i] = min_rep(c[i], hcnt[i]);
	}
	LL ans = 0;
	rep(i, n) {
		rep(j, i) {
			reverse(c[i], c[i] + 4);
			rep(k, 4) {
				ans += solve(i, j);
				rotate(c[j], c[j] + 1, c[j] + 4);
			}
			reverse(c[i], c[i] + 4);
		}
		hv[ha[i] % HMOD].push_back(ha[i]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 23680
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict
from operator import itemgetter
from heapq import heappop, heappush
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

N, M = inpl()
D = [0] + [10**18]*(N-1)
g0 = itemgetter(0)
Q = sorted([inpl() for _ in range(M)], key=g0, reverse=True)
#print(*Q, sep="\n")

HQ = [(0, 0), (10**18, N)]

for i in range(N):
    while HQ[0][1] < i:
        heappop(HQ)
    v = HQ[0][0]
    while len(Q) and (i == (Q[-1][0]-1)):
        l, r, c = Q.pop()
        heappush(HQ, (v+c, r-1))


if v == 10**18:
    print(-1)
else:
    print(v)

Measured memory_bytes: 83852
import math


def generate_prime_numbers(num_max, num_min = 2):

    num_max_sqrt = round(math.sqrt(num_max))

    for num in range(num_min, num_max_sqrt + 1):
        if num == 2:
            yield 2

        if num % 2 == 0:
            continue

        flag_prime = True
        i = 3
        while i ** 2 <= num:
            if num % i == 0:
                flag_prime = False

            i = i + 2

        if flag_prime:
            yield num

    yield None


n = int(input())

n_calc = n
list_prime_factor = []

for prime_number in generate_prime_numbers(num_max = n):
    if prime_number == None:
        list_prime_factor.append(int(n_calc))
        break

    if n_calc < prime_number:
        list_prime_factor.append(int(n_calc))
        break

    while n_calc % prime_number == 0:
        list_prime_factor.append(prime_number)

        n_calc /= prime_number

    if n_calc == 1:
        break

    
print(f"{n}:", *list_prime_factor)



Measured memory_bytes: 5680
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

int nC2(int n){
    return n*(n-1)/2;
}

signed main(){
    FASTER;
    int n,k;cin>>n>>k;
    if(k>nC2(n-1)){
        cout<<-1;
        return 0;
    }
    
    vii v;
    for(int i=2;i<=n;i++)v.push_back({1,i});
    k=nC2(n-1)-k;
    for(int i=2;i<=n && k;i++){
        for(int j=i+1;j<=n && k;j++){
            v.push_back({i,j});
            k--;
        }
    }
    
    cout<<v.size()<<"\n";
    for(pii p:v){
        cout<<p.first<<" "<<p.second<<"\n";
    }
}


Measured memory_bytes: 3780
import Control.Monad
import Control.Monad.ST
import Data.List
import Control.Monad.Trans.State.Strict
import Data.Char (isSpace)
import Data.Maybe (fromJust)
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Unboxed.Mutable as MV

import qualified Data.ByteString.Char8 as B

type Parser a = StateT B.ByteString Maybe a

parseInt :: Parser Int
parseInt = StateT (B.readInt . B.dropWhile isSpace)

parseInt2 :: Parser (Int,Int)
parseInt2 = liftM2 (,) parseInt parseInt

parse :: Parser [(Int,Int)]
parse = do
    q<-parseInt
    replicateM q parseInt2

pr :: [Integer]
pr=2:3:2#pr;m#(a:b:x)=[n|n<-[a^2..b^2-2],gcd m n<2]++(m*b)#(b:x)

prs = takeWhile (<=100000) pr

csum = UV.create $ do
    pv <- MV.replicate 100001 0:: ST s (MV.STVector s Int)
    sv <- MV.replicate 100001 0:: ST s (MV.STVector s Int)
    forM_ prs $ \p -> MV.write pv (fromIntegral p) 1
    forM_ prs $ \p -> do
        a <- MV.read pv ((fromIntegral p+1)`div`2)
        when (a == 1) $ MV.write sv (fromIntegral p) 1
    forM_ [1..100000] $ \i -> do
        si <- MV.read sv i
        si0 <- MV.read sv (i-1) 
        MV.write sv i (si+si0)
    return sv

main = do
    lrs<- fromJust.evalStateT parse <$> B.getContents::IO[(Int,Int)]
    putStr $ unlines $ map (show.(\(l,r)-> (csum UV.! r) - (csum UV.! (l-1)))) lrs


Measured memory_bytes: 25596
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define mod 998244353
//#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//↑templete
int main() {
	int N;
	cin>>N;
	vint H;
	for(int i=0;i<N;i++){
		int h;
		cin>>h;
		H.pb(h);
	}
	ll DP[SIZE]={0,abs(H[1]-H[0]),0};	//DP[i]=i番目の足場にたどり着くための最小コスト
	for(int i=2;i<N;i++)
		DP[i]=INF;
	for(int i=2;i<N;i++){
		DP[i]=min(DP[i],DP[i-2]+abs(H[i]-H[i-2]));
		DP[i]=min(DP[i],DP[i-1]+abs(H[i]-H[i-1]));
	}
	cout<<DP[N-1]<<endl;
	return 0;
}

Measured memory_bytes: 1528
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
from decimal import Decimal
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

a = S()

if a.isupper():
    print("A")
else:
    print("a")

Measured memory_bytes: 27240
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;
vi R,G,B;
int check[314514]={0};
int main(){
	cin>>N;
	string str;
	cin>>str;
	rep(i,3*N){
		if(str[i]=='R')R.pb(i);
		else if(str[i]=='G')G.pb(i);
		else B.pb(i);
	}
	rep(i,N){
		check[min(R[i],min(G[i],B[i]))]=-1;
		check[max(R[i],max(G[i],B[i]))]=1;
	}
	ll ans=1;
	int resa=0,resb=0,resc=0;
	rep(i,3*N){
		if(check[i]==-1){
			ans*=(N-resa);
			ans%=MOD;
			resa++;
		}
		if(check[i]==0){
			ans*=(resa-resb);
			ans%=MOD;
			resb++;
		}
		if(check[i]==1){
			ans*=(resb-resc);
			ans%=MOD;
			resc++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int H, W;
vector<vector<int>>h, w;
vector<string>S;
void SWAPH(int h1, int h2) {
	swap(S[h1], S[h2]);
	swap(h[h1], h[h2]);
}
void SWAPW(int w1, int w2) {
	for (int i = 0; i < H; ++i) {
		swap(S[i][w1], S[i][w2]);
	}
	swap(w[w1], w[w2]);
}

bool slovew(int x) {
	if (x == W / 2) {
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (S[i][j] != S[H - i - 1][W - j - 1])
					return false;
			}
		}
		return true;
	}
	for (int i = x + 1; i < W - x; ++i) {
		if (w[x] == w[i]) {
			SWAPW(i, W - x - 1);
			if (slovew(x + 1))
				return true;
			SWAPW(i, W - x - 1);
		}
	}
	if ((W & 1) && W != 1) {
		SWAPW(x, x + 1);
		for (int i = x + 1; i < W - x; ++i) {
			if (w[x] == w[i]) {
				SWAPW(i, W - x - 1);
				if (slovew(x + 1))
					return true;
				SWAPW(i, W - x - 1);
			}
		}
		SWAPW(x, x + 1);
	}
	return false;
}

bool sloveh(int x) {
	if (x == H / 2) {
		if (slovew(0))
			return true;
		else
			return false;
	}
	for (int i = x + 1; i < H - x; ++i) {
		if (h[x] == h[i]) {
			SWAPH(i, H - x - 1);
			if (sloveh(x + 1))
				return true;
			SWAPH(i, H - x - 1);
		}
	}
	if ((H & 1) && H != 1) {
		SWAPH(x, x + 1);
		for (int i = x + 1; i < H - x; ++i) {
			if (h[x] == h[i]) {
				SWAPH(i, H - x - 1);
				if (sloveh(x + 1))
					return true;
				SWAPH(i, H - x - 1);
			}
		}
		SWAPH(x, x + 1);
	}
	return 0;
}

int main() {
	cin >> H >> W;
	h = vector<vector<int>>(H, vector<int>(26));
	w = vector<vector<int>>(W, vector<int>(26));
	S = vector<string>(H);
	for (int i = 0; i < H; ++i) {
		cin >> S[i];
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			++h[i][S[i][j] - 'a'];
			++w[j][S[i][j] - 'a'];
		}
	}
	puts(sloveh(0) ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int a = Character.getNumericValue(s.charAt(0));
        int b = Character.getNumericValue(s.charAt(1));
        int c = Character.getNumericValue(s.charAt(2));
        int d = Character.getNumericValue(s.charAt(3));

        boolean solved = false;
        for (OP op1 : OP.values()) {
            for (OP op2 : OP.values()) {
                for (OP op3 : OP.values()) {
                    int total = a;
                    total = calc(total, b, op1);
                    total = calc(total, c, op2);
                    total = calc(total, d, op3);
                    if (!solved && total == 7) {
                        System.out.println(a + op1.symbol + b + op2.symbol + c + op3.symbol + d + "=7");
                        solved = true;
                    }
                }
            }
        }
    }

    static int calc(int m, int n, OP op) {
        return op == OP.PLUS ? m + n : m - n;
    }

    enum OP {
        PLUS("+"),
        MINUS("-");

        private String symbol;
        OP(String symbol) {
            this.symbol = symbol;
        }
    }
}

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a == 1 ? (b == 1 ? "Draw" : "Alice") : (b == 1 ? "Bob" : (a == b ? "Draw" : (a > b ? "Alice" : "Bob")))) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, x; cin >> n >> x;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    if(a[0] > x){
        ans += a[0] - x;
        a[0] = x;
    } 
    for(int i = 0; i < n-1; ++i){
        if(a[i] + a[i+1] > x){
            ans += (a[i] + a[i+1]) - x;
            a[i+1] -= (a[i] + a[i+1]) - x;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
n,m=map(int, input().split())
ans=0
for i in make_divisors(m):
  if m//i>=n:
    ans=i
print(ans)

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

int main(){
    int n;
    cin >>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(a.rbegin(),a.rend());
    bool flag = true;
    for(int i = 0; i < n;i++){
        if(a[i] == a[i+1]) flag = false;
    }
    if(flag){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }

}



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

int main() {
    long long N;
    long long total;
    cin>>N;
    if(N==1)
        cout<<0;
    else{
        N=N-1;
        if(N%2==0){
            total=N/2;
            total=total*(N+1);
            cout<<total;
        }
        else{
            total=(N+1)/2;
            total=total*N;
            cout<<total;
        }
    }    
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[1001][1001];
int b[1001][1001];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	cin>>a[i][j];
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	{
		if(a[i][j]=='#')
		b[i][j]=-10;
		if(a[i][j]=='.')
		{
			if(a[i-1][j]=='#')
			b[i][j]++;
			if(a[i][j+1]=='#')
			b[i][j]++;
			if(a[i+1][j]=='#')
			b[i][j]++;
			if(a[i][j-1]=='#')
			b[i][j]++;
			if(a[i-1][j-1]=='#')
			b[i][j]++;
			if(a[i-1][j+1]=='#')
			b[i][j]++;
			if(a[i+1][j-1]=='#')
			b[i][j]++;
			if(a[i+1][j+1]=='#')
			b[i][j]++;
		}
	}
	for(int i=1;i<=n;i++)
	{
	for(int j=1;j<=m;j++)
	{
		if(b[i][j]<0)
		cout<<'#';
		else
		cout<<b[i][j];
	}
	cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 2432
//import for Scanner and other utility classes
import java.util.*;


// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

class Main {
    public static void main(String args[] ) throws Exception {
     
        Scanner s = new Scanner(System.in);
      String ss=s.next();
      int c=0;
      for(int i=0;i<ss.length();i++){
      if(ss.charAt(i)!=ss.charAt(ss.length()-i-1))
        c++;
      }
      System.out.println(c/2);
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <fstream>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <list>
#include <array>
#include <cstdlib>
#include <stack>
#include <string>
#include <queue>
#include <chrono>
#include <functional>
#include <limits>
#include <cmath>
#include <algorithm>
#include <random>
#include <regex>
#include <tuple>
#include <utility>
#include <bitset>
#include <complex>
#include <iomanip>
#include <ostream>
#include <sstream>
#include <ctime>
using namespace std;
#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define V vector<int>
#define VP vector<pair<int, int> >
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define index INDEX
#ifndef ONLINE_JUDGE
#define print(x) PRINT(x, #x)
template<typename T> inline const void PRINT(T VARIABLE, const string& NAME) {
	cerr << NAME << " = " << fixed << VARIABLE << "\n";
}
#else
#define print(x) 0 
#endif
#ifdef RAND_MAX
#undef RAND_MAX
#endif
#define RAND_MAX 999999937 
int generate_random() {
	const int MAX_RANDOM = (int)1e6;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	return uniform_int_distribution<int>(0, MAX_RANDOM)(rng);
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll INFLL = 2 * (ll)1e18 + 100;
#define int ll
#ifdef int 
const int INFINT = INFLL;
#else
const int INFINT = 2 * (int)1e9 + 100;
#endif
const double PI = atan(1) * 4;
const double EPS = 1e-6;
const int SEED = (int)1e3 + 7;
const int MOD = (int)1e9 + 7;
const int NMAX = (int)1e6 + 5;


int32_t main() {
#ifndef ONLINE_JUDGE
	double START_PROGRAM = clock();
#endif
	srand(time(0));
	cout << setprecision(20) << fixed;
	FASTIO;
	double n, k;
	cin >> n >> k;
	double sol = 0;
	for1(i, min(k - 1, n))
	{
		int here = 1;
		while (i * (1 << here) < k) here++;
		sol += 1 / (n * static_cast<double>((1 << (int)here)));
	}
	for (int i = k; i <= n; i++) sol += 1 / n;
	cout << sol;






#ifndef ONLINE_JUDGE
	double END_PROGRAM = clock();
	double ELAPSED_TIME = (END_PROGRAM - START_PROGRAM) / CLOCKS_PER_SEC;
	cerr << "\n\nElapsed Time: " << ELAPSED_TIME * 1000 << "\n";
	system("pause");
#endif
	return 0;
}







Measured memory_bytes: 504
#include <stdio.h>
#include <math.h>

int n,a,b,sum1,sum2;

int digit_sum(int target){
  int result = 0;
  while (target > 0) {
    result += target % 10;
    target = target / 10;
  }
  return result;
}

int main() {
  sum2 = 0;
  scanf("%d%d%d", &n, &a, &b);
  for (size_t i = 1; i <= n; i++) {
    sum1 = digit_sum(i);
    if(a <= sum1 && sum1 <= b) sum2 += i;
  }
  printf("%d", sum2);
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> vec_N(N), a(N), b(N);
    for (int i = 0; i < N; i++) {
        vec_N.at(i) = i + 1;
    }
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < N; i++) {
        cin >> b.at(i);
    }

    int count_a = 0, count_b = 0, i = 0;
    do {
        if (vec_N == a) {
            count_a = i;
        }
        if (vec_N == b) {
            count_b = i;
        }
        i++;
    } while (next_permutation(vec_N.begin(), vec_N.end()));

    cout << abs(count_a - count_b) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int solve(int h[],int curr,int n){
  if(n<=1)
    return 0;
  int dp[n]={0};
  dp[n-2] = abs(h[n-1]-h[n-2]);
  for(int i=n-3;i>=0;i--){
    int a1 = abs(h[i+1]-h[i]);
    int a2 = abs(h[i+2]-h[i]);
    dp[i] = min(a1+dp[i+1],dp[i+2]+a2);
  }
  return dp[0];
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin>>n;
  int h[n];
  for(int i=0;i<n;i++)
    cin>>h[i];
  cout<<solve(h,0,n)<<endl;
}


Measured memory_bytes: 1024
<?php

fscanf(STDIN, "%s", $s);
fscanf(STDIN, "%s", $t);

$s_arr = str_split($s);
$t_arr = str_split($t);

$count = 0;
foreach ($s_arr as $i => $s_char) {
    if ($s_char === $t_arr[$i]) {
        ++$count;
    }
}

echo $count;


Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,a,b,c,k,d;
    queue<ll> q;
    cin>>k;
    c=1;
    if(k%2==0)cout<<"-1"<<endl;
    else
    {
       n=7;
       d=0;
       q.push(d);
       while(n%k!=0)
       {
           if(n<k)
           {
               n=n*10+7;
               c++;
           }
           else if(n>=k)
           {
               a=n%k;
               if(a!=q.front())
               {
                  q.pop();
                  q.push(a);
                  c++;
               }
               else
               {
                   d=1;
               }
               n=a*10+7;
           }
           if(d==1||c>1000000)break;
       }
       if(d==1||c>1000000)cout<<"-1"<<endl;
       else cout<<c<<endl;
    }
    return 0;
}


Measured memory_bytes: 3628
n = gets.to_i
strs = []
n.times { strs << gets.chomp }
 
checks = []
strs.each do |str|
  checks << str.chars.sort.join('')
end
 
checks = checks.group_by { |i| i }.values
 
num = 0
checks.each do |check|
  num += check.size*(check.size-1)/2
end
 
p num

Measured memory_bytes: 41596
A,B,C = list(map(int,input().split()))
sum = 0
if B == C:
    sum += B*2
    B = 0
    C = 0
elif B > C:
    sum += C+B
    B -=C
    C = 0
else:
    sum += B*2
    C -=B
    B = 0
if A == C:
    sum += C
elif A > C:
    sum += C
else:
    sum += A+1
print(sum)


Measured memory_bytes: 3064
using System;

namespace ABC122
{
    class A
    {
        static void Main(string[] args)
        {
            string b = Console.ReadLine();

            if (b == "A") { Console.WriteLine("T"); }
            if (b == "T") { Console.WriteLine("A"); }
            if (b == "G") { Console.WriteLine("C"); }
            if (b == "C") { Console.WriteLine("G"); }
        }
    }
}


Measured memory_bytes: 11092
def solve(num, l):
  if num == 0:
    return l

  l.append(num % 2)
  return solve(num // 2, l)

while True:
  try:
    num = int(input())
    nums = solve(num, [])
    ans = ""
    for i, v in enumerate(nums):
      if v:
        ans += str(2 ** i) + " "
    print(ans.rstrip())

  except EOFError:
    break



Measured memory_bytes: 5596
#include<iostream>
using namespace std;
int main(){
  string S;
  int ans=0;
  cin>>S;
  for(int i=1;i<S.length();i++){
    if(S[i]==S[i-1]){
      ans++;
      if(S[i]=='0') S[i]='1';
      else S[i]='0';
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <list>
#include <cstring>
#include <map>
#include <queue>
#include <ctime>
#include <set>
#include <sstream>
#include <unordered_set>
#include <unordered_map>
#include <cmath>

#define pb push_back
#define mp make_pair
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ull unsigned long long
#define iloop(a,b) for(ll i = a; i < b; ++i)
#define jloop(a,b) for(ll j = a; j < b; ++j)
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(typeofa((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define p(a) cout << a << "\n";
#define p1(a) cout << a << " ";

#define PI 3.141592653589793
#define MOD (ll)(1e9 + 7)

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

void solve()
{
	int n;
	cin >> n;
	int a = n%10;
	int b = (n/100)%10;
	if(a == b)
		p("Yes")
	else
		p("No")
}
int main()
{
	bool testing = false;
	IOS
	if(testing)
	{
		freopen("test.txt","rt",stdin);
		int start = clock();
		solve();
		int end = clock();
		cout << "time: " << (end - start)/(double)(CLOCKS_PER_SEC)*1000 << " milliseconds\n";
	}
	else
	{
		solve();
	}
} 

Measured memory_bytes: 256
class dice:
    def __init__(self,A):
        self.side = {
            "TOP":A[0],
            "S":A[1],
            "E":A[2],
            "W":A[3],
            "N":A[4],
            "BOT":A[5],
            }
        self.reverse = {
            "E":"W",
            "W":"E",
            "S":"N",
            "N":"S"}
        
    def main(self,A):
        for s in A:
            var = int(self.side[s])
            self.side[s] = self.side["TOP"]
            self.side["TOP"] = self.side[self.reverse[s]]
            self.side[self.reverse[s]] = self.side["BOT"]
            self.side["BOT"] = var
        # print("{}".format(self.side["TOP"]))
    def rotate(self,top,flont):
        if self.side["TOP"] != top:
            if self.side["BOT"] == top:
                self.main("NN")
            elif self.side["N"] == top:
                self.main("S")
            elif self.side["S"] == top:
                self.main("N")
            elif self.side["E"] == top:
                self.main("W")
            elif self.side["W"] == top:
                self.main("E")
        for x in range(4):
            if self.side["S"] == flont:
                break
            else:
                var = int(self.side["N"])
                self.side["N"] = self.side["E"]
                self.side["E"] = self.side["S"]
                self.side["S"] = self.side["W"]
                self.side["W"] = var
        print(self.side["E"])

var = dice(list(map(int,input().split())))
# var.main(input())
num = int(input())
for n in range(num):
    top,front = map(int,input().split())
    var.rotate(top,front)


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

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

    vector<string> s(n);
    for(int i=0; i<n; i++){
        cin >> s[i];
    }

    vector<vector<int>> word(n, vector<int>(26));
    for(int i=0; i<n; i++){
        for(int j=0; j<s[i].length();j++){
            word[i][s[i][j] - 'a'] += 1;
        }
    }
    for(int j=0; j<26; j++){
        int count = 100;
        for(int i=0; i<n;i++) count = min(count, word[i][j]);
        for(int i=0; i<count;i++) cout << (char)('a' + j);
    }
    cout << endl;
    return 0;
}

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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

#define maxn 100005
int A[maxn];
ll dp[maxn];

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

    for(int i = 0; i < N; ++i) 
        scanf("%d", A + i);

    dp[1] = abs(A[0] - A[1]);

    for(int i = 2; i < N; ++i) 
        dp[i] = min(dp[i - 1] + abs(A[i - 1] - A[i]), dp[i - 2] + abs(A[i - 2] - A[i]));
    
    printf("%lld\n", dp[N - 1]);
    
    return 0;
}

Measured memory_bytes: 1408
a = int(input())
i = 1
while(True):
  if a == 4:
    print(i+3)
    break
  elif a == 2 or a == 1:
  	print(i+3)
  	break
  else:
    if a % 2 == 0:
      a //= 2
      i += 1
    else:
      a = a*3 + 1
      i += 1
      


Measured memory_bytes: 38256
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int ans=2100000000,a[3];
int main(){
	for(int i=0;i<3;i++) scanf("%d",&a[i]);
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			if(j!=i)
				for(int k=0;k<3;k++)
					if(k!=i&&k!=j)
						ans=min(ans,abs(a[j]-a[i])+min(abs(a[k]-a[i]),abs(a[k]-a[j])));
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
import sys

N, Y = map(int,input().split())
for i in range(N+1):
    for j in range(N-i+1):
        if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y:
            print(i, j, N - i - j)
            sys.exit()
print(-1, -1, -1)

Measured memory_bytes: 9092