akhauriyash/Code-Regression huggingface dataset:
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

const int MAX = 510000;
 const int MOD = 1000000007;
 
 long long fac[MAX], finv[MAX], inv[MAX];
 
 // テーブルを作る前処理
 void COMinit() {
     fac[0] = fac[1] = 1;
     finv[0] = finv[1] = 1;
     inv[1] = 1;
     for (int i = 2; i < MAX; i++){
         fac[i] = fac[i - 1] * i % MOD;
         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
         finv[i] = finv[i - 1] * inv[i] % MOD;
     }
 }
 
 // 二項係数計算
 long long COM(int n, int k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
 }
 long long modpow(long long a, long long n) {
      long long res = 1;
      while (n > 0) {
          if (n & 1) res = res * a % MOD;
          a = a * a % MOD;
          n >>= 1;
      }
      return res;
  }
  
 ll inv_mul(ll x, ll y){
     return (x % MOD* modpow(y,MOD-2))%MOD;
 }

int main() {
    COMinit();
    ll n;
    ll result = 0;
    std::cin >> n;
    for (int i = 0; i <= (ll)pow(4,10); i++) {
        ll now = i;
        ll now_v=0;
        ll count = 0;
        bool out = false;
        while(true){
            if(now%4==0){
                out = true;
                break;
            }
            now_v += (( (now)%4)*2+1 )*(ll)pow(10,count);
            
            count++;
            now = (now)/4;
            if(now==0){
                break;
            }
        }
        if(out){
            continue;
        }
        // std::cout << now_v<<" "<<i << std::endl;
        if(now_v>n){
            break;
        }
        std::stringstream ss;
        ss << now_v;
        std::string str = ss.str();
        map<ll,bool> ok;
        
        for (int i = 0; i < str.length(); i++) {
            ok[str[i]-'0'] = true;
        }
        if( ok[3] && ok[5] && ok[7] ){
            result++;
        }
    }
    std::cout << result << std::endl;
}


Measured memory_bytes: 12416
#include <stdio.h>

int main(){
  char b[1];
  if(scanf("%s",b)==1){}
  switch(b[0]){
    case 'A':
      printf("T");
      break;
    case 'C':
      printf("G");
      break;
    case 'G':
      printf("C");
      break;
    case 'T':
      printf("A");
      break;      
  }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#define int long 
using namespace std;

signed main() {
	int A,B,C,D,E;
	cin >> A >> B >> C >> D >> E;
	int Acount = A % 10;
	int Bcount = B % 10;
	int Ccount = C % 10;
	int Dcount = D % 10;
	int Ecount = E % 10;
	if(Acount == 0) {
		Acount += 10;
	}
	if(Bcount == 0) {
		Bcount += 10;
	}
	if(Ccount == 0) {
		Ccount += 10;
	}
	if(Dcount == 0) {
		Dcount += 10;
	}
	if(Ecount == 0) {
		Ecount += 10;
	}
	int AA,BB,CC,DD,EE;
	for(int i = 0;i < 20;i++) {
		if(A <= 10 * i) {
			AA = 10 * i;
			break;
		}
	}
	for(int i = 0;i < 20;i++) {
		if(B <= 10 * i) {
			BB = 10 * i;
			break;
		}
	}
	for(int i = 0;i < 20;i++) {
		if(C <= 10 * i) {
			CC = 10 * i;
			break;
		}
	}
	for(int i = 0;i < 20;i++) {
		if(D <= 10 * i) {
			DD = 10 * i;
			break;
		}
	}
	for(int i = 0;i < 20;i++) {
		if(E <= 10 * i) {
			EE = 10 * i;
			break;
		}
	}
	int N = min(Acount,min(Bcount,min(Ccount,min(Dcount,Ecount))));
	int S = AA + BB + CC + DD + EE;
	if(N == Acount) {
		cout << S - (10 - Acount) << endl;
	}
	else if(N == Bcount) {
		cout << S - (10 - Bcount) << endl;
	}
	else if(N == Ccount) {
		cout << S - (10 - Ccount) << endl;
	}
	else if(N == Dcount) {
		cout << S - (10 - Dcount) << endl;
	}
	else if(N == Ecount) {
		cout << S - (10 - Ecount) << endl;
	}
}

Measured memory_bytes: 256
//Harjot Singh Student NIT JALANDHAR	

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long int ll;
struct item
{
	int wt,val;
};
int main()
{
   

    int n,w;
    cin>>n>>w;
      item arr[n];
      for(int i=0;i<n;i++)
      	cin>>arr[i].wt>>arr[i].val;
    
    ll dp[n+1][w+1];

    for(int i=0;i<=w;i++)
    	dp[0][i]=0;

    for(int j=0;j<=n;j++)
    	dp[j][0]=0;

    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=w;j++)
    	{
    		dp[i][j]=dp[i-1][j];
    		if(j>=arr[i-1].wt)
    			dp[i][j]=max(dp[i][j],dp[i-1][j-arr[i-1].wt]+arr[i-1].val);
    	}
    }

     

     cout<<dp[n][w]<<endl;
	return 0;
}

