akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin>>N;
	vector<int> d(N);
	for(int i=0;i<N;i++) cin>>d[i];
	sort(d.begin(),d.end());
	int ans=0;
	for(int i=1;i<=100000;i++) {
		int cnt=lower_bound(d.begin(),d.end(),i)-d.begin();
		if(cnt==N/2) ans++;
	}
	cout<<ans<<endl;
}

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

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

int main(){
    long long x,y,buf;
    int res=0;
    scanf("%lld%lld",&x,&y);
    buf=x;
    while(buf<=y){
        buf*=2;
        res++;
    }

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

    return 0;
}


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

	int a[10010];
   int main(){
     int n,m;
     
     scanf("%d%d",&n,&m);
     for(int i=0;i<m;i++)scanf("%d",&a[i]);
     int s=0;
     for(int i=0;i<m;i++)s+=a[i];
     if(s>n){
     printf("-1\n");
     }else{
     printf("%d\n",n-s);
       }
     }


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

int main()
{
    int n, ans = 1e9, tmp = 0;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i];
    }
    for (int i = 1; i <= 100; i++)
    {
        for (int j = 0; j < x.size(); j++)
        {
            tmp += (x[j] - i) * (x[j] - i);
        }
        ans = ans < tmp ? ans : tmp;
        tmp = 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N;
int A[18], B[18];
unsigned char dp[36][1 << 18];
int keisan(int b, bool n, int k) {
	if (dp[k][b] != 255) return dp[k][b];
	if (b == (1 << N) - 1) return 0;

	int saishou = 254;
	int num2 = 0;
	rep(i, N) {
		if (!(b >> i & 1)) {
			if (A[i] < k && B[i] < k) return dp[k][b] = 254;
			if ((n + i) & 1) {
				if (B[i] >= k) {
					chmin(saishou, keisan(b + (1 << i), !n, B[i]) + num2);
				}
			}
			else {
				if (A[i] >= k) {
					chmin(saishou, keisan(b + (1 << i), !n, A[i]) + num2);
				}
			}
			num2++;
		}
	}
	return dp[k][b] = saishou;
}

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


	cin >> N;
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];

	pair<int, int> kari[36];
	rep(i, N) kari[i] = mp(A[i], i);
	rep(i, N) kari[i + N] = mp(B[i], i + N);
	sort(kari, kari + N * 2);
	int k = 0;
	int mae = kari[0].first;
	rep(i, N * 2) {
		if (mae != kari[i].first) k++;
		mae = kari[i].first;
		if (kari[i].second < N) A[kari[i].second] = k;
		else B[kari[i].second - N] = k;
	}

	rep(i, k + 1) rep(j, 1 << N) dp[i][j] = 255;

	int kotae = keisan(0, 0, 0);
	if (kotae == 254) co(-1);
	else co(kotae);

	Would you please return 0;
}

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

