akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
vector<vector<int> > v(1000);
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll q,a,b,c,sum=0;
    cin>>q;
    vector<pair<ll,ll> > ans;
    multiset<ll> mi,ma;
    ll le=0,ri=0;
    while(q--){
    	cin>>a;
    	if(a==1){
    		cin>>b>>c;
    		sum+=c;
    		if(mi.empty()){
    			mi.insert(b);
    			continue;
    		}
    		if(ma.empty()){
    			ll x=*(mi.begin());
    			if(b<x){
    				mi.erase(x);
    				mi.insert(b);
    				ma.insert(x);
    				ri+=x-b;
    			}
    			else{
    				ma.insert(b);
    				ri+=b-x;
    			}
    			continue;
    		}
    		ll x=*(--mi.end()),y=*ma.begin();
    		if(x<=b&&b<=y){
    			if(ma.size()==mi.size()){
    				ll niko=ma.size();
    				ri+=niko*x;
    				le+=niko*x;
    				mi.insert(b);
    				ri-=b*niko;
    				le-=b*niko;
    		    }else{
    		    	ma.insert(b);
    		    	ri+=b-x;
    		    }
    		}else if(b<x){
    			if(ma.size()==mi.size()){
    				mi.insert(b);
    				le+=b-x;
    			}else{
    				ll niko=ma.size();
    				ri+=niko*x;
    				le+=niko*x;
    				mi.erase(mi.lower_bound(x));
    				ri+=x;
    				ma.insert(x);
    				mi.insert(b);
    				le+=b;

    				c=*(--mi.end());
    				niko++;
    				ri-=c*niko;
    				le-=c*niko;
    			}
    		}else{
    			if(ma.size()==mi.size()){
    				ll niko=ma.size();
    				ri+=niko*x;
    				le+=niko*x;
    				ri+=b;
    				ma.insert(b);
    				ri-=y;
    				ma.erase(ma.begin());
    				mi.insert(y);

    				ri-=niko*y;
    				le-=niko*y;
    			}else{
    				ma.insert(b);
    				ri+=b-x;
    			}
    		}
    		
    	}else{
    		ans.push_back({*(--mi.end()),ri-le+sum});
    	}
    }
    for(auto& i:ans){
    	cout << i.first<< " "<<i.second <<endl;
    }
    return 0;
}


Measured memory_bytes: 9728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

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

		int n = Integer.parseInt(br.readLine());

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

		Set<Integer> set = new HashSet<>();

		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(str[i]);
			if (set.contains(a)) {
				System.out.println("NO");
				return;
			} else
				set.add(a);
		}
		System.out.println("YES");
	}
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N; cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    REP(i,N){
        cin >> A[i] >> B[i];
    }

    sort(ALL(A));
    sort(ALL(B));
    if(N%2 == 1){
        int A_median = A[N/2];
        int B_median = B[N/2];
        cout << B_median - A_median + 1 << endl;
    }else{
        int A_median = (A[N/2-1] + A[N/2]);
        int B_median = (B[N/2-1] + B[N/2]);
        cout << B_median - A_median + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4744
/* BISMILLAHIR RAHMANIR RAHIM */
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	vector<int> res;
	for(int i = n; i > 0; ) {
		int j, nxt = -1;
		for(j = i - 1; j >= max(0, i - k); j--) {
			if( s[j] == '1' ) continue;
			nxt = j;
		}
		if( nxt == -1 ) {
			cout << "-1\n";
			exit(0);
		}
		res.push_back(i - nxt);
		i = nxt;
	}
	reverse(res.begin(), res.end());
	for(auto x : res) {
		cout << x << " ";
	}
}

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

// +を入れるか入れないかを分岐させて再帰する関数
void ReFunc(vector<int> vec, int place, long long left, long long right, long long &sum)
{
    // 最後まで終わったら算出する。
    if (place == vec.size() - 1)
    {
        sum += left + right;
    }
    else
    {
        //足し算の場合、今考えている左辺と右辺を足して左辺を作り、次を右辺とする(例：123)の場合、(vec, 1, 1, 2)→(vec, 2, 3, 3)
        ReFunc(vec, place + 1, left + right, vec.at(place + 1), sum);
        //なしの場合、今考えている左辺はそのままにして、右辺を10倍して次の右辺に足して、次の演算を行う (vec, 1, 0, 12)→(vec, 2, 0, 123)
        ReFunc(vec, place + 1, left, right * 10 + vec.at(place + 1), sum);
    }
}



