akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll n;
	map<string,ll> mp;
	cin>>n;
	for(auto i=0;i<n;++i){
		string tmp;
		cin>>tmp;
		++mp[tmp];
	}
	ll mx=0;
	for(auto e:mp){
		mx=max(mx,e.second);
	}
	for(auto e:mp){
		if(e.second==mx)cout<<e.first<<'\n';
	}
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

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

using namespace std;

#define MAXN 200010
#define INF 0x3f3f3f3f
typedef long long LL;

int n, k, m, a[MAXN];
int b[MAXN];

int main()
{
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; ++i)
        scanf("%d", a + i);
    sort(a + 1, a + 1 + n);
    for(int i = 1; i <= n; ++i){
        if(a[i] != a[i - 1]){
            a[++m] = a[i];
        }
        ++b[m];
    }
    sort(b + 1, b + 1 + m);
    if(m <= k) printf("%d\n", 0);
    else{
        int ans = 0;
        for(int i = m - k; i; --i) ans += b[i];
        printf("%d\n", ans);
    }
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
  int N;
  int gokei;
  
  scanf("%d",&N);
   
  for(int i=1;i<=N;i++){
    gokei+=800;
    if(i%15==0)gokei-=200;
  }
  
  printf("%d",gokei);
  
  return 0;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

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

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int bfs(vs& grid,int si,int sj,int gi,int gj)
{
	int h=grid.size(),w=grid[0].size();
	vvi vis(h,vi(w));
	queue<tuple<int,int,int>> q;
	q.emplace(si,sj,0);
	while(q.size()){
		int i,j,d; tie(i,j,d)=q.front(); q.pop();
		if(i<0 || h<=i || j<0 || w<=j || grid[i][j]=='X' || vis[i][j]) continue;
		vis[i][j]=1;
		if(i==gi && j==gj) return d;
		rep(k,4) q.emplace(i+"\xff\x1\0\0"[k],j+"\0\0\xff\x1"[k],d+1);
	}
	return -1;
}

int main()
{
	for(int h,w,n;cin>>h>>w>>n;){
		vs grid(h,"#");
		rep(i,h) cin>>grid[i];
		
		rep(i,h) rep(j,w) if(grid[i][j]=='S') grid[i][j]='0';
		int res=0;
		rep(k,n){
			int si,sj,gi,gj;
			rep(i,h) rep(j,w){
				if(grid[i][j]=='0'+k)
					si=i,sj=j;
				if(grid[i][j]=='0'+k+1)
					gi=i,gj=j;
			}
			res+=bfs(grid,si,sj,gi,gj);
		}
		cout<<res<<endl;
	}
}

Measured memory_bytes: 7868
#include<stdio.h>
int main(void){
  int a,b,add,sub,mul;
  scanf("%d %d",&a,&b);
  add=a+b;
  sub=a-b;
  mul=a*b;
  if(add>sub){
    if(add>mul){
      printf("%d",add);
    }
    else{
      printf("%d",mul);
    }
  }
  else{
    if(sub>mul){
        printf("%d",sub);
    }
    else{
        printf("%d",mul);
    }
  }
  return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  vector<int> s = {a, b, c};

  sort(s.begin(), s.end());

  if((s[2]-s[1]+s[2]-s[0]) % 2 == 0) {
    cout << (s[2]-s[1]+s[2]-s[0]) / 2 << endl;
  } else {
    cout << (s[2]-s[1]+s[2]-s[0]+1) / 2 + 1 << endl;
  }
}

Measured memory_bytes: 256
<?php
//define('DEBUG', true);
define('DEBUG', false);
 
