akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    vector<int> s(n);
    for (int i = 0; i < n; i++)
    {
        char cc;
        cin >> cc;
        if (cc == '.')
        {
            s[i] = 1;
        }
        else
        {
            s[i] = 0;
        }
    }
    // print(s);
    if (a < b && c < d)
    {
        for (int i = a; i < d; i++)
        {
            if (s[i - 1] == 0 && s[i] == 0)
            {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        for (int i = a; i < c; i++)
        {
            if (s[i - 1] == 0 && s[i] == 0)
            {
                cout << "No" << endl;
                return 0;
            }
            if (b <= i && i <= d)
            {
                if (s[i - 2] == 1 && s[i - 1] == 1 && s[i - 0] == 1)
                {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
        cout << "No" << endl;
        return 0;
    }
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
};

Measured memory_bytes: 4048
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
ll INF = 1000000007;
using Graph = vector<vector<ll>>;

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)


int main() {
    ll a, b, k;
    cin >> a >> b >> k;

    if(k < a){
        cout << a-k << " " << b << endl;
    }else if(k > a+b){
        cout << "0 0" << endl;
    }else{
        cout << "0 " << b-(k-a) << endl;
    }


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
  int N , M ;
  bool board[10][10] ;
 bool visited[10] ;
int dfs(int v , int N , bool visited[10]){
  bool all_visited=true ;
  
  for(int i = 0 ; i < N ; i++){
    if(visited[i]==false)
      all_visited=false ;
  }
  
  if(all_visited){
    return 1 ;
  }
  
  int ret = 0 ;
  for(int i = 0 ; i < N ; i++){
    if(board[v][i]==false) continue ;
    if(visited[i]) continue ;
    
    visited[i] = true ;
    ret+=dfs(i,N,visited);
    visited[i]= false ;
  }
  return ret ;
}

int main () {
  //入力
  cin >> N >> M ;
  
  for(int i = 0 ; i < M ; i++ ){
    int A , B ; 
    cin >> A >> B ;
    board[A-1][B-1] = board[B-1][A-1] = true ;
  }
  
  //演算
  
 
  for(int i = 0 ; i < N ; i++ ){
    visited[i] = false ;
  }
  visited[0] = true ;
  cout << dfs(0,N,visited) << endl ;
  
}

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


#tmp = factorization(n)
#print(tmp)

ans = 0
for i in range(1, n+1, 2):
    tmp = 0
    for j in range(1,i+1):
        if i % j == 0:
            tmp += 1
    if tmp == 8:
        ans += 1
 
print(ans)

Measured memory_bytes: 38768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 1e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int n,m;
int a[310][310];
bool toru[310];

void input() {
    cin >> n >> m;
    REP(i,n) REP(j,m) {
        cin >> a[i][j];
        a[i][j]--;
    }
}

void solve() {
    REP(i,m) toru[i] = 1;
    int mx = n;
    REP(kk,m) {
        int cnt[m] = {};
        REP(i,n) {
            REP(j,m) {
                if (!toru[a[i][j]]) continue;
                cnt[a[i][j]]++;
                break;
            }
        }
        int pos = -1;
        int mmx = 0;
        REP(i,m) {
            if (cnt[i] > mmx) {
                mmx = cnt[i];
                pos = i;
            }
        }
        toru[pos] = 0;
        mx = min(mx,mmx);
    }
    cout << mx << endl;
}

int main(int argc, char *argv[]){
    input();
    solve();
    return 0;
}


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

int main() {
	ll n, T, t[500000], ans,hoge;
	cin >> n >> T;
    ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < n - 1; i++) {
        hoge = t[i + 1] -  t[i];
		if (hoge < T) {
			ans += hoge;
		}
		else {
			ans += T;
		}
	}
	ans += T;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<vector>

int main() {
	int n;
	std::cin >> n;
	std::vector<std::pair<int, int>>r(n), b(n);
	for (int i = 0; i < 2 * n; i++) {
		if (i < n)std::cin >> r[i].first >> r[i].second;
		else std::cin >> b[i - n].first >> b[i - n].second;
	}
	//printf("\n");
	//for (int i = 0; i < n; i++)printf("%d %d\n", r[i].first, r[i].second);
	//for (int i = 0; i < n; i++)printf("%d %d\n", b[i].first, b[i].second);
	//printf("\n");
	std::vector<bool>useR(n, 0), useB(n, 0);

	int ans = 0;

	for (int i = 0; i < n; i++) {
		int min = 1 << 30;
		int minIndex = -1;
		for (int j = 0; j < n; j++) {
			if (useB[j])continue;
			if (min > b[j].first) {
				min = b[j].first;
				minIndex = j;
			}
		}
		useB[minIndex] = true;

		int max = -1;
		int maxIndex = -1;
		for (int j = 0; j < n; j++) {
			if (r[j].first >= b[minIndex].first || r[j].second >= b[minIndex].second||useR[j])continue;
			if (max < r[j].second) {
				max = r[j].second;
				maxIndex = j;
				//printf("%d ", j);
			}
		}
		//printf("\n");
		if (maxIndex == -1)continue;
		useR[maxIndex] = true;
		//for (int i = 0; i < n; i++)std::cout<<useR[i];
		//printf("\n");
		ans++;
	}

	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

bool ok(string s) {
  return s.find("##") == string::npos;
}

void solve() {
  int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
  string s; cin >> s;
  s = '.' + s;

  if (a < b && b < c && c < d) {
    string sub1 = s.substr(a, b - a);
    string sub2 = s.substr(c, d - c);
    if (ok(sub1) && ok(sub2)) Yes();
    else No();
  } else if (a < b && b < d && d < c) {
    string sub1 = s.substr(a, c - a);
    if (!ok(sub1)) {
      No();
      return;
    }

    if (s[d-1] == '.') {
      Yes();
      return;
    }

    string sub2 = s.substr(b-1, d-(b-1));
    if (sub2.find("...") == string::npos) No();
    else Yes();

  } else if (a < c && c < b && b < d) {
    string sub1 = s.substr(a, c - a);
    string sub2 = s.substr(b, d - b);
    if (ok(sub1) && ok(sub2)) Yes();
    else No();
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

int main() {
  long long x;
  cin >> x;
  long long result = 0;
  result += x / (5 + 6) * 2;
  ///*
  if (x % 11 > 6) {
    result += 2;
  } else if (x % 11 > 0) {
    result += 1;
  }

  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN

    ll n;cin>>n;
    vector<string> v(n);
    map<string,ll>mp;
    bool ok = true;
    REP(i,n){
        cin>>v[i];
        if (mp[v[i]]) ok = false;
        mp[v[i]]++;
    }
    
    REP(i,n-1){
        if (v[i][v[i].size()-1] != v[i+1][0]) ok =false;
    }
    
    if(ok) v[0]= "Yes";
    else v[0]="No";
    cout<<v[0]<<endl;
    return 0;
}

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

ll mod = 1e9 + 7;
ll dp[110][10]; // dp[h][k] = h段からなり0がkになる組合せ
int h, w, k;

int main(){
    cin >> h >> w >> k;
    dp[0][0] = 1, k--;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < (1 << (w - 1)); j++){
            bool out = true;
            for (int k = 0; k < w - 2; k++){
                if ((j >> k) % 4 == 3)out = false;
            }
            if (!out)continue;
            int p[w];
            for (int k = 0; k < w; k++)p[k] = k;
            for (int k = 0; k < w - 1; k++){
                if ((j >> k) & 1)swap(p[k], p[k + 1]);
            }
            for (int k = 0; k < w; k++){
                dp[i + 1][p[k]] += dp[i][k];
                dp[i + 1][p[k]] %= mod;
            }
        }
    }
    cout << dp[h][k] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;


typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define Pi 3.14159265
#define double
#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>

bool compare(pii a, pii b){
    if(a.first==b.first)return a.second<b.second;
    return a.first>b.first;
}

const int mod = 1e9 + 7;
const ll inf = ll(1e18);

ll modexp(ll x,ll n,ll k){
    if(n==0)return k;
    if(n%2==0)return modexp((x*x)%mod,n/2,k);
    return (x*modexp((x*x)%mod,n/2,k))%mod;
}
vi g[100005];
int main(){
    fastio;
    //clock_t tm = clock();
    int m,n;string s;
    cin>>n>>m;
    cin>>s;
    vi a;a.pb(0);int l=1;
    f(i,1,n){
        if(s[i]=='1')continue;
        int x = lower_bound(all(a),i-m)-a.begin();
        if(x==l)continue;
        g[i].pb(a[x]);
        a.pb(i);l++;
    }
    int x = lower_bound(all(a),n-m)-a.begin();
    if(x==l)cout<<-1<<endl;
    else {
        int step=1;vi ans;ans.pb(n-a[x]);x=a[x];
        if(x!=0) {
            while (g[x][0] != 0) {
                ans.pb(x - g[x][0]);
                step++;
                x = g[x][0];
            }
            step++;
            ans.pb(x);
        }
        //cout<<step<<endl;
        fd(i,step-1,0)cout<<ans[i]<<" ";
        cout<<endl;
    }
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 6984
package main

import "fmt"

func main(){
	var s,t,u string
	var a,b int
	fmt.Scan(&s,&t)
	fmt.Scan(&a,&b)
	fmt.Scan(&u)
	if s == u {
		a--
	} else {
		b--
	}
	fmt.Println(a,b)
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define inf 1001001001001000
#define mod 1000000007
#define pi 3.1415926535
using namespace std;

ll ones[100001];

struct UnionFind {
    vl par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vl num;
    
    UnionFind(ll n) : par(n),num(n) { //最初は全てが根であるとして初期化
        rep(i,n){
            par[i] = i;
            num[i] = 1;
        }
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        num[ry] += num[rx];
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
    
    ll count(ll x){
        return num[root(x)];
    }
};


int main(void){
    ll n,m,k;
    cin>>n>>m>>k;
    vvl edge(n),unchi(n);
    UnionFind uf(n);
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        a--,b--;
        uf.unite(a,b);
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    rep(i,k){
        ll a,b;
        cin>>a>>b;
        a--,b--;
        if(uf.same(a,b)){
            unchi[a].push_back(b);
            unchi[b].push_back(a);
        }
    }
    rep(i,n){
        cout<<uf.count(i)-1-edge[i].size()-unchi[i].size()<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 14836
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> N >> K;
  DV(dp,lli,N,K+100,0);
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  dp[0][0]=2;
  if(P[0]<=K)dp[0][P[0]]=1;
  rep(i,1,N)rep(j,0,K+1){
    if(j+P[i]<=K)dp[i][j+P[i]]=(dp[i][j+P[i]]+dp[i-1][j])%mod;
    dp[i][j]=(dp[i][j]+2*dp[i-1][j])%mod;
  }
  Out(dp[N-1][K]%mod);
}

Measured memory_bytes: 76044
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

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

	int ans1, ans2;

	if (a < c) ans1 = c;
	else ans1 = a;

	if (b < d) ans2 = b;
	else ans2 = d;

	cout << (ans2 - ans1 > 0 ? ans2 - ans1 : 0) << endl;

}


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

typedef long long LL;

const int N=10;
const int a[N+9]={0,1,2,4,7,12,20,29,38,52,73};

int n,p[N+9];
LL ans[N+9][N+9],mx;

void into(){
  scanf("%d",&n);
}

void Get_ans(){
  for (int i=2;i<=n;++i){
	for (int j=1;j<i;++j) ans[i][j]=ans[j][i]=(mx+1)*a[j];
	if (i==n) break;
	for (int j=1;j<=i;++j) p[j]=j;
	for (;2333;){
	  LL sum=0;
	  for (int j=1;j<i;++j) sum+=ans[p[j]][p[j+1]];
	  mx=max(mx,sum);
	  if (!next_permutation(p+1,p+i+1)) break;
	}
  }
}

void work(){
  Get_ans();
}

void outo(){
  for (int i=1;i<=n;++i){
	for (int j=1;j<=n;++j)
	  printf("%lld ",ans[i][j]);
    puts("");
  }
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 3768
using System;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int num1 = int.Parse(s[0]);
            int num2 = int.Parse(s[1]);
            double avg = (num1 + num2) / 2.0d;
            Console.WriteLine(Math.Ceiling(avg));
        }
    }
}

Measured memory_bytes: 11092
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => {
  var arry = input.split(' ').map(Number);
  var r = arry[0];
  var a = r * r * Math.PI;
  var b = 2 * r * Math.PI;

  var output = a.toFixed(5) + ' ' + b.toFixed(5)

  console.log(output);
})



Measured memory_bytes: 15288
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if(a==b && b==c && c==a){
        cout << a%2-1 << endl;
        return 0;
    }
    int cnt=0;
    while(a%2==0 && b%2==0 && c%2==0){
        ll s=a+b+c;
        a=(s-a)/2;
        b=(s-b)/2;
        c=(s-c)/2;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
n, x, y = map(int, input().split())

# 点aと点b(b>a)の最短距離は、min((b-a), (abs(x-a) + abs(y-b) + 1))
for k in range(1, n):
    count = 0
    for a in range(1, (n-k) + 1):
        # b-aパターンの確認
        b = k+a
        if((abs(x-a) + abs(y-b) + 1) >= k):
            count += 1
        # abs(x-a) + abs(y-b)パターンの確認.
        to_y = k - abs(x-a) - 1
        if(to_y >= 0):
            b1 = y + to_y
            b2 = y - to_y
            if(b1 <= n and b1 - a >= k and b != b1):
                count += 1
            if(b2 - a >= k and b != b2 and b1 != b2):
                count += 1
    print(count)


Measured memory_bytes: 49364
#include <stdio.h>
#include <limits.h>
int main(){
  long N,A,B,C,L,R;
  scanf("%ld%ld%ld",&N,&A,&B);
  C=B-A;
  L=B-1;
  R=N-A;
  if(C%2 == 0){printf("%ld",C/2);}
  else if(R>L){printf("%ld",A+(C-1)/2);}
  else printf("%ld",(N-B+1)+(C-1)/2);
}

Measured memory_bytes: 128
"use strict";
function main(input) {
  let kari = input[0].trim().split(" ");

  let a = parseInt(kari[0]);
  let b = parseInt(kari[1]);

  let tax = -1;

  for(let i=1; i < 10000 ; i++){
    if((Math.floor(i*0.08) === a) && (Math.floor(i*0.1) === b)){
      tax = i;
      break;
    }
  }

  console.log(tax);
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

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

using namespace std;

const int MXN = 100 + 9;

char s[MXN];
int K, ans, a, b;
bool cha[MXN];

void solve() {
	int len = strlen(s);
	bool flag = true;
	for (; a < len; a++) 
		if (s[a] != s[0]) break;
	for (b = len - 1; b >= 0; b--)
		if (s[b] != s[len - 1]) break;
	b = len - b - 1;
	if (a != len) flag = false; 
	for (int i = 0; i < len - 1; i++) {
		if (s[i] == s[i + 1]) {
			cha[i + 1] = true;
			i++; ans++;
		}
	}
	long long res;
	if (flag) {
		res = (1LL * len * K) / 2;
	}
	else if (s[0] != s[len - 1]) {
		res = 1LL * K * ans;
	}
	else {
		res = 1LL * K * ans - ((a >> 1) + (b >> 1) - (a + b >> 1)) * 1LL * (K - 1);
	}
	
	printf("%lld\n", res);
}

int main() {
	scanf("%s %d", s, &K);
	solve();	
	return 0;
}

Measured memory_bytes: 256
import bisect
n,k=map(int, input().split())
V=list(map(int, input().split()))
ans=0
for i in range(k+1):
  for j in range(k+1-i):
    if i+j>n:
      break  
    #手に取りだしたもの
    A=sorted(V[:i]+V[n-j:])
    a=min(k-i-j,bisect.bisect_left(A, 0))
    ans=max(ans,sum(A[a:]))
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
 
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25136
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



long long N;
vector<long long> A;

int main() {
    while (cin >> N) {
        A.resize(N);
        for (int i = 0; i < N; ++i) cin >> A[i];
        A.push_back((1LL<<21)-1);
        
        long long res = 0;
        long long left = 0, right = 0;
        long long bit = 0;
        for (left = 0; left < N;) {
            if ((bit & A[right]) == 0) {
                bit |= A[right];
                if (right < N) ++right;
            }
            else {
                long long bet = right - left;
                res += bet;
                bit &= ~A[left];
                
                //cout << left << ": " << right << endl;
                
                ++left;
            }
        }
        
        cout << res << endl;
            
    }
}






















Measured memory_bytes: 4864
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int f(int n,int x,vi &a,vi &p){
  if(n==0)return (x<=0)?0:1;
  if(x<=1)return 0;
  if(x<a[n-1]+2)return f(n-1,x-1,a,p);
  if(x==a[n-1]+2)return p[n-1]+1;
  if(x<2*a[n-1]+3)return p[n-1]+f(n-1,x-a[n-1]-2,a,p)+1;
  if(x==2*a[n-1]+3)return 2*p[n-1]+1;
  return 0;
}

void run(){
  int n,x;
  cin>>n>>x;
  vi a(n+1),p(n+1);
  a[0]=p[0]=1;
  rep(i,n){
    a[i+1]=2*a[i]+3;
    p[i+1]=2*p[i]+1;
  }
  cout<<f(n,x,a,p)<<endl;
}


Measured memory_bytes: 256
s = input()
mae = int(s[:2])
ato = int(s[2:])

flag1 = 0
flag2 = 0
if 0<mae and mae<=12:
    flag1 = 1
if 0<ato and ato<=12:
    flag2 = 1

if flag1 == 1 and flag2 == 1:
    print('AMBIGUOUS')
elif flag1 == 1:
    print('MMYY')
elif flag2 == 1:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 9196
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999
#define ALL(x) (x).begin(), (x).end()
#define LBi(x, n) lower_bound(ALL(x), n) - (x).begin()
#define ZIP(x) (x).erase(unique(ALL(x)), (x).end())
#define Pi pair<int, int>
#define Vi vector<int>

#define rep(n) for(int i = 0; i < n; i++)

string s, t;
char ch[10];
int n, a, b, c, d, x, m[5];

int main() {
	cin >> x >> a >> b;
	cout << (abs(a - x) > abs(b - x) ? "B" : "A") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 2000000
void Heep(int);
int n,A[MAX+1];

int main() {
  int i;

  scanf("%d",&n);
  for(i = 1 ; i <= n ; i++) {
    scanf("%d",&A[i]);
  }
  for(i = n / 2 ; i >= 1 ; i--) {
    Heep(i);
  }
  
  for(i = 1 ; i <= n ; i++) {
    printf(" %d", A[i]);
  }
  printf("\n");
  return 0;
}

void Heep(int i) {
  int l,r,large,com;

  l = 2 * i;
  r = 2 * i + 1;

  if(l <= n && A[l] > A[i])
    large = l;
  else large = i;
  if(r <= n && A[r] > A[large])
    large = r;
  if (large != i) {
    com = A[i];
    A[i] = A[large];
    A[large] = com;
    Heep(large);
  }
}



Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,i,ans=1;
	bool flag=false;
	cin>>a>>b;
	if(a<=b){
		for(i=a;i<=b;i++){
			ans=i*a*b;
			if(ans%2==1) flag=true;
			ans=0;
		}
	}
	else{
		for(i=b;i<=a;i++){
			ans=i*a*b;
			if(ans%2==1) flag=true;
			ans=0;
		}
	}
	if(!flag) cout<<"No";
	else
	cout<<"Yes";
	
	return 0;
	}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
 
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    L, R = list(map(int,input().split()))
    m=2020
    if R%2019==0:
        print(0)
    elif R-L>2025:
        print(0)
    else:
        for i in range(L,R+1):
            # print(i)
            for j in range(i+1,R+1):
                # print(i,j)
                t=(i*j)%2019
                if t<m:
                    m=t
                    # print(m,i)
        print(m)
        # for i in range(L,R):
        #     # print(m,i)
        #     t=(i*(i+1))%2019
        #     print(t)
        #     if t<m:
        #         m=t
        #         print(m,i)
        # print(m)

    # print(A,B)
    
if __name__ == "__main__":
    main()

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

int main() {
	//cout<<"GfG!";
	long long int n;
	cin>>n;
	long long int arr[n],i=0,sum=0,answer=0,mod=pow(10,9)+7;
	while(i<n)
	{
	    cin>>arr[i];
	    sum+=arr[i];
	    i++;
	}
	i=0;
	while(i<n-1)
	{
	    long long int c=sum;
	    c%=mod;
	    answer=(answer+(arr[i]*((sum-arr[i])%mod))%mod)%mod;
	    sum-=arr[i];
	    i++;
	}
	cout<<answer<<endl;
	return 0;
}

Measured memory_bytes: 5200
def f(A,p,x):
  for i in range(len(A)):
    A[i][p//(2**i)] += x

def g(A,l,r):
  n = 0
  a = [int(i) for i in list(bin(r)[2:])]
  if l > 0:
    b = [int(i) for i in list(bin(l)[2:])]
  t = 0
  for i in range(len(a)):
    n += A[len(a)-i-1][t]*a[i]
    t += a[i]
    t *= 2
  t = 0
  if l == 0:
    print(n)
  else:
    for i in range(len(b)):
      n -= A[len(b)-i-1][t]*b[i]
      t += b[i]
      t *= 2
    print(n)
N,Q = [int(i) for i in input().split()]
L = [[int(i) for i in input().split()]]
L[0].append(0)
while N > 1:
  N = -(-N//2)
  A = [0]*(N+1)
  for i in range(N):
    A[i] = L[-1][2*i] + L[-1][2*i + 1]
  L.append(A)


for _ in range(Q):
  a,b,c = [int(i) for i in input().split()]
  if a == 0:
    f(L,b,c)
  if a == 1:
    g(L,b,c)

Measured memory_bytes: 130272
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;


vector<int>  dx = {1,-1,0,0};
vector<int>  dy = {0,0,1,-1};


int main() {
	int A,B,X; cin >> A >> B >> X;

	if (A + B >= X and A <= X) {
		cout << "YES" << endl;
	}else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while( true ){
			int w = Integer.parseInt(scan.next());
			int h = Integer.parseInt(scan.next());
			if( w == 0 && h == 0 ){
				break;
			}
			MAP[][] state = new MAP[w][h];
			for( int j = 0; j < h; j++ ){
				for( int i = 0; i < w; i++ ){
					state[i][j] = new MAP();
					state[i][j].Reset();
				}
			}
			//??????????????\??????
			int temp = 0;
			for( int j = 0; j < h-1; j++ ){
				for( int i = 0; i < w-1; i++ ){
					//??????????£?
					temp = Integer.parseInt(scan.next());
					state[i][j].r = temp;
					state[i+1][j].l = temp;
				}
				for( int i = 0; i < w; i++ ){
					//??????????£?
					temp = Integer.parseInt(scan.next());
					state[i][j].d = temp;
					state[i][j+1].u = temp;
				}
			}
			//????????????????????????????£?
			for( int i = 0; i < w-1; i++){
				temp = Integer.parseInt(scan.next());
				state[i][h-1].r = temp;
				state[i+1][h-1].l = temp;
			}
			
			System.out.println(Move(state, w, h));
			
		}
		
		return;
	}
	
	public static int Move(MAP state[][], int w, int h){
		int[] x = new int[w*h];
		int[] y = new int[w*h];
		int sum = 0;
		int num = 0;
		int nextNum = 0;
		
		num = 1;
		x[0] = 0;
		y[0] = 0;
		state[0][0].step = 0;
		for( int i = 0; ; i++ ){
			for( int j = sum; j < sum + num; j++ ){
				if( x[j] == w - 1 && y[j] == h - 1 ){
					return i+1;
				}
				if( state[x[j]][y[j]].r == 0 ){
					if( state[x[j]+1][y[j]].step == -1){
						x[sum+num+nextNum] = x[j]+1;
						y[sum+num+nextNum] = y[j];
						state[x[j]+1][y[j]].step = i+1;
//						System.out.printf("%d %d\n", x[sum+num+nextNum], y[sum+num+nextNum]);
						nextNum++;
					}
				}
				if( state[x[j]][y[j]].d == 0 ){
					if( state[x[j]][y[j]+1].step == -1){
						x[sum+num+nextNum] = x[j];
						y[sum+num+nextNum] = y[j]+1;
						state[x[j]][y[j]+1].step = i+1;
//						System.out.printf("%d %d\n", x[sum+num+nextNum], y[sum+num+nextNum]);
						nextNum++;
					}
				}
				if( state[x[j]][y[j]].l == 0 ){
					if( state[x[j]-1][y[j]].step == -1){
						x[sum+num+nextNum] = x[j]-1;
						y[sum+num+nextNum] = y[j];
						state[x[j]-1][y[j]].step = i+1;
//						System.out.printf("%d %d\n", x[sum+num+nextNum], y[sum+num+nextNum]);
						nextNum++;
					}
				}
				if( state[x[j]][y[j]].u == 0 ){
					if( state[x[j]][y[j]-1].step == -1){
						x[sum+num+nextNum] = x[j];
						y[sum+num+nextNum] = y[j]-1;
						state[x[j]][y[j]-1].step = i+1;
//						System.out.printf("%d %d\n", x[sum+num+nextNum], y[sum+num+nextNum]);
						nextNum++;
					}
				}
				
			}
			sum += num;
			num = nextNum;
			if( nextNum == 0 ){
				break;
			}
			nextNum = 0;
		}
		return 0;
	}
	
}

class MAP{
	//1???????£????????????????????£????2???
	int u;
	int l;
	int r;
	int d;
	int step;	//?????????????????????????°??§?????????°???
	public void Reset(){
		u = 1;
		l = 1;
		r = 1;
		d = 1;
		step = -1;
		return;
	}
}

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

template<class T>
void prvec(vector<T>& v) {
	for (T n: v) cout << n << " ";
	cout << "\n";
}


int main() {
	// freopen("./input.txt", "r", stdin);
	int N, T, A;
	cin >> N >> T >> A;
	int ansi;
	double mind;
	for (int i = 1; i <= N; i++) {
		int H;
		cin >> H;
		double t = T - H * 0.006;
		double diff = abs(t - A);
		if (i == 1 || diff < mind) {
			mind = diff;
			ansi = i;
		}
	}
	cout << ansi << "\n";
		
	return 0;
}


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

int main() {
  string a,b;
  cin>>a>>b;
  if(a.size()>b.size())cout<<"GREATER"<<endl;
  if(a.size()<b.size())cout<<"LESS"<<endl;
  if(a.size()==b.size()){
    if(a>b)cout<<"GREATER"<<endl;
    else if(a<b)cout<<"LESS"<<endl;
    else if(a==b)cout<<"EQUAL"<<endl;
  }
  
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int r;
    cin >> r;
    cout << 3 * r * r;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){

  int a,b;
  cin>>a>>b;
     if(a>b)cout<<"a > b"<<endl;
           else
           if(a<b)cout<<"a < b"<<endl;
                  else
                      cout<<"a == b"<<endl;

  return 0;
}



Measured memory_bytes: 3108
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
int n, m, cnt = 0;
vector < pair<int, int>>v;
bool f(int k) {
	bool b[60] = {}, p;
	b[v[k].first] = true;
	do {
		p = false;
		for (int i = 0; i < m; i++) {
			if (i == k)continue;
			else if (b[v[i].first]&&b[v[i].second])continue;
			else if (b[v[i].first]) { b[v[i].second] = true; p = true; }
			else if (b[v[i].second]) { b[v[i].first] = true; p = true; }
		}
	} while (p);
	return !b[v[k].second];
}
int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		v.push_back(make_pair(a, b));
	}
	for (int i = 0; i < m; i++) {
		if (f(i))cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{

    int[] par, rank;
    int INF = Integer.MAX_VALUE;

    void init(int n){
        par = new int[n];
        rank = new int[n];
        for(int i=0; i<n ;i++){
            par[i] = i;
            rank[i] = 0;
        }
    }

    int find(int x){
        if(par[x]==x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x==y) return;

        if(rank[x] < rank[y]) par[x] = y;
        else{
            par[y] = x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    boolean same(int x, int y){
        return find(x) == find(y);
    }

    class Edge{
        int u, v, cost;
        Edge(int u, int v, int cost){
            this.u = u;
            this.v = v;
            this.cost = cost;
        }
    }

    void solve(){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt(), m = sc.nextInt();
            if(n==0 && m==0) break;

            Edge[] e = new Edge[m];
            for(int i=0; i<m; i++){
                int a = sc.nextInt()-1, b = sc.nextInt()-1;
                int w = sc.nextInt();
                e[i] = new Edge(a, b, w);
            }

            Arrays.sort(e, new Comparator<Edge>(){
                    public int compare(Edge e1, Edge e2){
                        return e1.cost - e2.cost;
                    }
                });

            int min = INF;
            for(int start=0; start<=m-n+1; start++){
                int ma = 0, mi = INF;
                init(n);
                int cnt = 0;
                for(int i=start; i<m; i++){
                    Edge ee = e[i];
                    if(!same(e[i].u, e[i].v)){
                        unite(e[i].u, e[i].v);
                        ma = Math.max(ma, e[i].cost);
                        mi = Math.min(mi, e[i].cost);
                        cnt++;
                    }
                }
                if(cnt!=n-1) continue;
                min = Math.min(min, ma-mi);
            }
            if(min==INF) min = -1;
            System.out.println(min);
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 77240
n = int(input())
cards = [[ s+' '+str(n) for n in range(1,14)] for s in ['S','H','C','D']]
for _ in range(n):
   suit,num = input().split()
   if   suit=='S': cards[0][int(num)-1] = 0
   elif suit=='H': cards[1][int(num)-1] = 0
   elif suit=='C': cards[2][int(num)-1] = 0
   elif suit=='D': cards[3][int(num)-1] = 0
for s in cards:
   for n in s:
       if n!=0: print(n)


Measured memory_bytes: 5600
import itertools
n = int(input())
p = list(map(int , input().split()))
q = list(map(int , input().split()))
idx = 1
a = 0
b = 0
for x in itertools.permutations(list(range(1, n+1)), n):
    if tuple(p) == x:
        a = idx
    if tuple(q) == x:
        b = idx
    idx += 1

print(abs(a-b))




Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
const ll MOD=1e9+7;
using namespace std;

//ある文字xを決めてそれを全探索
//一番処理回数が少ないものが答え
int main(){
  bool al[26]={};
  string s;
  cin >> s;
  rep(i,s.size()){
    al[s[i]-'a']=true;
  }
  ll ans = LLONG_MAX;
  rep(i,26){
    if(!al[i]) continue;
    char key = char('a'+i);
    string tmp = s;
    ll num = 0;

    while(1){
      bool flag =true;
      char k = tmp[0];
      for(int j=1;j<tmp.size();j++){
        if(k != tmp[j]){
          flag = false;
          break;
        }
      }
      if(flag) break;


      rep(j,tmp.size()){
        if(tmp[j] == key || tmp[j+1] == key){
          tmp[j] = key;
        }
      }
      tmp.pop_back();
      num++;
    }

    if(num<ans) ans = num;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>

using namespace std;


int main(void) {

	int H, W;

	while (cin >> H >> W, H, W) {
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3072
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;

int cnt[26];
char S[200010];
int group[200010];
int N;
vector<int> pos[26];
vector<char> answer;

int main() {
  memset(S,0,sizeof(S));
  memset(cnt,0,sizeof(cnt));
  scanf("%s", S);
  N= strlen(S);
  for(int i=0;i<N;++i) {
    S[i]= S[i]-'a';
  }
  int gid=0;
  group[N]=-1;
  for(int i=N-1;i>=0;--i) {
    group[i] = gid;
    cnt[S[i]] ++;
    bool no=false;
    for(int j=0;j<26;++j) {
      if(cnt[j] ==0){
        no=true;
      }
    }
    if (!no) {
      gid++;
      memset(cnt,0,sizeof(cnt));
    }
  }
  for(int i=0;i<N;++i) {
    pos[S[i]].push_back(i);
  }
  for(int i=0;i<26;++i) {
    pos[i].push_back(N);
  }
  int currentPos=-1;
  for(int i=gid;i>=0;--i) {
    for(int j=0;j<26;++j) {
      int nextPos=*lower_bound(pos[j].begin(), pos[j].end(), currentPos+1);
      if (group[nextPos]==i-1) {
        currentPos = nextPos;
        answer.push_back('a' + j);
        break;
      }
    }
  }
  for(int i=0;i<answer.size();++i) {
    printf("%c", answer[i]);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 2176
;; F - Many Many Paths

(defparameter *modulus* (+ (expt 10 9) 7))
(defparameter *max-rc* (expt 10 6))

(defun main ()
  (let ((r1 (read))
        (c1 (read))
        (r2 (read))
        (c2 (read)))
    (princ (solve r1 c1 r2 c2))))

(defun solve (r1 c1 r2 c2)
  ; f(r,c) == choose(r+c, r)
  ; sum_{r=0}^{r2} sum_{c=0}^{c2} f(r,c) == f(r+1, c+1) - 1
  (labels ((f (r c) (choose (+ r c) r)))
    (mod+ (f (1+ r2) (1+ c2))
          (- (f (1+ r2) c1))
          (- (f r1 (1+ c2)))
          (f r1 c1))))

;; modulo addition/product/division

(defun mod+ (&rest rest)
  (mod (apply #'+ rest) *modulus*))

(defun mod* (&rest rest)
  (mod (apply #'* rest) *modulus*))

(defun mod/ (num &rest denom)
  (apply #'mod* (cons num (mapcar #'mod-inverse denom))))

(defun bit-sequence (v)
  "(bit-sequence 13) => (1 1 0 1)"
  (nreverse
    (loop for x = v then (ash x -1) while (plusp x)
          collect (logand x 1))))

(let ((modulus-2-bits (bit-sequence (- *modulus* 2))))
  ; Mが素数のとき，a^(M-2) ≡ a^(-1) mod M (フェルマーの小定理より)
  (defun mod-inverse (a)
    (loop for b in modulus-2-bits
          for e = a then (mod* e e (if (zerop b) 1 a))
          finally (return e))))

(let* ((max-n (+ *max-rc* *max-rc* 2))
       (fact (make-array (1+ max-n)))) ; 階乗
  (setf (aref fact 0) 1) ; 0! = 1
  (loop for i from 1 to max-n
     do (setf (aref fact i) (mod* (aref fact (1- i)) i)))
  (defun choose (n k)
    (mod/ (aref fact n) (aref fact k) (aref fact (- n k)))))

(main)


Measured memory_bytes: 32992
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    vector<int> balls;
    int i,j,t;
    cin >> n >> k;
    balls.resize(n);
    for(i=0;i<n;i++){
        cin >> t;
        balls[t-1]++;
    }
    t=0;
    sort(balls.begin(),balls.end());
    for(i=0;i<n-k;i++) t += balls[i];
    cout << t << endl;
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		
		if ( 1200 > x ){
			System.out.println("ABC");
		} else {
			System.out.println("ARC");
		}
	
		

	}

}

Measured memory_bytes: 21844
s = input()
ev = "10"*(10**5)
od = "01"*(10**5)
evcnt = 0
odcnt = 0
for cnt, i in enumerate(s):
	if i == ev[cnt]:
		evcnt += 1
	if i == od[cnt]:
		odcnt += 1
print(len(s)-max(evcnt, odcnt))

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

int main() {
  int H,W,K;
  int cnt = 0;
  cin >> H >> W >> K;
  vector<vector<char>> G(H,vector<char>(W));
  rep(i,H){
    rep(j,W){
      cin >> G.at(i).at(j);
    }
  }
  int ans = 0;
  for (int tmpH = 0; tmpH < (1 << 6); tmpH++) {
    bitset<6> sH(tmpH);
    for (int tmpW = 0; tmpW < (1 << 6); tmpW++) {
       bitset<6> sW(tmpW);
      // (ビット列sに対する処理)
      vector<vector<char>> Gc = G;
      bool flag = false;
      for(int al = H;al<6;al++){
        if(sH.test(al)){
          flag = true;
        }
      }
      for(int al = W;al<6;al++){
        if(sW.test(al)){
          flag = true;
        }
      }
      if(flag){
        continue;
      }
      rep(i,H){
        if(sH.test(i)){
          rep(v,W){
            Gc.at(i).at(v) = '.';
          }
        }
      }
      rep(i,W){
        if(sW.test(i)){
          rep(v,H){
            Gc.at(v).at(i) = '.';
          }
        }
      }
      rep(i,H){
        rep(j,W){
          if(Gc.at(i).at(j) == '#'){
            cnt++;
          }
        }
      }
      if(cnt == K){
        ans++;
      }
      cnt = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(void) {
  int x1;
  int x2;
  int x3;
  int x4;
  int x5;
  scanf("%d""%d""%d""%d""%d",&x1,&x2,&x3,&x4,&x5);
  if(x1 == 0){
    printf("%d",1);
  }
  else if(x2 == 0){
    printf("%d",2);
  }
  else if(x3 == 0){
    printf("%d",3);
  }
  else if(x4 == 0){
    printf("%d",4);
  }
  else if(x5 == 0){
    printf("%d",5);
  }

  return 0;
}

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

int main(){
    string S;cin>>S;int L=S.size();
    long N[L];
    for(int i=0;i<L;i++){
        N[i]=S.at(i)-'0';
    }long temp,count;long sum=0;
    for(int i=0;i<(1<<L-1);i++){
        count=1;
        temp=N[L-1];
        for(int j=L-2;j>=0;j--){
            if(i&(1<<j)){
                count=1;
            }else{
                count*=10;
            }temp+=N[j]*count;
        }sum+=temp;
    }cout<<sum<<endl;
}

Measured memory_bytes: 256