int main()
{
    string S;
    cin >> S;
    vector<int> vec(S.size());
    for (int i = 0; i < S.size(); i++)
    {
        vec.at(i) = S.at(i) - '0';
    }

    long long sum = 0;
    ReFunc(vec, 0, 0, vec.at(0), sum);
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    string s, t;
    cin >> s >> t;
    rep(i, s.size()){
        if(s == t) {
            printf("Yes\n");
            return 0;
        }
        else {
            char temp = s[s.size() - 1];
            s = temp + s;
            s.pop_back();
        }
    }
    printf("No\n");
    return 0;
}

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

int main(){
	int N;
	scanf("%d\n", &N);
	int answer = 0, begins_B = 0, ends_A = 0;
	bool flag = true;
	for (int i = 0; i < N; ++i){
		string s;
		cin >> s;
		for (int j = 0; j < s.size() - 1; ++j){
			if(s[j] == 'A' && s[j + 1] == 'B') answer++;
		}
		if(s[0] == 'B'){
			begins_B++;
			if(s[s.size() - 1] != 'A') flag = false;
		}
		if(s[s.size() - 1] == 'A'){
			ends_A++;
			if(s[0] != 'B') flag = false;
		}
	}
	if(flag && begins_B > 0 && ends_A > 0) answer--; 
	printf("%d\n", answer + (begins_B < ends_A ? begins_B : ends_A));
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define maxn 100005
#define mod 1000000007
int n,a[maxn],deg[maxn],pre[maxn],cnt[maxn],f[maxn],ans=1;
bool vis[maxn];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) { scanf("%d",&a[i]); deg[a[i]]++; }
	for(int i=1;i<=n;i++)
	{
		if(deg[i]>2) { printf("0\n"); return 0; }
		if(deg[i]<2||vis[i]) continue;
		int p=i;
		do
		{
			if(vis[p]) { printf("0\n"); return 0; }
			vis[p]=true; pre[a[p]]=p,p=a[p];
		}while(p!=i);
	}
	for(int i=1;i<=n;i++)
		if(!deg[i])
		{
			int p=i,l1=0,l2=0;
			while(!vis[p]) vis[p]=true,p=a[p],l1++;
			do l2++,p=pre[p]; while(deg[p]!=2);
			if(l1<l2) ans=ans*2%mod;
			else if(l1>l2) { printf("0\n"); return 0; }
		}
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			int p=i,l=0;
			do l++,p=a[p],vis[p]=true; while(p!=i);
			cnt[l]++;
		}
	for(int i=1;i<=n;i++)
	{
		int mul=1;
		if(i!=1&&(i&1)) mul++;
		f[0]=1,f[1]=mul;
		for(int j=2;j<=cnt[i];j++) f[j]=(1ll*f[j-2]*(j-1)%mod*i%mod+1ll*f[j-1]*mul%mod)%mod;
		ans=1ll*ans*f[cnt[i]]%mod;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple


int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	string s; cin>>s;
	int len=s.length();
	map <char,int> mp;
	map <char,int> pp;
	int st=-1,en=-1;
	for(int i=0;i<len;i++)
	{
	    mp[s[i]]++;
	    if(mp[s[i]]==1) pp[s[i]]=i;
	    else
	    {
	        if( i-pp[s[i]] <= 2 )
	        {    
	            st=pp[s[i]]+1; en=i+1;
	            break;
	        }
	        pp[s[i]]=i;
	    }
	}
	cout<<st<<' '<<en;
	
	
	return 0;
}


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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++) {
    cin >> a[i];
  }
  //先頭を正にする
  ll sum1=0,ans1=0;
  for(int i=0;i<n;i++) {
    sum1 += a[i];

    if(i%2==0) {
      if(sum1<=0) {
        ans1 += -sum1+1;
        sum1 = 1;
      }
    }else {
      if(sum1>=0) {
        ans1 += sum1+1;
        sum1 = -1;
      }
    }
  }
  //先頭を負にする
  ll sum2=0,ans2=0;
  for(int i=0;i<n;i++) {
    sum2 += a[i];

    if(i%2==0) {
      if(sum2>=0) {
        ans2 += sum2+1;
        sum2 = -1;
      }
    }else {
      if(sum2<=0) {
        ans2 += -sum2+1;
        sum2 = 1;
      }
    }
  }
  cout << min(ans1,ans2) << endl;
}

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

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200)cout << s << endl;
	else cout << "red" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repll(i, a, b) for(ll i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;

vector<vector<char> > A(50,vector<char>(50));
vector<vector<char> > B(50,vector<char>(50));

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false); 
    int N, M;
    bool flag,res=false;
    cin >> N >> M;

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

    rep(i,0,N){
        rep(j,0,N){
            if(i+M>N || j+M>N) continue;
            flag = true; 
            rep(k,0,M){
                rep(l,0,M){
                    if(A[i+k][j+l] != B[k][l]) flag=false;
                }
            }
            if(flag) res=true;
        }
    }
    if(res) Yes;
    else No;
}