Measured memory_bytes: 79104
from math import sqrt

A, B = map(int, input().split())
rootA = int(sqrt(A))+1
rootB = int(sqrt(B))+1

PrimeFactorA = []
PrimeFactorB = []
for i in range(2, rootA+1):
	while A%i == 0:
		A //= i
		PrimeFactorA.append(i)
	if A == 1:
		break
else:
	PrimeFactorA.append(A)
PrimeFactorA = set(PrimeFactorA)

for i in range(2, rootB+1):
	while B%i == 0:
		B //= i
		PrimeFactorB.append(i)
	if B == 1:
		break
else:
	PrimeFactorB.append(B)
PrimeFactorB = set(PrimeFactorB)

count = 1
for a in PrimeFactorA:
	if a in PrimeFactorB:
		count += 1

print(count)

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int a[51][51], b[51][51];

signed main() {
  int n, m;
  cin >> n >> m;

  rep(i, 0, n) {
    string s;
    cin >> s;
    rep(j, 0, n) {
      a[i][j] = s[j];
    }
  }
  rep(i, 0, m) {
    string s;
    cin >> s;
    rep(j, 0, m) {
      b[i][j] = s[j];
    }
  }

  rep(i, 0, n - m + 1) {
    rep(j, 0, n - m + 1) {
      bool f = 1;
      rep(k, 0, m) {
        rep(l, 0, m) {
          if(a[k + i][l + j] != b[k][l]) f = 0;
        }
      }
      if(f) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))


n,m,q = inpl()
abc = [inpl() for _ in range(q)]
q = deque()
q.append([1])
res = 0
while q:
    now = q.popleft()
    if len(now) == n+1:
        # print(now)
        ans = 0
        for i,x in enumerate(abc):
            a,b,c,d = x
            if now[b] - now[a] == c:
                ans += d
        res = max(ans, res)
        continue
    for i in range(now[-1], m+1):
        q.append(now + [i])
print(res)


Measured memory_bytes: 113188
#include <cstdio>
#define INF 1e9
#define eps 1e-6
typedef long long ll;

int a, b, c;

int main(){

	scanf("%d%d", &a, &b);
	if(b * 2 < a)
		printf("%d\n", a - b * 2);
	else
		puts("0");

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  int n; cin >>n;
  cout << n*n;
}

/// confirm df==0 ///

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int a, x;
	cin >> x >> a;

	if (x < a)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << 10 << endl;
	}

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
 
n = int(input())
s = [input().strip() for _ in range(n)]
plus = []
minus = []
for i in s:
    min_v = 0
    sum_v = 0
    for j in i:
        sum_v += 1 if j == '(' else -1
        min_v = min(min_v, sum_v)
    if sum_v > 0:
        plus.append((min_v, sum_v))
    else:
        minus.append((min_v-sum_v, -sum_v))
 
plus.sort(key=lambda x:x[0], reverse=True)
minus.sort(key=lambda x:x[0], reverse=True)
 
sum_plus = 0
for min_v, sum_v in plus:
    if sum_plus + min_v < 0:
        print("No")
        exit()
    sum_plus += sum_v
 
sum_minus = 0
for min_v, sum_v in minus:
    if sum_minus + min_v < 0:
        print("No")
        exit()
    sum_minus += sum_v
 
if sum_plus == sum_minus:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 92020
#include <iostream>
#include <string>
#include <stack>
#include <vector>
using namespace  std;

struct StDtl
{
  int m_nLeft;

  StDtl(int nLeft) :
    m_nLeft(nLeft)
  { }

  ~StDtl() { }
};

struct StSum
{
  int m_nLeft;
  int m_nRight;
  int m_nArea;

  StSum(int nLeft, int nRight, int nArea) :
    m_nLeft(nLeft), m_nRight(nRight), m_nArea(nArea)
  { }

  ~StSum() { }
};

