akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A_i = list(map(int, input().split()))

ans = 1

if 0 in A_i:
    print(0)
else:
    for i in range(N):
        ans *= A_i[i]
        if ans > 1000000000000000000:
            print(-1)
            break

        if i == N - 1:
            print(ans)


Measured memory_bytes: 21792
#include<stdio.h>
#include<stdlib.h>
int main(){
  int i,j,n,x,k=0,flag;
  int *A;

  scanf("%d",&n);
  if(n<1 || n>100)return 0;

  A = (int *)malloc(sizeof(int) * n);

for(i = 0;i < n;i++){
  scanf("%d",&A[i]);
    if(A[i]<0 || A[i]>100)return 0;
}

flag = 1;
 i = 0; // 未ソート部分列の先頭インデックス
 while (flag){
   flag = 0;

   for( j = n-1 ;j > 0; j--){

     if (A[j] < A[j-1]){
       x = A[j];
       A[j] = A[j-1];
       A[j-1] = x;
        flag = 1;
       k++;
    }
     }
  i++;
 }

  printf("%d",A[0]);
for(i=1;i<n;i++){
  printf(" %d",A[i]);
}
printf("\n");
printf("%d\n",k);

return 0;
}


Measured memory_bytes: 2140
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String result = "";
		if(a.equals(b)){
			result += "=";
		}else{
			String[] alp = {"A", "B", "C", "D", "E", "F"};
			for(int i=0; i<alp.length; i++){
				if(alp[i].equals(a)){
					result += "<";
					break;
				}else if(alp[i].equals(b)){
					result += ">";
					break;
				}
			}
		}
		System.out.println(result);
	}
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

struct Node {
  int key_;
  Node *left_, *right_;
  Node *parent_;

  Node(int key) : key_(key), left_(0), right_(0) {}
  Node() : key_(0), left_(0), right_(0) {}
  ~Node()
  {
    if (left_) { delete left_; left_ = 0; }
    if (right_) { delete right_; right_ = 0; }
    parent_ = 0;
    //fprintf(stderr, "DEBUG: deleting %d\n", key_);
  }

  void print_inorder()
  {
    if (left_) { left_->print_inorder(); }
    fprintf(stdout, " %d", key_);
    if (right_) { right_->print_inorder(); }
  }

  void print_preorder()
  {
    fprintf(stdout, " %d", key_);
    if (left_) { left_->print_preorder(); }
    if (right_) { right_->print_preorder(); }
  }
};

class BST {
public:
  BST() : root_(0) {}
  ~BST() { delete root_; }

  void insert(Node *node)
  {
    Node *x = root_, *y = 0;
    while (x != 0) {
      y = x;
      if (node->key_ < x->key_) {
        x = x->left_;
      }
      else if (node->key_ > x->key_) {
        x = x->right_;
      }
      else {
        // duplicate node
        return;
      }
    }
    node->parent_ = y;

    if (y == 0) { root_ = node; }
    else if (node->key_ < y->key_) {
      y->left_ = node;
    }
    else if (node->key_ > y->key_) {
      y->right_ = node;
    }
  }

  void print_inorder()
  {
    if (root_) {
      root_->print_inorder();
      fprintf(stdout, "\n");
    }
  }

  void print_preorder()
  {
    if (root_) {
      root_->print_preorder();
      fprintf(stdout, "\n");
    }
  }

private:
  Node *root_;
};

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  char buf[64] = { '\0' };
  int key = -1;
  BST tree;
  for (int i = 0; i < n; ++i) {
    fscanf(stdin, "%s", buf);
    if (buf[0] == 'i') {
      fscanf(stdin, "%d", &key);
      tree.insert(new Node(key));
    }
    else if (buf[0] == 'p') {
      tree.print_inorder();
      tree.print_preorder();
    }
  }
  return 0;
}

Measured memory_bytes: 24640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0; i<(N); i++)
typedef long long ll;
const ll mod=1e9+7;

ll H,N;
ll A[100005];
ll sm;

int main(){ 

cin.tie(0);
ios::sync_with_stdio(false);

cin>>H>>N;

rep(i,N){
	cin>>A[i];
	sm+=A[i];
}

if(sm>=H){
	cout<<"Yes"<<endl;
}else{
	cout<<"No"<<endl;
}

}


Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    S = input()
    T = input()
    ans = 0
    for i in range(len(S)):
        if S[i] == T[i]:
            ans += 1
    print(len(S) - ans)




if __name__ == '__main__':
    main()

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

using namespace std;

