akhauriyash/Code-Regression huggingface dataset:
//#include <tourist>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//g++ yarudake.cpp -std=c++17 -I .
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll op(ll a, ll b)
{
    return max(a, b);
}
ll e()
{
    return -1;
}
ll target;
bool f(ll v)
{
    return v < target;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll maxa=0;
    rep(i,n){
        chmax(maxa,a[i]);
    }
    segtree<ll, op, e> seg(maxa+1);
    rep(i, n)
    {
        ll l=max(ll(0),a[i]-k);
        ll r=min(maxa,a[i]+k);
        ll temp=seg.prod(l,r+1);
        if(temp==-1){
            temp++;
        }
        seg.set(a[i],temp+1);
        /*
        rep(j,10){
            cout<<seg.get(j)<<" ";
        }
        cout<<"\n";
        */
    }
    cout<<seg.all_prod()<<"\n";
}


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

int main()
{
	int a[5];
	int mi1 = 10000, mic = 1000;
	for (int i = 0; i < 5; ++i)
	{
		cin >> a[i];
		if (a[i] % 10 != 0 && mi1 > a[i]%10)
		{
			mi1 = a[i] % 10;
			mic = i;
		}
	}
	int ans = 0;
	for (int i = 0; i < 5; ++i)
	{
		if (i == mic)
		{
			ans += a[i];
		}
		else
		{
			ans += ((a[i] + 9) / 10) * 10;
		}
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>


using namespace std;

int P[110];

void init(int N){
    for(int i = 0; i < N; i++) P[i] = i;
}

int root(int a){
    if (P[a] == a) return a;
    return (P[a] = root(P[a]));
}

bool is_same_set(int a, int b){
    return root(a) == root(b);
}

void unite(int a, int b){
    P[root(a)] = root(b);
}

int main(){
    int n; 
    cin >> n; 
    int w;
    init(n);
    vector< pair<int, pair<int, int> > > edges;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            cin >> w;
            if (i > j && w != -1) edges.push_back(make_pair(w, make_pair(i, j)));
        }
    }
    sort(edges.begin(),edges.end());
    int sum = 0;
    while(!edges.empty()){
        pair<int, pair<int, int> > edge = edges[0];
        edges.erase(edges.begin());
        int cost = edge.first;
        int src = edge.second.first;
        int dst = edge.second.second;
        //cout << cost << " " << src << " " << dst << endl;
        if (!is_same_set(src, dst)){
            //cout << "unite " << src << " " <<  dst << " cost = " << cost << endl;
            unite(src, dst);
            sum += cost;
        }
    }
    cout << sum << endl;
}

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

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

  int cnt = 0;
  for (int i=A; i<=B; i++){
    int a=i%10, b=i/10000%10, c=i/10%10, d=i/1000%10;
    if (a==b && c==d){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 36

struct Card {
  char suit;
  int value;
};

void bubbleSort(Card A[], int n) {
  for ( int i = 0; i < n; i++ ) {
    for ( int j = n - 1; j > 0; j-- ) {
      if ( A[j].value < A[j - 1].value ) {
        Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
      }
    }
  }
}

void selectionSort(Card A[], int n) {
  for ( int i = 0; i < n; i++ ) {
    int min = i;
    for ( int j = i; j < n; j++ ) {
      if ( A[min].value > A[j].value ) min = j;
    }
    Card t = A[min]; A[min] = A[i]; A[i] = t;
  }
}

int main() {
  int n;
  Card A[MAX], B[MAX];
  char t[3];

  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) {
    scanf("%s", t);
    A[i].suit = B[i].suit = t[0];
    A[i].value = B[i].value = t[1] - '0';
  }

  bubbleSort(A, n);
  selectionSort(B, n);

  for ( int i = 0; i < n; i++ ) {
    if(i) printf(" ");
    printf("%c%d", A[i].suit, A[i].value);
  }
  printf("\nStable\n");
 for ( int i = 0; i < n; i++ ) {
    if(i) printf(" ");
    printf("%c%d", B[i].suit, B[i].value);
  }

  int i = 0;
  while ( i < n - 1) {
    if ( A[i].suit != B[i].suit ) break;
    i++;
  }
  if ( i == n - 1 ) printf("\nStable\n");
  else printf("\nNot stable\n");

  return 0;
}



Measured memory_bytes: 2740
#include <cstdio>

int N,P;
int suffix[200000];
int count[10000];
int power[200000];

typedef long long int ll;

int main(){

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

    for(int i=0;i<N;i++){
        int digit=getchar()-'0';
        suffix[i]=digit;
    }

    ll c_early=0;
    if (P==2||P==5){
        for (int i=N-1;i>=0;i--){
            if (suffix[i]%P==0)
                c_early+=(i+1);
        }

        printf("%lld\n",c_early);
        return 0;
    }

    for (int i=N-1,prev=0,power=1,j=0;i>=0;i--,power=(power*(10%P))%P){
        suffix[i]=(prev+(suffix[i]*power)%P)%P;
        prev=suffix[i];
        // printf("%d\n",prev);
    }

    ll c=0;
    count[0]=1;
    for (int i=N-1;i>=0;i--){
        c+=count[suffix[i]];
        count[suffix[i]]++;
    }

    printf("%lld\n",c);

    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	var S string
	fmt.Scan(&S)
	ans := 0
	count := 0
	for _, K := range S {
		k := string(K)
		if k != "A" && k != "T" && k != "G" && k != "C" {
			count = 0
		} else {
			count++
			ans = max(ans, count)
		}
	}
	fmt.Println(ans)
}


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

using namespace std;

int main(void) {
        long long int X;
        scanf("%lld", &X);


        long long int sum = 100;
        int cnt = 0;

        while(sum < X) {
                sum = sum + (long long int)(sum*0.01);
//              printf("%lld\n", (long long int)(sum*0.01));
                cnt ++;
        }

        printf("%d\n", cnt);

        return 0;
}


Measured memory_bytes: 3828
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, n) {cin >> a[i];}
#define readmat(a, n, m) int a[(n) + 1][(m) + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

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

    #ifndef ONLINE_JUDGE 
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        freopen ("OUTPUT_ERROR.txt" , "w" , stderr);
    #endif

    //start from here

    read(n) readarr(h, n)

    int dp[n + 1]; dp[1] = 0;

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

    dp[2] = abs(h[1] - h[2]);

    fori (i, 3, n)
    {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i-2] - h[i]));
    }

    print(dp[n])
    return 0;
}