void fnCroSecSet(stack<StDtl> &rskStDtl, vector<StSum> &rvStSum, int &rnTotalArea)
{
  string sCrossSect;
  cin >> sCrossSect;

  for (int i = 0; i < sCrossSect.size(); i++)
  {
    if (sCrossSect[i] == '\\')
    {
      StDtl oDtl(i);
      rskStDtl.push(oDtl);
    }
    else if (sCrossSect[i] == '/')
    {
      if (rskStDtl.size() > 0)
      {
        int nLeft = rskStDtl.top().m_nLeft; rskStDtl.pop();
        int nSum = i - nLeft; 
        rnTotalArea += nSum;

        while (rvStSum.size()  &&
               nLeft < rvStSum.back().m_nLeft  &&
               rvStSum.back().m_nRight < i       )
        {
          nSum += rvStSum.back().m_nArea;
          rvStSum.pop_back();
        }
        StSum oSum(nLeft, i, nSum);
        rvStSum.push_back(oSum);
      }
      else;
    }
  }
}

void  fnCroSecGet(const vector<StSum> &cnrvStSum, int nTotalArea)
{
  cout << nTotalArea << endl;
  cout << cnrvStSum.size();
  if (cnrvStSum.size() > 0)
  {
    cout << " ";
    for (auto itvStSum = begin(cnrvStSum); itvStSum != end(cnrvStSum); ++itvStSum)
    {
      if (itvStSum != begin(cnrvStSum)) cout << " ";
      cout << itvStSum->m_nArea;
    }
  }
  cout << endl;
}

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

  stack<StDtl> skStDtl;
  vector<StSum> vStSum;
  int iTtlAra = 0;

  fnCroSecSet(skStDtl, vStSum, iTtlAra);
  fnCroSecGet(vStSum, iTtlAra);

  return 0;
}

Measured memory_bytes: 1328
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v) { cout << v << endl; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

bool dfs(vector<ll> A, int k) {
  if (A[0] < A[1] and A[1] < A[2]) {
    return true;
  }
  
  if (k==0) {
    return false;
  }
  
  bool result = false;
  auto B = A;
  B[1] *= 2;
  result |= dfs(B, k-1);
  A[2] *= 2;
  result |= dfs(A, k-1);
  return result;
}

int main() {
  int n = 3;
  vector<ll> A(n);
  loop(i,0,n) in(A[i]);
  int k; in(k);
  if (dfs(A, k)) print("Yes");
  else print("No");
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9+7;
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};

void solve() {
    string s;
    cin >> s;
    if(s=="ABC"){
        cout << "ARC\n";
    }
    else{
        cout << "ABC\n";
    }
}

signed main() {
    boost;
    solve();
}

Measured memory_bytes: 3616
import scala.io.Source.stdin

object Main extends App {
  def gcd(m:Long,n:Long):Long = if(n==0) m else gcd(n, m % n)

  println {
    {
      for(l <- stdin.getLines) yield {
      	  val s	= l.split(" ").map(_.toLong)
          val g = gcd(s(0),s(1))
          g + " " + (s(0)*s(1)/g)
      }
    }.mkString("\n")
  }
}

Measured memory_bytes: 43700
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define P pair<int,int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

#define MAX_V 2000
struct edge { int to, cost; };
int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P>>	que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();	que.pop();
        int v = p.second;
        if (d[v] < p.first)	continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[v] + e.cost < d[e.to]) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    int X, Y;  cin >> V >> X >> Y;  X--, Y--;
    for(int i = 0 ; i < V - 1 ; i++){
      G[i].push_back(edge{i + 1, 1});
      G[i+1].push_back(edge{i, 1});
    }
    G[X].push_back(edge{Y, 1});
    G[Y].push_back(edge{X, 1});

    M mp;
    for(int i = 0 ; i <= V ; i++)  mp[i] = 0;
    for(int i = 0 ; i < V - 1; i++){
      dijkstra(i);
      for(int j = i + 1 ; j < V ; j++)
        mp[d[j]]++;
    }

    for(int i = 1 ; i < V ; i++)  cout << mp[i] << endl;
    
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T, typename U, typename V>
ostream &operator<<(ostream &os, const tuple<T, U, V> &t){
  os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef tuple<int, int, int> TT;
typedef pair<int, TT> PT;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);


const int mod = 1e9+7, MAX = 10000;
// fac[n]: n!, inv[n]:1/n, finv[n]:1/n!
int fac[MAX], inv[MAX], finv[MAX];

// テーブルを作る前処理
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i-1]*i%mod;
        inv[i] = mod-inv[mod%i]*(mod/i)%mod;
        finv[i] = finv[i-1]*inv[i]%mod;
    }
}