int main(){
    int n;
    cin>>n;
    map<string,int>cnt;
    for(int t=0;t<n;t++){
        string s;
        cin>>s;

        cnt[s]++;
    }

    cout<<"AC"<<" x "<<cnt["AC"]<<"\n";
    cout<<"WA"<<" x "<<cnt["WA"]<<"\n";
    cout<<"TLE"<<" x "<<cnt["TLE"]<<"\n";
    cout<<"RE"<<" x "<<cnt["RE"]<<"\n";
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    cout << (A + B) % 24 << endl;

    return 0;
}


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

typedef long long ll;

int main() {
  ll n, q;
  cin >> n >> q;

  vector<pair<ll, ll>> v(n);
  for (int i = 0; i < n; i++)
    cin >> v[i].first >> v[i].second;

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

  ll ans = 0;

  for (int i = 0; i < n; i++) {
    int amount = min(q, v[i].second);
    ans += v[i].first * amount;
    q -= amount;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
n = gets.to_i
as = gets.split.map(&:to_i).sort!

ans = Array.new(as.last + 1, 0)
counts = Hash.new(0)

as.each do |a|
  ans[a] = 1
  counts[a] += 1
end

as.each do |a|
  next if ans[a] == 0
  ans[a] = 0 if counts[a] > 1

  (a * 2).step(as.last, a) do |i|
    ans[i] = 0
  end
end

puts ans.count { |d| d == 1 }


Measured memory_bytes: 45312
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = INT_MAX;
const int mod = 1e9+7;

const int N = 2e5 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
clock_t time_p=clock();

int dp[N];
int a[N];
int32_t main(){
    fast;

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    int n;
    cin >> n;
    FOR(i,1,n) {
        cin >> a[i];
    }

    dp[a[n]] = 1;
    NFOR(i,n-1,1) {
        dp[a[i]] = 1 + dp[a[i] + 1];
    }
    if(dp[1] == 0)cout << "-1\n";
    else cout << (n - dp[1]) << "\n";

    time_p=clock()-time_p;
    cerr<<"\nTime Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,a,b) for(ll i=a;i<=b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define endl "\n"
#define deb(x) cerr << #x << "=" << x << endl
#define debb(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define mod ((ll)1e9+7)
#define N ((ll)1e4)
#define pb push_back
#define in insert
#define F first
#define S second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define PI 3.1415926535897932384626
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
ll dr[] = { -1, 1, 0, 0};
ll dc[] = {0, 0, 1, -1};

/*Functions*/
ll gcd(ll a, ll b);
ll exp(ll x, ll y, ll p);
ll exp(ll x, ll y);
void InverseofNumber();
void InverseofFactorial();
void factorial();
ll Binomial(ll n, ll R);


ll factorialNumInverse[N + 1];
ll naturalNumInverse[N + 1];
ll fact[N + 1];

void fileIO() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main() {
    clock_t start, end;
    start = clock();
    speed
    // InverseofNumber(),InverseofFactorial(),factorial();
    // fileIO();
    ll n; cin >> n;
    if (n % 1000 == 0) {
        cout << 0;
        return 0;
    }
    ll x = n / 1000;
    x++;
    x = x * 1000;
    cout << x - n << endl;

    end = clock();
    double timeTaken = double(end - start) * 1000 / double(CLOCKS_PER_SEC);
    deb(timeTaken);

    return 0;
}



/*All Functions*/
ll gcd(ll a, ll b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll exp(ll x, ll y, ll p) {
    ll res = 1;
    while (y) {
        if (y % 2)
            res = (res * x % p) % p;
        x = (x * x) % p;
        y /= 2;
    }
    return res;
}
ll exp(ll x, ll y) {
    ll res = 1;
    while (y) {
        if (y % 2)
            res = (res * x ) ;
        x = (x * x) ;
        y /= 2;
    }
    return res;
}
void InverseofNumber() {
    naturalNumInverse[0] = naturalNumInverse[1] = 1;
    for (ll i = 2; i <= N; i++)
        naturalNumInverse[i] = naturalNumInverse[mod % i] * (mod - mod / i) % mod;
}
void InverseofFactorial() {
    factorialNumInverse[0] = factorialNumInverse[1] = 1;
    for (ll i = 2; i <= N; i++)
        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % mod;
}
void factorial() {
    fact[0] = 1;
    for (ll i = 1; i <= N; i++)
        fact[i] = (fact[i - 1] * i) % mod;
}
ll Binomial(ll n, ll R) {
    ll ans = ((fact[n] * factorialNumInverse[R]) % mod * (factorialNumInverse[n - R]) % mod) % mod;
    return ans;
}

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

using namespace std;


int main(){
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
	int n,m;
	cin >> n >> m;
	int left=INT_MIN;
	int right = INT_MAX;
	int a,b;
	for(int i=0;i<m;i++){
		cin >> a >> b;
		left = max(left,a);
		right = min(right,b);
	}
	cout << max(0,right-left+1);
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

// FIXME: graphをグローバル変数にしているのどうにかしたい
vector<int> graph[200010];
vector<int> par(200010);

bool topologicalSort(int V, int E, vector<int> &order) {
  assert(order.size() == 0);
  // トポロジカルソートした結果をorderに格納して返す. 返り値はDAGならtrue
  vector<int> indegree(V); // 200000とかだと遅い？ 厳しそうならグローバル変数にする
  // 入次数の初期化. ほんとは読み込み時にやったほうが効率が良いけど許容する
  for (int v = 0; v < V; ++v) {
    for (int nv : graph[v]) ++indegree[nv];
  }

  stack<int> st;
  for (int v = 0; v < V; ++v) {
    // 入次数0の点をstackにいれる
    if (indegree[v] == 0) {
      par[v] = -1;
      st.push(v);
    }
  }

  while (st.size() > 0) { 
    int v = st.top(); st.pop();
    order.push_back(v);
    for (int nv : graph[v]) {
      --indegree[nv];
      if (indegree[nv] == 0) {
        st.push(nv);
        par[nv] = v;
      }
    }
  }

  return order.size() == V;
}

// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  return s;
}

int main() {
  int V, E;
  cin >> V >> E;
  for (int i = 0; i < V-1+E; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    // cerr << a << " " << b << endl;
    // 点a -> 点bの辺をはる
    graph[a].push_back(b);
  }
  vector<int> order;
  bool is_dag = topologicalSort(V, E, order);

  // cout << "This graph is ";
  // if (is_dag) { cout << "DAG" << endl; }
  // else { cout << "not DAG" << endl; }
  // cout << order << endl;
  for (int i = 0; i < V; ++i) {
    cout << par[i]+1 << " ";
  }
  cout << endl;
}



Measured memory_bytes: 9968
#include <bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define pb push_back
#define si second
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  mod 100000000000
#define double long double
#define all(o) o.begin(),o.end()
using namespace std;

int power(int x, int y)
{
    int res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1; // y = y/2
        x = (x*x) % mod;
    }
    return res%mod;
}
int inv(int n)
{
    return power(n,mod-2)%mod;
}


int a[1000005];
int32_t main() {

  //  fast
    int n,i,j,k;
    cin>>n;
    for(i=1;i<=100;i++)
        for(j=1;j<=100;j++)
            for(k=1;k<=100;k++)
            {
                int val=i*i+j*j+k*k+i*j+j*k+k*i;
                a[val]++;
            }
    for(i=1;i<=n;i++)
        cout<<a[i]<<"\n";
}


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

using namespace std;
typedef long long ll;
int main()
{
    string s;
    cin >>s;
    ll n =s.size();
    ll x=0;
    for(int i = 0 ; i < n ; i++)
    {
        x+=(s[i]-'0');
    }
    if(x%9==0)
    {
        cout << "Yes\n";
    }
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 3720
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer[][] A = new Integer[N][2];
		for (int i = 0; i < A.length; i++) {
			A[i][0] = sc.nextInt();
			A[i][1] = i;
		}
		Arrays.sort(A, (x, y) -> {
			if (x[0].compareTo(y[0]) > 0) {
				return 1;
			} else if (x[0].compareTo(y[0]) < 0) {
				return -1;
			} else {
				return 0;
			}
		});
		for (int i = 0; i < A.length; i++) {
			if (i != A[A.length - 1][1]) {
				System.out.println(A[A.length - 1][0]);
			} else {
				System.out.println(A[A.length - 2][0]);
			}
		}
		sc.close();
	}
}

Measured memory_bytes: 103844
#define  _CRT_SECURE_NO_WARNiINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <cassert>
#include <set>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define cycle_per_sec 2806192512
int main() {
	int a, b;
	cin >> a >> b;
	vector<string> input;
	REP(i, a) {
		string s;
		cin >> s;
		input.push_back(s);
	}
	for (int i = 0; i < a; ++i) {
		for (int q = 0; q < b; ++q) {
			if (input[i][q] == '#') {
				int hoge = 0;
				if (i != 0 && input[i - 1][q] == '#') hoge = 1;
				if (i != a-1 && input[i + 1][q] == '#') hoge = 1;
				if (q != 0 && input[i][q-1] == '#') hoge = 1;
				if (q != b - 1 && input[i][q+1] == '#') hoge = 1;
				if (hoge == 0) {
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<math.h>
#include<functional>
#include<bitset>
#include<cassert>
using namespace std;
using lint = long long;
using ld = long double;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(lint i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	lint n;
	cin >> n;
	vector<lint> a(n);
	REP(i, n) cin >> a[i];
	lint acmxor = 0;
	REP(i, n) acmxor = acmxor ^ a[i];
	if(acmxor != 0) {
		// cerr << "debug" << endl;
		lint acm = 0;
		lint c0 = 1, c1 = 0;
		REP(i, n - 1) {
			acm = acm ^ a[i];
			if(acm == acmxor) {
				c1 += c0;
				c1 %= MOD;
			} else if(acm == 0) {
				c0 += c1;
				c0 %= MOD;
			}
		}
		cout << c0 << endl;
	} else {
		lint ans = 0, acm = 0;
		lint c = 1;
		REP(i, n - 1) {
			acm = acm ^ a[i];
			if(acm == 0) {
				c *= 2;
				c %= MOD;
			}
		}
		ans += c;
		map<pint, plint> ma;
		acm = 0;
		REP(i, n - 1) {
			acm = acm ^ a[i];
			if(acm == 0) continue;
			ma[{acm, 0}] = {1, 0};
			ma[{acm, 1}] = {0, 0};
		}
		c = 0;
		acm = 0;
		REP(i, n - 1) {
			acm = acm ^ a[i];
			if(acm == 0) {
				c++;
			} else {
				ma[{acm, 0}].first += (c - ma[{acm, 0}].second) * ma[{acm, 1}].first;
				ma[{acm, 0}].first %= MOD;
				ma[{acm, 0}].second = c;
				ma[{acm, 1}].first += ma[{acm, 0}].first;
				ma[{acm, 1}].first %= MOD;
			}
		}
		set<lint> mita;
		for(auto p: ma) {
			acm = p.first.first;
			if(mita.count(acm)) continue;
			ans += ma[{acm, 1}].first;
			ans %= MOD;
			mita.insert(acm);
		}
		cout << ans << endl;
	}
	return 0;
}
/* --------------------------------------- */


Measured memory_bytes: 53504
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long n;

	std::cin >> n;

	std::string s;

	std::cin >> s;

	if (s.length() <= n) {
		std::cout << s << std::endl;
	}
	else {
		std::cout << s.substr(0, n) << "..." << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3604
#include <iostream>

using namespace std;


int main() {
    int A[200];
    int N;
    int res_cnt = 0;

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

    for (;;) {
        for (int i = 0; i < N; i++) {
            if (A[i] % 2 == 1) {
                cout << res_cnt;
                return 0;
            }
            A[i] = A[i] / 2;
        }
        res_cnt++;
    }
}

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

queue<pair<int,int>> q;
vector<vector<char>> table(1010,vector<char>(1010,'#'));
vector<vector<int>> dist(1010,vector<int>(1010,-1));
vector<vector<bool>> seen(1010,vector<bool>(1010,0));

void bfs(int a, int b,int d){
  if(!seen[a][b]){
    if(dist[a][b] == -1) dist[a][b] = d+1;
    else dist[a][b] = min(dist[a][b],d+1);
    auto tmp = make_pair(a,b);
    q.push(tmp);
  }
}

int main(){
  int h,w;
  cin >> h >> w;
  rep1(i,h)rep1(j,w){
    cin >> table[i][j];
    if(table[i][j] == '#'){
      auto tmp = make_pair(i,j);
      q.push(tmp);
      dist[i][j] = 0;
    }
  }
  while(!q.empty()){
    int a = q.front().first;
    int b = q.front().second;
    q.pop();
    if(seen[a][b]) continue;
    seen[a][b] = 1;
    if(a<1 || a>h) continue;
    if(b<1 || b>w) continue;
    int d = dist[a][b];
    bfs(a-1,b,d);
    bfs(a+1,b,d);
    bfs(a,b-1,d);
    bfs(a,b+1,d);
  }
  int ans = 0;
  rep1(i,h){
    rep1(j,w) ans = max(ans,dist[i][j]);
  }
  cout << ans << endl;
}


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

int main(){
    int n,a,b,c,ans=0;
    cin>>n>>a>>b;
    for(int i=1;i<=n-2;i++){
        cin>>c;
        if(b!=max(a,max(b,c))&&b!=min(a,min(b,c)))ans++;
        a=b;b=c;
    }
    cout<<ans;
    return 0;
}

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

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

double f(double r1, double r2) {
	double b = r1 - r2;
	double c = r1 + r2;
	return sqrt(c*c - b*b);
}

signed main() {
	cout << fixed << setprecision(8);
	int N; cin >> N;
	vector<int> r(N); rep(i, 0, N) { cin >> r[i]; }
	vector<double> x(N);

	if (N == 1) {
		cout << r[0] * 2 << endl;
		return 0;
	}

	int jl = 0;
	rep(i, 1, r.size()) {
		rep(j, jl, i) {
			double d = f(r[i], r[j]);
			chmax(x[i], d + x[j]);
		}
		if (r[jl] <= r[i])jl = i;
	}
	double left = INF, right = -INF;
	rep(i, 0, x.size()) {
		chmin(left, x[i] - r[i]);
		chmax(right, x[i] + r[i]);
	}
	dumpc(x);
	cout << right - left << endl;
	return 0;
}

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

int main()
{
	int n;
	cin >> n;

	vector<int> size(n+1);
	int r,c;
	for (int i=0;i<n;++i)
	{
		cin >> r >> c;
		size[i]=r;
	}
	size[n]=c;

	vector<vector<int>> m(n+1,vector<int>(n+1));
	const int infinity=32768*32767;

	// length=2
	for (int i=0;i<=n-(2-1);++i)
	{
		m[i][i+1]=0;
	}

	// length=3
	for (int i=0;i<=n-(3-1);++i)
	{
		m[i][i+2]=size[i]*size[i+1]*size[i+2];
	}

	// length>=4
	for (int i=4;i<=n+1;++i)
	{
		for (int j=0;j<=n-(i-1);++j)
		{
			int minimum=infinity;
			for (int k=1;k<=i-2;++k)
			{
				int sum=m[j][j+k]+m[j+k][j+i-1]+size[j]*size[j+k]*size[j+i-1];
				minimum=min(minimum,sum);
			}
			m[j][j+i-1]=minimum;
		}
	}

	cout << m[0][n] << endl;
}








Measured memory_bytes: 3168
#include <stdio.h>
#define abs(x) ((x)<0 ? -(x) : (x))
#define min(a, b) ((a)<(b) ? (a) : (b))

void solve(int h[], int cost[], int t, int n){
  if(t+1 <= n){
    if(cost[t+1] != -1){
      cost[t+1] = min((cost[t+1]), (abs((h[t+1])-(h[t])))+cost[t]);
    }else{
      cost[t+1] = cost[t] + abs((h[t+1]-h[t]));
    }
  }
  if(t+2 <= n)
    if(cost[t+2] != -1)
      cost[t+2] = min(cost[t+2], (cost[t]+abs((h[t+2]-h[t]))));
    else
      cost[t+2] = cost[t] + abs((h[t+2]-h[t]));

  if(t+1 <= n) solve(h, cost, t+1, n);
}

int main(){
  int n, h[100001];
  scanf("%d", &n);
  for(int i=0; i<n; i++) scanf("%d", &h[i]);
  
  int cost[100001];
  for(int i=0; i<n; i++) cost[i] = -1;
  cost[0] = 0;
  solve(h, cost, 0, n-1);

  printf("%d\n", cost[n-1]);

  return 0;
}


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

int main()
{
  char c;
  cin>>c;
  if(c>='a' and c<='z')
  {
    cout<<"a"<<endl;
  }
  else if(c>='A' and c<='Z')
  {
    cout<<"A"<<endl;
  }
}

Measured memory_bytes: 3576
import sys
sys.setrecursionlimit(10 ** 8)

n,m,k=map(int,input().split())


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 998244353
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

result=0
#ペアの個数が0,1,2,3,....k
for pair in range(k+1):
    result+=m*pow(m - 1, n - 1 - pair, p) *cmb(n-1, pair, p)
    #nこの中からpairを洗濯する　nCpair


print(result%p)





Measured memory_bytes: 165908
#include <bits/stdc++.h>
#define Dim 100009
using namespace std;
ifstream f("A.in");
int N,M,K,d,x,H[Dim],a,b,ans;

vector < int > V[Dim];

int main()
{
   cin>>N>>M;
   for(int i=1;i<=N;i++) cin>>H[i];
   for(int i=1;i<=M;i++)
   {
       cin>>a>>b;
       V[a].push_back(b);
       V[b].push_back(a);
   }
   for(int i=1;i<=N;i++)
   {
       if(V[i].size()==0) {ans++; continue;}
       bool stop=0;
       for(unsigned int j=0;j<V[i].size()&&stop==0;j++)
       {
           int vecin=V[i][j];
           if(H[vecin] >= H[i] ) stop=1;
       }
       if(!stop) ans++;
   }
   cout<<ans;

    return 0;
}


Measured memory_bytes: 9176
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int n;
int A[55];

LL dp[55][55 * 55];
LL M;
int main()
{
	scanf("%d", &n);
	scanf("%lld", &M);
	for (int i = 1; i <= n; i++) scanf("%d", &A[i]);

	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int k = i - 1; k >= 0; k--) {
			for (int j = 0; j <= 50 * 50; j++) {
				if (dp[k][j]) {
					dp[k+1][j + A[i]] += dp[k][j];
				}
			}
		}
	}

	LL ans = 0;
		for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= 50 * 50; j++) {
			if (j == i * M)
				ans += dp[i][j];
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 768
IDENTIFICATION DIVISION.
       PROGRAM-ID. ATCODER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  indata PIC X(100).
       01  a1 PIC S9(08).
       01  a2 PIC S9(08).
       01  a3 PIC S9(08).
       01  r1 PIC S9(08).
       01  r2 PIC S9(08).
       01  r3 PIC S9(08).
       01  r pic S9(08).
       01  g pic S9(08).
       01 disp pic Z(20)9.
       PROCEDURE DIVISION.
        ACCEPT indata.
        
        UNSTRING indata DELIMITED BY SPACE INTO a1 a2 a3.
        COMPUTE a2 = a2 + (a1 * 3)
        divide a2 by 2 giving g

        MOVE FUNCTION TRIM(g) to disp
        DISPLAY disp


       STOP RUN.


Measured memory_bytes: 636
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
 
using namespace std;

int main(){
    int N;cin>>N;
    int X;cin>>X;
    vector<int>L(N);
    for(int i=0;i<N;i++){
        cin>>L[i];
    }
    int position=0;
    int count =1;
    for(int i=0;i<N;i++){
        if((position + L[i]) <= X){
            count++;
            position += L[i];
        }else break;
    }

    cout<<count<<endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] a = in.next().toCharArray();
            out.println(a[0] == a[2] ? "Yes" : "No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 23124
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int sei(int a){
  return a>0 ? a : 0;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int A,B,C,D;
  scanf("%d %d %d %d",&A,&B,&C,&D);
  //for(int i=0;i<N;i++) scanf("%d",&num[i]);
  if(A+B == C+D)printf("Balanced");
  else if(A+B > C+D)printf("Left");
  else printf("Right");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}



int main(){
    std::string S;
    std::cin >> S;
    if(S=="ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
    return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define pid pair<int,double>
#define vi vector<int>
#define ff first
#define ss second
#define int long long int
#define ull unsigned long long
#define PI 3.14159265
#define SIZE 200010
#define MOD 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define tc int tcs;cin>>tcs;while(tcs--)
#define set_bit __builtin_popcount
#define MSET(table,i) memset(table, i, sizeof(table))
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ){stringstream ss; ss<< number; return ss.str();}
int power(int x,int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}



int32_t main()
{
    fast;
    int n,m,x;
    cin>>n>>m>>x;

    int arr[n][m+1];

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            cin>>arr[i][j];
        }
    }
    int answer=INT_MAX;
    for(int i=0 ; i< pow(2,n);i++)
    {
        int ans=0;
        int a[m+1]={0};
        for(int j=0;j<n;j++) 
        {
            if( (1<<j) & i )
            {
                ans+=arr[j][0];

                for(int k=1;k<=m;k++)
                {
                    a[k] += arr[j][k];
                }
            }
        }
        int j;
        for(j=1;j<=m;j++)
        {
            if(a[j] < x)
            {
                break;
            }
        }
        if(j==m+1)
        {
            answer=min(ans,answer);
        }

    }
    if(answer==INT_MAX)
    cout<<-1;
    else
    cout<<answer;
    return 0;
}

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

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

template <class T>
inline bool chmin(T& a, T b)
{
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T& a, T b)
{
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

typedef long long ll;

#define MAX_N 10000
#define ORD_MONEY 1000000000000000

struct Edge {
    ll from;
    ll to;
    ll cost;
    Edge(ll f, ll t, ll c)
        : from(f)
        , to(t)
        , cost(c)
    {
    }
    bool operator<(const Edge& o) const
    {
        return cost < o.cost;
    }
};
using Graph = vector<vector<int>>;
using Graph_e = vector<vector<Edge>>;

vector<int> dx = { 1, 0, -1, 0 };
vector<int> dy = { 0, 1, 0, -1 };
typedef pair<int, int> P; // first:最短距離，second:頂点番号

typedef pair<ll, int> P_ll;

struct UnionFind {
    // par[i]:データiが属する木の親の番号．i==par[i]のとき，データiは木の根ノード
    vector<int> par;
    // sizes[i]:根ノードiの木に含まれるデータの数．iが根ノードでない場合は無意味な値となる
    vector<int> sizes;

    UnionFind(int n)
        : par(n)
        , sizes(n, 1)
    {
        // 最初はすべてのデータiがグループiに存在するものとして初期化
        rep(i, n) par[i] = i;
    }

    // データxが属する木の根を得る
    int find(int x)
    {
        if (x == par[x])
            return x;
        return par[x] = find(par[x]); // 根を張り替えながら再帰的に根ノードを探す
    }

    // 2つのデータx,yが属する木をマージ
    void unite(int x, int y)
    {
        //データの根ノードを得る
        x = find(x);
        y = find(y);

        // すでに同じ木に属しているならマージしない
        if (x == y)
            return;
        // xの木がyの木より大きくなるようにする
        if (sizes[x] < sizes[y])
            swap(x, y);

        // xがyの親になるように連結
        par[y] = x;
        sizes[x] += sizes[y];
        // sizes[y] = 0; // sizes[y]は無意味な値となるので0を入れておいてもよい
    }

    // 2つのデータx,yが属する木が同じならtrueを返す
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }

    // データxが含まれる木の大きさを返す
    int size(int x)
    {
        return sizes[find(x)];
    }
};

// 配るDP
int main()
{
    int N;
    cin >> N;
    vector<int> h(N + 10);
    rep(i, N)
    {
        cin >> h.at(i);
    }

    vector<int> dp(N + 10, INF_32);

    dp.at(0) = 0;

    for (int i = 0; i < N; i++) {
        chmin(dp.at(i + 1), dp.at(i) + abs(h.at(i + 1) - h.at(i)));
        chmin(dp.at(i + 2), dp.at(i) + abs(h.at(i + 2) - h.at(i)));
    }

    cout << dp.at(N - 1) << endl;
}


Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです
*/

// Dep crates are...
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::{i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_integer::{binomial, gcd, lcm, Integer};
use permutohedron::Heap;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

// code...
fn main() {
    input! {
        n: usize, m: usize,
        h: [usize; n],
        root: [(Usize1, Usize1); m]
    }

    let mut g: Vec<Vec<usize>> = vec![vec![]; n];
    for (a, b) in root {
        g[a].push(b);
        g[b].push(a);
    }

    let mut ans = 0usize;

    for (i, peak) in h.iter().enumerate() {
        if g[i].iter().all(|x| h[*x] < h[i]) {
            // dbg!(i);
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 12192
#include <iostream>
#include <string>
#include <vector>

int N;

typedef struct range {
    int start;
    int end;
} Range;

using namespace std;

int evaluate(string str) {
    int score = 0;
    for (int i = 0; i < str.length() - 1; ++i) {
        if (str[i] == str[i + 1]) {
            ++score;
        }
    }
    return score;
}

int main() {
    int K;
    string S;
    cin >> N >> K >> S;

    vector< Range > R, L;

    int start = 0;
    for (int i = 0; i < N - 1; i++) {
        if (S[i] != S[i + 1]) {
            if (S[i] == 'R') {
                R.push_back(Range{start, i});
            } else {
                L.push_back(Range{start, i});
            }
            start = i + 1;
        }
    }

    if (S[N - 1] == 'R') {
        R.push_back(Range{start, N - 1});
    } else {
        L.push_back(Range{start, N - 1});
    }

    string r_str(S);
    string l_str(S);
    for (int i = 0; i < K && i < R.size(); i++) {
        Range r = R[i];

        // cout << r.start << " " << r.end << endl;
        for (int j = r.start; j <= r.end; j++) {
            r_str[j] = 'L';
        }
    }
    // cout << r_str << endl;

    for (int i = 0; i < K && i < L.size(); i++) {
        Range l = L[i];
        // cout << l.start << " " << l.end << endl;
        for (int j = l.start; j <= l.end; j++) {
            l_str[j] = 'R';
        }
    }
    // cout << l_str << endl;

    int ans = max(evaluate(r_str), evaluate(l_str));
    cout << ans << endl;
}


Measured memory_bytes: 1524
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int A, B;
    cin >> A >> B;
    if(A==1) A+=14;
    if(B==1) B+=14;
    bool c1 = A>B;
    bool c2 = A<B;
    bool c3 = A==B;
    if(c1) cout << "Alice" << '\n';
    else if(c2) cout << "Bob" << '\n';
    else if(c3) cout << "Draw" << '\n';
}


Measured memory_bytes: 3576
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);

	LLI a, b, c, k;
	cin >> a >> b >> c >> k;

	LLI ans = 0;
	ans += _min(a, k);
	k -= _min(a, k);
	k -= _min(b, k);
	ans -= _min(c, k);
	k -= _min(c, k);

	cout << ans;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>

int main (void) {
	std::string b;
	std::cin >> b;
	std::string out;
	
	if (b == "A") {
		out = "T";
	} else	if (b == "T") {
		out = "A";
	} else	if (b == "C") {
		out = "G";
	} else	if (b == "G") {
		out = "C";
	}
	
	std::cout << out;
	
	return 0;
}

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

template <typename _Tp> inline _Tp read(_Tp&x){
	char c11=getchar(),ob=0;x=0;
	while(c11^'-'&&!isdigit(c11))c11=getchar();if(c11=='-')ob=1,c11=getchar();
	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();if(ob)x=-x;return x;
}

const int N=101000;
bool f[N];int ball[N];
int n,m,ans;

int main(){
	read(n),read(m);f[1]=true;
	for(int i=n;i;--i)ball[i]=1;
	for(int i=1,u,v;i<=m;++i){
		read(u),--ball[u];
		read(v),++ball[v];
		if(f[u])f[v]=true;
		if(!ball[u])f[u]=false;
	}
	for(int i=n;i;--i)ans+=f[i];
	printf("%d\n",ans);return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    int r1[7]={1,3,5,7,8,10,12},r2[4]={4,6,9,11};
    if(count(r1,r1+7,a)>0 && count(r1,r1+7,b)>0){
        cout << "Yes";
    }else if(count(r2,r2+4,a)>0 && count(r2,r2+4,b)>0){
        cout << "Yes";
    }else if(a==2&&b==2){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
import itertools
import bisect
n=input()
l=[]
for i in range(3,len(n)+1):
    for j in itertools.product([3,5,7],repeat=i):
        if len(set(j))==3:
            l.append(int(''.join(map(str,j))))
l.sort()
print(bisect.bisect_right(l,int(n)))

Measured memory_bytes: 4108
using System;
 
class Program
{
    static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
 
        int a = int.Parse(str[0]);
 
        int b = int.Parse(str[1]);
 
        System.Console.WriteLine("{0} {1}", a * b, 2 * (a + b));
    }
}

Measured memory_bytes: 9212
using System;

namespace ITP1_5_C
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                string[] x = Console.ReadLine().Split(' ');
                int h = int.Parse(x[0]);
                int w = int.Parse(x[1]);
                
                if (h == 0 && w == 0) break;
                
                //奇数行かつ奇数列または偶数行かつ偶数列
                for (int i = 0; i < h; i ++)
                {
                    for (int j = 0; j < w; j++)
                    {
                        if ((i + j) % 2 == 0)
                        {
                            Console.Write("#");
                        }
                        else
                        {
                            Console.Write(".");
                        }
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
            
        }
    }
}


Measured memory_bytes: 17912
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e,i=0,j=0,k=1,l;
    string ss,sa,cc;
    char s;
    cin>>a;
    for(l=1;l<=a;l++)
    {
        cin>>s;
      ss+=s;
    }
     for(l=1;l<=a;l++)
    {
        cin>>s;
      sa+=s;
    }
     for(l=1;l<=a;l++)
    {

      cc+=l+'0';
    }
  
    if(cc==ss)i=1;
    if(cc==sa)j=1;
    for(l=0;l<a;l++)
    while(next_permutation(cc.begin(),cc.end()))
    {k++;
    if(ss==cc&&i==0)i=k;
    if(sa==cc&&j==0)j=k;
    }
    cout<<abs(i-j)<<endl;
}


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

namespace codeTester.contest190810
{
    class ProblemB
    {
        static List<long> kx = new List<long>();
        static string answer = "";

        public static void Main(string[] args)
        {
            Input();
            Logic();
            Output();
        }

        static void Input()
        {
            kx = ReadSpaceSeparatedValues();
        }

        public static List<long> ReadSpaceSeparatedValues()
        {
            List<long> values = new List<long>();
            string[] inputs = Console.ReadLine().Split(' ');
            foreach (string input in inputs)
            {
                values.Add(long.Parse(input));
            }

            return values;
        }

        static void Logic()
        {
            long k = kx[0];
            long x = kx[1];
            long mayStart = Math.Max(-1000000, x - (k - 1));
            long mayEnd = Math.Min(1000000, x + (k - 1));
            List<long> mayList = new List<long>();
            for (long i = mayStart; i <= mayEnd; i++)
            {
                mayList.Add(i);
            }
            answer = string.Join(" ", mayList);
        }

        static void Output()
        {
            Console.WriteLine(answer);
        }

        static void DebugPrint(string msg)
        {
            // 提出時に消す
            // Console.WriteLine(msg);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  if(N*2 >= M){
    cout << M/2 << endl;
  }
  else{
    cout << N + (M-N*2)/4 << endl;
  }
}

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

int main() {
	string b;
	cin >> b;
	if(b == "A") cout << "T" << endl;
	if(b == "T") cout << "A" << endl;
	if(b == "C") cout << "G" << endl;
	if(b == "G") cout << "C" << endl;
}


Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	vector<int>b(n);
	for(int i=0;i<n;i++) cin >> a.at (i);
	b=a;
	sort(b.begin(),b.end());
	for(int i=0;i<n;i++){
		if(a.at(i)==b.at(n-1)) cout << b.at(n-2) << endl;
		else cout << b.at(n-1) << endl;
	}

}


Measured memory_bytes: 3200