fscanf(STDIN, "%d", $N);
for ($i = 1; $i <= $N; $i++) {
    fscanf(STDIN, "%d", $A);
    $r[$i] = [];
    for ($j = 0; $j < $A; $j++) {
        fscanf(STDIN, "%d %d", $x, $y);
        $r[$i][] = [$x => $y];
    }
}
//var_dump($r);
//exit;
$ans = 0;
$pat = pow(2, $N);
for ($i = 1; $i < $pat; $i++) {
    $tmp = str_pad(base_convert($i, 10, 2), $N + 1, "0", STR_PAD_LEFT);
    if (DEBUG) echo "test " . $i . " " . $tmp . PHP_EOL;
    $a = str_split($tmp);
	$score = array_sum($a);
	if ($score <= $ans) continue;
    $rel = [];
    $wait = [];
    $done = [];
    $bool = true;
    for ($j = 1; $j <= $N; $j++) {
        if ($a[$j] === "1") {
            array_push($wait, $j);
        }
    }
	if (DEBUG) echo "wait: " . implode(',', $wait) . PHP_EOL;
	//exit;
    while($wait) {
        $target = array_pop($wait);
		if (DEBUG) echo "target: {$target}\n";
        if (in_array($target, $done)) continue;
        $done[] = $target;
        foreach ($r[$target] as $k => $v1) {
            foreach ($v1 as $k2 => $v2) {
                if (DEBUG) echo "Rule no.{$k2} => v.{$v2} !!! \n";
                if (!isset($rel[$k2])) {
                    if (DEBUG) echo "i {$k2} => {$v2}\n";
                    $rel[$k2] = $v2;
                    if ($v2 === 1) {
                        if (!in_array($k2, $wait)) {
                            array_push($wait, $k2);
                        }
                    }
                    if ($v2 === 0) {
                        if ($a[$k2] === "1") {
                            $bool = false;
                            break;
                        }
                    }
                } else {
                    if ($rel[$k2] !== $v2) {
                        if (DEBUG) echo "{$k2} = {$v2} x\n";
                        $bool = false;
                        break;
                    } else {
                        if (DEBUG) echo "{$k2} => {$v2} o\n";
                        if ($v2 === 1) {
                            if (!in_array($k2, $wait)) {
                                array_push($wait, $k2);
                            }
                        }
                        if ($v2 === 0) {
                            if ($a[$k2] === "1") {
                                $bool = false;
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
    
    if ($bool === true) {
        if (DEBUG) echo $i . PHP_EOL;
        $ans = array_sum($a);
    }
}
printf("%d", $ans);

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,m,l,r,c,i,j,mx,mn;
    cin>>n>>m;
    ll s[m],p[m];

    for(i=0;i<m;i++)
    {

        cin>>s[i]>>p[i];
        }sort(s,s+m);
        sort(p,p+m);
        for(i=0;i<m;i++)
        {
           if(p[0]-s[m-1]+1>0)c=p[0]-s[m-1]+1;
           else c=0;
        }
         cout<<c;}


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

string p(string s){
  for(int i=0;i<s.length();i++){
    if('0'<=s[i] && s[i]<='9'){
      s[i]=s[i] -1;
      if(s[i]=='0'-1)s[i]='9';
    }
  }
  return s;

}

string m(string s){
  for(int i=0;i<s.length();i++){
    if('0'<=s[i] && s[i]<='9'){
      s[i]=(s[i] -'0'+1)%10 + '0';
    }
  }
  return s;
}

string a(string s){
  string res=s;
  for(int i=0;i<s.length()/2;i++){
    res[i]=s[s.length()-1-i];
    res[s.length()-1-i]=s[i];
  }
  return res;
}

string e(string s){
  int half=s.length()/2;
  string first,latter;
  first=s.substr(0,half);
  latter=s.substr(s.length()-half,s.length());
  if(s.length()%2==0){
    return latter + first;
  }else{
    return latter + s[half] + first;
  }
}

string j(string s){
  char tmp=s[s.length()-1];
  for(int i=s.length()-1;i>0;i--){
    s[i]=s[i-1];
  }
  s[0]=tmp;
  return s;
}

string c(string s){
  char tmp=s[0];
  for(int i=0;i<s.length()-1;i++){
    s[i]=s[i+1];
  }
  s[s.length()-1]=tmp;
  return s;
}

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    string mg,mes;
    cin>>mg>>mes;
    for(int i=mg.length()-1;i>=0;i--){
      if(mg[i]=='A'){
	mes=a(mes);
      }else if(mg[i]=='J'){
	mes=j(mes);
      }else if(mg[i]=='C'){
	mes=c(mes);
      }else if(mg[i]=='E'){
	mes=e(mes);
      }else if(mg[i]=='P'){
	mes=p(mes);
      }else if(mg[i]=='M'){
	mes=m(mes);
      }
    }
    cout << mes << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
def toInteger(string):
  try:
    integer = int(string)
    return integer
  except:
    print('Number Format Exception')
    exit()

def myInput():
  s = input()
  i = toInteger(s)
  return i

def isEqual(a, b):
  try:
    1 / (a - b)
  except:
    return True
  return False

def isValue1(v):
  boolean = isEqual(v, 1)
  if isEqual(boolean, True) == True:
    return True
  elif isEqual(boolean, False) == True:
    return False
  else:
    None

def isValue2(v):
  boolean = isEqual(v, 2)
  if isEqual(boolean, True) == True:
    return True
  elif isEqual(boolean, False) == True:
    return False
  else:
    None

def printString(String):
  print(String)

def printHelloWorld():
  printString('Hello World')
  
def printInteger(integer):
  print(integer)

def sumTwoValues(a, b):
  c = a + b
  return c

def solve(v):
  boolean1 = isValue1(v)
  boolean2 = isValue2(v)
  if isEqual(boolean1, True) == True:
    printHelloWorld()
  elif isEqual(boolean2, True) == True:
    a = myInput()
    b = myInput()
    c = sumTwoValues(a, b)
    printInteger(c)
  else:
    None

def main():
  a = myInput()
  solve(a)
  
main()

Measured memory_bytes: 3064
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>
# include <thread>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ui32 = unsigned int;
constexpr ll INFLL = 1e18;

#define CHECK_IMPL1(cond)              \
if (!(cond)) {                         \
    DEBUG("expected cond: " << #cond); \
    assert(cond);                      \
}

#define CHECK_IMPL2(cond, message)                                            \
if (!(cond)) {                                                                \
    DEBUG("expected cond: " << #cond << " failed with message: " << message); \
    assert(cond);                                                             \
}
#define CHECK_IMPL(_1, _2, NAME, ...) NAME
#define CHECK(...) CHECK_IMPL(__VA_ARGS__, CHECK_IMPL2, CHECK_IMPL1, CHECK_IMPL0)(__VA_ARGS__)

#ifdef __APPLE__
#define DEBUG(message) std::cerr << message << std::endl;
#else
#define DEBUG(message)
#endif

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> left(n, 0);
  vector<int> right(n, n - 1);
  vector<int> st;
  for (int i = 0; i < n; i++) {
    while (!st.empty() && a[st.back()] > a[i]) {
      st.pop_back();
    }
    if (!st.empty()) {
      left[i] = st.back() + 1;
    }
    st.push_back(i);
  }
  st.clear();
  ll ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    while (!st.empty() && a[st.back()] > a[i]) {
      st.pop_back();
    }
    if (!st.empty()) {
      right[i] = st.back() - 1;
    }
    st.push_back(i);
    ans += (i - left[i] + 1LL) * (right[i] - i + 1LL) * a[i];
  }
  cout << ans << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef __APPLE__
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3832
#include <stdio.h>

int main(void)
{
	int S, h, m, s;

	h = 0;
	m = 0;
	s = 0;

	scanf("%d", &S);
	while (S >= 3600) {
		++h;
		S = S - 3600;
	}
	while (S >= 60) {
		++m;
		S = S - 60;
	}
	s = S;
	printf("%d:%d:%d\n", h, m, s);

	return 0;
}



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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<(x)<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

const li N=1000007;

vector<bool> prime(N,true);

void sieve()
{
    prime[1]=false;

    for(li i=2;i*i<N;i++)
    {
        if(prime[i])
        {
            for(li j=i*2;j<N;j+=i)
            {
                prime[j]=false;
            }
        }
    }
}

void solve()
{
    li n;

    sieve();

    cin>>n;

    map<li,li> m;

    if(n==1)
    {
        cout<<0;
        return;
    }

    li ans=0;

    for(li i=2;i*i<=n;i++)
    {
            if(!prime[i])
                continue;

           if(n%i==0)
           {
                li count=0;

                while(n%i==0)
                {
                    n/=i;
                    count++;
                }

                m[i]=count;
           }
    }

    if(n>1)
    {
        m[n]++;
    }

    for(auto it:m)
    {
        // cout<<it.F<<endl;

        li j=1,tp=it.S;

        while((j*(j+1))/2<=tp)
        {
            j++;
        }

        ans+=(j-1);
    }

    cout<<ans;
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3784
#include<stdio.h>

int main() {

    long long int N;
    long long int A, B;

    scanf("%lld %lld %lld", &N, &A, &B);

    long long int num1;
    num1 = N / (A + B);

    long long int num2;
    num2 = N % (A + B);

    while(num2 > A) {
        num2--;
    }

    long long int count = 0;
    count = num1 * A + num2;

    printf("%lld", count);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define inf 1<<30
using namespace std;

class State{
public:
  int n,a,dis;
  State(int n,int a,int dis):n(n),a(a),dis(dis){}
  bool operator<(State s)const{
    return s.dis<dis;
  }
};

int n,m,cap;
int s=0,d=1,c;
map<string,int> M;
vector<pair<int,int> > v[6000];
bool sta[6000];
int dp[6000][2002];

void init(){
  M.clear();
  for(int i=0;i<n*2;i++){
    for(int j=0;j<=2001;j++){
      if(i==0)dp[i][j]=0;
      else dp[i][j]=inf;
    }
    sta[i]=false;
    v[i].clear();
  }
}

int main()
{
  string a,b;

  while(1){
    cin>>n>>m>>cap;
    if(n+m+cap==0)break;
    cap*=10;
    init();
    cin>>a>>b;
    M[a]=s;M[b]=d;
    int num=2;
    for(int i=0;i<n;i++){
      cin>>a>>b>>c;
      if(M.find(a)==M.end()){
	M[a]=num;
	num++;
      }
      if(M.find(b)==M.end()){
	M[b]=num;
	num++;
      }
      v[M[a]].push_back(mp(M[b],c));
      v[M[b]].push_back(mp(M[a],c));
    }
    for(int i=0;i<m;i++){
      cin>>a;
      sta[M[a]]=true;
    }

    priority_queue<State> pq;
    pq.push(State(0,cap,0));
    int ans=inf;

    while(!pq.empty()){
      State u=pq.top();
      pq.pop();

      if(u.n==1){
	ans=u.dis;
        break;
      }

      if(sta[u.n])u.a=cap;

      bool flag=true;
      for(int i=u.a;i<=cap;i++){
	if(dp[u.n][i]<u.dis){
	  flag=false;
	  break;
	}
      }
      if(!flag)continue;
      
      for(int i=0;i<v[u.n].size();i++){
	if(v[u.n][i].s<=u.a){
	  int x=u.dis+v[u.n][i].s,y=u.a-v[u.n][i].s,z=v[u.n][i].f;
	  if(x<dp[z][y]){
	    dp[z][y]=x;
	    pq.push(State(z,y,x));
	  }
	}
      }

    }
    if(ans==inf)cout<<-1<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 57296
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    map<long long, int> mp;
    for(int i=0; i<N; i++){
        long long A;
        cin >> A;
        mp[A]++;
    }

    int cnt = 0;
    long long ans = 1;
    for(auto itr=mp.rbegin(); itr!=mp.rend(); itr++){
        if(cnt==2) break;
        if(cnt==0){
            if(itr->second >= 4){
                ans = itr->first * itr->first;
                cnt = 2;
            }else if(itr->second >= 2){
                ans = itr->first;
                cnt = 1;
            }
        }else if(cnt==1){
            if(itr->second >= 2){
                ans *= itr->first;
                cnt = 2;
            }
        }
    }
    if(cnt!=2) ans = 0;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6528
#include <iostream>

using namespace std;

int N, K, h[100005];
int dp[100005];

int main() {
    const int inf = 1e9;

    cin >> N >> K;

    fill(dp, dp+N, inf);

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

    dp[0] = 0;
    // 差し上げるDP
    for (int i = 0; i < N-1; i++) {
        for (int j = 1; j <= K; j++) {
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]));
        }
    }
    cout << dp[N-1] << endl;

    return 0;
}


Measured memory_bytes: 1024
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdlib;

void main() {
    auto N = readln.chomp.to!int;
    long ans = 0;
    foreach (i; 1..N+1) if (i % 3 != 0 && i % 5 != 0) ans += i;
    ans.writeln;
}

Measured memory_bytes: 3232
w,h,x,y,r=map(int, input().split())

x_max=int(x+r)
x_min=int(x-r)
y_max=int(y+r)
y_min=int(y-r)

#print(x_max,x_min,y_max,y_min)


if y_max > h:
    print("No")
else:
    if y_min < 0:
        print("No")
    else:
        if x_max > w:
            print("No")
        else:
            if x_min < 0:
                print("No")
            else:
                print("Yes")

Measured memory_bytes: 7684
#include "stdio.h"

long long int A, B, C, D, res, X, Y, R;

int main(void){
  scanf("%lld %lld %lld %lld", &A, &B, &C, &D);
  if(C > D){
    X = C;
    Y = D;
  }else{
    X = D;
    Y = C;
  }
  while( (R = X % Y) != 0 ) {
    X = Y;
    Y = R;
  }
  Y = C * D / Y;
  res = (long long int)(B / C) + (long long int)(B / D) - (long long int)(B / Y) - (long long int)((A - 1) / C) - (long long int)((A - 1) / D) + (long long int)((A - 1) / Y);
  res = B - A - res + 1;
  printf("%lld", res);
}

Measured memory_bytes: 128
from collections import defaultdict

n = int(input())
s = input()

rgb = defaultdict(list)
blue = defaultdict(int)

for i in range(n):
    if s[i] == 'R':
        rgb[0].append(i)
    elif s[i] == 'G':
        rgb[1].append(i)
    else:
        blue[i] = i

ans = len(rgb[0]) * len(rgb[1]) * len(blue)

for r in rgb[0]:
    for g in rgb[1]:
        tmp = sorted([r, g])
        if tmp[0] - (tmp[1]-tmp[0]) in blue:
            ans -= 1
        if tmp[1] + (tmp[1]-tmp[0]) in blue:
            ans -= 1
        if (tmp[1]+tmp[0]) % 2 == 0 and (tmp[1]+tmp[0])//2 in blue:
            ans -= 1

print(ans)


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

int main()
{
	int n,l,r,ans=0;
	cin>>n>>l>>r;
	for (int i=1;i<=n;i++)
	{
		int num=i,sum=0,tem;
		do{
			tem=num%10;
			sum+=tem;
			num/=10;
		}while(num!=0);
		if (sum>=l&&sum<=r)	ans+=i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
constexpr int MOD = 1000000007;
constexpr ll INF = 50000000000000000;
typedef std::pair<int,int> P;
constexpr ll SIZE= 100010;

ll N,A[100010],B[SIZE];
ll ans=0,sum=0,wa=0;
int main() {
    std::ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        cin>>A[i];
        sum+=A[i];
        wa+=i+1;
    }
    REP(i,N){
        B[i]=A[(i+1)%N]-A[i];
    }
    bool f=true,g=true;
    if(sum%wa!=0)g=false;
    REP(i,N){
        B[i]-=sum/wa;
    }
    DEB(sum)DEB(wa)END
    int cnt=0;
    REP(i,N){
        DEB(-B[i])END
        if(-B[i]%N==0){
            if(-B[i]/N<0)f=false;
            cnt+=-B[i]/N;
        }
        else if(B[i]!=0)f=false;
    }
    if(cnt!=sum/wa)f=false;
    cout<<(f&&g?"YES":"NO")<<endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long x = sc.nextLong();
    
    long ans = (b/x+1) - (a/x+1) + (a%x == 0 ? 1 : 0);
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 23892
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
#include<set>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	char s[100010];
	cin >> s;
	set<char> st;
	for (int i = 0;i < strlen(s);i++) {
		st.insert(s[i]);
	}
	rep(i, 26) {
		if (st.count('a' + i) == 0) {
			cout << (char)('a' + i) << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 16 21:24:48 2020

@author: W_Indicate
"""
Y = 0

N = int(input()) #1行目のNを取得する
s = [int(i) for i in input().split()] #

for item in s:
    if (item % 2) == 0:
        if ((item % 3) != 0) and ((item % 5) != 0):
            Y = 1 
            
if Y == 0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
# mod = 10 ** 9 + 7
mod = 998244353 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def f(A, S):
    T = [0] * len(A[0])
    for a in A:
        for k in a:
            if k in S:
                continue
            T[k] += 1
            break
    
    v = max(T)
    return (T.index(v), v)


def main():
    N, M = read_values()
    A = [list(read_index()) for _ in range(N)]

    res = V(min, N)
    S = set()
    for _ in range(M - 1):
        k, v = f(A, S)
        S.add(k)
        res.ud(v)

    print(res)


if __name__ == "__main__":
    main()



Measured memory_bytes: 5288
/*GRATITUDE*/
//Arise Awake and Stop Not Till the Goal is reached. You are the greatest of all. Hare Krishna
//Break through all barriers..
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define ff              first
#define ss              second
#define uint            unsigned long long
#define int             long long
#define double           long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define vpii            vector<pii>
#define umpii           unordered_map<int,int>
#define ustii           unordered_set<int>   
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             10000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define endl            "\n"
#define all(x)             x.begin(), x.end()
#define all_r(x)           x.rbegin(), x.rend()
#define sortall(x)         sort(all(x))
#define sortall_r(x)       sort(all_r(x))  
#define tr(it, a)          for(auto it = a.begin(); it != a.end(); it++)
#define PI                 acos(-1)
#define w(t)              int t; cin>>t; while(t--)
#define for_f(a,b,c)      for(int i=a;i<=b;i=i+c)
#define for_r(a,b,c)      for(int i=a;i>=b;i=i-c) 
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define trace1(x) cout << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cout<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
void ash_god()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#ifndef ONLINE_JUDGE
    freopen("i.txt", "r", stdin);
    freopen("o.txt", "w", stdout);
#endif
}
/*************************************************************************************************/
//Write your functions here..............................


/***************************************************************************************************/
void solve() {
/*Write your code here*/
    int n; cin>>n; int a[n+1]={0};
    int k,d,x; cin>>k;
    for_f(1,k,1) {
        cin>>d;
        for_f(1,d,1) {
            cin>>x;
            a[x]++;
        }


    }
    int res=0;
    for_f(1,n,1) {
        if(a[i]==0) res++;
    }
    cout<<res;

}
int32_t main()
{
ash_god();
bool tc=0;
if(tc)  {
    w(t) solve();
}
else solve();

return 0;
} 



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


using namespace std;
const int maxn = 2e5 + 10;

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;cin >> n;string a[maxn];string b[maxn];
	for(int i = 0  ; i < n ; i++) cin >> a[i];
	sort(a,a + n);
	int maxx = -1;int cur = 1;
	for(int i = 1 ; i < n ; i++){
		if(a[i] == a[i - 1]) cur++;
		else{
			maxx = max (maxx,cur);cur = 1;
		}
	}
	maxx = max (cur,maxx);
	cur = 1;int len = 0;
	
	for(int i = 1 ; i <n;i++){
		if(a[i] == a[i -1]) cur++;
		else{
			if(cur == maxx) b[len++] = a[i - 1];
			cur = 1;
		}
	}
	if(cur == maxx) b[len++] = a[n - 1];
	sort(b,b + len);
	for(int i = 0 ;i < len ;i++) cout << b[i] << endl;
}

Measured memory_bytes: 14464
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, K := ReadInt(), ReadInt()
	hs := ReadInts(N)

	ans := 0
	for i := 0; i < N; i++ {
		if hs[i] >= K {
			ans++
		}
	}

	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }

func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 2980
import sys


def int1(x): return int(x) - 1
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def mi1(): return map(int1, 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)]


if __name__ == "__main__":
    x = li()
    for i in range(len(x)):
        if x[i] == 0:
            print(i+1)


Measured memory_bytes: 9068
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) ((m).find((a)) != m.end())
#define CONTAINS_SET(m, a) ((m).find((a)) != m.end())
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }



signed main()
{
	int N;
	cin >> N;

	bool y = false;
	int cnt = 0;
	REP(i, N)
	{
		int d1, d2;
		cin >> d1 >> d2;
		if (d1 == d2)
		{
			cnt++;
		}
		else
		{
			cnt = 0;
		}
		if (cnt >= 3) y = true;
	}
	YesNo(y);
}



Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
	double a, b = 0.0;
	int h, m = 0;
	cin >> a >> b >> h >> m;

	auto totalm = h * 60 + m;
	auto ang_a = totalm / (12 * 60.0) * 2 * M_PI;
	auto ang_b = m / 60.0 * 2 * M_PI;

	auto ang = abs(ang_a - ang_b);

	auto res = sqrt(a * a + b * b - 2 * a * b * cos(ang));

	cout << fixed << setprecision(15) <<res;
}



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

using namespace std;


int main() {
	
	int t[5];

	while (cin >> t[0]) {

		t[4] = t[0];
		for (int i = 1; i < 4; i++) {
			cin >> t[i];
			t[4] += t[i];
		}
		cout << t[4] / 60 << "\n";
		cout << t[4] % 60 << "\n";
	}

	return 0;

}


Measured memory_bytes: 3100
#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // XIII LO Szczecin
using LL = long long;    // Poland
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define REP(i, n) FOR(i, 0, (n) - 1)
template<class T> int size(T &&x) {
	return int(x.size());
}
template<class A, class B> ostream& operator<<(ostream &out, const pair<A, B> &p) {
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	out << '{';
	for(auto it = x.begin(); it != x.end(); ++it)
		out << *it << (it == prev(x.end()) ? "" : ", ");
	return out << '}';
}
void dump() {}
template<class T, class... Args> void dump(T &&x, Args... args) {
	cerr << x << ";  ";
	dump(args...);
}
#ifdef DEBUG
  struct Nl{~Nl(){cerr << '\n';}};
# define debug(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dump(x), Nl(), cerr << ""
#else
# define debug(...) 0 && cerr
#endif
mt19937_64 rng(0);
int rd(int l, int r) {
	return uniform_int_distribution<int>(l, r)(rng);
}
// end of templates

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

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int &ai : a)
		cin >> ai;

	while(k --> 0) {
		vector<int> b(n);
		REP(i, n) {
			int l = max(0, i - a[i]),
				r = min(n - 1, i + a[i]);
			debug(i, l, r);
			++b[l];
			if(r != n - 1)
				--b[r + 1];
		}
		debug(b);
		FOR(i, 1, n - 1)
			b[i] += b[i - 1];
		a = b;
		debug(a);

		if(a == vector<int>(n, n))
			break;
	}

	for(int ai : a)
		cout << ai << ' ';
	cout << '\n';
}


Measured memory_bytes: 5568
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    p,q,r = LI()
    print(p+q+r-max(p,q,r))
    return

#B
def B():
    n = I()
    w = LI()
    ans = float("inf")
    for i in range(n):
        m = sum(w[:i])
        l = sum(w[i:])
        ans = min(ans,abs(m-l))
    print(ans)
    return

#C
def C():
    n,m = LI()
    f = defaultdict(lambda : 1)
    for i in range(m):
        a = I()
        f[a] = 0
    dp = [0 for i in range(n+10)]
    dp[0] = 1
    for i in range(1,n+1):
        if f[i]:
            dp[i] = dp[i-1]+dp[i-2]
            dp[i] %= mod
    print(dp[n])
    return

#D
def D():
    h,w = LI()
    s = SR(h)

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 56536
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
-13 3
---+/

void main(string[] args) {
  long A, B;
  readf(" %d %d ", &A, &B);
  max(A+B, A-B, A*B).writeln;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
template<typename T>
bool all_same(vector<T> v1,vector<T> v2)
{
    sort(ALL(v1));
    sort(ALL(v2),greater<T>());
    return v1 == v2;
}
   
// g++ -std=c++11 prac.cpp
ll Max=-1e9,Min=1e9+1;

int main(){
    ll a,b,c,d,x,y,z,n,m,l,w,sum=100000,sum2=0,ans=0;
    string s,t;
    bool ok=true;
    cin >> a >> b >> c;
    
    if( a%2!=0 || b%2!=0 || c%2!=0 ){
            cout << ans << endl;
            return 0;
        }
    while(sum){
        x = (b+c)/2;
        y = (a+c)/2;
        z = (a+b)/2;
        if( x%2!=0 || y%2!=0 || z%2!=0 ){
            ans++;
            cout << ans << endl;
            return 0;
        }
        ans++;
        a = x;
        b = y;
        c = z;
        sum--;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    char a, b;
    cin >> a >> b;
    bool ans;
    if (b == 'H') {
        ans = true;
    } else {
        ans = false;
    }

    if (a == 'D') {
        ans = !ans;
    }

    if (ans) {
        cout << "H" << endl;
    } else {
        cout << "D" << endl;
    }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


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

int read(string &s, int idx) {
    char c = s[idx];
    int sz = s.size();
    int i = 0;
    for (; idx + i < sz && s[idx + i] == c; ++i);
    return i;
}

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

    int idx = 0;
    int ans = 0;
    int sz = s.size();

    while (idx < sz) {
        int i = read(s, idx);
        
        if (idx + i >= sz) {
            int i_div = i / 3;
            int i_rem = i % 3;
            ans += i_div * 2 + (i_rem == 0 ? 0 : 1);
            break;
        }

        int j = read(s, idx + i);
        
        int i_div = i / 3;
        int i_rem = i % 3;
        int j_div = j / 3;
        int j_rem = j % 3;

        if (i_rem == 2 && j_rem == 2) {
            ans += (i_div + j_div) * 2 + 3;
            idx += i + j;
        }
        else if (i_rem == 2 && j_rem == 0) {
            ans += i_div * 2 + 2;
            idx += i + 1;
        }
        else {
            ans += i_div * 2 + (i_rem == 0 ? 0 : 1);
            idx += i;
        }
    }

    cout << ans << endl;

    return 0;
}


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

s = input()

sc = 0
ec = len(s)

for i in range(len(s)):
  if(s[i] == "A"):
    sc = i
    break

for i in range(len(s)):
  if(s[len(s) - i -1] == "Z"):
    ec = len(s) - i - 1
    break

print(ec - sc + 1)


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

#define LL long long

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	LL n;
	cin >> n;
	vector<LL> h(n);
	for (LL i = 0; i < n; i++)
		cin >> h[i];
	vector<LL> dp(n);
	dp[n-1] = 0;
	for (LL i = n-2; i >= 0; i--){
		if (h[i] >= h[i+1])
			dp[i] = 1+dp[i+1];
		else
			dp[i]  = 0;
	}
	cout << *(max_element(dp.begin(),dp.end())) << "\n";
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Text;

namespace AOJ
{
    class Program
    {
        // 実際にはこんな時間のかかる構成にはせずdictionary等々を使用する
        class Card
        {
            public string suit;
            public int rank;

            public override bool Equals(object obj)
            {
                var rhs = (Card)obj;
                return suit.Equals(rhs.suit) && rank.Equals(rhs.rank);
            }
        }
        class Deck
        {
            List<Card> cards = new List<Card>();

            static Deck FullDeck()
            {
                var deck = new Deck();
                var suits = new List<string> { "S", "H", "C", "D" };
                foreach (var suit in suits)
                {
                    for (int i = 1; i <= 13; ++i)
                    {
                        deck.cards.Add(new Card { suit = suit, rank = i });
                    }
                }
                return deck;
            }

            public void AddCard(string suit, string rank)
            {
                cards.Add(new Card { suit = suit, rank = int.Parse(rank) });
            }

            public static List<Card> GetMissingCards(ref Deck yours)
            {
                var missing = new Deck();

                var full = FullDeck();
                foreach (var test in full.cards)
                {
                    bool isMissing = true;
                    foreach (var yourCard in yours.cards)
                    {
                        if (yourCard.Equals(test))
                        {
                            isMissing = false;
                            break;
                        }
                    }
                    if (isMissing)
                    {
                        missing.cards.Add(test);
                    }
                }

                return missing.cards;
            }
        }
        static void Main(string[] args)
        {
            var inputFirstLine = Console.In.ReadLine();
            var cardCount = int.Parse(inputFirstLine);

            var deck = new Deck();

            for (int icard = 0; icard < cardCount; ++icard)
            {
                var inputLine = Console.In.ReadLine();
                var inputs = inputLine.Split(new char[] { ' ', '\t', '　' });
                if (inputs.Length != 2)
                {
                    return;
                }

                deck.AddCard(inputs[0], inputs[1]);
            }

            var missing = Deck.GetMissingCards(ref deck);
            foreach (var card in missing)
            {
                Console.WriteLine("{0} {1}", card.suit, card.rank);
            }
        }
    }
}



Measured memory_bytes: 18024
N = int(input())
a = list(map(int, input().split()))
brick = [0]
number = 1

import sys

if min(a) > 1:
  print('-1')
  sys.exit()

for i in range(N):
  if a[i] == number:
    brick.append(number)
    number += 1
print(N - max(brick))

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

bool m[100000][11];
int col[100000];
vector<int>E[100000];
int v[100000], d[100000], c[100000];
void rec(int v, int d, int c) {
	if (m[v][d])return;
	m[v][d] = 1;
	if (col[v] == 0)col[v] = c;
	if (!d)return;
	rec(v, d - 1, c);
	for (int u : E[v])rec(u, d - 1, c);
}
int main() {
	int n, m; scanf("%d%d", &n, &m);
	rep(i, m) {
		int a, b; scanf("%d%d", &a, &b); a--; b--;
		E[a].push_back(b); E[b].push_back(a);
	}
	int q; scanf("%d", &q);
	rep(i, q) {
		scanf("%d%d%d", &v[i], &d[i], &c[i]); v[i]--;
	}
	for (int i = q - 1; i >= 0; i--)rec(v[i], d[i], c[i]);
	rep(i, n)printf("%d\n", col[i]);
}

Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
inline int read(void){
	int num = 0, f = 1;
	char ch;
	while(!isdigit(ch=getchar())) if(ch == '-') f = -1;
	while(isdigit(ch)) num = num*10 + ch-'0', ch = getchar();
	return num * f;
}
int main()
{
	int n = read(), cnt = 0, ans = 0;
	char s[MAXN];
	scanf("%s", s+1);
	int len = strlen(s+1);
	for(int i = 1; i <= len; i++){
		if(s[i] == 'R') cnt++;
	}
	for(int i = 1; i <= len && cnt; i++){
		if(s[i] == 'R') cnt--;
		else cnt--, ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4004
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    string A, op, B;
    scan(A, op, B);
    long a = A.to!long();
    long b = B.to!long();
    if (op == "-")
    {
        writeln(a - b);
    }
    else
    {
        writeln(a + b);
    }
}


Measured memory_bytes: 256
from collections import deque
s = input()
q=int(input())
d=deque(s)
r=True

for _ in range(q):
    buf = input()
    if buf[0]=='1':
        if r:
            r=False
        else :
            r=True
    elif buf[0]=='2':
        c=buf.split()
        if (c[1]=='1' and r) or (c[1]=='2' and r==False):
            d.appendleft(c[2])
        else:
            d.append(c[2])
if r==False:
    d.reverse()
for i in d:
    print(i,end='')


        

Measured memory_bytes: 94296
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sec = sc.nextInt();

		int h = sec / 3600;
		int m = (sec % 3600) / 60;
		int s = (sec % 3600) % 60;

		System.out.println(h + ":" + m + ":" + s);
	}
}

Measured memory_bytes: 17160
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#define int LL
typedef long long LL;
int n,a,b,c,d,u=0;
void ans(const char *str){puts(str);exit(0);}
#undef int
int main(){
#define int LL
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	if(c==d)ans(a==b?"YES":"NO");
	n--;
	if(a>b)std::swap(a,b);
	n-=(b-a)/d; u+=(b-a)/d;
	a+=((b-a)/d)*d;
	if(n<0)ans("NO");
	if(n&1){
		a+=d,n--,u++;
		if(a>b)a-=std::min(a-b,(d-c)*u);
		ans(std::abs(a-b)<=(n/2)*(d-c)?"YES":"NO");
	}else{
		ans(std::abs(b-a)<=(n/2)*(d-c)?"YES":"NO");
	}
}

Measured memory_bytes: 256
#include<stdio.h>

void swap(int *x,int *y){
	int tmp=0;

	tmp=*x;
	*x=*y;
	*y=tmp;
}

void bubble_sort(int array[],int array_size, int *count){
	int i=0, j=0,c_count=0;
	for(i=0; i<array_size-1; i++){
		for(j=array_size-1; j>=i; j--){
			if(array[j]<array[j-1]){
				swap(&array[j],&array[j-1]);
				c_count++;
			}
		}
	}
	*count=c_count;
}

int main(){
	int size=0,count=0;;
	scanf("%d",&size);
	int array[100]={};
	for(int i=0; i<size; i++){
		scanf("%d",&array[i]);
	}
	bubble_sort(array,size,&count);
	for(int i=0; i<size-1; i++){
		printf("%d ",array[i]);
	}
	printf("%d\n%d\n",array[size-1],count);
	return 0;
}



Measured memory_bytes: 2732
import itertools

N, M, Q = map(int, input().split())
ABCD = [[int(x) for x in input().split()] for i in range(Q)]

ans=0
t=[m for m in range(1,M+1)]
for A in itertools.combinations_with_replacement(t, N):
  ans2=0
  for (a,b,c,d) in ABCD:
    if A[b-1]-A[a-1]==c:
      ans2+=d
  ans=max(ans, ans2)
print(ans)


Measured memory_bytes: 9176
#include <iostream>
#include <cstring>

using namespace std;

int n, m;

int main() {
  scanf("%d%d", &n, &m);
  if(n + m == 15) {
    printf("+\n");
    return 0;
  } else {
    if(n * m == 15) {
      printf("*\n");
      return 0;
    } else {
      printf("x\n");
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256