// 二項係数計算
int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

signed main(){
  int n, k;cin >> n >> k;
  COMinit();
  rrep(i,k){
    int ans = COM(n-k+1, i) * COM(k-1, i-1) % mod;
    cout << ans << endl;
  }
  return 0;
}






Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m; string f[505];
int main(){
	cin>>n;
	rep(i,n)cin>>f[i];
	int ans = INF;
	rep(i,n){
		int cnt = 0;
		rep(j,n) cnt+=f[i][j]=='#';
		if(cnt == 0) continue;
		int ret = n-cnt; cnt = 0;
		rep(j,n) cnt += f[j][i]=='#';
		if(cnt == 0) ret++;
		rep(j,n){
			rep(i,n) if(f[i][j]=='.') {ret++;break;}
		}
		ans=min(ans,ret);
	}
	if(ans>1e8) ans=-1;
	cout<<ans<<endl;
}

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

int main(){
    int N; cin >> N;
    long long prev; cin >> prev;
    prev--;
    bool flag = true;
    for(int i=0; i < N-1; i++){
        long long h; cin >> h;
        if(prev > h){
            flag = false;
            break;
        } else if(prev == h){
            prev = h;
        } else {
            prev = h - 1;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#include <utility>
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1e9
typedef long long int ll;
using namespace std;

int main(){
    int n,h,w;
    cin >> n >> h >> w;

    cout << (n-w+1)*(n-h+1) << endl;

    return 0;
}

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

int main() {
  string S, T;
  int res = 0;
  cin >> S >> T;
  for(int i= 0; i < S.size(); i++) {
    if(S.at(i) != T.at(i)) {
    res++;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3836
#include <iostream>

using namespace std;

int main(int argc, const char *argv[]) {
  int N, a;
  cin >> N;

  while(1){
    a = N % 10;
    N /= 10;
    if(a == 7){
      cout << "Yes" << endl;
      return 0;
    }
    if(N == 0){
      break;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = 0;
    ans = (n/(a+b))*a;
    ll ama = min(n - (n/(a+b))*(a+b), a);
    ans += ama;
    cout << ans << endl;
    return 0;
}

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

using ULLint = unsigned long long int;

int Egcd(ULLint x, ULLint y) {
	if (y == 0) return x;
	return Egcd(y, x % y);
}

int Glcd(ULLint x, ULLint y, int gcd) {
	return x * y / gcd;
}

int main() {
	ULLint a, b;
	while (cin >> a >> b)
		cout << Egcd(a, b) << " " << Glcd(a, b, Egcd(a, b)) << endl;
	return 0;
}


Measured memory_bytes: 3068
#include <iostream>
#include <math.h>
#include <stdio.h>

#define MAX_N 1'000'000'000'000'000'000

typedef long long ll;

using namespace std;

int main() {
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  ll res = K % 2 == 0 ? A - B : B - A;
  if (abs(res) >= MAX_N) {
    printf("Unfair\n");
  } else {
    printf("%lld\n", res);
  }
}

Measured memory_bytes: 3216
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE


void solve(void)
{
  int N,K;
  cin>>N>>K;
  int ANS = 0;
  for (int b = K+1; b <= N; b++)
  {
    int Q =N/b;
    int R = N%b;
    ANS += Q*(b-K) + max(0LL,R-K+1);
    // DEBUG(b,ANS);
  }
  if(K == 0) ANS -= N;//If K == 0, above summation occur Duplication Conting. 
  cout<<ANS<<endl;
  

  return;
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int dfs(vector<set<int> > &G, int v, vector<int> &deg, vector<bool> &del){
  if(del[v]) return 0;
  if(deg[v] == 1) del[v] = true;
  else return 0;
  int num = 1;
  for(const int& u : G[v]){
    G[u].erase(v);
    --deg[u];
    num += dfs(G, u, deg, del);
  }
  return num;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,M;cin >> N >> M;
  vector<set<int> >G(N);
  vector<int> deg(N,0);
  vector<bool> del(N,false);
  rep(j,M){
    int x,y;cin >> x >> y;
    --x;--y;
    G[x].insert(y);
    G[y].insert(x);
  }
  rep(i,N) deg[i] = G[i].size();
  int num = 0;
  rep(i,N) num += dfs(G,i,deg,del);

  cout << num << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
#define mop2 998244353

using namespace std;

void print(vector <ll> v) {
	for (auto itr = v.begin(); itr != v.end(); itr++) {
		cout << *itr;
		if (itr+1 != v.end()) {
			cout << " ";
		}
	}
	cout << endl;
}

void insertionSort(vector <ll> v) {
	ll n = v.size();
	for (ll i = 0; i < n; i++) {
		ll vt = v[i];
		ll j = i - 1;
		while (j >= 0 && vt < v[j]) {
			v[j + 1] = v[j];
			j--;
		}
		v[j+1] = vt;
		print(v);
	}
}

int main() {
	ll n;
	cin >> n;
	vector <ll> v;
	v.resize(n);
	for (ll i = 0; i < n; i++) {
		ll tmp;
		cin >> tmp;
		v[i] = tmp;
	}
	insertionSort(v);
	
}


Measured memory_bytes: 3120
x = int(input())
flg = 0
def isPrimenum(n):
	if n < 2:
		return False
	if n == 2:
		return True
	for p in range(2, n):
		if n % p == 0:
			return False
	return True
while flg == 0:
	if isPrimenum(x) == True:
		flg = 1
		break
	x += 1
print (x)


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

int main(){
    int n, l; cin >> n >> l;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    sort(s.begin(), s.end());

    string ans="";
    rep(i, n){
        ans.append(s[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3580
class UnionFind:
    __slots__ = ["N", "root"]

    def __init__(self, N):
        """
        N:要素数
        root:各要素の親要素の番号を格納するリスト.
             ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
        """
        self.N = N
        self.root = [-1] * N

    def __repr__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    def find(self, x):
        """頂点xの根を見つける"""
        r = x
        while self.root[r] >= 0:
            r = self.root[r]

        while self.root[x] >= 0:
            self.root[x], x = r, self.root[x]

        return r

    def union(self, x, y):
        """x, yが属する木をunion"""
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.root[y] < self.root[x]:
            x, y = y, x
        self.root[x] += self.root[y]
        self.root[y] = x

    def same(self, x, y):
        """xとyが同じグループに属するかどうか"""
        return self.find(x) == self.find(y)

    def count(self, x):
        """頂点xが属する木のサイズを返す"""
        return - self.root[self.find(x)]

    def members(self, x):
        """xが属する木の要素を列挙"""
        _root = self.find(x)
        return [i for i in range(self.N) if self.find(i) == _root]

    def roots(self):
        """森の根を列挙"""
        return [i for i, x in enumerate(self.root) if x < 0]

    def group_count(self):
        """連結成分の数"""
        return len(self.roots())

    def all_group_members(self):
        """{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す"""
        return {r: self.members(r) for r in self.roots()}


import sys
input = sys.stdin.readline
n, q = map(int, input().split())
uf = UnionFind(n)
res = []
for i in range(q):
    t, u, v = map(int, input().split())
    if t:
        res.append(int(uf.same(u, v)))
    else:
        uf.union(u, v)
print("\n".join(map(str, res)))


Measured memory_bytes: 83448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  ll x,l;
  cin>>n;
  pair<ll,ll>itv[n];
  for(ll u=0;u<n;u++){
    cin>>x>>l;
    itv[u].first=x+l;
    itv[u].second=x-l;
  }
  
  sort(itv,itv+n);
  ll ans=0,t=-pow(10,10);
  
  for(ll i=0;i<n;i++){
    //cout<<itv[i].first<<" "<<itv[i].second<<endl;
    if(t<=itv[i].second){
      ans++;
      t=itv[i].first;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>
#include <math.h>
#include <string.h>


using namespace std;


void f(bool box[12][12]){
    for(int i=1; i<=10; i++){
        for(int j=1; j<=10; j++){
            cout<<box[i][j];
        }
        cout<<endl;
    }
    cout<<endl;
}

int main(){
    int n;
    while(cin>>n){
        for(int roop=0; roop<n; roop++){
            bool box[12][12]={0};
            
            for(int i=1; i<=10; i++){
                for(int j=1; j<=10; j++){
                    cin>>box[i][j];
                }
            }
            //cout<<"----------------------"<<endl;
            
            bool box2[12][12]={0};
            
            for(int i=0; i<(1<<11 - 1); i++){
                memcpy(box2, box, sizeof(box));
                int l[12][12]={0};
                for(int j=1; j<=10; j++){
                    l[0][j]= (i>>(j-1))%2;
                    //cout<<l[0][j];
                }
                
                //cout<<endl;
                
                for(int j=1; j<=10; j++){
                    for(int k=1; k<=10; k++){
                        if(l[j-1][k]==1){
                            box2[j][k]=(box2[j][k]+1)%2;
                            box2[j][k+1]=(box2[j][k+1]+1)%2;
                            box2[j][k-1]=(box2[j][k-1]+1)%2;
                            box2[j-1][k]=(box2[j-1][k]+1)%2;
                            box2[j+1][k]=(box2[j+1][k]+1)%2;
                        }
                    }
                    
                    for(int k=1; k<=10; k++){
                        l[j][k]=box2[j][k];
                    }
                }
                
                bool end_flag=true;
                for(int i=1; i<=10; i++){
                    if(l[10][i]==1){
                        end_flag=false;
                        break;
                    }
                }
                
                
                if(end_flag){
                    for(int i=0; i<=9; i++){
                        for(int j=1; j<=10; j++){
                            cout<<l[i][j];
                            if(j==10)break;
                            cout<<" ";
                        }
                        cout<<endl;
                    }
                    break;
                    
                }
            }
            //cout<<"============================"<<endl;
            
            

        }
                
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,x; cin >>n >>m >>x; int ans=0;
  vector<vector<int>>a(n,vector<int>(m));
  vector<int>c(n);
  for(int i=0; i<n; i++)
  {cin >>c[i]; for(int j=0; j<m; j++) cin >>a[i][j];}
  for(int i=1; i<(1<<n); i++)
  {
    int ii=i,jj=0,anst=0; bool shit=1;
    vector<int>u(m);
    while(ii){
      if(ii%2){
        anst+=c[jj];
        for(int j=0; j<m; j++) u[j]+=a[jj][j];
      }
      ii/=2; jj++;
    }
    for(int j=0; j<m; j++) if(u[j]<x){shit=0; break;}
    if(shit){
      if(ans) ans=min(ans,anst);
      else ans=anst;
    }
  }
  cout <<(ans==0?-1:ans);
return 0;}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    vector<int> vec(N, 0);
    for(int i=0; i<N; i++){
       vec[A[i]-1] = i+1; 
    }
    for(int i=0; i<N; i++){
       cout << vec[i] << ' '; 
    }
}

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

using namespace std;

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

Measured memory_bytes: 3912
import math
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
m = max(math.ceil(N/A),math.ceil(N/B),math.ceil(N/C),math.ceil(N/D),math.ceil(N/E))
print(m+4)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pi M_PI
#define inf 1<<30
#define eps (1e-11)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1=Point(),Point p2=Point()):p1(p1),p2(p2){}
};
typedef Segment Line;

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

static const int COUNTER_CLOCKWISE=1;
static const int CLOCKWISE=-1;
static const int ONLINE_BACK=2;
static const int ONLINE_FRONT=-2;
static const int ON_SEGMENT=0;

int ccw(Point p0,Point p1,Point p2){
  Vector a=p1-p0;
  Vector b=p2-p0;
  if(cross(a,b)>eps)return COUNTER_CLOCKWISE;
  if(cross(a,b)<-eps)return CLOCKWISE;
  if(dot(a,b)<-eps)return ONLINE_BACK;
  if(a.norm()<b.norm())return ONLINE_FRONT;
  return ON_SEGMENT;
}

bool intersect(Point p1,Point p2,Point p3,Point p4){
  return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 &&
          ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}

bool intersect(Segment s1,Segment s2){
  return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

int n,m;
vector<Point> a,b;
double dis[1001][1001];
Segment s;

void init(){
  for(int i=0;i<1000;i++)for(int j=0;j<1000;j++)dis[i][j]=inf;
}

double dijkstra(int size){
  double d[1000];
  for(int i=0;i<1000;i++)d[i]=inf;
  priority_queue<pair<double,int> > pq;
  pq.push(mp(0,0));
  d[0]=0;

  while(!pq.empty()){
    pair<double,int> u=pq.top();
    pq.pop();
    u.f*=-1;

    if(d[u.s]<u.f)continue;

    for(int i=0;i<size;i++){
      if(dis[u.s][i]==inf)continue;
      if(u.f+dis[i][u.s]<d[i]){
	d[i]=u.f+dis[i][u.s];
	pq.push(mp(d[i]*(-1),i));
      }
    }
  }
  return d[1];
}

int main()
{
  int x,y;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    a.push_back(Point(x,y));
  }
  for(int i=0;i<m;i++){
    cin>>x>>y;
    b.push_back(Point(x,y));
  }
  
  double ans=inf;
  
  s=Segment(b[0],b[1]);
  init();
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i==j)continue;
      if(intersect(Segment(a[i],a[j]),s))continue;
      dis[i][j]=abs(a[i]-a[j]);
    }
  }
  ans=min(dijkstra(n)+abs(b[0]-b[1]),ans);
  
  s=Segment(a[0],a[1]);
  init();
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      if(i==j)continue;
      if(intersect(Segment(b[i],b[j]),s))continue;
      dis[i][j]=abs(b[i]-b[j]);
    }
  }
  ans=min(dijkstra(m)+abs(a[0]-a[1]),ans);
  
  if(ans<inf)printf("%.10f\n",ans);
  else cout<<-1<<endl;

  return 0;
}

Measured memory_bytes: 9196
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int dp[2][5555];
vector<int>ko[1111];
int mok[1111];
int dfs(int node)
{
	vector<int>v;
	for (int i = 0; i < ko[node].size(); i++)v.push_back(dfs(ko[node][i]));
	int cur = 0;
	for (int i = 0; i <= mok[node]; i++)dp[0][i] = 0, dp[1][i] = 1000000000;
	for (int i = 0; i < ko[node].size(); i++)
	{
		int z = v[i], y = mok[ko[node][i]];
		for (int j = 0; j <= mok[node]; j++)
		{
			if (j + y <= mok[node])dp[1 - cur][j + y] = min(dp[1 - cur][j + y], dp[cur][j] + z);
			if (j + z <= mok[node])dp[1 - cur][j + z] = min(dp[1 - cur][j + z], dp[cur][j] + y);
		}
		for (int j = 0; j <= mok[node]; j++)dp[cur][j] = 1000000000;
		cur = 1 - cur;
	}
	return dp[cur][mok[node]];
}
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 1; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		z--;
		ko[z].push_back(i);
	}
	for (int i = 0; i < num; i++)scanf("%d", &mok[i]);
	if (dfs(0) >= 1000000000)printf("IMPOSSIBLE\n");
	else printf("POSSIBLE\n");
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long 
#pragma GCC optimize("Ofast", "unroll-loops")
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define pii pair<int,int>
#define SZ(x) x.size()
#define ALL(x) x.begin(), x.end()
#define ull unsigned ll 
#define pb push_back
#define f first 
#define s second
using namespace std;
int main (){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	if (c-(a-b)<=0) cout<<0<<'\n';
	else cout<<c-(a-b)<<'\n';
}

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

signed main(void){ 
  int N; cin >> N;
  string S; cin >> S;
  
  map<pair<string,string>,int> mp;
  
  string former = S.substr(0,N); string later = S.substr(N,N);
  
  int ans = 0;
  
  for(int bit = 0; bit < (1<<N); bit++){
    
    string a = "",b = "";
    
    for(int i = 0; i < N; i++){ 
      if( bit>>i&1 ){ a +=later[i];}
      else{ b += later[i];}
    }
    
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    
    mp[{a,b}]++;
  }
  
  for(int bit = 0; bit < (1<<N); bit++){ 
    
    string a = ""; string b = "";
    
    for(int i = 0; i < N; i++){ 
      if( bit>>i&1 ){ a += former[i];}
      else{ b += former[i];}
    }
    
    ans += mp[{a,b}];
  }

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

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

int main(void){
    int a,b;
    cin >> a;
    cin >> b;
    int d =a/b;
    int r =a%b;
    double f =double(a)/double(b);
    cout << d;
    cout << " ";
    cout << r;
    cout << " ";
    cout << fixed << setprecision(5) << f;
    cout << endl;
}



Measured memory_bytes: 3288
import std;

long calc(long[] a) {
    if (a.any!(e => e == 0)) return 0;

    long x = 1;
    foreach (e; a) {
        long y = x * e;
        if (y < x) return -1; // overflow
        if (y > 10L ^^ 18) return -1;
        x = y;
    }
    return x;
}

void main() {
    int n; scan(n);
    auto a = reads!long;
    writeln(calc(a));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;


Measured memory_bytes: 8056
N,K=map(int,input().split())


d=[]
a=[]
for i in range(K):
  d.append(input())
  a.extend(map(int,input().split()))

n=[]
for j in range(N):
  n.append(j+1)
  
cnt=0
for j in range(N):
  if a.count(j+1)==0:
    cnt=cnt+1
print(cnt)

Measured memory_bytes: 9200
#include<stdio.h>
static const int INFTY = (1<<21);
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2


int n,v,i,M[MAX][MAX];
int prim(void);

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

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j]=(e==-1)?INFTY:e;
    }
  }
  printf("%d\n",prim());
  return 0;
}

int prim(){
  int u,minv,sum=0;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }

  d[0]=0;

  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACK){
        u=i;
        minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK&&M[u][v]!=INFTY){
        if(d[v]>M[u][v]){
          d[v]=M[u][v];
          p[v]=u;
          color[v]=GRAY;
        }
      }
    }
  }
  for(i=0;i<n;i++){
    if(p[i]!=-1)sum+=M[i][p[i]];
  }
  return sum;
}

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



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


		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		String[] text;
		int text_num;

		try{
			text=reader.readLine().split("");

		text_num=text.length;

		for(int i=0;i<text_num;i++){
			if(text[i].equals(text[i].toLowerCase())){
				text[i]=text[i].toUpperCase();
			}
			else if(text[i].equals(text[i].toUpperCase())){
				text[i]=text[i].toLowerCase();
			}

			System.out.print(text[i]);
		}System.out.println();


		reader.close();

		}catch(IOException e){
			System.out.println("??????:"+e);
		}




	}
}

Measured memory_bytes: 25660
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int arr[4];
    cin>>arr[0]>>arr[1]>>arr[2];
    sort(arr,arr+3);
    if(arr[0]!=arr[1])cout<<arr[0]<<endl;
    else if(arr[2]!=arr[1])cout<<arr[2]<<endl;

return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  int x;
  cin >> x;
  string ans = x < 1200 ? "ABC" : "ARC";
  cout << ans << endl;
}

