akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine();
		String[] array = s.split(" ");

		int x = Integer.parseInt(array[0]);
		int a = Integer.parseInt(array[1]);
		int b = Integer.parseInt(array[2]);

		if (a - b >= 0) {
			System.out.println("delicious");
		} else if ((a + x) - b >= 0) {
			System.out.println("safe");
		} else {
			System.out.println("dangerous");
		}
	}
}


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

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s[k-1] = s[k-1] - 'A' + 'a';
  cout << s << endl;
  return 0;
}

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

using namespace std;

long long getDist(long long x, long long s, long long t) {
    if(s > t) swap(s,t);
    if(s <= x && x <= t) {
        long long d1 = x - s;
        long long d2 = t - x;
        return d1 + d2 + min(d1, d2);
    }

    if(x < s) {
        return t - x;
    }
    if(x > t) {
        return x - s;
    }
    return 1e13;
}

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

    vector<long long> s(A), t(B);
    for(int i=0;i<A;i++) cin >> s[i];
    for(int i=0;i<B;i++) cin >> t[i];

    s.insert(s.begin(), (long long)-1e13);
    s.insert(s.end(), (long long)1e13);
    t.insert(t.begin(), (long long)-1e13);
    t.insert(t.end(), (long long)1e13);

    long long x;
    for(int i=0;i<Q;i++) {
        cin >> x;
        long long lb_s = *(upper_bound(s.begin(),s.end(), x)-1);
        long long ub_s = *upper_bound(s.begin(),s.end(), x);
        long long lb_t = *(upper_bound(t.begin(),t.end(), x)-1);
        long long ub_t = *upper_bound(t.begin(),t.end(), x);


        long long cand1 = (long long)1e13;
        long long cand2 = (long long)1e13;
        long long cand3 = (long long)1e13;
        long long cand4 = (long long)1e13;

        cand1 = getDist(x, lb_s, lb_t);
        cand2 = getDist(x, lb_s, ub_t);
        cand3 = getDist(x, ub_s, lb_t);
        cand4 = getDist(x, ub_s, ub_t);

        cout << min(cand1, min(cand2, min(cand3, cand4))) << endl;
    }

    return 0;
}



Measured memory_bytes: 2912
#include<iostream>
#include<vector>
#define P (1000000000 + 7)

using namespace std;

typedef struct node_T
{
        std::vector<node_T *> neb;
        int k;
}node;

long long *memPOW;
void choose(int n, int k, long long * ans);
long long inv(int n);
long long search(int K, node* tree, node* tgt, node* par);

int main(){
        int n, k;
        cin >> n >> k;
        node* tree = new node[n];
        memPOW = new long long [n];
        for(int i=0;i<n;i++){
                tree[i].k=0;
                memPOW[i] = -1;
        }

        if(k <= 2){
                if(n<=k){
                        cout << k << endl;
                }else{
                        cout << 0 << endl;
                }
                return 0;
        }

        int maxk = 0;
        int idxk =-1;
        for(int i=0;i<n-1;i++){
                int a,b;
                cin >> a >> b;
                tree[a-1].neb.push_back(&tree[b-1]);
                tree[a-1].k++;
                tree[b-1].neb.push_back(&tree[a-1]);
                tree[b-1].k++;

                if(tree[a-1].k > maxk){
                        maxk = tree[a-1].k;
                        idxk = a - 1;
                }
                if(tree[b-1].k > maxk){
                        maxk = tree[b-1].k;
                        idxk = b - 1;
                }
        }

        long long ans = 1;
        for(int i=0;i<tree[idxk].neb.size();i++){
                ans *= search(k, tree, tree[idxk].neb[i], &tree[idxk]);
                ans %= P;
        }
        //cout << "prev:" << ans << endl;

        choose(k, tree[idxk].neb.size() + 1, &ans);

        cout << ans << endl;
}


long long search(int K, node* tree, node* tgt, node* par)
{
        //cout << "size: " << tgt->neb.size() << endl;
        long long ans = 1;
        if(tgt->neb.size() == 1){
                ans = 1;
        }else{
                for(int i=0;i<tgt->neb.size();i++){
                        if(tgt->neb[i] == par){
                                continue;
                        }

                        ans *= search(K, tree, tgt->neb[i], tgt);
                        ans %= P;
                }
        }

        choose(K-2, tgt->neb.size() - 1, &ans);
        //cout << "ret: " << ans << endl;
        return ans;
}

void choose(int n, int k, long long * ans)
{
        //cout << "choose (" << n << "," << k << "): " << *ans << endl;
        for(int i=0;i<k;i++){
                *ans *= n - i;
                *ans %= P;
        }
        //cout << *ans << endl;
}