Measured memory_bytes: 256
use proconio::input;
use superslice::*;

fn main() {
    input! {
        n: usize,
        mut a: [usize; n],
        b: [usize; n],
        mut c: [usize; n],
    }

    a.sort();
    c.sort();

    let mut ans = 0;
    for nb in &b {
        let smaller = a.lower_bound(nb);
        let bigger = c.upper_bound(nb);
        //println!("smaller {} bigger {}", smaller, bigger);
        ans += smaller * (n-bigger);
    }

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


Measured memory_bytes: 7760
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define long long long // for codeforces

int main(){
  long a = 1;
  long n;
  cin>>n;

  while((a+1)*(a+1) <= n) a++;

  cout << a*a << endl; 
  return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = 26
D = inp()
c = inpl()
s = [inpl() for _ in range(D)]
last = [0] * n
res = [-1] * D
for d in range(D):
    ans = -1
    mx = -INF
    for i in range(n):
        now = s[d][i]
        for j in range(n):
            if i == j: continue
            now -= s[d][j] * (last[j]+1)
        if now > mx:
            mx = now
            ans = i
    res[d] = ans+1
    for j in range(n):
        last[j] += 1
        if j == ans: last[j] = 0
for x in res:
    print(x)

Measured memory_bytes: 79612
import sys
input = sys.stdin.readline

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

def main():
    mod=10**9+7
    N,M=MI()
    ans=(N*(N-1))//2+(M*(M-1))//2
    print(ans)
main()


Measured memory_bytes: 38256
#include<iostream>
int main()
{
	int data[10000];
	int number;
	for(int i=0;;i++)
	{
		std::cin>>data[i];
		if(data[i]==0)
		{
			number=i;
			break;
		}
	}
	for(int i=0;i<number;i++)
	{
		std::cout<<"Case "<<i+1<<": "<<data[i]<<std::endl;
	}
	return 0;
}


Measured memory_bytes: 3116
#include<stdio.h>
int main()
{
    int N, A, B;
    scanf("%d%d%d",&N, &A, &B);
    if(N*A<=B)
    {
        printf("%d",N*A);
    }
    else if(B<=N*A)
    {
        printf("%d",B);
    }
    return 0;
}


Measured memory_bytes: 128
import java.io.*;

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

        String input = br.readLine();
        int notes = Integer.parseInt(input.substring(0,input.indexOf(" ")));
        input = input.substring(input.indexOf(" ") + 1);
        int money_l = Integer.parseInt(input);
        int money = money_l/1000;
        String result = "-1 -1 -1";


        if(notes<=money && money<=notes*10){//too much notes or too much mooney
            OUTSIDE:for(int x = 0; x<=notes; x++){
                if(x*10>money){break;}
                if(money <= x*10 + (notes-x)*5){
                    for(int y = 0; y<=notes-x; y++){
                        if(x*10 + y*5 > money){break;}
                        if(x*10 + y*5 + (notes-x-y) == money){
                            result = String.valueOf(x) + " " + String.valueOf(y) + " " + String.valueOf(notes-x-y);
                            break OUTSIDE;
                        }
                    }
                }
            }
        }
    System.out.println(result);
    }
}

Measured memory_bytes: 21332
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: chars,
    }

    let mut sum = 0isize;
    for i in n {
        sum += (i as u32 - '0' as u32) as isize;
    }

    if sum % 9 == 0 {
        print!("Yes");
    } else {
        print!("No");
    }
}

Measured memory_bytes: 3160
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <tuple>
#include <vector>

// lib/quo.hpp
#ifndef QUO_H
#define QUO_H

/*
a == tools:quo(a, b) * b + tools::mod(a, b)
0 <= tools::mod(a, b) < std::abs(b)
*/