Measured memory_bytes: 256
# 解説動画の通り
import sys
from bisect import *
from collections import defaultdict

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    def dfs(u):
        fin[u] = True
        for v, e in to[u]:
            if fin[v]: continue
            dfs(v)
            if xx[v]:
                ans.append(e + 1)
                xx[u] ^= 1

    n, m = MI()
    ab = [LI() for _ in range(n)]
    lr = [LI() for _ in range(m)]
    # (a,b)をaでソートして分ける
    # bは先頭と末尾に番兵の0を追加する（全部を0にするのが目標だから）
    aa = []
    bb = [0]
    for a, b in sorted(ab):
        aa.append(a)
        bb.append(b)
    bb.append(0)
    # print(aa)
    # print(bb)
    # bの差分列を作る
    xx = [b0 ^ b1 for b0, b1 in zip(bb, bb[1:])]
    # print(xx)
    # lrをxxのインデックスに対応させる
    lr = [(bisect_left(aa, l), bisect_right(aa, r)) for l, r in lr]
    # print(lr)
    # lrを辺、xxの要素を頂点としてグラフを作る
    to = defaultdict(list)
    for i, (l, r) in enumerate(lr):
        if l == r: continue
        to[l].append((r, i))
        to[r].append((l, i))
    # 各連結成分についてdfsする
    ans = []
    fin = [False] * (n + 1)
    for i in range(n + 1):
        if fin[i]: continue
        dfs(i)
        # 根が1のときは実現不可能なので-1を出力して終了
        if bb[i]:
            print(-1)
            exit()
    # 答えの出力
    ans.sort()
    print(len(ans))
    print(*ans)