Measured memory_bytes: 5096
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#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()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n, v) rep(i, n) cin >> v[i]

using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1, 0, -1, 0}, y_pos[4] = {0, 1, 0, -1};
int ctoi(char c)
{
	if (c >= '0' && c <= '9')
	{
		return c - '0';
	}
	return 0;
}

char upper(char c)
{
	return c - 0x20;
}

char lower(char c)
{
	return c + 0x20;
}

void unique_vector(vector<int> &v)
{
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	std::fill((T *)array, (T *)(array + N), val);
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y)
{
	if (y == 0)
		return x;
	return gcd(y, x % y);
}

//最小公倍数
ll lcm(ll x, ll y)
{
	ll g = gcd(x, y);
	return x / g * y;
}

ll myPow(ll x, ll n, ll m)
{
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

//k!
ll facctorialMethod(ll k)
{
	ll sum = 1;
	for (ll i = 1; i <= k; ++i)
	{
		sum *= i;
		sum %= MOD;
	}
	return sum;
}

//nCr
ll permutationMethod(ll n, ll r)
{
	ll n_sum, r_sum;
	ll i;
	r = n - r;
	n_sum = facctorialMethod(n);
	r_sum = facctorialMethod(r);
	return n_sum / r_sum;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	rep(i, s.length()){
		int x = s[i] - 'A';
		x = (x + n) % 26;
		cout << (char)(x + 'A');
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    int k,n,M=0;
    int A[200005];
    cin>>k>>n;
    REP(i,n)cin>>A[i];
    REP(i,n-1) M=max(M,A[i+1]-A[i]);
    M=max(M,k-(A[n-1]-A[0]));
    cout<<k-M<<endl;
}

Measured memory_bytes: 1024
N,K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))

import copy
A.sort(reverse = True)
DA = copy.copy(A)
F.sort()

import sys
if (sum(A) <= K):
    print(0)
    sys.exit()

values = [0]*N
for i in range(N):
    values[i] = A[i]*F[i]

def judge(val):
    cnt = 0
    for i in range(N):
        if (values[i] > val):
            cnt += A[i]-val//F[i]
    
    return cnt<=K

s = 0
e = max(A)*max(F)
while (s<e):
    c = (s+e)//2
    if judge(c):
        e = c-1
        
    else:
        s = c+1

while(judge(c)):
    c-=1
while (not(judge(c))):
    c+=1
print(c)
    

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