namespace tools {
  template <typename T>
  constexpr T quo(const T lhs, const T rhs) {
    return lhs > 0 ? lhs / rhs : rhs > 0 ? -((-lhs - 1 + rhs) / rhs) : (-lhs - 1 + -rhs) / -rhs;
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// lib/extgcd.hpp
#ifndef EXTGCD_HPP
#define EXTGCD_HPP


/*
usage:

std::tuple<int, int, int> result = tools::extgcd(4, 5);
int gcd = std::get<0>(result);
int x0 = std::get<1>(result);
int y0 = std::get<2>(result);
*/

namespace tools {
  template <typename T>
  std::tuple<T, T, T> extgcd(T prev_r, T r) {
    T prev_s = 1;
    T prev_t = 0;
    T s = 0;
    T t = 1;
    while (r != 0) {
      const T q = quo(prev_r, r);
      const T next_r = prev_r - q * r;
      prev_r = r;
      r = next_r;
      const T next_s = prev_s - q * s;
      prev_s = s;
      s = next_s;
      const T next_t = prev_t - q * t;
      prev_t = t;
      t = next_t;
    }
    return std::make_tuple(std::abs(prev_r), prev_s, prev_t);
  }
}

#endif

// main.cpp

int main() {
  i64 A, B;
  std::cin >> A >> B;
  std::cout << A * B / std::get<0>(tools::extgcd(A, B)) << std::endl;
  return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int calc(int *a,int n,int k,char *dp){
  if(n==1){
    if(a[0]>=k) return 0;
    for(int i=k-1;i>=k-a[0];i--) if(dp[i]) return 0;
    return 1;
  }
  int m=n/2;
  char *save=(char *)calloc(k,sizeof(char));
  memcpy(save,dp,k);
  int i,j;
  for(i=m;i<n;i++){
    if(a[i]>=k) continue;
    for(j=k-1;j>=a[i];j--) dp[j]|=dp[j-a[i]];
  }
  int cnt=calc(a,m,k,dp);
  memcpy(dp,save,k);
  free(save);
  for(i=0;i<m;i++){
    if(a[i]>=k) continue;
    for(j=k-1;j>=a[i];j--) dp[j]|=dp[j-a[i]];
  }
  cnt+=calc(a+m,n-m,k,dp);
  return cnt;
}

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int *a=(int *)calloc(n,sizeof(int));
  for(int i=0;i<n;i++) scanf("%d",a+i);
  char *dp=(char *)calloc(k,sizeof(char));
  dp[0]=1;
  int ans=calc(a,n,k,dp);
  printf("%d\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
$line = trim(fgets(STDIN));
$arr = explode(" ", $line);

$sum = array_sum($arr);
$S = ((1+$n)*$n)/2;
$k = $sum/$S;

$flag = 0;
if ($sum%$S != 0) {
    $flag = 1;
} else {
    for ($i = 0; $i < $n; $i++) {
        $d = $arr[($i+1)%$n]-$arr[$i]-$k;
        $y = $d%$n;
        if ($y != 0 || $d > 0) {
            $flag = 1;
            break;
        }
    }
}
if ($flag) {
    echo "NO";
} else {
    echo "YES";
}

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

// "1" = "Red"
int ask(vector<int>& A){
    cout << "?";
    for(int a : A) cout << " " << a+1;
    cout << endl;
    string S;
    cin >> S;
    if(S == "-1") exit(1);
    return (S[0] == 'R');
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N), ans(2*N, -1);
    for(int i=0; i<N; i++) A[i] = i;
    int col = ask(A);

    int ok = N-1, ng = -1;
    while(ok-ng>1){
        int mid = (ok+ng)/2;
        for(int i=0; i<N; i++) A[i] = (i<=mid ? i+N : i);
        int col2 = ask(A);
        (col != col2 ? ok : ng) = mid;
    }
    vector<int> A0, A1;
    for(int i=0; i<N; i++){
        if(i == ok) continue;
        if(i<ok){
            A0.push_back(i+N);
            A1.push_back(i);
        }else{
            A0.push_back(i);
            A1.push_back(i+N);
        }
    }
    ans[ok] = col;
    ans[ok+N] = 1-col;
    for(int a : A0){
        A1.push_back(a);
        int c = ask(A1);
        ans[a] = c;
        A1.pop_back();
    }
    for(int a : A1){
        A0.push_back(a);
        int c = ask(A0);
        ans[a] = c;
        A0.pop_back();
    }

    cout << "! ";
    string BR = "BR";
    for(int i=0; i<2*N; i++) cout << BR[ans[i]];
    cout << endl;
    return 0;
}


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

#define MAX 1000000
#define MIN -1000000

int main()
{
	int a,b,m,M;
	cin>>a>>b;
	
	m=b-a+1;
	M=b+a-1;
	
	if(M>MAX)
		M=MAX;
	
	if(m<MIN)
		m=MIN;
	
	while(m<=M)
	{
		cout<<m<<" ";
		m++;
	}
		
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,j,n,data[10000+1],suu[10000+1];
	scanf("%d",&n);
	while(n!=0) {
		for(i=0;i<10;i++) {
			suu[i]=0;
		}
		for(j=0;j<n;j++) {
			scanf("%d",&data[j]);
		}
		for(i=0;i<10;i++) {
			for(j=0;j<n;j++) {
				if(data[j]==i) {
					suu[i]++;
				}
			}
		}
		for(i=0;i<10;i++) {
			if(suu[i]!=0) {
				for(j=0;j<suu[i];j++) {
					printf("*");
				}
				printf("\n");
			}
			else if(suu[i]==0) {
				printf("-\n");
			}
		}
	scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 616
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V
 
getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]
 
type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)
 
mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
fi = fromInteger
fig = fromIntegral
rf = realToFrac
 
(.<.) f g -- combination
    | f < g = 0 
    | g < 1 || f < 1 = 1
    | True = foldr1 (*) (take g [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)
 
unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)
 
mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a
 
countIf f = length . filter f
 
-- 
--
--

main = do
  [t, a] <- getLine >> getDs
  ns <- zip [0..] <$> getDs
  putStrLn . show . fst . head . sortOn snd $ map (succ *** \x -> abs (a - t + 0.006 * x)) ns


Measured memory_bytes: 1404
package main

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

)

func int2str(nums []int) []string{
	var tmp []string

	for i:= 0; i<len(nums);i++{
		tmp = append(tmp,strconv.Itoa(nums[i]))
	}
	return tmp
}

func  main()  {
	var N int
	var tmp []string
	var nums []int

	fmt.Scan(&N)

	var sc = bufio.NewScanner(os.Stdin)
	sc.Scan()
	tmp = strings.Split(sc.Text()," ")

	for i := 0; i < N ; i++{
		n,_:= strconv.Atoi(tmp[i])
		nums = append(nums,n)
	}
	fmt.Println(strings.Join(int2str(nums)," "))

	for i := 1; i< len(nums); i++ {
		v := nums[i]
		j := i-1
		for  j>= 0 && nums[j] > v{
			nums[j+1] = nums[j]
			j--
		}
		nums[j+1] = v
		fmt.Println(strings.Join(int2str(nums)," "))
	}
	
}


Measured memory_bytes: 1692
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end);

#define CIN_FILE "input.txt"
#define COUT_FILE "output.txt"

using namespace std;

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

typedef long long ll;

int n,a,b,p[110];
vector<int> p1,p2,p3;

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)cin>>p[i];
	
	sort(p,p+n);
	
	for(int i=0;i<n;i++)
	{
		if(p[i]<=a)p1.pb(p[i]);
		else if((p[i]>=(a-1))&&(p[i]<=b))p2.pb(p[i]);
		else p3.pb(p[i]);
	}
	
	cout<<min(p1.size(),min(p2.size(),p3.size()));
	
	//printf("Time used = %.4f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>