main()


Measured memory_bytes: 194312
c5 = 0
c7 = 0
gets.chomp.split.map(&:to_i).each do |x|
  c5 += 1 if x == 5
  c7 += 1 if x == 7
end
puts "YES" if c5 == 2 && c7 == 1
puts "NO" if c5 != 2 || c7 != 1


Measured memory_bytes: 1788
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
vp factorize(ll n) {
    vp res;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0) continue;
        res.emplace_back(i,0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        } 
    }
    if (n != 1) res.emplace_back(n,1);
    return res;
}
int main(){
  ll n,p;cin>>n>>p;
  vp res=factorize(p);
  ll ans=1;
  
  rep(i,0,res.size()){
    if(res[i].second>=n){
      ll tmp=pow(res[i].first,res[i].second/n);
      ans*=tmp;
    }
  }
  cout<<ans<<endl;
}


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

using namespace std;

int main(){
	int a, b; cin >> a >> b;
	for(int i = 1; i <= 3; ++i){
		if((a*b*i)%2 != 0){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main()
{
	int h,w;
	scanf("%d%d",&h,&w);
	int dp[1005] = {};
	char c[1005];
	for(int i=1; i<=h; i++)
	{
		scanf("%s",c+1);
		for(int j=1; j<=w; j++)
			if(c[j]=='#') dp[j] = 0;
			else if(i==1&&j==1) dp[j] = 1;
			else dp[j] = (dp[j] + dp[j-1])%mod;
	}
	printf("%d\n",dp[w]);
	return 0;
}

Measured memory_bytes: 256
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

a,b,c,d = inm()
print(max([a*c,a*d,b*c,b*d]))


Measured memory_bytes: 61828