int main(){
  string y;
  long long cnt=0;

  cin >> y;
  int l=y.length();

  for(int i=0;i<l;i++){
    int tmp=y.at(i)-'0';
    cnt+=tmp;
  }

  if(cnt%9==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3720
def main():
    N, A, B = map( int, input().split())
    if A > B:
        print(0)
        return
    if N == 1 and A != B:
        print(0)
        return
    print( (A+B*(N-1)) - (A*(N-1)+B) + 1)
if __name__ == '__main__':
    main()


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = INF + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 300 + 7;

int n;
int a[N];

bool read () {
	if (scanf("%d", &n) != 1)
		return false;
	forn(i, n)
		scanf("%d", &a[i]);
	return true;
}

ld dp[N][N][N];

ld calc(int a, int b, int c){
	ld& d = dp[a][b][c];
	if (d > -0.5) return d;
	d = 0;
	if (a + b + c == 0) return d;
	if (a > 0) d += calc(a - 1, b, c) * a;
	if (b > 0) d += calc(a + 1, b - 1, c) * b;
	if (c > 0) d += calc(a, b + 1, c - 1) * c;
	d /= (a + b + c);
	if (n != a + b + c)
		d += n / ld(a + b + c);
	else
		d += 1;
	return d;
}

void solve() {	
	int cnt1 = 0, cnt2 = 0, cnt3 = 0;
	forn(i, n){
		cnt1 += (a[i] == 1);
		cnt2 += (a[i] == 2);
		cnt3 += (a[i] == 3);
	}
	forn(i, n + 1) forn(j, n + 1) forn(k, n + 1)
		dp[i][j][k] = -1;
	printf("%.15Lf\n", calc(cnt1, cnt2, cnt3));
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
	
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

	while(read()) {	
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 444672
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; ll k; cin >> n >> k;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  auto bsearch = [&]() {
    auto test = [&](ll t) {
      ll cnt = 0;
      rep(i, n) cnt += (A[i]-1)/t;
      return cnt <= k;
    };
    ll ok = longinf, ng = 0;
    while(ok-ng>1) {
      ll mid = (ok+ng)/2;
      (test(mid) ? ok : ng) = mid;
    }
    return ok;
  };
  cout << bsearch() << "\n";
  return 0;
}


Measured memory_bytes: 4716
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

bool first_change(const pair<int,int>& first, const pair<int,int>& second){
    return first.first < second.first;
}

int main(){
    long N,M,tmp_first,tmp_second,ans=0,count=0;
    cin >> N;
    cin >> M;
    vector< pair<long,long> > pairs(N);

    for(int i=0;i<N;i++){
        cin >> tmp_first;
        cin >> tmp_second;
        pairs[i] = make_pair(tmp_first,tmp_second);
    }

    sort(pairs.begin(),pairs.end(),first_change);

    for(int i=0;i<N;i++){
        for(int j=0;j<pairs[i].second;j++){
            if(count != M){
                ans += pairs[i].first;
                count++;
            }else{
                break;
            }
        }
        if(count == M)break;
    }

    cout << ans << endl;

    return 0;
}

/**
重複を許すkeyとvalueのセットを用意
keyで昇順にソートしたい
**/

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> doup;

int main(void) {
    ll N;
    cin >> N;
    ll cnt[4]={0};
    ll i;
    char c;
    for(i=0; i<N; i++) {
        cin >> c;
        if(c=='P')cnt[0]++;
        else if(c=='W') cnt[1]++;
        else if(c=='G') cnt[2]++;
        else cnt[3]++;
    }
    ll ans=0;
    for(i=0; i<4; i++) {
        if(cnt[i]) ans++;
    }
    
    if(ans==3) cout << "Three" << endl;
    else cout << "Four" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int dp[31];

int rec(int i){
  if (dp[i] != -1) return dp[i];
  if (i == 0) return 1;
  if (i == 1) return 1;
  if (i == 2) return 2;
  return dp[i] = rec(i - 1) + rec(i - 2) + rec(i - 3);
}

int main(void)
{
  int n;
  while (1){
    scanf("%d", &n);
    if (n == 0) break;
    memset(dp, -1, sizeof(dp));
    printf("%d\n", rec(n) / 3650 + 1);
  }

  return 0;
}

Measured memory_bytes: 600
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//using ll = long long;
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    int a, b ,k;
    cin >> a >> b >> k;
    for(int i = a;i <= min(a+k-1,b); i++)cout << i << endl;
    for(int i = max(a+k,b-k+1);i <= b; i++)cout << i << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    int a;
    cin>>n;
  	int count=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        if(i%2!=0 && a%2!=0)
            count++;
    }
    cout<<count;
    return 0;
}

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

int A[101][101];
char type[101];
int p[101];//親
int d[101];//重み
int n;
int dsum = 0;

int Prim(int k){
    type[k] = 'B';
    //cout << "now in " << k << endl;;
    for(int i=1; i<=n; i++){
        if((A[k][i] != -1) && (type[i] != 'B')){
            if(A[k][i] < d[i]){
                d[i] = A[k][i];
                type[i] = 'G';
                //cout << "d[" << i << "] is " << d[i] << endl;
            }
        }
    }
    int min = 0;
    for(int j=1; j<=n; j++){
        if(type[j] == 'G'){
            if(d[j] < d[min]){
                min = j;
            }
        }
    }
    if(min == 0){
        return 0;
    } else {
        dsum += d[min];
        Prim(min);
    }
}

int main(){
    cin >> n;
    for(int i=1; i<=n; i++){//データを代入
        for(int j=1; j<=n; j++){
            cin >> A[i][j];
        }
    }

    //p,d,typeの初期化
    for(int i=0; i<=n; i++){
        type[i] = 'W';
        d[i] = 2001;
    }

    Prim(1);

    cout << dsum << endl;
}


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

template<int MOD> struct modint{
    int val;
    constexpr modint(int v): val(v % MOD){
        if(val < 0) val += MOD;
    }
    constexpr int getmod(){
        return MOD;
    }
    constexpr modint operator-(){
        return val? MOD - val : 0; 
    }

    constexpr modint operator+(const modint& r){
        return modint(*this) += r;
    }
    constexpr modint operator-(const modint& r){
        return modint(*this) -= r;
    }
    constexpr modint operator*(const modint& r){
        return modint(*this) *= r;
    }
    constexpr modint operator/(const modint& r){
        return modint(*this) /= r;
    }


    constexpr modint& operator+=(const modint &r){
        val += r.val;
        if(val >= MOD) val -= MOD;
        return *this;
    }
    constexpr modint& operator-=(const modint& r){
        val -= r.val;
        if(val < 0) val += MOD;
        return *this;
    }
    constexpr modint& operator*=(const modint& r){
        val = (val * r.val) % MOD;
        return *this;
    }
    constexpr modint& operator/=(const modint& r){
        // ax + bz = a, ay + bw = b からスタートして
        // 右辺について互除法して係数を変えていく
        // (x, y) -> (y, x-y*(a/b)), (z, w) -> (w, z-w*(a/b))
        // 最終的に ax + bz = gcd(a, b) となるので a, b が互いに素なら x が逆元
        // z と w を覚えておく必要はない
        int a = r.val, b = MOD, x = 1, y = 0;
        while(b){
            x -= y * (a/b); swap(x, y);
            a -= b * (a/b); swap(a, b);
        }
        val = (val * x) % MOD;
        if(val < 0) val += MOD;
        return *this;
    }

    constexpr bool operator==(const modint& r){
        return val == r.val;
    }
    constexpr bool operator!=(const modint& r){
        return val != r.val;
    }

    constexpr modint modpow(int e){
        modint ans = 1, n = *this;
        while(e){
            if(e & 1) ans *= n;
            n *= n;
            e /= 2;
        }
        return ans;
    }

    friend constexpr ostream& operator<<(ostream &os, const modint<MOD>& x){
        return os << x.val;
    }
};

const int MOD = 998244353;
using mint = modint<MOD>;

signed main(){
    // cout << fixed << setprecision(10) << flush;


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

    vector<vector<mint>> dp(n+1, vector<mint>(s+1, 0));
    dp[0][0] = 1;
    for(int i=0; i<n; i++){
        for(int j=s; j>=a[i] && j>=0; j--){
            // 荷物 i を追加するパターンとしないパターンがある
            dp[i+1][j] = dp[i][j-a[i]] + dp[i][j] * 2;
        }
        for(int j=min(a[i]-1, s); j>=0; j--){
            // 荷物 i は追加できない
            dp[i+1][j] = dp[i][j] * 2;
        }
    }

    cout << dp[n][s] << endl;


    return 0;
}

Measured memory_bytes: 73596
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    int x,k;
    cin>>x>>k;
    cout<<(x%k?1:0);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = int.Parse(Console.ReadLine());

            int[] M = new int[5] {1, 2, 3, 4, 5 };

            int a = X / 100;
            X -= 100 * a;
            int ans = 0;
            for (int i = 4; i >= 0; i--)
            {
                int t = X / M[i];
                X -= t * M[i];
                ans += t;
            }

            if (X == 0 && ans <= a)
            {
                Console.WriteLine(1);
            }
            else
            {
                Console.WriteLine(0);
            }

        }

    }

}