long long inv(int n)
{
        if(memPOW[n-1] != -1) return memPOW[n-1];
        long long ans = 1;
        long long k = P - 2;
        for(;k>0;k/=2){
                if(k%2 == 1){
                        ans += n;
                        ans %= P;
                }
                ans = ans * ans;
                ans %= P;
        }
        memPOW[n-1] = ans;
        return ans;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
string bit(ll x){
    string s = "";
    int i = 0;
    for(int i = 0;i < 40;i++){
        if(x % 2 == 1)s = '1'+s;
        else s = '0'+s;
        x /= 2;
    }
    return s;
}
int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<string> A(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        A[i] = bit(a[i]);
        //cout << A[i] << endl;
    }
    ll x = 0;
    ll max = 0;
    for(int i = 0;i < 40;i++){
        int count = 0;
        for(int j = 0;j < n;j++){
            if(A[j][i] == '0')count++;
        }
        if(count > n-count) x += pow(2,39-i);
        else count = n - count;
        //cout << ans << endl;
        if(x > k){
            x -= pow(2,39-i);
            count = n - count;
        }
    }
    for(int i = 0;i < n;i++){
        max += (a[i]^x);
    }
    cout << max << endl;
    //cin >> n;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)
const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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

int main()
{
    string S;
    cin >> S;
    string ans;
    for (int i = 0; i < S.size(); i++)
    {
        if(S[i] == '0'){
            ans += '0';
        }
        else if(S[i] == '1'){
            ans += '1';
        }
        else{
            if(ans.size() != 0){
                ans.erase(ans.size()-1);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3600
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

MOD = 10 ** 9 + 7  
N = int(input())
A = list(map(int, input().split()))
 
l = 1
for i in A:
  l = lcm(l, i)
  
ans = 0
for a in A:
  ans += l // a
print(ans % MOD)

Measured memory_bytes: 6072
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}
const int n_max = 425;
int dp[n_max][n_max];

signed main(){
    int n,ma,mb;
    cin >> n >> ma >> mb;
    REP(i,n_max) REP(j,n_max) dp[i][j] = INF;
    dp[0][0] = 0;

    int a[n],b[n],c[n];
    REP(i,n){
        cin >> a[i] >> b[i] >> c[i];
    }
    REP(i,n){
        REPR(j,10 * n + 1){
            REPR(k,10* n + 1){
                chmin(dp[j + a[i]][k + b[i]], dp[j][k] + c[i]);
            }
        }
    }


    int ans = INF;
    int i = 1;
    while(ma * i < n_max and mb *i < n_max){
        chmin(ans,dp[ma*i][mb*i]);
        i ++;
    }
    if(ans != INF){
        cout << ans << endl;
    }
    else{
        cout << - 1 << endl;
    }
}


Measured memory_bytes: 1664
import java.util.Scanner;


 class Main{
    int hi,lo,su;
     public void solve(){
    Scanner sc=new Scanner(System.in);

    for(int i=0;i<7;i++){
       hi=sc.nextInt();
        lo=sc.nextInt();
        su=hi-lo;
        System.out.println(su);
    }
}
    public static void main(String[] args){
        Main obj = new Main();
         obj.solve();
    }
}

Measured memory_bytes: 17172
#include<iostream>
using namespace std;
int main()
{
     int h,a,ans;
     cin >> h >> a;
  
	 if(a > h){
     ans = 1;
     }
     else if(h % a == 0){
     ans = h / a;
     }
  	 else{
     ans = (h / a) + 1;
     }  
  
     cout << ans << endl;
}

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    ll R;
    cin>>R;
    double ans=R*2*M_PI;
    printf("%.12f\n",ans);
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define LL long long
#define endl '\n'
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    bool card[4][13];
    REP(i, 4)
    {
        REP(j, 13)
        {
            card[i][j] = false;
        }
    }
    cin >> n;
    REP(i, n)
    {
        char ch;
        int num;
        cin >> ch >> num;
        num--;
        if (ch == 'S') {
            card[0][num] = true;
        } else if (ch == 'H') {
            card[1][num] = true;
        } else if (ch == 'C') {
            card[2][num] = true;
        } else /*if (ch == 'D') */{
            card[3][num] = true;
        }
    }

    REP(i, 4)
    {
        REP(j, 13)
        {
            if (card[i][j] == false) {
                if (i == 0) {
                    cout << "S ";
                } else if (i == 1) {
                    cout << "H ";
                } else if (i == 2) {
                    cout << "C ";
                } else {
                    cout << "D ";
                }
                cout << j + 1 << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
int main(){
  char M[4];
  cin >> M;
  if ( M[0] == M[1] && M[1] == M[2] || M[1] == M[2] && M[2] == M[3] ){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
def func(n):
    if n % 2 == 0:
        return n / 2
    else:
        return 3 * n + 1


def main():
    from builtins import int, map, list, print, len
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    s = input_number()
    ls = [s]
    for i in range(1000000):
        a = func(ls[-1])
        ls.append(a)
        if a in ls[:-1]:
            print(len(ls))
            break


if __name__ == '__main__':
    main()


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



int main(){

    string s;
    cin>>s;
    int n=s.length();
    unordered_map<char,int> m;
    m['A']=1;m['C']=1;m['G']=1;m['T']=1;
    int c=0,ans=0;
    for(int i=0;i<n;i++){
        if(m[s[i]]){
            c++;
        }
        else{
            c=0;
        }
        ans=max(ans,c);
    }
    cout<<ans;


return 0;
}


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

using namespace std;

int main()
{
	int N, answer = 0;
	cin >> N;
	vector<int> C(N);
	vector<int> V(N);

	for(int i = 0; i < N; i++)
	{
		cin >> C.at(i);
	}
	for(int i = 0; i < N; i++)
	{
		cin >> V.at(i);
	}

	for(int i = 0; i < N; i++)
	{
		if(C.at(i) - V.at(i) > 0)
		{
			answer += C.at(i) - V.at(i);
		}
	}

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 256
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def calc(x)
  (x * (x - 1)) / 2
end

def main(argv)
  (n, m) = InputLine.to_ia

  puts (calc(n) + calc(m)).to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll T;cin>>T;
    while(T){
        T--;
        ll n;cin>>n;
        vector<vector<ll> >a(n);
        vector<vector<ll> >b(n+1);

        ll ans=0;
        rep(i,n){
            ll k,l,r;cin>>k>>l>>r;
            k--;
            if(l-r>=0){
                if(k>=n)k=n-1;
                a[k].pb(l-r);
            }else{
                if(k+1>=n)k=n-1;
                b[k+1].pb(r-l);
            }
            ans+=min(l,r);
        }
        priority_queue<ll>pq;
        for(int i=n-1;i>=0;i--){
            for(auto e:a[i]){
                pq.push(e);
            }
            if(pq.empty())continue;
            ans+=pq.top();
            pq.pop();
        }
        while(!pq.empty()){
            pq.pop();
        }
        rep(i,n){
            for(auto e:b[i]){
                pq.push(e);
            }
            if(pq.empty())continue;
            ans+=pq.top();
            pq.pop();
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 17344
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final long n = sc.nextLong();
        final long k = sc.nextLong();

        final long t = n % k;
        System.out.println(Math.min(t, k-t));
    }
}


Measured memory_bytes: 35600
#include<stdio.h>

int main(void)
{
  int n,t;
  double a;
  scanf("%d%d%lf",&n,&t,&a);

  int i,ans;
  double h[n],min=1000,temp;
  for(i=0;i<n;i++){
    scanf("%lf",&h[i]);
    temp = t - h[i]*0.006;
    temp -= a;
    if(temp<0)
      temp = -temp;
    if(temp<min){
      min = temp;
      ans = i+1;
    }
  }

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

Measured memory_bytes: 1692
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
ll MOD = 1e9 + 7;
 
int y[100004],Y[100004],b[100004];

int main() {
    int q;
    cin >> q;
    for(int i = 1; i <= 100000; i++){
        int k = 100000/i;
        for(int j = 1; j <= k; j++){
            y[i*j]++;
        }
    }
    for(int i = 3; i <= 100000; i+=2){
        if(y[i] == 2 && y[(i+1)/2] == 2) {
            Y[i]++;
            b[i]++;
        }
    }
    //rep(i,100) if(Y[i]==1) cout<<i<<endl;

    for(int i = 0; i < 100000; i++) Y[i+1] += Y[i];
    
    for(int i = 0; i < q; i++){
        int l,r; 
        cin >> l >> r;
        int ans = Y[r] - Y[l];
        if(b[l] == 1) ans++;
        cout << ans << endl;       
    }
}

Measured memory_bytes: 4712
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
from collections import deque

import queue

def get_ind(pre_tuple, num):
    a, b = pre_tuple
    ans = (a - 1) * num + b
    return ans



def main():
    num = int(input())
    data = [list(map(int, input().split())) for i in range(num)]

    graph_data = [set() for i in range(num * num)]
    parent_node = [0 for i in range(num * num)]

    for i in range(num):
        now_node = i + 1
        pre_tuple = (0, 0)
        for j in range(num - 1):
            next_node = data[i][j]
            now_tuple = (min(now_node, next_node), max(now_node, next_node))
            if j == 0:
                pass
                # parent_node[now_tuple] += 0
            else:
                index = get_ind(pre_tuple, num)
                # print(index, pre_tuple)
                graph_data[index].add(now_tuple)
                index2 = get_ind(now_tuple, num)
                parent_node[index2] += 1
            pre_tuple = now_tuple

    q = deque([])
    count_node, ans = 0, 0

    for i in range(1, num + 1):
        for j in range(i + 1, num + 1):
            node = (i, j)
            index = get_ind(node, num)
            if parent_node[index] == 0:
                q.append((node, 1))
                count_node += 1

    while len(q) > 0:
        now_node, length = q.popleft()
        index = get_ind(now_node, num)
        for next_node in graph_data[index]:
            index2 = get_ind(next_node, num)
            parent_node[index2] -= 1
            if parent_node[index2] == 0:
                q.append((next_node, length + 1))
                count_node += 1

    if count_node < (num * (num - 1)) // 2:
        print(-1)
    else:
        print(length)







if __name__ == '__main__':
    main()



Measured memory_bytes: 205772
program main
implicit None
character(len = 100)::s
character(len = 7)::a
integer::i,p,f,b
	a ="keyence"
	f =0
	b =0
	
	read *,s
	
	do i = 1,7
		if(s(i:i) /= a(i:i))then
			f = i-1
			exit
		endif
		if(i == 7) f = 7
	enddo
	
	p = len_trim(s)
	do i = 1,7
		if(s((p-i+1):(p-i+1)) /= a((8-i):(8-i)))then
			b = i-1
			exit
		endif
		if(i ==7) b = 7
	enddo
	
	if((f+b) >= 7)then
		print "(a)","YES"
		else
			print"(a)","NO"
	endif
end program main

Measured memory_bytes: 256
function main(input) {
   input = input.trim();
  const a = input.split(" ").map(Number);
  console.log(Math.max(a[0],Math.max(a[1],a[2]))*9+a[0]+a[1]+a[2]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;

int main() {
  int X;
  cin >> X;
  ll a, b;
  for(a = -1000; a <= 1000; a++){
    for(b = -1000; b <= 1000; b++){
      if(a*a*a*a*a - b*b*b*b*b == X) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3632
//Solution by Tima
#include <bits/stdc++.h>
 
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
 
using namespace std;    
const int N = 82, mod = int(1e9)  + 7; 

int n,m, a[N][N], b[N][N];

int dp[N][N][N*N*2];

int main () {
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			cin >> a[i][j];
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			cin >> b[i][j];
		}
	}
	int mx = N * N;
	dp[1][1][mx + a[1][1] - b[1][1]] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			for(int s = 0; s < 2 * mx; s++) if(dp[i][j][s]){
				dp[i + 1][j][s + a[i + 1][j] - b[i + 1][j]] = 1;
				dp[i][j + 1][s + a[i][j + 1] - b[i][j + 1]] = 1;
				dp[i + 1][j][s + b[i + 1][j] - a[i + 1][j]] = 1;
		 	 	dp[i][j + 1][s + b[i][j + 1] - a[i][j + 1]] = 1;
		 	 }
		}
	}

	int ans = mx;

	for(int s = 0; s < 2*mx; s++){
		if(dp[n][m][s]) ans = min(ans, abs(mx - s));
	}

	cout << ans;

return 0;
}

Measured memory_bytes: 349440
import copy
from itertools import combinations
h, w, k = map(int, input().split())
lis =[input() for i in range(h)]
res = 0
x = []
for i in range(h):
    x.append(i)
y = []
for i in range(w):
    y.append(i)
for i in range(h+1):
    f = list(combinations(x, i))
    for j in range(w+1):
        g = list(combinations(y, j))
        for l in f:
            for m in g:
                count = 0
                for p in l:
                    for q in m:
                        if lis[p][q] == '#':
                            count += 1
                if count == k:
                    res += 1
print(res)

Measured memory_bytes: 9332
#include <bits/stdc++.h>
using namespace std;
int n,a;
int main(){
    cin>>n;
    if((n%2)==0)a=(n/2.0);
    else a=((n+1.0)/2.0);
    double b=(a/(n*1.0));
    cout<<(double)b<<endl;
}

Measured memory_bytes: 256
N, H, W = map(int, input().strip().split())
A, B = [], []
for _ in range(N):
  a, b = map(int, input().strip().split())
  A.append(a)
  B.append(b)

i = 0
for a, b in zip(A, B):
  if a >= H and b >= W:
    i += 1
print(i)


Measured memory_bytes: 3060
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();

    sc.close();

    String[] S = s.split("");

    int count = 0;

    String current = S[0];

    for (int i = 1; i < S.length; i++) {
  
      if (!(current.equals(S[i]))){
        count++;
        current = S[i];
      }

    }
    
    System.out.println(count);

  }

}

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

const int maxn = 500;
int n, mod, L[maxn + 3], R[maxn + 3], dp[maxn + 3][maxn + 3];
pair<int, int> a[maxn + 3];

int get(int x, int y) {
	int z = 0;
	while (z < n * 2 - 1 && (z + 1) * (z + 1) + x <= y) {
		z++;
	}
	return z;
}

int solve(int k) {
	/*
	puts("-----");
	printf("solve %d\n", k);
	*/
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	int A = 0, C = 0;
	for (int i = 0; i < n * 2; i++) {
		// printf("! %d %d %d\n", i, a[i].fi, a[i].se);
		if (~a[i].se) {
			for (int j = 0; j <= A; j++) {
				dp[i + 1][j + 1] = (dp[i + 1][j + 1] + 1ll * dp[i][j] * (a[i].fi - j - C)) % mod;
			}
			for (int j = 0; j <= A; j++) {
				dp[i + 1][j] = (dp[i + 1][j] + 1ll * dp[i][j] * (a[i].se - k - n - (A - j))) % mod;
			}
			A++;
		} else {
			for (int j = 0; j <= A; j++) {
				dp[i + 1][j] = (dp[i + 1][j] + 1ll * dp[i][j] * (a[i].fi - j - C)) % mod;
			}
			C++;
		}
		/*
		for (int j = 0; j <= A; j++) {
			printf("%d %d %d\n", i, j, dp[i][j]);
		}
		*/
	}
	/*
	for (int j = 0; j <= A; j++) {
		printf("%d %d %d\n", n * 2, j, dp[n * 2][j]);
	}
	*/
	return dp[n * 2][k];
}

int main() {
	scanf("%d %d", &n, &mod);
	for (int i = 0; i < n; i++) {
		a[i] = make_pair(get(i * i, n * n - 1) + 1, get(i * i, n * n * 4) + 1);
	}
	for (int i = n; i < n * 2; i++) {
		a[i] = make_pair(get(i * i, n * n * 4) + 1, -1);
	}
	sort(a, a + n * 2);
	/*
	for (int i = 0; i < n * 2; i++) {
		printf("%d %d\n", a[i].fi, a[i].se);
	}
	*/
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		ans = (ans + 1ll * (i & 1 ? mod - 1 : 1) * solve(i)) % mod;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1280
S = input()
isTappable = True
for i,e in enumerate(S):
    if i % 2 == 0:
        #奇数文字列目
        if e == 'L':
            isTappable = False
    else:
        if e == 'R':
            isTappable = False

if isTappable:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int r=nxt(),c=nxt();
    for(int i=0;i<c+2;i++)
        cout<<"#";
    cout<<endl;
    for(int i=0;i<r;i++)
    {
        string s;
        cin>>s;
        cout<<"#";
        cout<<s<<"#";
        cout<<endl;

    }
    for(int i=0;i<c+2;i++)
        cout<<"#";
    cout<<endl;
    
    
    return 0;   
}




 
 


Measured memory_bytes: 256
def args():
    W, a, b = map(int, input().split())

    # print(W, a, b)

    return W, a, b

def solve(W, a, b):
    a_tail = a + W
    b_tail = b + W

    if a <= b <= a_tail:
        return 0
    elif a <= b_tail <= a_tail:
        return 0
    else:
        return min(abs(b - a_tail), abs(a - b_tail))


if __name__ == '__main__':
    res = solve(*args())
    print(res)


Measured memory_bytes: 38384
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

using ld= long double;

struct aa {
	vector<int>v;
	int cost;
};
class Compare {
public:
	bool operator()(const aa&l, const aa&r) {
		return l.cost>r.cost;
	}
};

int main() {
	int N;cin>>N;
	vector<vector<int>>field(N,vector<int>(N));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			int a;cin>>a;
			field[i][j]=a;
		}
	}
	priority_queue<aa,vector<aa>,Compare>que;
	vector<int>start(N);
	iota(start.begin(),start.end(),0);
	que.push(aa{ start,0 });
	map<vector<int>,int>memo;
	memo[start]=0;
	while (!que.empty()) {
		auto atop(que.top());
		que.pop();
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				auto nv(atop.v);
				swap(nv[i],nv[j]);
				if (memo.find(nv) == memo.end()) {
					memo[nv]=1e9;
				}
				if (memo[nv] > atop.cost + field[i][j]) {
					memo[nv]=atop.cost+field[i][j];
					que.push(aa{ nv,atop.cost + field[i][j] });
				}
			}
		}
	}
	int ans=0;
	for (auto m : memo) {
		ans=max(ans,m.second);
	}
	cout<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 12552
n, m = gets.chop.split.map(&:to_i)

ab={}

ans = 0

num = 0

#{}でハッシュをつくる

n.times do
  a,b = gets.chop.split.map(&:to_i)

  if ab.has_key?(a)
    ab[a] += b
  else
    ab[a] = b
  end
end


ab = Hash[ab.sort]


ab.each{ |key, value|

  if num == m then
    break
  end


  if m >= num + value then
    num = num + value
    ans = ans + key * value
  else
    value.times do
      if num == m then
        break
      else
        num = num + 1
        ans = ans + key
      end
    end
  end
}

puts ans


Measured memory_bytes: 20584
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  string a;
 int sum=0,n;
    cin>>a;
  n=a.size();
  for(int i=0;i<n;i++)
  {
   sum=sum+( a[i]-'0');  
    
  }
  //cout<<sum<<endl;
if(sum%9==0)
  cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 3696
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    map <int,bool> mp;
    int n,m,x; cin>>n>>m>>x; 
    while (m--){
        int a; cin>>a;
        mp[a]=true;
    }
    int l=0,r=0;
    for (int i=x;i<n;i++) if (mp[i]) r++;
    for (int i=x;i>0;i--) if (mp[i]) l++;
    cout << min(l,r) << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3640
A,B,C,D=map(int, input().split())

def andiv(M,N):
    return((N//M) * (M-1) + N%M)

def gcd(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def lcm(a,b):
    return(a*b // gcd(a,b))

E = andiv(C,B) + andiv(D,B) - andiv(lcm(C,D),B)
F = andiv(C,A-1) + andiv(D,A-1) - andiv(lcm(C,D),A-1)

print(int(E-F))

Measured memory_bytes: 3064
def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def cmb(n,r,mod):
    X=1
    Y=1
    for i in range(r):
        X*=n-i
        X%=mod
        Y*=i+1
        Y%=mod
    Y=pow(Y,mod-2,mod)
    X*=Y
    return X%mod

mod=10**9+7
n,a,b=map(int,input().split())
result=pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1
if result<0:
    result+=mod
result%=mod
print(result)

Measured memory_bytes: 38512
#include<iostream>
#include<bitset>
#include<string>
#include<cmath>
#include<vector>
#include<tuple>
using namespace std;
bool iseven(int x){ return x % 2 == 0; }
bool isodd(int x){ return !iseven(x); }
int dist(int x, int y) { return abs(x - y);}
//# Functions for Vector/Matrix
template <typename T>
vector<T> zeros(int length){
    vector<T> vec(length, 0);
    return vec;
}
template <typename T>
vector<vector<T>> zeros(tuple<int, int> dim){
    vector<vector<T>> mat(get<0>(dim), vector<T>(get<1>(dim), 0));
    return mat;
}
template <typename T>
void show(vector<T> &vec){
    for (auto value : vec) {
        cout << value << " ";
    }
    cout << endl;
}
template <typename T>
void show(vector<vector<T>> &mat){
    for (auto vec : mat) {
        show(vec);
    }
}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}
int main(){
    int N; cin >> N;
    int x; cin >> x;
    int res; res = x;
    for(int i=1; i < N; i++){
        cin >> x;
        res = gcd(res, x);
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int mod = 998244353;
typedef long long ll;
const int maxn = 1e6 + 233;
char s[maxn];
int main()
{
	int cnt[3];
	memset(cnt,0,sizeof(cnt));
	int n;cin>>n;
	scanf("%s",s+1);
	ll ans = 1,tmp = 0;
	for(int i=1;i<=3*n;i++){
		int c,a,b;
		if(s[i]=='R')c=0,a=1,b=2;
		if(s[i]=='G')c=1,a=0,b=2;
		if(s[i]=='B')c=2,a=0,b=1;
		if(cnt[a]&&cnt[b]){
//			cout<<"->"<<tmp<<endl; 
			ans = (ans*tmp)%mod;
			cnt[a]--;cnt[b]--;
			tmp--;
		}
		else if(cnt[a]||cnt[b]){
			if(!cnt[a])swap(a,b);
			if(cnt[a]>tmp){
				ans = ans*(cnt[a]-tmp)%mod;
//				cout<<"!"<<cnt[a]<<" "<<tmp<<endl;
				tmp++;
			} 
			cnt[c]++;
		}
		else{
			cnt[c]++;
		}
	}
//	cout << ans << endl; 
	for(int i=1;i<=n;i++)ans = (ans*i)%mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

// mint
int64_t const MOD = 1e9+7;

template<int64_t Prime>
struct mod_int {
  int64_t v_;
  mod_int(int64_t x=0) : v_(x) { normalize(); }
  void normalize() { ((v_ %= Prime) += Prime) %= Prime; }
  mod_int operator+=(mod_int const& r){ (v_ += r.v_) %= Prime; return *this; }
  mod_int operator-=(mod_int const& r){ (v_ += Prime - r.v_) %= Prime; return *this; }
  mod_int operator*=(mod_int const& r){ (v_ *= r.v_) %= Prime; return *this; }
  mod_int operator+(mod_int const& r) { mod_int res(*this); return res += r; }
  mod_int operator-(mod_int const& r) { mod_int res(*this); return res -= r; }
  mod_int operator*(mod_int const& r) { mod_int res(*this); return res *= r; }
  mod_int pow(int x) const {
    int64_t res = 1, v = v_;
    while(x > 0) {
      if(x&1) (res *= v) %= Prime;
      x/=2; (v *= v) %= Prime;
    }
    return mod_int(res);
  }
  mod_int inv() const { return pow(Prime-2); }
};
typedef mod_int<MOD> mint;

//optional
template<typename T>
struct optional {
  bool valid;
  T v_;
  optional(): valid(false) {}
  optional& operator=(T const& v)
    { v_ = v; valid = true; return *this; }
  T& operator*() { return v_; }
  T const& operator*() const { return v_; }
};

int const MAXN=50;
int const MAXK=MAXN*MAXN/2;

optional<mint> dp[MAXN+1][MAXN+1][MAXK+1];

mint calc(int i, int j, int k) {
  if(dp[i][j][k].valid) return *dp[i][j][k];
  mint res;
  int new_k = k-j;
  if(new_k >= 0 && i >= 1) {
    if(i-1 >= j) res += mint(j+j+1)*calc(i-1, j, new_k);
    if(i-2 >= j) res += mint(j+1)*(j+1)*calc(i-1, j+1, new_k);
    if(i >= j && j >= 1) res += calc(i-1, j-1, new_k);
  }
  return *(dp[i][j][k] = res);
}

int main() {
  int n, k; std::cin >> n >> k;
  if(k%2==1) fin(0);
  dp[0][0][0] = 1;
  fin(calc(n, 0, k/2).v_);
  return 0;
}


Measured memory_bytes: 51072
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    double d,t,s;
    cin >> d >> t >> s;
    if(d/s > t){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

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

int main(){
  int N;
  int maxd=0;
  int temp=0;
  cin >> N;
  for (int i=1;i<N+1;i++){
    temp=i;
    int count=0;
    while (temp>0){
      count++;
      temp=temp/2;
    }
    maxd=max(maxd,count);
  }
  cout<<pow(2,maxd-1)<<endl;
  return 0;
}

  
      

Measured memory_bytes: 256
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
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; }

const string YES = "Yes";
const string NO = "No";



// ***************************************


int main(){

    double A, B, C, D;
    cin >> A >> B >> C >> D;

    int tk = ceil(C / B);
    int ao = ceil(A / D);

    if (tk <= ao) cout << YES << endl;
    else cout << NO << endl;

    return 0;
}


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

int main() {
  string s;
  cin >> s;
  
  if (s[0] == s[1] && s[1] == s[2]){
    cout << "Yes" << endl;
  }else if (s[1] == s[2] && s[2] == s[3]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

using namespace std;

void output(int n, int element[])
{
	for (int i = 0; i < n - 1; i++)
		cout << element[i] << " ";
	cout << element[n - 1] << endl;
}

int selection_sort(int n, int element[])
{
	int swap_count = 0;
	for (int i = 0; i < n; i++) {
		int minimam = i;
		// select minimam element
		for (int j = i + 1; j < n; j++) {
			if (element[j] < element[minimam])
				minimam = j;
		}
//		output(n, element);
		if (minimam != i)
			swap(element[i], element[minimam]), swap_count++;
	}
	return swap_count;
}

int main()
{
	int n, element[100];

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> element[i];
	}
	int swap_count = selection_sort(n, element);
	output(n, element);
	cout << swap_count << endl;
	return 0;
}

Measured memory_bytes: 1160
n = int(input())
a = list(map(int,input().split()))


if sum(a) % n == 0:
    c = sum(a)//n
else:
    if sum(a)/n < sum(a)//n + 0.5:
        c = sum(a)//n
    else:
        c = sum(a)//n + 1

ans = 0
for i in range(n):
    ans += (c-a[i])**2
print(ans)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream &operator << (ostream &os, const vector<T> &);
template<size_t n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, const tuple<T...> &){}
template<size_t n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream &os, const tuple<T...> &t){
    os << (n == 0 ? "" : " ") << get<n>(t); _ot<n+1>(os, t);
}
template<class...T> ostream &operator << (ostream &os, const tuple<T...> &t){
    _ot<0>(os, t); return os;
}
template<class T, class U> ostream & operator << (ostream &os, const pair<T,U> &p){
    return os << "(" << p.first << ", " << p.second << ") ";
}
template<class T> ostream &operator << (ostream &os, const vector<T> &v){
    for(size_t i = 0; i < v.size(); i++) os << v[i] << (i + 1 == v.size() ? "" : ", "); return os;
}
#ifdef DEBUG
#define dump(...) (cerr << #__VA_ARGS__ << " = " << make_tuple(__VA_ARGS__) \
                   << " (L : " << __LINE__ << ")" << endl)
#else
#define dump(...)
#endif
#define all(c) begin(c), end(c)
#define range(i,a,b) for(int i = a; i < (int)(b); i++)
#define rep(i,b) range(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using ll = long long;
// #define int ll
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
void fastios(){ ios_base::sync_with_stdio(0); cin.tie(0); }
int const mod = 1000000007;
auto const inf = numeric_limits<int>::max()/8;

using Weight = int;
using Capacity = int;
struct Edge {
    int src, dst; Weight weight;
    Edge(int s, int d, int w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

Weight tsp(const Graph &g){
    int n = g.size();
    Matrix m(n, Array(n, inf));
    for(auto &es : g) for(auto &e : es) m[e.src][e.dst] = min(m[e.src][e.dst], e.weight);
    Matrix dp(1<<n, Array(n, inf));
    dp[0][0] = 0;
    for(int S = 0; S < 1<<n; S++)
        for(int u = 0; u < n; u++)
            for(int v = 0; v < n; v++)
                if(!((S >> v) & 1))
                    dp[S|1<<v][v] = min(dp[S|1<<v][v], dp[S][u] + m[u][v]);
    return dp[(1<<n)-1][0];
}

int main(){
    fastios();
    int n,m;
    while(cin >> n >> m){
        Graph g(n);
        rep(i,m){
            int a,b,c;
            cin >> a >> b >> c;
            g[a].eb(a,b,c);
        }
        int ans = tsp(g);
        cout << (ans==inf ? -1 : ans) << '\n';
    }
}

Measured memory_bytes: 6324
// https://atcoder.jp/contests/agc043/tasks/agc043_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  string S;
  cin >> N >> S;

  VL as(N);
  rep(i, N) as[i] = (S[i] - '0') - 1;

  // C(N-1, i) が奇数か偶数か
  VL comb_parity(N);

  {
    // i! が 2 で割れる回数
    VL fact_two_div_ct(N);

    rep1(num, N) {
      ll ct = 0;
      ll _num = num;
      while (_num % 2 == 0) ++ct, _num /= 2;

      fact_two_div_ct[num] = fact_two_div_ct[num - 1] + ct;
    }

    rep(i, N) {
      ll two_div_ct = fact_two_div_ct[N - 1] - fact_two_div_ct[i] -
                      fact_two_div_ct[N - 1 - i];
      comb_parity[i] = two_div_ct > 0 ? 0 : 1;
    }
  }

  // 答えの偶奇を求める。奇であれば 1 で確定
  {
    ll parity = 0;

    rep(i, N) {
      if (as[i] % 2 == 0 || comb_parity[i] == 0) continue;
      parity ^= 1;
    }

    if (parity == 1) drop(1);
  }

  // 答えが 2 だとすると、１つ目の列に 1 は存在し得ない
  if (any_of(all(as), [](ll v) { return v == 1; })) {
    drop(0);
  }

  // 0 か 2 か存在し得ないため、 2 を 1 と捉えた時の
  // 答えの偶奇を見て、奇数であれば 2 偶数であれば 0 が答えとなる
  {
    ll parity = 0;

    rep(i, N) {
      if (as[i] == 0 || comb_parity[i] == 0) continue;
      parity ^= 1;
    }

    if (parity == 1) {
      drop(2);
    } else {
      drop(0);
    }
  }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  } catch (exception e) {
    ll x = 1;
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 24860
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> k;

  vi a(11,10),b(100000);
  a[0]=0;

  REP(i,100000){
    REP(j,10){
      if (a[j]==10)a[j]=0;
      int flag=0;
      if (a[j]>a[j+1])flag++;
      if ((a[j]+1)==10)flag++;
      if (flag!=0){
        a[j]=0;
        continue;
      }
      a[j]++;
      break;
    }

    REP(j,9){
      if (a[9-j]==10)continue;
      if ((a[9-j]-1)>a[8-j]){
        a[8-j]=max(a[9-j]-1,0LL);
      }
    }



    b[i]=0;
    ll bk=1;
    REP(j,10){
      if (a[j]!=10){
        b[i]+=a[j]*bk;
      }
      bk*=10;
    }
    

    
  }

  cout<<b[k-1]<<endl;
  return 0;
}

Measured memory_bytes: 1024
from collections import Counter

n = int(input())
s = input()
c = Counter(s)
cnt = c['R'] * c['G'] * c['B']

for i in range(n-2):
    for j in range(i+1, n-1):
        w = j - i
        if j+w >= n:
            continue
        if s[i] != s[j] and s[j+w] != s[j] and s[j+w] != s[i]:
            cnt -= 1

print(cnt)


Measured memory_bytes: 74204
class UnionFind():
    def __init__(self, n):
        self.n = n
        #親の添字、親自身は木の要素数*-1をもつ
        self.root = [-1]*(n)
        #枝の最大長さ
        self.rank = [0]*(n)
        #最大メンバー数
        self.maxmem = 1

    def find_root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]
    #高さによる合併    
    def unite(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return 
        elif self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
            if self.maxmem < -1*self.root[x]:
                self.maxmem = -1*self.root[x]
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rank[x] == self.rank[y]):
                self.rank[y] += 1
            if self.maxmem < -1*self.root[y]:
                self.maxmem = -1*self.root[y]
    def same(self, x, y):
        return self.find_root(x) == self.find_root(y)
    
    def count(self, x):
        return -self.root[self.find_root(x)]    
    
    def members(self, x):
        root = self.find_root(x)
        return [i for i in range(self.n) if self.find_root(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.root) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
n, m = map(int,input().rstrip().split())
ab = [list(map(int,input().split()))for _ in range(m)]

u = UnionFind(n)
for a,b in ab:
    u.unite(a-1,b-1)
print(u.maxmem)

Measured memory_bytes: 110768
#include "stdio.h"
int main(void)
{
  int H,W,h,w,result=0;
  scanf("%d %d %d %d",&H,&W,&h,&w);
  result=H*W;
  result-=h*W;
  result-=(H-h)*w;
  printf("%d",result);
  return 0;
}

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

using namespace std;
int main(){
	int var1=0,var2=0,var4=0;
	int n,var;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>var;
		if(var%2==1){//奇数
			var1++;
		}else{//偶数
			if(var%4!=0){//2の倍数
				var2++;
			}else{//4の倍数
				var4++;
			}
		}
	}
	if(var2==0){
		if(var1-1>var4){printf("No");}else{printf("Yes");}
	}else{
		if(var1>var4){printf("No");}else{printf("Yes");}
	}
	return 0;
}


Measured memory_bytes: 256