ll N;
vector<ll> A;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  char n[3];
  rep(i, 3) cin >> n[i];
  rep(i, 3) {
    if (n[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<string>
using namespace std;
 
int main() {
  int n, m;
  cin >> n;
  vector <string> s(n);
  for(int i(0);i<n;i++)
    cin >> s.at(i);
  cin >> m;
  vector <string> t(m);
  for(int i(0);i<m;i++)
    cin >> t.at(i);
  
  int max(0);
  for(int i(0);i<n;i++){
    int c(1);
    if(i<n-1)
      for(int j(i+1);j<n;j++)
      	if(s.at(i)==s.at(j))	c++;
    for(int j(0);j<m;j++)
      if(s.at(i)==t.at(j))	c--;
    if(c > max)	max=c;
  }
  cout << max;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int cntt;

const int INFTY = 1e9;
void merge(vector<int> &A, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    vector<int> L, R;
    REP(i,n1) L.push_back(A[left + i]);
    REP(i,n2) R.push_back(A[mid + i]);
    L.push_back(INFTY);
    R.push_back(INFTY);
    int i = 0;
    int j = 0;
    FOR(k, left, right) {
        cntt++;
        if (L[i] <= R[j]) {
            A[k] = L[i];
            i = i + 1;
        }else {
            A[k] = R[j];
            j = j + 1;
        }
    }
}

void mergeSort(vector<int> &A, int left, int right) {
    cntt;
    if (left+1 < right) {
        int mid = (left + right)/2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

void printvec(vector<int> A) {
    REP(i,A.size()-1) cout << A[i] << " ";
    cout << A[A.size()-1] << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> v;
    PUSH(n,v);
    mergeSort(v, 0, v.size());
    printvec(v);
    cout << cntt << endl;
    return 0;
}

Measured memory_bytes: 6004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int k, t;
    cin >> k >> t;
    int a[t];
    for (int i = 0; i < t; i++) {
        cin >> a[i];
    }

    sort(a, a + t);
    int sum = 0;
    for (int i = 0; i < t - 1; i++) {
        sum += a[i];
    }

    cout << max(0, a[t - 1] - sum - 1) << endl;;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new aoj1116().doIt();
    }
    class aoj1116{
    	int result = 0;
    	char map[][] = new char [9][4];
    	boolean check[] = new boolean[9];
    	int t_map[][] = new int [3][3];
    	int alf[] = new int[256];
//    	int cnt = 0;
    	// 0 1 2
		// 3 4 5
		// 6 7 8
    	void rotate(int num){
//    		if(num == 0){
//    			for(int i = 0;i < 4;i++){
//    				System.out.print(map[num][i]);
//    			}
//    			System.out.println();
//    		}
    		char c = map[num][0];
    		for(int i = 0;i < 3;i++){
    			map[num][i] = map[num][i+1];
    		}
    		map[num][3] = c; 
    	}
    	void dfs(int num){
//    		cnt++;
//    		System.out.println(num);
    		if(num == 9)result++;
    		else{
    			for(int i = 0;i < 9;i++){
    				if(check[i])continue;
    				check[i] = true;
    				t_map[num/3][num%3] = i;
    				for(int j = 0;j < 4;j++){
    					if(num / 3 > 0 && num % 3 > 0){
    						if(alf[map[t_map[num/3][num%3]][1]] == -alf[map[t_map[num/3][(num%3)-1]][3]]
    								&& alf[map[t_map[num/3][num%3]][0]] == -alf[map[t_map[(num/3)-1][num%3]][2]])dfs(num+1);
    					}else if(num / 3 > 0){
    						if(alf[map[t_map[num/3][num%3]][0]] == -alf[map[t_map[(num/3)-1][num%3]][2]])dfs(num+1);
    					}else if(num % 3 > 0){
    						if(alf[map[t_map[num/3][num%3]][1]] == -alf[map[t_map[num/3][(num%3)-1]][3]])dfs(num+1);
    					}else{
    						dfs(num+1);
    					}
    					rotate(i);
    				}
    				check[i] = false;
    			}
    		}
    	}
    	void doIt(){
    		alf['r'] = 1;alf['g'] = 2; alf['b'] = 3;alf['w'] = 4;
    		alf['R'] = -1;alf['G'] = -2; alf['B'] = -3;alf['W'] = -4;
    		int n = sc.nextInt();
    		for(int i = 0;i < n;i++){
    			for(int j = 0;j < 9;j++){
    				String str = sc.next();
    				char ctr[] = str.toCharArray();
    				for(int k = 0;k < 4;k++){
    					map[j][k] = ctr[k];
    				}
    			}
    			result = 0;
    			dfs(0);
    			System.out.println(result);
//    			System.out.println(cnt);
    		}
    	}
    }
}

Measured memory_bytes: 30316
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

// 終了判定
template <typename T,
		  typename enable_if<is_integral<T>::value>::type* = nullptr>
bool finds(T left, T right) {
	return right - left > 1;
}

// 二分探索
template <typename T>
T bin_search(T left, T right, auto pred) {
	while(finds<T>(left, right)) {
		T middle = (left + right) / 2;
		if(pred(middle)) {
			left = middle;
		} else {
			right = middle;
		}
	}
	return left;
}

int main() {
	int n;
	cin >> n;
	vector<vector<ll>> abc(3, vector<ll>(n + 1, 0));
	REP(i, n) { cin >> abc[0][i]; }
	REP(i, n) { cin >> abc[1][i]; }
	REP(i, n) { cin >> abc[2][i]; }

	sort(ALL(abc[0]));
	sort(ALL(abc[1]));
	sort(ALL(abc[2]));
	vector<vector<ll>> dp(3, vector<ll>(n + 1, 0));
	REP(i, 3) {
		REP(j, n + 1) {
			if(i == 0) {
				dp[0][j] = j;
				continue;
			}
			if(j == 0) {
				dp[i][0] = 0;
				continue;
			}
			int l = bin_search(
				0, n + 1, [&](int x) { return abc[i - 1][x] < abc[i][j]; });
			dp[i][j] = dp[i][j - 1] + dp[i - 1][l];
		}
	}

	cout << dp[2][n] << endl;
	return 0;
}


Measured memory_bytes: 8620
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        a1: u32,
        a2: u32,
        a3: u32,
    }
    if a1 + a2 + a3 >= 22 {
        println!("bust");
    } else {
        println!("win");
    }
}
/* vim:set foldmethod=marker: */


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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define I1000000007 (1000000007)
#define I998244353   (998244353)
#define IINF             (1<<28)
#define LINF           (1LL<<60)
#define ALL(a)         (a).begin(), (a).end()
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"
template<class T> inline bool chmin(T& a, const T& b) {
  if (a > b) { a = b; return true; } else return false;
}
template<class T> inline bool chmax(T& a, const T& b) {
  if (a < b) { a = b; return true; } else return false;
}

namespace solver {
  using namespace std;
  using ll = long long;

  void init() {
  }

  void solve() {
    string S, T;
    map<char, char> m;
    vector<bool> used(30);
    fill(ALL(used), false);
    cin >> S >> T;
    rep(i, S.size()) {
      if(m.find(S[i]) == m.end() && !used[T[i]-'a']) m[S[i]] = T[i], used[T[i]-'a'] = true;
      else if(m.find(S[i]) == m.end() || m[S[i]] != T[i]) {
        cout << "No" << "\n";
        return;
      }
    }
    cout << "Yes" << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 916
#include<stdio.h>
int main()
{
	int i,a,b,n,cp,co;
	char str[100001];
	while(~scanf("%d %d %d", &n, &a, &b)){
		scanf("%s", str);
		cp=co=0;
		for(i=0; i<n; i++)
		{
			if(cp<a+b)
			{
				if(str[i]=='a')
				{
					cp++;
					printf("Yes\n");
				}
				else if(str[i]=='b' && co<b)
				{
					cp++;
					co++;
					printf("Yes\n");
				}
				else
					printf("No\n");
			}
			else
				printf("No\n");
		}
	}
}

Measured memory_bytes: 640
from math import sqrt


def F(a, b):
    return max(len(str(a)), len(str(b)))

N = int(input())

best = 1<<30
for A in range(1, int(sqrt(N)) + 1):
    B = N // A
    if A * B != N:
        continue
    c = F(A, B)
    if best > c:
        best = c

print(best)

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

using namespace std;

int main() {
  long long ans = 0;
  int d;
  cin >> d;
  for(int i = 1 ; i <= 10000000 ; ++i) {
   		ans = (ans * 10);
        ans += 7;
        ans %= d;
    	if(ans == 0) {
           cout << i << endl;
           exit(0);
        }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3604
N, K = map(int, input().split())
A = list(map(int, input().split()))
res = 0

# dより上位の桁については、XはKと一致
# d桁目についてはXは0で、Kは1である
# dより下位の桁については、Xはなんでもいい

# d = -1 は X = K の場合
for d in range(60, -2, -1):
    # Kが0の場合はダメ

    # ex.
    # 3 7
    # 1 6 3
    # の場合、d = 60, 59, ..., 3は除外される

    # K = 7 = 111(2)
    # d = 2の時、0**
    # d = 1の時、10*
    # d = 0の時、110
    # d = -1の時、111

    if d != -1 and (K & 1 << d) == 0:
        continue

    tmp = 0
    for e in range(60, -1, -1):
        mask = 1 << e

        # 今考えている桁について、bitが立っているAの要素の個数
        num = 0
        for i in range(N):
            if A[i] & mask:
                num += 1

        # XがKと一致している領域
        if e > d:
            # Kのbitが立っている場合
            # 反転が起こり、0の数(N-num)の分が足される
            if K & mask:
                tmp += mask * (N - num)
            # Kのbitが立っていない場合
            # bitの反転は起きない、1の数(num)の分が足される
            else:
                tmp += mask * num
        # この時、Xのbitは立っておらず、反転は起きない
        # 1の数(num)の分を足す
        elif e == d:
            tmp += mask * num
        # Xのbitは0と1の好きな方を取ることが出来る
        else:
            tmp += mask * max(num, N - num)
    res = max(res, tmp)

print(res)


Measured memory_bytes: 86400
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
  public static void main (String[] args) throws java.lang.Exception
   {
	try{
	    Scanner sc=new Scanner(System.in);
		   int a=sc.nextInt();
		   int b=sc.nextInt();
		   int c=sc.nextInt();
		   System.out.println(c+" "+a+" "+b);
		  }     
	catch(Exception e)
		 {}
	}
}


Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);
ll dx[8]={0,0,-1,1,-1,1,-1,1};
ll dy[8]={1,-1,0,0,1,1,-1,-1};
vector<vector<ll> > c(10,vector<ll>(10,0));

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    string s; cin>>s;
    
    // ....####のようにする
    
    ll cnt=0;
    rep(i,sz(s)){
        if(s[i]=='.') cnt++;
    }
    //#########
    ll ans=cnt;
    
    // .#######
    //  i
    // ..######
    rep(i,sz(s)){
        if(s[i]=='.') cnt--;
        else cnt++;
        chmin(ans,cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3696
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

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

var n int
var A []int

func main() {
	n, _ := strconv.Atoi(readLine())
	A := make([]int, 0, 1000000)
	str := readLine()
	strSlices := strings.Split(str, " ")
	for _, s := range strSlices {
		i, _ := strconv.Atoi(s)
		A = append(A, i)
	}
	mod := 1000000000 + 7

	counter := make([]int, n)
	if n%2 == 1 { // 奇数（最小値は1）
		for i := 0; i < n; i += 2 {
			if i == 0 {
				counter[i] = 1
			} else {
				counter[i] = 2
			}
		}
	} else { // 偶数（最小値は2）
		for i := 1; i < n; i += 2 {
			counter[i] = 2
		}
	}

	// 判定
	for i := 0; i < n; i++ {
		idx := A[i]
		counter[idx]--
	}
	for _, e := range counter {
		if e != 0 {
			fmt.Println(0)
			return
		}
	}

	// 答えは2^(n/2)
	index := n / 2
	answer := 1
	for i := 0; i < index; i++ {
		answer = answer * 2 % mod
	}
	fmt.Println(answer)
}


Measured memory_bytes: 8448
import std.stdio, std.string, std.array, std.conv;

void main() {
    int[] tmp = readln.chomp.split.to!(int[]);
    int a = tmp[0], b = tmp[1];
    int d = a / b;
    int r = a % b;
    double f = a.to!double / b.to!double;
    writefln("%d %d %0.5f", d, r, f);
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vi c(n);
    vii a(n, vector<int>(m));

    for(int i = 0; i < n; i++) {
        cin >> c[i];
        for(int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    //-1はじき
    vi test(m, 0);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            test[j] += a[i][j];
        }
    }
    for(int t : test) {
        if(t < x) {
            cout << -1 << endl;
            return 0;
        }
    }
    //bit全探索
    int ans = 10000000;
    for(int bit = 0; bit < (1 << n); bit++) {
        int sum = 0;
        vi know(m);
        for(int i = 0; i < n; i++) {
            if(bit & (1 << i)) {
                sum += c[i];
                for(int j = 0; j < m; j++) {
                    know[j] += a[i][j];
                }
            }
        }
        bool check = true;
        for(int y : know) {
            if(y < x) check = false;
        }
        if(check) ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>

using namespace std;
const int MOD = 10000;

int main()
{
  int N,K;
  while(cin >> N){
    int  preplan[1+N];
    cin >> K;
    for(int i = 0; i < 1+N; ++i)preplan[i]=-1;
    for(int i = 0; i < K; ++i){
      int a,b;
      cin >> a >> b;
      //--a;
      preplan[a] = b;
    }

    int dp[N+1][4][4][4];

    for(int i = 0; i < N+1; ++i){
      for(int j = 0; j < 4; ++j){
        for(int k = 0; k < 4; ++k){
          for(int l = 0; l < 4; ++l){
            dp[i][j][k][l] = 0;
          }
        }
      }
    }

    if(preplan[1]!=-1){
      dp[1][preplan[1]][0][0] = 1;
    }else{
      dp[1][1][0][0] = 1;
      dp[1][2][0][0] = 1;
      dp[1][3][0][0] = 1;
    }
    for(int i = 1; i < N; ++i){
      for(int j = 1; j < 4; ++j){
        for(int k = i==1?0:1; k < 4; ++k){
          for(int l = i<=2?0:1; l < 4; ++l){
            for(int m = 1; m < 4; ++m){
              if( (m == j && j == k ) || (j == k && k == l) ) continue;
              if( preplan[i+1] != -1 && m != preplan[i+1] ) continue;
              //printf("dp[%d][%d][%d][%d] = dp[%d][%d][%d][%d] : %d <- %d+1\n",
              //i+1,m,j,k,i,j,k,l,dp[i+1][m][j][k],dp[i][j][k][l]);
              dp[i+1][m][j][k] += dp[i][j][k][l];
              dp[i+1][m][j][k] %= MOD;
            }
          }
        }
      }
    }

    int res = 0;
    for(int i = 1; i < 4; ++i){
      for(int j = 1; j < 4; ++j){
        for(int k = 1; k < 4; ++k){
          if( i==j&&j==k ) continue;
          res += dp[N][i][j][k];
          res %= MOD;
        }
      }
    }

    cout << res << endl;
    
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

char even(int x)
{
	if (x % 2 == 0) return '1';
	else return '0';
}
char odd(int x)
{
	if (x % 2 == 1) return '1';
	else return '0';
}

int main()
{
	int aMin, bMin, i;
	aMin = 0;
	bMin = 0;
	string S; 
	cin >> S;
	for (i = 0; i < S.length(); i++)
	{
		if (S[i] != even(i)) aMin += 1;
	}
	for (i = 0; i < S.length(); i++)
	{
		if (S[i] != odd(i)) bMin += 1;
	}
	cout << min(aMin, bMin);

	return 0;
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    val M = readInputLine().toInt()

    var digit = 0L
    var sum = 0L

    for (i in 1..M) {
        var (d, c) = readInputLine().split(" ").map { it.toLong() }
        
        digit += c
        sum += d * c
    }
    
    println(digit - 1L + (sum - 1L) / 9L)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 70500
// C
#include <stdio.h>
#include <stdlib.h>

int main(void){
	int n;
	scanf("%d", &n);
	char *c = malloc(sizeof(char) * (n + 5));
	scanf("%s", c);
	int l = 0, r = n - 1;
	int count = 0;
	while(1){
		while(c[l] != 'W' && l < r)l++;
		while(c[r] != 'R' && l < r)r--;
		if(l < r)count++;
		else break;
		l++;
		r--;
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 2324
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<map>
#define N 200060
#define ll long long
using namespace std;

map<ll,int>mp[33];
typedef map<ll,int>::iterator iter;
int seq[N][5];
int n ,m;
void del(int pos,int val){
    iter t1 = mp[pos].find(val);
    t1->second--;
    if (t1->second == 0)
        mp[pos].erase(t1);
    return ;
}
int mm;
int myabs(int x){
    return x<0?-x:x;
}
ll get_ans(){
    ll res = 0;
    for (int i=0;i<mm;i++){
        iter l = mp[i].begin();
        iter r = mp[i].end();
        r--;
        ll tmp = myabs((l->first) - (r->first));
        if (tmp > res)
            res = tmp;
    }
    return res;
}
void dfs(int deep,int val,int root,int pos,int id){
    if (deep >= m){
        if (id == 0){
            mp[root][val]++;
        }else{
            del(root,val);
        }
        return ;
    }
    dfs(deep+1, val + seq[pos][deep],root*2,pos,id);
    dfs(deep+1, val - seq[pos][deep],root*2+1,pos,id);
    return ;
}
signed main()
{
    scanf("%d",&n);
    m=2;
        mm = 1<<m;
        for (int i=0;i<mm;i++)
            mp[i].clear();

        for (int i=1;i<=n;i++){
                for (int j=0;j<m;j++)
                    scanf("%d",&seq[i][j]);
                dfs(0,0,0,i,0);
          //  puts("d");
            
        }
	printf("%lld\n",get_ans());
}

Measured memory_bytes: 57140
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  pair<int, int> T; 
  pair<int, int> A; 
  pair<int, int> B; 

  cin >> T.first >> T.second;
  cin >> A.first >> A.second;
  cin >> B.first >> B.second;

  int x, y;
  x = T.first*(A.first-B.first);
  y = T.second*(A.second-B.second);
  
  if(x > 0){
    x *= -1;
    y *= -1;
  }
  if(x+y < 0){
    cout << 0 << endl;
  }
  else if(x+y == 0){
    cout << "infinity" << endl;
  }
  else{
    int ans = -x/(x+y)*2;
    if(-x%(x+y) != 0) ans++;

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int x;
signed main()
{
	scanf("%lld",&x);
	for(int i=0;i<=1000;i++)for(int j=i;j<=1000;j++)
	{
		int i5=i*i*i*i*i,j5=j*j*j*j*j;
		if(i5+j5==x)
		{
			printf("%lld %lld",i,-j);
			return 0;
		}
		if(i5-j5==x)
		{
			printf("%lld %lld",i,j);
			return 0;
		}
		if(-i5+j5==x)
		{
			printf("%lld %lld",j,i);
			return 0;
		}
		if(-i5-j5==x)
		{
			printf("%lld %lld",-i,j);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3724
N,x = map(int, raw_input().split())
candies = map(int, raw_input().split())

count = 0
prev_eat = 0
for i in range(N-1):
    a = candies[i]
    b = candies[i+1]
    eat = max((a + b - prev_eat) - x, 0)
    count += eat
    prev_eat = min(eat, b)
print count

Measured memory_bytes: 11340
#include<iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
	ll a, b, x, y;
	ll t;
	scanf("%lld", &t);
	a = 1, b = 1;
	while (t--)
	{
		scanf("%lld%lld", &x, &y);
		if (x <= a || y <= b)
		{
// 			ll tp1, tp2;
// 			ll n = max((ll)floor(a*1.0 / x), (ll)floor(b*1.0 / y));
// 			tp1 = (ll)n*x,tp2 = (ll)n*y;
// 			if (tp1 < a || tp2 < b)
// 				tp1 += x,tp2 += y;
// 			
// 			a = tp1, b = tp2;

			ll n = max(a / x + (a%x != 0), b / y + (b%y != 0));
			ll tp1, tp2;
			tp1 = (ll)n*x,tp2 = (ll)n*y;
			a = tp1, b = tp2;

		}
		else
		{
			a = x, b = y;
		}
	}
	printf("%lld\n", (ll)(a + b));


	return 0;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict
from heapq import heappop, heappush
n = int(sys.stdin.readline().split()[0])
A = defaultdict(list)
ans = []
for query in sys.stdin:
    if query[0] == '0':
        t, x = query[2:].split()
        heappush(A[t], -int(x))
    elif query[0] == '1':
        if A[query[2:-1]]:
            ans.append(f'{-A[query[2:-1]][0]}' + '\n')
    else:
        if A[query[2:-1]]:
            heappop(A[query[2:-1]])
sys.stdout.writelines(ans)


Measured memory_bytes: 16108
#include <iostream>
#include <queue>
#include <tuple>
#include <vector>

using namespace std;

int H, W, ans;
bool S[20][20];
pair<int, int> D[4]{{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

void dfs(int sh, int sw) {
  queue<tuple<int, int, int>> q;
  vector<vector<int>> p(H, vector<int>(W,H*W));
  q.emplace(sh, sw, 0);
  p[sh][sw] = 0;
  int maxt{};
  while (!q.empty()) {
    auto [h, w, t] = q.front();
    maxt = t;
    q.pop();
    for (auto [dh, dw] : D) {
      int nh = h + dh, nw = w + dw;
      if (nh >= 0 && nh < H && nw >= 0 && nw < W && S[nh][nw] &&
          p[nh][nw] > t + 1) {
        q.emplace(h + dh, w + dw, t + 1);
        p[nh][nw] = t + 1;
      }
    }
  }
  ans = max(maxt, ans);
}

int main() {
  cin >> H >> W;
  string r;
  vector<pair<int, int>> v;
  for (int i = 0; i != H; ++i) {
    cin >> r;
    for (int j = 0; j != W; ++j) {
      S[i][j] = r[j] == '.';
      if (S[i][j]) v.emplace_back(i, j);
    }
  }
  for (auto [sh, sw] : v) dfs(sh, sw);
  cout << ans << endl;
}


Measured memory_bytes: 3648
package main

import (
	"fmt"
	"strings"
)

func main() {

	for {
		var H, W int
		fmt.Scan(&H)
		fmt.Scan(&W)

		if H == 0 && W == 0 {
			break
		}
		for h := 0; h < H; h++ {
			if h % 2 == 0 {
				fmt.Println(strings.Repeat("#.", W)[:W])
			} else {
				fmt.Println(strings.Repeat(".#", W)[:W])
			}
		}
		fmt.Println()
	}
}



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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int main()
{
    int dx[8]={0,1,1,1,0,-1,-1,-1};
    int dy[8]={-1,-1,0,1,1,1,0,-1};

    int n;
    while(cin >>n,n)
    {
        vector<string> s(n);
        rep(i,n) cin >>s[i];

        int a[255][255];
        rep(i,n)rep(j,n) a[i][j]=s[i][j]-'0';

        int ans=0;

        //??????????????????
        rep(i,n)rep(j,n)
        {
            if(a[i][j]==0) continue;

            rep(k,8)
            {
                int t=0;
                int nx=j, ny=i;
                while(0<=nx&&nx<n && 0<=ny&&ny<n)
                {
                    if(a[ny][nx]==1)
                    {
                        ++t;
                        ny+=dy[k];
                        nx+=dx[k];
                    }
                    else break;
                }

                ans=max(ans,t);
            }
        }

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

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){

  int h,w;
  cin >> h >> w;
  vector<string> v(h);
  rep(i,h)cin >> v[i];
  vector<vector<int>> dp(h,vector<int>(w,1 << 30));
  dp[0][0] = 0;
  rep(i,w-1)if(v[0][i+1] == '#' && v[0][i] == '.'){
    dp[0][i+1] = dp[0][i]+1;
  }else{
    dp[0][i+1] = dp[0][i];
  }
  for(int i = 1;i < h;i++)rep(j,w){
    if(v[i-1][j] == '.' && v[i][j] == '#')dp[i][j] = min(dp[i][j],dp[i-1][j] + 1);
    else dp[i][j] = min(dp[i][j],dp[i-1][j]);
    if(j-1 >= 0 && v[i][j-1] == '.' && v[i][j] == '#')dp[i][j] = min(dp[i][j],dp[i][j-1]+1);
    else if(j-1 >= 0)dp[i][j] = min(dp[i][j],dp[i][j-1]);
  }
  cout << dp[h-1][w-1] + (v[0][0] == '#') << endl;





  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2000000)
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
ab=[list(map(int,input().split())) for i in range(n-1)]
ki=[[] for i in range(n+1)]
for i in range(n-1):
    ki[ab[i][0]].append(ab[i][1])
    ki[ab[i][1]].append(ab[i][0])
# print(ki)
kyori=[[float("INF"), float("INF")] for i in range(n+1)]
def tansaku(m, dis, hito):
    q=[[m,dis]]
    while q:
        po=q.pop()
        for i in ki[po[0]]:
            if kyori[i][hito]>po[1]:
                kyori[i][hito]=po[1]
                q.append([i,po[1]+1])

tansaku(1,1,0)
tansaku(n,1,1)
fe,su=0,0

for i in range(1,n+1):
    if kyori[i][0]<=kyori[i][1]:
        fe+=1
    else:
        su+=1

if fe>su:
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 90204
s = input().split()
m,d=int(s[0]),int(s[1])
n = 0
for i in range(d):
    w = str(i+1)
    if len(w)==2 and int(w[1])>1 and int(w[0])>1:
        p = 1
        for j in w:
            p*=int(j)
        if p<=m and p!= 0:
            n+=1
print(n)

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, L: int, A: "List[int]", B: "List[int]", C: "List[int]", Q: int, s: "List[int]", t: "List[int]"):
    import numpy as np    
    from scipy.sparse import coo_matrix    
    from scipy.sparse.csgraph import floyd_warshall
   # coo_matrix((data, (i, j)), [shape=(M, N)])
    mat = floyd_warshall(coo_matrix((C, (A, B)), shape=(N+1, N+1), dtype=np.int32).tocsr(), directed=False)
    mat = floyd_warshall(mat <= L, directed=False)
    for ss, tt in zip(s, t):
        yield -1 if np.isinf(mat[ss][tt]) else int(mat[ss][tt]) - 1


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    L = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    C = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    Q = int(next(tokens))  # type: int
    s = [int()] * (Q)  # type: "List[int]"
    t = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        s[i] = int(next(tokens))
        t[i] = int(next(tokens))
    print(*solve(N, M, L, A, B, C, Q, s, t), sep="\n")

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

using namespace std;

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

	int sum = 0;
  for (int i = 0; i < N; i++) {
		sum += W[i];
	}
	int ans = sum;
	int a = 0;

	for (int i = 0; i < N; i++) {
		a += W[i];
		int diff = abs((sum - a) - a);
		if (diff < ans) {
			ans = diff;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mod 1000000007

int Max(int x, int y)
{
    return (((y-x)>>(32-1))&(x^y))^y;
}

int Min(int x, int y)
{
    return (((y-x)>>(32-1))&(x^y))^x;
}


int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //Initialize variables while declaring them
    string s;
    cin>>s;
    for(int i=1; i<4; i++)
        if(s[i]==s[i-1])
        {
            cout<<"Bad";
            return 0;
        }
    cout<<"Good";
    return 0;
}

Measured memory_bytes: 256
n,k,*a=map(int,open(0).read().split())
r=range(n)
while(min(a)<n)*k:
 k-=1;b=[0]*n*3
 for i in r:t=a[i];b[max(0,i-t)]+=1;b[i-~t]-=1
 for i in r:b[i+1]+=b[i]
 a=b[:n]
print(*a)

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

int main (void)
{
	char p[100],s[100],s2[200];
	int i,j;
	int result;
	
	for(i = 0 ; i < 100 ; i++)
	{
		p[i] = '\0';
		s[i] = '\0';
	}
	
	scanf("%s",s);
	scanf("%s",p);
	strcpy(s2,s);
	strcat(s2,s);
	
	if(strstr(s2,p) == NULL)
	{
		printf("No\n");
	}
	else
	{
		printf("Yes\n");
	}
	
	return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
int a[200005];
int main(){
	cin>>n;
	rep(i,n){
		cin>>a[i];
	}
	sort(a,a+n);
	P ans = mp(INF+100,-1);
	rep(i,n-1){
		int x = abs(a[i]*2-a[n-1]);
		ans = min(ans,mp(x,a[i]));
	}
	cout<<a[n-1]<<" "<<ans.sc<<endl;
}

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

int main() {

    int N , M ;

    cin >> N >> M;

    vector<int> vec(M) ;

    for ( int i = 0 ; i < M ; i ++){

        cin >> vec[i] ;

    }

    int day = 0 ;

    for ( int i = 0 ; i < M ; i++ ) day += vec[i] ;

    if ( N - day >= 0) {

        cout << N - day << endl ;

    }

    else {cout << "-1" << endl ;

    }

}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
const int MAXN = 1e6 + 10;
inline int read() {
	char c = getchar(); int x = 0, f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * f;
}
int N, M, a[MAXN], b[MAXN], ti[MAXN];
std::vector<int> v;
void solve() {
	int n = v.size();
	int mn = 0, mx = 0, cnt = 0;
	for(int i = 0; i < n; i++) {
		if(!mn || (mn == v[i])) mn = v[i], cnt++;
		else if(!mx || (v[i] == mx)) mx = v[i];
		else {puts("No"); exit(0);}		
	}
	if(mn > mx && mx) std::swap(mn, mx), cnt = n - cnt;
	if(!mx) {
		if((mn == n - 1) || (mn * 2 <= n)) puts("Yes");
		else puts("No");
	} else {
		if((mx == mn + 1) && (2 * (mx - cnt) <= n - cnt) && (mx - cnt > 0)) puts("Yes");
		else puts("No");
	}	
}
main() {
	N = read(); //M = read();
	for(int i = 1; i <= N; i++) {
		a[i] = i, b[i] = read();
		if(!ti[a[i]]) ti[a[i]] = b[i], v.push_back(b[i]);
		else if(ti[a[i]] != b[i]) {puts("NO"); return 0;}
	}
	solve();
}

Measured memory_bytes: 9336
s = list(input())
flag = False
for i in range(len(s)):
    if i%2 == 0:
        if s[i] == "L":
            flag = False
            break
        else:
            flag = True
    elif i%2 == 1:
        if s[i] == "R":
            flag = False
            break
        else:
            flag = True
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
N = int(input())
B = list(map(int, input().split()))

A = [0] * N
A[0] = B[0]
#print(A[0])

for i in range(1,N-1):
  A[i] = min(B[i-1], B[i])
#  print(A[i])

A[N-1] = B[N-2]
#print(A)
print(sum(A))


Measured memory_bytes: 3060
// https://atcoder.jp/contests/abc131/tasks/abc131_a

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
vector<vector<int>> G;
vector<ll> res;
void dfs(int i, int p) {
    for (auto &e : G[i]) {
        if (e == p) {
            continue;
        }
        res[e] += res[i];
        dfs(e, i);
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    vector<vector<ll>> id(26);
    for (int i = 0; i < s.length(); i++) {
        id[s[i] - 'a'].push_back(i);
    }
    ll pos = -1;
    ll res = 0, m = s.length();
    for (int i = 0; i < t.length(); i++) {
        int c = t[i] - 'a';
        if (id[c].empty()) {
            cout << -1 << endl;
            return 0;
        }
        if (pos >= id[c].back()) {
            res += m - pos;
            res += id[c].front();
            pos = id[c].front();
        } else {
            int t = upper_bound(all(id[c]), pos) - id[c].begin();
            res += id[c][t] - pos;
            pos = id[c][t];
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 1736
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
s=0
for i in range(N):
	s+= B[A[i]-1]
	if(A[i]==A[i-1]+1)&(i>0):
		s+=C[A[i-1]-1]
print(s)


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;


#define MAX 1000000000000000000

int main(){
    ll A;
    ll ans = 0;
    ll N;
    ll over = 0;

    cin >> N;
    
    cin >> A;
    ans += A;
    for(ll i = 1; i < N; i++){
        cin >> A;
        if(A == 0){
            cout << 0 << endl;
            return 0;
        }
        if(ans <= MAX / A){
            ans *= A;
        }else{
            over = 1;
        }
    }

    if(over == 1){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
import java.util.*;
public class Main {
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    if(n!=0){
		int[] point = new int[n];
		for(int i=0; i<n; i++) {
		    for(int j=0; j<5; j++){
			point[i] += kbd.nextInt();
		    }
		}

		int max = point[0];
		int min = point[0];
		
		for(int i=0; i<n; i++){
		    if(point[i] > max) max = point[i];
		    if(point[i] < min) min = point[i];
		}

		System.out.println(max+" "+min);
	    }
	}
    }
}

Measured memory_bytes: 12000
#include "bits/stdc++.h"
using namespace std;
#define F first
#define S second
#define show(x) cout<<#x<<" "<<x<<" ";
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define ll long long
#define all(A)  A.begin(),A.end()  
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
const int MSIZE = 3e3+5;
const int MOD = 1e9+7;


int N; 
string S;

ll dp[MSIZE][MSIZE];

int main(){

    FIO
    cin>>N>>S;
    //Bottom Up
    memset(dp,0,sizeof(dp));
    f(g,0,N-1)    dp[N][g] = 1;
    fr(i,N-1,0) f(g,0,N-i) {
        if(i==0 || g==0 ) {
            if(i==0 or S[i-1]=='>')  f(j,1, N-i)    { 
                dp[i][g]+=dp[i+1][N-i-j];  dp[i][g]%=MOD;   
            }
            continue;
        }
        dp[i][g] = dp[i][g-1]+(S[i-1]=='<'?1:-1)*dp[i+1][g-1];
        dp[i][g] = (dp[i][g]+MOD)%MOD;
    }

    cout<<dp[0][0]<<endl;

    return 0;

}
    


Measured memory_bytes: 70784
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			long x = sc.nextLong();
			TreeSet<Long> set = new TreeSet<Long>();

			for (int i = 0; i < n; i++) {
				long tmp = sc.nextLong() - x;
				if (tmp < 0) {
					set.add(-tmp);
				} else if (tmp != 0){
					set.add(tmp);
				}
			}

			long near = set.first();
			long result = set.first();
			int cnt = 1;
			while(1 < result) {
				boolean flg = true;
				for (int i = cnt; i < near; i++) {
					if (near % i == 0) {
						result = near / i;
						cnt = i;
						break;
					}
				}
				if (near <= cnt) {
					System.out.println("1");
					return;
				}
				for (long l : set) {
					if (l % result != 0) {
						flg = false;
						break;
					}
				}
				if (flg) {
					System.out.println(result);
					return;
				}
				cnt++;
			}
			System.out.println("1");
		}
	}
}


Measured memory_bytes: 65976
import sys

# import bisect
from collections import Counter, deque, defaultdict

# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter

# import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    k = int(input())

    run = [0] * 100000
    que = deque()

    for i in range(1, 10):
        que.append(str(i))

    cnt = 0
    while que:
        x = que.popleft()
        cnt += 1
        if cnt == k:
            print(int(x))
            sys.exit()

        xlast = x[-1]
        if xlast == "0":
            for i in ("0", "1"):
                nx = x + i
                que.append(nx)
        elif xlast == "9":
            for i in ("8", "9"):
                nx = x + i
                que.append(nx)
        else:
            for i in range(int(xlast) - 1, int(xlast) + 2):
                nx = x + str(i)
                que.append(nx)


if __name__ == '__main__':
    main()


Measured memory_bytes: 72668