using namespace std;

int main()
{
    int n;
    char str[8];
    scanf("%s", str);
    switch(str[0]){
        case 'S':
            if(str[1]=='A') n=1;
            else n = 7;
            break;
        case 'M':
            n=6; 
            break;
        case 'T':
            if(str[1]=='U') n=5;
            else n=3;
            break;
        case 'W':
            n=4;
            break;
        case 'F':
            n=2;
            break;
        default:
            break;


    }

    cout << n << endl;
    
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void saiki( int n ){
	int a = n % 4;
	if( n == 0 ) return;
	saiki( n / 4 );
	cout << a;
}

int main(int argc, char const* argv[])
{
	int n;

	while( cin >> n && n != -1 ){
		if( n == 0 ) cout << 0;
		else saiki( n );
		cout << endl;
	}
	return 0;
}

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

int main() {
  int A,B,C,D;
  cin >>A>>B>>C>>D;
  if((A+B)<(C+D)){
    cout<<"Right"<<endl;
  }
  else if((A+B)==(C+D)){
    cout<<"Balanced"<<endl;
  }
  else {
    cout<<"Left"<<endl;
  }
}

Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll a, b, ans = 0;
  scanf("%lld%lld", &a, &b);
  if (a >= b)
  {
    ans += a;
    a--;
  }
  else
  {
    ans += b;
    b--;
  }
  printf("%lld\n", ans + MAX(a, b));
  return 0;
}


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

using namespace std;
using ll = long long;

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