Measured memory_bytes: 13140
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int

int main()
{
    string s;
    int c[3] = {};

    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'a')
            c[0]++;
        if (s[i] == 'b')
            c[1]++;
        if (s[i] == 'c')
            c[2]++;
    }
    for (int i = 0; i < s.size(); i++)
    {
        if (c[i] != 1)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n, h[100000+1]={0};
  scanf("%d", &n);
  for(int i=0; i<n; i++){ scanf("%d", &h[i]); }

  int cnt=0, ans=0;
  for(int i=0; i<n-1; i++){
    if( h[i] >= h[i+1] ){ cnt++; }
    else                { cnt=0; }
    if( cnt > ans ){ ans = cnt; }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 2096
using System;
using System.Linq;

namespace _0217
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0)
                {
                    break;
                }
                int nowp = 0;
                int nowd = 0;
                for (int i = 0; i < n; i++)
                {
                    int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    if (nowd < x[1] + x[2])
                    {
                        nowd = x[1] + x[2];
                        nowp = x[0];
                    }
                }
                Console.WriteLine(nowp + " " + nowd);
            }
        }
    }
}

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

using namespace std;

int main()
{
    string str;
    cin>>str;
    int streak = 0, ans = 0;
    for(auto i = 0 ; i < str.size() ; ++i) {
        if(str[i] == 'R')
            streak++;
        else {
            ans = max(streak,ans);
            streak = 0;
        }
    }
    ans = max(streak,ans);
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

typedef pair<int, int> P;
int main(){
   long long n,d;
   cin>>n>>d;
   long long x[n][d];
   rep(i,n)
       rep(j,d){
            long long t;
            cin>>t;
            x[i][j]=t;
       }
    long long ans=0;
    rep(i,n){
        for(int j=i+1; j<n; j++){
            long long dis=0;
            rep(k,d){
                dis+=pow((x[i][k]-x[j][k]),2);
             }
             long long p=(long long)sqrt(dis);
             if(p*p==dis){
                 ans++;
             }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<vector<vector<int>>> v3int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef vector<vector<vector<ll>>> v3ll;
typedef list<int> liint;
typedef pair<int, int> pint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, int>> vpll_int;
typedef vector<pair<int, ll>> vpint_ll;
typedef set<pair<int, int>> spint;
typedef set<pair<ll, int>> spll;
typedef unordered_map<int, unordered_set<int>> Graph;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    int K;
    cin >> K;
    vll a(N);
    rep(i, N) cin >> a[i];
    ll now = a[0];
    int j = 0;
    REP(i, K, N) {
        if (now < a[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
        j++;
        now = a[j];
    }

    return 0;
}

Measured memory_bytes: 4788
/* One original thought is worth a thousand mindless quotings */

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<algorithm>
#include<bitset>
#include<queue>
#include <math.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);cout << fixed;
#define dbset(x) for(int i=0 ; i<x.size(); i++) cerr << x[i] << " "; cerr << endl;
#define inf 1000000007
#define INF 1000000000000000000LL
#define PI 3.14159265358979323846
#define mod 1000000007
#define mod1 1000696969
#define flusz fflush(stdout);
#define VI vector<int>
#define VPI vector < pair<int,int> >
#define PII pair<int, int>
#define PIII pair<pair<int,int>,int>
#define BIT bitset<N>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define M (L+R)/2
#define endl '\n'
#define REP(x, y) for(int x = 0; x < (y); ++x)
#define FOR(x, y, z) for(int x = y; x <= (z); ++x)
#define FORR(x, y, z) for(int x = y; x >= (z); --x)
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define int long long
const int N = 1000*1000 + 7;

int test;

int l;

int n = 20,m;

int sum[N];

vector<PIII> e;

void solve()
{	
	cin >> l;

	int pom = 0;

	FORR(i,20,1){
		sum[i] = pom+1;
		pom += sum[i];
	}

	FORR(i,19,1){
		e.eb(mp(i,i+1),0);
	}

	int zalatwione = 0;

	debug(sum[1]);

	FORR(i,19,1){
		if (sum[i] > l){
			l -= sum[i+1];
			zalatwione = sum[i+1];
			break;
		}

		e.eb(mp(i,i+1),sum[i+1]);
	}

	if (l >= sum[1]){
		l -= sum[1];
		zalatwione = sum[1];
	}

	while(l > 0){
		FOR(i,1,20){
			if (l >= sum[i]){
				e.eb(mp(1,i),zalatwione);
				zalatwione += sum[i];
				l -= sum[i];
			}
		}
	}

	cout << n << " " << e.size() << endl;

	for(auto it:e){
		cout << it.st.st << " " << it.st.nd << " " << it.nd << endl;
	}

    return;
}

int32_t main()
{
    boost

    test=1;

	for(int i=1; i <= test; i++){
        solve();
	}

    return 0;
}


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

int main() {
  int N;
  cin>>N;
  vector<int> T(N);
  int sum=0;
  rep(i,N) {
    cin>>T[i];
    sum += T[i];
  }
  int M;
  cin>>M;
  rep(i,M) {
    int P,X;
    cin>>P>>X;
    P--;
    int ans=sum;
    ans -= T[P];
    ans += X;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
while True:
    a, op, b = input().split()
    a, b = int(a), int(b)
    if op == '?':
        break
    elif op == '+':
        print(a + b)
    elif op == '-':
        print(a -b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)



Measured memory_bytes: 5600
#include <iostream>
using namespace std;
#define N 1010

int main(){
  int A[N];
  int cnt=0;
  A[0]=0;
  for (int i=1; i<1000; i++){
    cnt += i;
    A[i] = cnt;
  }

  int a, b;
  cin >> a >> b;
  int c = b - a;
  cout << A[c]-b << endl;
}

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

struct Node
{
  vector<int> to;
  vector<int> cost;
};
Node Graph[1010];
void AddEdge(int from, int to, int cost, Node *graph)
{
  graph[from].to.push_back(to);
  graph[from].cost.push_back(cost);
}
bool negative[1010];
ll dp[1010];

int main()
{
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i)
  {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    AddEdge(a, b, -c, Graph);
  }

  for (int i = 0; i < 1010; ++i)
  {
    dp[i] = 1e15;
  }

  dp[0] = 0;
  for (int i = 0; i < n; ++i)
    for (int v = 0; v < n; ++v)
    {
      for (int k = 0; k < Graph[v].to.size(); ++k)
      {
        int to = Graph[v].to[k];
        ll cost = Graph[v].cost[k];
        if (dp[v] != 1e15 && dp[to] > dp[v] + cost)
        {
          dp[to] = dp[v] + cost;
        }
      }
    }
  for (int v = 0; v < n; ++v)
  {
    for (int k = 0; k < Graph[v].to.size(); ++k)
    {
      int to = Graph[v].to[k];
      ll cost = Graph[v].cost[k];
      if (dp[v] != 1e15 && dp[to] > dp[v] + cost)
      {
        dp[to] = dp[v] + cost;
        negative[to] = true;
      }
      if (negative[v])
        negative[to] = true;
    }
  }
  if (negative[n - 1])
  {
    cout << "inf" << endl;
    return 0;
  }
  cout << -dp[n - 1] << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
using namespace std;

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

    char maze[h][w];
    int dist[h][w];

    int count_w = 0;

    for(int y = 0; y < h; y++){
        for(int x = 0; x < w; x++){
            cin >> maze[y][x];
            dist[y][x] = 1e9;
            if(maze[y][x] == '.'){
                count_w++;
            }
        }
    }

    queue <pair<int, int> > q;
    pair<int, int> t;
    q.push(make_pair(0, 0));
    dist[0][0] = 0;

    while(!q.empty()){
        t = q.front();
        q.pop();
        if(t.first-1 >= 0 and maze[t.first-1][t.second] == '.' and dist[t.first-1][t.second] == 1e9){
            q.push(make_pair(t.first-1, t.second));
            dist[t.first-1][t.second] = dist[t.first][t.second] + 1;
        }
        if(t.first+1 < h and maze[t.first+1][t.second] == '.' and dist[t.first+1][t.second] == 1e9){
            q.push(make_pair(t.first+1, t.second));
            dist[t.first+1][t.second] = dist[t.first][t.second] + 1;
        }
        if(t.second-1 >= 0 and maze[t.first][t.second-1] == '.' and dist[t.first][t.second-1] == 1e9){
            q.push(make_pair(t.first, t.second-1));
            dist[t.first][t.second-1] = dist[t.first][t.second] + 1;
        }
        if(t.second+1 < w and maze[t.first][t.second+1] == '.' and dist[t.first][t.second+1] == 1e9){
            q.push(make_pair(t.first, t.second+1));
            dist[t.first][t.second+1] = dist[t.first][t.second] + 1;
        }
    }

    if(dist[h-1][w-1] == 1e9){
        printf("-1\n");
    }
    else{
        printf("%d\n", count_w - dist[h-1][w-1]-1);
    }

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
    int v0 = a, v1 = b, v2 = a % b;
    while (v2 != 0) {
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    };
    return v1;
}

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}


int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> a(N+2);
    rep(i,N) {
        cin >> a[i];
        a[i]/=2;
    }
    ll ans = 1;
    for (ll i = 0; i < N; i++) ans = lcm(ans, a[i]);
    ll b = 0;
    for(ll i = 1; ; i+=2){
        if(ans*i > M) break;
        b++;
    }
    rep(i, N) {
        if(ans/a[i]%2==0) {
            b = 0;
            break;
        }
    }
    cout << b << endl;
    return 0;
}

Measured memory_bytes: 1024
import itertools

N = int(input())
S = input()

r = len(list(filter(lambda x: x == "R", S)))
g = len(list(filter(lambda x: x == "G", S)))
b = len(list(filter(lambda x: x == "B", S)))

# print("r:{}, g:{}, b:{}".format(r, g, b))

ans = r * g * b
RGB = list(itertools.permutations(["R", "G", "B"], 3))

# print(RGB)

for i in range(1, N):
    for j in range(N-i*2):
        if (S[j], S[j+i], S[j+2*i]) in RGB:
            ans -= 1

print(ans)


Measured memory_bytes: 9184
#include <iostream>

using namespace std;

void f(int a, int b) {
    if ((a & 1) && (b & 1)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

int main() {

    int a, b;
    cin >> a >> b;

    f(a, b);

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,m,k;
    int sum=0;
    scanf("%d%d%d",&n,&m,&k);
    while(m>=n)
    {
        m-=n;
        sum++;
        if(sum>=k)break;
    }
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	string ans = "";
	for(char ch:s){
		if(ch=='0'){
			ans+='0';
		}
		else if(ch=='1'){
			ans+='1';
		}
		else if(ch=='B' && ans!=""){
			ans.erase(ans.end()-1);
		}
	}
	cout<<ans<<endl;
}

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

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

    int ans = 0;
    for (int i = 0; i < n-2; i++) {
        for (int j = i+1; j < n-1; j++) {
            for (int k = j+1; k < n; k++) {
                if (l[i]==l[j] || l[j]==l[k] || l[k]==l[i]) {
                    continue;
                }
                int m = max(l[i],max(l[j],l[k]));
                int sum = l[i]+l[j]+l[k];
                if (sum - m > m) {
                    ans++;
                }
            }
        }
    }

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

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

int main() {
  int n;
  vector<int> point(2);
  cin >> n;
  rep(i,n) {
    string t,h;
    cin >> t >> h;
    if(t == h) {
      point[0]++; point[1]++;
    }else if(t < h) {
      point[1] += 3;
    }else if(t > h) {
      point[0] += 3;
    }
  }
  cout << point[0] << ' ' << point[1] << endl;;
  return 0;
}


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

int main(){
    int homu, homuhomu, homuhomuhomu;
    cin >> homu >> homuhomu >> homuhomuhomu;
    int HOMU = homu + homuhomu;
    while(homuhomuhomu){
        --HOMU;
        if(!(homu % HOMU) && !(homuhomu % HOMU) ){
            --homuhomuhomu;
        }
    }
    cout << HOMU << endl;
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,m; cin>>n>>m;
    vector<ll> s(n,0),t(m,0),dp(m+1,0);
    dp[0]=1;
    rep(i,n) cin>>s[i];
    rep(i,m) cin>>t[i];
    rep(i,n){
        ll cnt=1;
        rep(j,m){
            ll temp=dp[j+1];
            if(s[i]==t[j]){
                dp[j+1]=(dp[j+1]+cnt)%MOD;
            }
            cnt=(cnt+temp)%MOD;
        }
    }
    ll ans=0;
    rep(i,m+1) ans=(ans+dp[i])%MOD;
    cout<<(ans+MOD)%MOD<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define FOR(i, N) for (long i = 0; i < (N); i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    string C;
    cin >> N;
    cin >> C;

    int incorrect_R = 0;
    int incorrect_W = 0;
    FOR(n, N) {
        if (C[n] != 'R') {
            incorrect_R += 1;
        }
    }

    int ans = max(incorrect_W, incorrect_R);
    for (int n = N - 1; n >= 0; n--) {
        if (C[n] == 'R') {
            incorrect_W += 1;
        } else {
            incorrect_R -= 1;
        }

        if (ans > max(incorrect_W, incorrect_R)) {
            ans = max(incorrect_W, incorrect_R);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3728
#include<stdio.h>
int main(){
    int n, ans = 0;
    scanf("%d",&n);
    char s[n + 1];
    scanf("%s",s);
    for(int i = 0; i < n - 2; i++)
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
            ans ++;
    printf("%d\n",ans);
    return 0;
}

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


int n, m, cnt, a[16], b[16];
bool flag;

void move(int num, int dest, int* a);

int main() {
	
	while (1) {
		cin >> n >> m;
		if (n == 0 && m == 0)break;

		int numt, tmp;
		for (int i = 0; i < 3; i++) {
			cin >> numt;
			for (int j = 0; j < numt; j++) {
				cin >> tmp;
				a[tmp] = i;
				b[tmp] = i;
			}
		}
		
		int ans1, ans2;

		cnt = 0;
		flag = true;
		for (int num = 1; num <= n; num++) {
			move(num, 2, a);
		}
		if (flag == true) {
			ans1 = cnt;
		} else {
			ans1 = -1;
		}

		cnt = 0;
		flag = true;
		for (int num = 1; num <= n; num++) {
			move(num, 0, b);
		}
		if (flag == true) {
			ans2 = cnt;
		} else {
			ans2 = -1;
		}


		int ans;
		if (ans1 == -1) {
			ans = ans2;
		} else if(ans2 == -1){
			ans = ans1;
		} else {
			ans = min(ans1, ans2);
		}
		//cout << ans1 << " " << ans2 << endl;
		cout << ans << endl;
	}


	return 0;
}

void move(int num, int dest, int* a) {
	
	if (cnt > m || flag == false) {
		flag = false;
		return;
	}

	int dist = abs(dest - a[num]);
	if (dist == 0) {
		return;
	} else if (dist == 1) {
		if (num == n) {
			cnt += 1;
			a[num] = dest;
		} else {
			int i = 1;
			while (num + i <= n) {
				move(num + i, 3 - dest - a[num], a);
				i++;
			}
			cnt += 1;
			a[num] = dest;
		}
	} else if (dist == 2) {
		if (num == n) {
			cnt += 2;
			a[num] = dest;
		} else {
			move(num, 1, a);
			move(num, dest, a);
		}
	}


	return;
}

Measured memory_bytes: 3052
#include<stdio.h>
#include <string.h>
int main(){
  int a,b,i,l;
  a = 0;
  b = 0;
  char s[200];
  scanf("%s",s);
  l = strlen(s);
  for(i=0;i!=l;i++){
    if(i%2==0 && s[i]!='L')a++;
    if(i%2==1 && s[i]!='R')b++;
  }
  if(a+b==l)printf("Yes");
  else printf("No");
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main{
        public static void main(String[] args){
                Scanner scn=new Scanner(System.in);
                String s=scn.next();
                int ans=0;
                for(int i=0;i<s.length();i++){
                        if(s.charAt(i)=='1'){
                                ans++;
                        }
                }
                System.out.println(ans);
        }
}

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

int main(int argc, char const *argv[]) {
    int n;
    string tCard, hCard;
    int tPoint = 0;
    int hPoint = 0;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> tCard >> hCard;
        if (tCard == hCard) {
            tPoint++;
            hPoint++;
        } else if (tCard > hCard) {
            tPoint = tPoint + 3;
        } else {
            hPoint = hPoint + 3;
        }
    }

    cout << tPoint << " " << hPoint << endl;
}



Measured memory_bytes: 3184
import datetime
S = input()
y, m, d = [int(x) for x in S.split("/")]
s = datetime.datetime(y, m, d, 0, 0)
ss = datetime.datetime(2019, 4, 30, 0, 0)

if s <= ss:
    print("Heisei")
else:
    print("TBD")


Measured memory_bytes: 3312
#include <iostream>
using namespace std;
int main(void){
   int m,f,b;
   cin >> m >> f >> b;
   if(m>=b){
       cout << 0;
   }
   else if(m<b&&m+f>=b){
       cout << b-m;
   }
   else{
       cout << "NA";
   }
   cout << endl;
}


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

int main() {
  int N;
  cin >>N;
  vector<long long> vec(N);
for (long long i = 0; i < N; i++) {
  cin >> vec.at(i);
}
  int A;
  A=0;
  for(int i=0;i<N;i++){
    for(int X=0;X<N-i-1;X++){
      for(int Y=0;Y<N-i-X-2;Y++){
        if(vec.at(i)+vec.at(i+1+X)>vec.at(i+1+X+1+Y)&&vec.at(i)+vec.at(i+1+X+1+Y)>vec.at(i+1+X)&&vec.at(i+1+X)+vec.at(i+1+X+1+Y)>vec.at(i)&&vec.at(i)!=vec.at(i+1+X)&&vec.at(i)!=vec.at(i+1+X+1+Y)&&vec.at(i+1+X)!=vec.at(i+1+X+1+Y)){
          A++;
        }
      }
    }
  }
  cout <<A;
}


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

int main() {
    string S,T;
    cin >> S >> T;
    for (int i=0; i<S.size(); i++) {
        if (S==T) {
            cout << "Yes\n";
            return 0;
        }
        char e = S.at(S.size()-1);
        S.pop_back();
        S = e+S;
    }
    cout << "No\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std;

int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	int s=0;
	s+=abs(a[2] - a[1]) + abs(a[0] - a[1]);
	cout << s;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll mod_div(ll a,ll b){
  ll tmp=MOD-2,c=b,ret=1;
  while(tmp>0){
    if(tmp&1){
      ret*=c;ret%=MOD;
    }
    c*=c;c%=MOD;tmp>>=1;
  }
  return a*ret%MOD;
}
 
#define MAX_K 2000100
vector<ll> kaijo(MAX_K);
ll combination(ll n, ll r){
  if(n<r||n<0||r<0)
    return 0;
  if(kaijo[0]!=1){
    kaijo[0]=1;
    for(ll i=1;i<MAX_K;i++)kaijo[i]=(kaijo[i-1]*i)%MOD;
  }
  ll ret=kaijo[n];
  long long tmp = (kaijo[r] * kaijo[n-r]) % MOD;
  return mod_div(ret,tmp);
}
ll dp[222222];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  if(n-1 <= k){
    cout<<combination(2*n-1,n)<<endl;
  }else{
    if(k==1){
      cout<<n*(n-1)<<endl;
      return 0;
    }
    ll ans = 1;
    for(ll i=1;i<=k;i++){
      // cout<<combination(n-1,i)<<endl;
      ans += combination(n-1,i)*combination(n,n-i);
      ans%=MOD;
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 15872
def main4():
    import fractions
    N, X = list(map(int, input().split()))
    xs = list(map(int, input().split()))

    diffs = []
    for x in xs:
        diffs.append(abs(X-x))

    if len(diffs) == 1:
        print(diffs[0])
        exit()

    ans = 10**9+1
    for i in range(len(diffs)-1):
        ans = min(fractions.gcd(diffs[i], diffs[i+1]), ans)
    print(ans)

if __name__ == "__main__":
    main4()


Measured memory_bytes: 16240
#include<stdio.h>
#define MAX 100000

int A[MAX],n;

int partition(int p, int r){
    int x,i,j,t;
    x=A[r];
    i=p-1;
    for(j=p;j<r;j++){
        if(A[j]<=x){
            i++;
            t=A[i];
            A[i]=A[j];
            A[j]=t;
        }
    }
    t=A[i+1];
    A[i+1]=A[r];
    A[r]=t;
    return i+1;
    
}


int main(){
    int i,q;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    
    q=partition(0,n-1);
    
    for(i=0;i<n;i++){
        if(i) printf(" ");
        if(i==q)printf("[");
        printf("%d",A[i]);
        if(i==q)printf("]");
    }
    printf("\n");
    
    return 0;
}



Measured memory_bytes: 2104