int main() {
  int r;
  cin >> r;
  printf("%.15f\n", M_PI * 2 * r);
  return 0;
}


Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	string s; cin >> s;


	FOR_LT(i, 0, 3) {
		if (s[i] == '7') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A;
  for(int i=0; i<N; i++){
    int in;
    cin >> in;
    A.push_back(in);
  }
  int ret = 0;
  bool able = true;
  while(able){
    for(int i=0; i<N; i++){
      if(A[i] % 2 == 0){
        A[i] /= 2;
      } else {
        able = false;
        break;
      }
    }
    if(able){
      ret++;
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/perl
my ($N) = map { $_ - 0 } split(/\s+/,<STDIN>);
my @A = map { $_ - 0 } split(/\s+/,<STDIN>);

my %aa = ();
for(my $i=0;$i<$N;$i++){
  $aa{$A[$i]} ++;
}

my $tot = 0;
foreach my $k ( keys %aa ){
  my $n = $aa{$k};
  if( $n >= 2 ){
    $tot += ( ( $n * ($n - 1) ) / 2 );
  }
}

for(my $i=0;$i<$N;$i++){
  my $n1 = $aa{$A[$i]};
  my $n2 = $n1 - 1;
  
  my $v1 = ( $n1 >= 2 ? ( ( $n1 * ($n1 - 1) ) / 2 ) : 0 );
  my $v2 = ( $n2 >= 2 ? ( ( $n2 * ($n2 - 1) ) / 2 ) : 0 );
  my $v = $tot - $v1 + $v2;
  print "$v\n";
}




Measured memory_bytes: 48684
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2,147,483,647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cint(n) int n;cin>>n;
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
    char t;cin>>t;
    if(isupper(t)){
        cout<<"A"<<endl;
    }else{
        cout<<"a"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    ll n;
    cin >> n;
    vector<ll> l, r;
    rep(i, n){
        ll a;
        cin >> a;
        if(i%2==0) r.push_back(a);
        else l.push_back(a); 
    }
    reverse(l.begin(), l.end());
    copy(r.begin(), r.end(), back_inserter(l));
    if(n%2 == 1) reverse(l.begin(), l.end());
    
    rep(i, l.size()){
        if(0 < i) cout << " ";
        cout << l[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mn=2e6+10;
const ll mod=998244353;
ll inv(ll x){
    ll ans=1;
    for(ll i=mod-2;i;i>>=1,x=x*x%mod)if(i&1)ans=ans*x%mod;
    return ans;
}
ll fact[mn];
ll ch(ll n,ll k){
    if(k<0||k>n)return 0;
    return fact[n]*inv(fact[k])%mod*inv(fact[n-k])%mod;
}
ll hail(ll k,ll n,ll m){
    m++;
    return ch(k+n-1,n-1)-n*ch(k+n-1-m,n-1)%mod;
}
int main()
{
    ll n,m,i;
    fact[0]=1;
    for(i=1;i<mn;i++)fact[i]=fact[i-1]*i%mod;
    scanf("%lld%lld",&n,&m);
    ll ans=0;
    for(i=m%2;i<=min(n,m);i+=2){
        ans+=ch(n,i)*hail((3*m-i)/2,n,m-1)+(hail((3*m-i)/2,n,m)-hail((3*m-i)/2,n,m-1))*ch(n-1,i);
        ans%=mod;
    }
    if(ans<0)ans+=mod;
    printf("%lld",ans);
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  vector<vector<char>> a(n, vector<char>(n));
  for (ll i = 0; i < n; ++i) {
    for (ll j = 0; j < n; ++j) {
      cin >> a[i][j];
    }
  }

  vector<vector<char>> b(m, vector<char>(m));
  for (ll i = 0; i < m; ++i) {
    for (ll j = 0; j < m; ++j) {
      cin >> b[i][j];
    }
  }

  for (ll i = 0; i <= n-m; ++i) {
    for (ll j = 0; j <= n-m; ++j) {
      bool ok = true;
      for (ll y = 0; y < m; ++y) {
        for (ll x = 0; x < m; ++x) {
          if (a[y+i][x+j] != b[y][x]) {
            ok = false;
            break;
          }
        }
        if (!ok) break;
      }
      if (ok) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string S;
int sums,sumt;
int main(){
    cin>>S;
    for(int i=0;i<S.size();i++){
        if(S[i] == 'S') sums++;
        if((sums)&&(S[i]=='T')){
            sums--;
            sumt+=2;
        }
    }
    cout<<S.size()-sumt<<"\n";
    return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);
    int k = Integer.parseInt(sl[1]);

    int a[] = new int[n];

    for(int i = 0; i < n; i++)
    {
      s = r.readLine();
      a[i] = Integer.parseInt(s);
    }

    Arrays.sort(a);

    int min = 1000000001;
    for(int i = 0; i <= n - k; i++)
    {
      min = Math.min(min, a[i + k - 1] - a[i]);
    }

    System.out.println(min);

  }

}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, M;
    cin >> N >> M;

    vector<vector<ll>> s(M);
    rep (i, M) {
        ll k;
        cin >> k;
        rep (j, k) {
            ll tmp;
            cin >> tmp;
            tmp--;
            s[i].push_back(tmp);
        }
    }

    vector<ll> p(M);
    rep (i, M) {
        cin >> p[i];
    }

    ll ans = 0;
    for (ll bit = 0; bit < (1<<N); bit++) {
        bool ok = true;
        rep (i, M) {
            ll cnt = 0;
            for (auto j : s[i]) {
                if (bit & (1<<j)) {
                    cnt++;
                }
            }
            
            if (cnt%2 != p[i]) {
                ok = false;
                break;
            }
        }

        if (ok) {
            ans++;
        }
    }

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

Measured memory_bytes: 256
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        l: chars,
    }

    let n = l.len();

    // dp[i][j] iは上位桁から見た固定する桁数、jが0なら=L、1なら<L
    let mut dp = vec![vec![0; 2]; n];

    dp[0][0] = 2; // (1,0),(0,1)
    dp[0][1] = 1; // (0,0)

    for i in 1..n {
        if l[i] == '1' {
            dp[i][0] = dp[i - 1][0] * 2; // (1,0),(0,1)
            dp[i][1] = dp[i - 1][1] * 3 + dp[i - 1][0]; // 妥協した方から(0,1),(1,0),(0,0)、妥協してない方から(0,0)
        } else {
            // l[i] == 0
            dp[i][0] = dp[i - 1][0];
            dp[i][1] = dp[i - 1][1] * 3; // (0,1),(1,0),(0,0)の3つが考えられる
        }

        dp[i][0] %= LARGE_PRIME;
        dp[i][1] %= LARGE_PRIME;
    }

    let mut ans = (dp[n - 1][0] + dp[n - 1][1]) % LARGE_PRIME;

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

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int t[5];
	int ans = 0;
	int m = 0;
	for (int i = 0;i < 5;i++){
		cin >> t[i];
		ans += ((t[i]-1)/10+1)*10;
		if(t[i]%10) m = max(10-t[i]%10,m);
	}

	cout << ans-m << endl;

	return 0;

}


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

using namespace std;

int main(){
  
  char c_a,c_b,c_c,c_d;
  
  cin >> c_a >> c_b >> c_c >> c_d;
  
  int a, b, c, d;
  
  a = c_a - '0';
  b = c_b - '0';
  c = c_c - '0';
  d = c_d - '0';
  
  if(a + b + c + d == 7){
    cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
  }
  else if(a + b + c - d == 7){
    cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
  }
  else if(a + b - c + d == 7){
    cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
  }
  else if(a + b - c - d == 7){
    cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
  }
  else if(a - b + c + d == 7){
    cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
  }
  else if(a - b + c - d == 7){
    cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
  }
  else if(a - b - c + d == 7){
    cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
  }
  else if(a - b - c - d == 7){
    cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
  }
  
  return 0;
}

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

int main() {
  int k,a,b;
  cin>>k>>a>>b;
  bool ans=false;
  for(int i=a;i<b+1;i++){
    if(i%k==0)ans=true;
  }
  if(ans)cout<<"OK"<<endl;
  else cout<<"NG"<<endl;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
int top, S[1000];

void push(int x) {
	S[++top] = x;
}
int pop() {
	top--;
	return S[top+1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];
	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		} else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		} else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		} else {
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first



typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n,m;
    cin >>n;
  	int a,b,c,d;
  	a = n%10;n/=10;
    b = n%10;n/=10;
    c = n%10;n/=10;
    d = n%10;
  
  	if((a==b || c==d )&& b==c){
    	flag = true;
    }
  
    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    if(flag)cout << "Yes" <<endl;
    else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
import heapq
H, W = map(int, input().split())
edges = [[] for _ in range(10)]
for i in range(10):
    e_list = list(map(int, input().split()))
    for j in range(10):
        if j == i:
            continue
        edges[i].append([j, e_list[j]])
A = []
for i in range(H):
    A.append(list(map(int, input().split())))

def dijkstra(edges, num_v, start):
    dist = [float('inf')] * num_v
    dist[start] = 0
    q = []
    heapq.heappush(q, [0, start])

    while len(q) > 0:
        _, u = heapq.heappop(q)
        for edge in edges[u]:
            if dist[edge[0]] > dist[u] + edge[1]:
                dist[edge[0]] = dist[u] + edge[1]
                heapq.heappush(q, [dist[u] + edge[1], edge[0]])
    return dist
ans = 0
root_list = [0] * 10
for i in range(10):
    if i == 1:
        continue
    root_list[i] = dijkstra(edges, 10, i)[1]
for a_line in A:
    for a in a_line:
        if a == -1 or a == 1:
            continue
        ans += root_list[a]

print(ans)

Measured memory_bytes: 3572
#include "bits/stdc++.h"

using namespace std;

const int maxn = 2e6 + 5;
const int MOD = 1e9 + 7;

struct mi {
      long long v;
      explicit operator long long() const { return v; }
      mi() { v = 0; }
      mi(long long _v) { v = (-MOD < _v && _v < MOD) ? _v : _v % MOD; if (v < 0) { v += MOD; } }

      friend bool operator == (const mi& a, const mi& b) { return a.v == b.v; }
      friend bool operator != (const mi& a, const mi& b) { return !(a == b); }
      friend bool operator < (const mi& a, const mi& b) { return a.v < b.v; }

      mi& operator += (const mi& m) { if ((v += m.v) >= MOD) { v -= MOD; } return *this; }
      mi& operator -= (const mi& m) { if ((v -= m.v) < 0) { v += MOD; } return *this; }
      mi& operator *= (const mi& m) { v = v * m.v % MOD; return *this; }
      mi& operator /= (const mi& m) { return (*this) *= inv(m); }

      friend mi pow(mi a, long long p) { mi ans = 1; assert(p >= 0); for (; p; p /= 2, a *= a) { if (p & 1) { ans *= a; } } return ans; }
      friend mi inv(const mi& a)       { assert(a.v != 0); return pow(a, MOD - 2); }

      mi operator - () const { return mi(-v); }
      mi& operator ++ () { return *this += 1; }
      mi& operator -- () { return *this -= 1; }
      mi operator ++ (int) { mi temp; temp.v = v++; return temp; }
      mi operator -- (int) { mi temp; temp.v = v--; return temp; }

      friend mi operator + (mi a, const mi& b) { return a += b; }
      friend mi operator - (mi a, const mi& b) { return a -= b; }
      friend mi operator * (mi a, const mi& b) { return a *= b; }
      friend mi operator / (mi a, const mi& b) { return a /= b; }

      friend ostream& operator << (ostream& os, const mi& m) { os << m.v; return os; }
      friend istream& operator >> (istream& is, mi& m) { long long x; is >> x; m.v = x; return is; }
};

mi fact[maxn];
mi ifact[maxn];

void preCalc() {
	fact[0] = 1;
	ifact[0] = 1;
	for (int i = 1; i < maxn; i++) {
		fact[i] = i * fact[i - 1];
		ifact[i] = 1 / fact[i];
	}
}

mi nCr(int n, int r) {
	if (n < 0 or r < 0 or n < r) {
		return 0;
	}
	return fact[n] * ifact[r] * ifact[n - r];
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	
	preCalc();
	
	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	mi ans = 0;
	for (int c = c1; c <= c2; c++) {
		mi add = 0;
		if (c + r2 >= c) {
			mi ncr = nCr(c + r2 + 1, c + 1);
			ncr = ncr - (c - 1);
			add = ncr;
		}
		if (c + r1 > c) {
			mi ncr = nCr(c + r1 + 1 - 1, c + 1);
			ncr = ncr - (c - 1);
			add -= ncr;
		}
		ans += add;
	}
	cout << ans << endl;
}

Measured memory_bytes: 34864
#include<stdio.h>
int main(){
  int n,y,a=0,b=0,c=0,sum;
  scanf("%d%d",&n,&y);
  y/=1000;
  if(y<n){
    a=-1; b=-1; c=-1;
  }else if(y==n) c=y;
  else{
    c=y;
    if((c-n)%9==0 && ((c-n)/9)*10<=c){
      a=(c-n)/9; c-=a*10;
    }
    else if((c-n)%4==0 && ((c-n)/4)*5<=c){
      b=(c-n)/4; c-=b*5;
    }
    else{
      for(a=0;a<=n;a++)
        for(b=0;b<=n-a;b++){
          c=n-a-b;
          if(a*10+b*5+c==y){
            printf("%d %d %d\n",a,b,c);
            return 0;
          }
        }
      puts("-1 -1 -1");
      return 0;
    }
  }
  printf("%d %d %d\n",a,b,c);
  return 0;
}



Measured memory_bytes: 128