akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    string a, b;
    cin >> a >> b;
    int n = a.size(), m = b.size();
    if (n == m) {
        if (a > b) cout << "GREATER\n";
        else if (a < b) cout << "LESS\n";
        else cout << "EQUAL\n";
    } else if (n > m) cout << "GREATER\n";
    else if (n < m) cout << "LESS\n";
}


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

int main() {
  int n;
  cin>>n;
  vector<int> h(n);

  for (size_t i = 0; i < n; i++) {
    cin>>h[i];
  }
  
  int max = 0, count = 0;
  
  for (size_t i = 0; i < n; i++) {
    if(h[i]>=max){
      max = h[i];
      count++;
    }
  }

  cout<<count<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}


	public void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<Integer, Integer> m = new HashMap<Integer, Integer>();
		List<Integer> a = new ArrayList<>();
		for(int i=0; i<n; i++) {
			int v = sc.nextInt();
			m.put(v, m.containsKey(v) ? m.get(v)+1 : 1);
			a.add(v);
		}
		Collections.sort(a);
		a = a.stream().distinct().collect(Collectors.toList());

		long ans = 0;
		for(int i=0; i<a.size(); i++) {
			long tmp = m.get(a.get(i));
			if(i>0 && a.get(i)-a.get(i-1)<=1) {
				tmp += m.get(a.get(i-1));
			}
			if(i<a.size()-1 && a.get(i+1)-a.get(i)<=1) {
				tmp += m.get(a.get(i+1));
			}
			ans = Math.max(ans, tmp);
		}
		System.out.println(ans);
		sc.close();
	}





}


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

using namespace std;
#define FOR(i,a,b) for(long long i=(a);i<(b);++i)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()


#define MOD (long long)(1e9 + 7)

long long modPow(long long x, long long n){
  if(n == 0) return 1;
  if(n % 2 == 0) {
    long long sqrtX = modPow(x,n/2);
    return sqrtX * sqrtX % MOD ;
  }else{
    return x * modPow(x,n-1) % MOD;
  }
}

long long kaizyou(long long x){
  long long res = 1;
  for(int i = 1; i <= x; i++){
    res = (res * i) % MOD;
  }
  return res;
}
// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	if (k == 0) return 1;
	return n * COM(n - 1, k - 1) / k;
}


int main(){
  long long N,A,B;
  //------input------
  cin >> N >> A >> B;
  vector<long long> v(N);
  rep(i,N) cin >> v[i];
  //------sort------
  sort(all(v),greater<long long>());

  //select A time
  double avg = 0;
  long long pattern = 0;
  rep(i,A){
    avg += v[i];
    if(v[A-1] == v[i]) pattern++;
  }
  printf("%lf\n",avg/(double)A);

  bool sameNumFlag = 0;
  if(A == pattern) sameNumFlag = true;

  long long pattern2 = 0;
  FOR(i,A,v.size()){
    if(v[i] == v[A-1]) pattern2++;
    else break;
  }

  long long ans = 0;
  if(sameNumFlag){
    FOR(i,pattern,min(B,pattern2 + pattern) + 1){
      ans += COM(pattern2 + pattern, i );
      //cout << ans << endl;
    }
    //cout << "pass1" << endl;
  }else{
    ans = COM(pattern+pattern2,pattern);
    //cout << pattern << ' ' << pattern2 << endl;;
  }
  cout << ans << endl;
  return 0;
}


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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */

  NodePointer cur = nil->next;
  while(cur != nil && cur->key != key)
    cur = cur->next;
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  if(t == nil)return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  deleteNode(nil->prev);
}

void delete(int key){
  /* your code */
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  /* 

   your code 

  */
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}

Measured memory_bytes: 31784
from itertools import product

H, W, K = map(int, input().split(' '))
C = [list(input()) for _ in range(H)]
ans = 0
for row_bit in product(range(2), repeat=H):
    for col_bit in product(range(2), repeat=W):
        cnt = 0
        for row in range(H):
            for col in range(W):
                if C[row][col] == '#' and (row_bit[row] == 0 and col_bit[col] == 0):
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Measured memory_bytes: 9076
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let mut n: u64 = sc.cin();
    let a: u64 = sc.cin();
    let b: u64 = sc.cin();

    let k = n / (a + b);
    let mut ans = k * a;
    n -= k * (a + b);
    ans += min!(a, n);
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
/*
ABHIJEET BISWAS
CSE (2017-2021)
MNNIT ALLAHBAD
*/

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e15
#define ll long long
#define ld long double
#define int ll
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define MAX 1000009
#define pb push_back
#define mp map<int,int>
#define F first
#define S second
#define popi __builtin_popcount
#define popll __builtin_popcountll
#define grp vector<int> graph[MAX];
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

//////////////////////TEMPLATE ENDS///////////////////////////////////////////////////////////////////////
ll power(ll,ll);
ll mpower(ll,ll);
//////////////////////////////////////////////////////////////////////////////////////////////////////////


int32_t main() {
	fastIO
	


	int n;
	cin>>n;
	multiset<double> s;
	
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		s.insert(t);
	}

	for(int i=0;i<n-1;i++)
	{
		double x = *s.begin();
		s.erase(s.begin());
		double y = *s.begin();
		s.erase(s.begin());
		s.insert((x+y)/2);
	}
	cout << fixed<<setprecision(9);
	cout<<*s.begin()<<endl;;
	return 0;
}







/*_________________________________________________Utility Functions HERE_______________________________*/

ll power(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b%2==1)
		res=res*a;
		a=a*a;
		b=b/2;
	}
	return res;
}
ll mpower(ll a ,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return res;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll D, T, S;
    cin >> D >> T >> S;
    if(S * T >= D) {
        output("Yes");
    }
    else {
        output("No");
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3640
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N, M = map(int, input().split())

    dp = [10 ** 9] * pow(2,N)
    dp[0] = 0

    for j in range(M):
        a, b = map(int, input().split())
        c = sum([pow(2, int(i) - 1) for i in input().split()])
        for i in range(pow(2,N)):
            dp[i | c] = min(dp[i | c], dp[i] + a)

    print(dp[-1] if dp[-1] !=10**9 else -1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 74196
n,k=map(int,input().split())
mati=list(map(int,input().split()))
count=0
i=mati[0]
matidic={}
frag=1
while frag:
    count+=1

    if i in matidic:
        frag=0
        bef=matidic[i]
        roop=count-bef

    else:
        matidic[i]=count
    i = mati[i - 1]

#print(roop,bef,matidic)
#print(k%roop)
if bef<k:
    ans=[i for i,j in matidic.items() if j==(k-bef)%roop+bef]
else:
    ans=[i for i,j in matidic.items() if j==k]
print(ans[0])



Measured memory_bytes: 111744
from decimal import *
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########
def main(a,b):
    a = int(a)
    b = Decimal(b)
    print(int(a*b))

def resolve():
    a,b = input().split()
    main(a,b)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 10080
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)

using namespace std;

inline void inp( int &n ) { 
	n=0;    int ch=getcx();int sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

inline void inp1( LL &n ) { 
	n=0;    LL ch=getcx();LL sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

LL get_ap_sum(LL st, LL nt, LL d) {
	return nt * (2*st + (nt-1)*d) / 2;
}

int main() {
	
	LL n;
	cin>>n;
	
	LL total = get_ap_sum(1, n, 1);
	LL minus = get_ap_sum(3, n/3, 3) + get_ap_sum(5, n/5, 5) - get_ap_sum(15, n/15, 15);
	cout<<total-minus<<endl;

    return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nuintptr)
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const int MAX= 4e5+6;
const ll inf =1e18;
 
 


int main(){
	fastio;
	ll k,n,m,q,a,b,c,xans=0;
	string s;
	cin>>s;
	if(s=="ABC") cout<<"ARC\n";
	else cout<<"ABC\n";
	
	
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e17;
#define int long long


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b; cin >> a >> b;
	if (a <= 9 && b <= 9)cout << a * b << endl;
	else cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,K;
    string S;
    cin >>N>>K>>S;
    if(N==1){
        cout<<1<<endl;
        return 0;
    }
    vector<ll> P;
    ll cnt=0;
    char now=S[0];
    rep(i,N){
        if(S[i] ==  now){
            cnt++;
            if(i==N-1){
                P.pb(cnt);
            }
        }else{
            P.pb(cnt);
            cnt = 1;
        }
        now = S[i];
    }
    
    ll ans=0;

    if(S[0] == '0'){
        P.insert(P.begin(),0);
    }
    if(S[N-1] == '0'){
        P.pb(0);
    }
    
   
 
        rep(i,K*2+1){
            if(i>= P.size()){
                cout<<ans<<endl;
                return 0;
            }
            ans+=P[i];
        }
        ll tmp = ans;
        ll k=0;
        while(1){
            if(2*k+2*K+2>= P.size()){
                cout<<ans<<endl;
                return 0;
            }
            tmp+= -P[2*k]-P[2*k+1]+P[2*k+2*K+1]+P[2*k+2*K+2];
            chmax(ans,tmp);
            k++;
        }
    

    
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 4468
#include<stdio.h>
#include<stdlib.h>

int main(void){
	int T,E;
	double tmp,ans;
	int *c,*cc;
	long long csum_m,csum_p;
	long long Q_m,Q_p,Qtmp;
	int i;
	
	scanf("%d%d",&T,&E);
	cc=(int *)calloc(2*T+1,sizeof(int));
	c=cc+T;
	
	for(i=0;i<2*T+1;i++) scanf("%d",&cc[i]);
	
	csum_m=csum_p=0;
	for(i=1;i<=T;i++){
		csum_p+=c[i-1];
		Qtmp=csum_p+(T-i+1)*(long long)c[i];
		if(i==1 || Q_p>Qtmp) Q_p=Qtmp;
		
		csum_m+=c[-(i-1)];
		Qtmp=csum_m+(T-i+1)*(long long)c[-i];
		if(i==1 || Q_m>Qtmp) Q_m=Qtmp;
	}
	
	ans=(T+1)*(double)E/(Q_p+Q_m-c[0]);
	if((tmp=(double)E/c[0])>=ans) ans=tmp;
	printf("%.7f\n",ans);
	
	free(cc);
	return 0;
}

Measured memory_bytes: 1152
# 2019/04/11
# AtCoder Beginner Contest 102 - B

n = int(input())
a = list(map(int, input().split()))

minval = 10 ** 10
maxval = 0
for i in range(n):
    if a[i] > maxval:
        maxval = a[i]
    if a[i] < minval:
        minval = a[i]

print(abs(maxval - minval))


Measured memory_bytes: 2940
s = gets.chomp
t = gets.chomp

candidates = []
s_chars = s.chars
t_chars = t.chars
(0..(s.length - t.length)).each do |i|
  ok = true
  t_chars.each.with_index do |t, j|
    if s[j+i] != '?' && s[j+i] != t_chars[j]
      ok = false
    end
  end

  if ok
    cand = s.dup
    cand = "#{cand[0...i]}#{t}#{cand[i + t.length..-1]}"
    cand.gsub!('?', 'a')
    candidates << cand
  end
end

if candidates.empty?
  puts "UNRESTORABLE"
else
  candidates.sort!
  puts candidates.first
end


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

int main()
{
    int w,a,b;
    cin >> w >> a >> b;

    if(max(a,b)-min(a,b)<w) cout << 0 << endl;
    else cout << max(a,b)-min(a,b)-w << endl;

    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <ll,ll>
#define N 100005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

int main()
{
	ll n, A[405], sum[405], l, r;
	cin >> n;
	vector <vector<ll>> dp(401, vector<ll>(401, INF));
	sum[0] = 0;
	for (int i = 1; i <= n; ++i)
	{
		cin >> A[i];
		sum[i] = sum[i - 1] + A[i];
		dp[i][i] = 0;
	}
	for (int len = 2; len <= n; ++len)
	{
		for (int st = 1; st <= n - len + 1; ++st)
		{
			l = st;
			r = st + len - 1;
			for (int k = l; k < r; ++k)
			{
				dp[l][r] = min(dp[l][r], dp[l][k] + dp[k + 1][r] + sum[r] - sum[l - 1]);
			}
		}
	}
	cout << dp[1][n];
}


Measured memory_bytes: 1536
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int t;
    if (a>b)
    {
        t=a;
        a=b;
        b=t;
    }
    if (b>c)
    {
        t=b;
        b=c;
        c=t;
    }
    printf("%d\n",a+b);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <map>
#include <stack>
using namespace std;
typedef long long int ll;

ll mod=998244353;
ll dp[200200];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<pair<ll,ll>> v;
	for(int i=0;i<n;i++){
		ll x,d; cin >> x >> d;
		v.push_back(make_pair(x,d));
	}
	sort(v.begin(),v.end());
	vector<ll> x(n);
	for(int i=0;i<n;i++){
		x[i]=v[i].first;
	}
	x.push_back(1e18);
	stack<int> st;
	st.push(n);
	dp[n]=1;
	for(int i=n-1;i>=0;i--){
		ll q=v[i].first+v[i].second;
		while(x[st.top()]<q){
			st.pop();
		}
		dp[i]=(dp[i+1]+dp[st.top()])%mod;
		st.push(i);
	}
	cout << dp[0] << endl;
}

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

using namespace std;

long long B(int H, int W) {
	if (H == 1 || W == 1)
		return 1;
	long long squares, r;
	r = (H & 1) ? H - 1 : H;
	squares = (r * W) / 2;
	squares += (H & 1) ? (W + 1) / 2 : 0;
	return squares;
}

int main() {
	int H, W;
	cin >> H >> W;
	cout << B(H, W);
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0, d = 0, e = 0, ans = 0, x = 0, y = 0, z = 0, N = 0, m = 0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <long long int> vec{}, vecsec{}, vecth{};
long long int iremono[100010], koware[100001];
long long  int iremono2[100001], check[100001], xpo[10000001], ypo[10000001], hei[1000001];
std::vector<std::string>kinds{}, kaku{};
char maze[1000];
int sx, sy;
int gx, gy;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
long long int dp[4][100003] ,ire[4][100003];
std::string input[103],one,two,three;
char re;

int H, W;//はんい
bool qw = false, er = false, ty = false, ui = false;
std::string code;
long long int gcd(long long int a, long long int b)
{
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}

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

int main() {
	cin >> a;
	rep(i, a) {
		cin >> b;
		vec.push_back(b);
	}
	sort(vec.begin(), vec.end());
	cout << vec[a / 2] - vec[a / 2 - 1] << endl;
}




Measured memory_bytes: 3448
import sys, math
from collections import defaultdict, deque, Counter
#from bisect import bisect_left, bisect_right
#from itertools import combinations, permutations, product
from heapq import heappush, heappop
#from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

H, W = rl()
C = rl()
D = rl()
M = []
for i in range(H):
	s = rs()
	M.append(s)

start = tuple([C[0]-1, C[1]-1])
end = tuple([D[0]-1, D[1]-1])

queue = deque()
queue.append((start, 0))
visited = defaultdict(lambda: float('inf'))
visited[start] = 0

ds = [(1,0),(-1,0),(0,1),(0,-1)]
while queue:
	n, d = queue.popleft()
	if n == end:
		print(d)
		exit()
	if visited[n] != d:
		continue
	i, j = n
	nd = d
	for di, dj in ds:
		ni, nj = i+di, j+dj
		if not (0 <= ni < H and 0 <= nj < W): continue
		if M[ni][nj] == '#': continue
		if nd < visited[(ni,nj)]:
			queue.appendleft(((ni,nj), nd))
			visited[(ni,nj)] = nd
	nd = d+1
	for di in range(-2, 3):
		for dj in range(-2, 3):
			if (di, dj) == (0,0): continue
			ni, nj = i+di, j+dj
			if not (0 <= ni < H and 0 <= nj < W): continue
			if M[ni][nj] == '#': continue
			if nd < visited[(ni,nj)]:
				queue.append(((ni,nj), nd))
				visited[(ni,nj)] = nd
print(-1)


Measured memory_bytes: 178056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string a;
ll searchh(ll inn, ll hey){
  if(hey==-1){
    return -1;
  }
  for(ll x=inn; x<a.length(); x++){
    if(a[x]-'0'==hey){
      return x+1;
    }
  }
  return -1;
}
int main(){
  ll n; cin>>n>>a;
  ll ans=0;
  vector <ll> count(1000,0);
  for(ll i=0; i<10; i++){
    for(ll j=0; j<10; j++){
      for(ll p=0; p<10; p++){
          ll one=searchh(0,i);
          ll two=searchh(one,j);
          ll three=searchh(two,p);
          if(three==-1){

          }else{
            count[(i*100+j*10+p)]++;
          }
      }
    }
  }
  for(ll i=0; i<1000; i++){
    if(count[i]>0){
      ans++;
    }
  }
  
cout<<ans;
  }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    string c;
    cin >> c;
    ll w_count=0, r_count=0;
    for(size_t i=0;i<N; i++)
    {
        if(c[i]=='R') r_count++;
        else w_count++;
    }
    //cerr << r_count << ":" << w_count << endl;
    ll need_to_change_to_red = 0;
    for(size_t i=0;i<r_count; i++)
    {
        if(c[i]=='W') need_to_change_to_red++;
    }
    ll need_to_change_to_white = 0;
    for(size_t i=N-w_count;i<N; i++)
    {
        if(c[i]=='R') need_to_change_to_white++;
    }
    cout << max(need_to_change_to_white, need_to_change_to_red) << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;
 
int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int k,x;
   cin >> k >> x;
   vector<int> coo;
   int kk = x-1;
   f(i,0,k-1){
      coo.pb(kk);
      kk--;
   }
   kk = x+1;
   f(i,0,k-1){
      coo.pb(kk);
      kk++;
   }
   coo.pb(x);
   sort(all(coo));
   // coo.pb(x);
   for(int i : coo){
      cout << i << ' ';
   }
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<bool> >;//ll or Edge
using Edge=pair<int,ll>;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++17

ll rec(int n,ll x){
    if(n==0)return 1;
    ll len=(1LL<<(n+1))-3;//一個前の
    ll num=(1LL<<(n))-1;
    if(x==1)return 0;
    if(x<=len+1)return rec(n-1,x-1);
    else if(x==len+2) return num+1;
    else if(x<=len*2+2)return num+1+rec(n-1,x-len-2);
    else return num*2+1;
}
int main(){
    int n;
    ll x;
    cin>>n>>x;
    cout<<rec(n,x)<<endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
    
#define int long long
    
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
#define MOD (int)(1e9)+7
    
using namespace std;
    
int dy[4]={1, 0, -1, 0};
int dx[4]={0, 1, 0, -1};

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

    int n;
    cin >> n;
    vector<int> v(n);
    REP(i, n) cin >> v[i];

    vector<int> f(100009, 0);
    REP(i, n){
        f[v[i]]++;
    }

    if(((n%2) && f[0]!=1) || (!(n%2) && f[0]!=0)){
        cout << 0 << endl;
        return 0;
    }
    FOR(i, 1, n){
        if(n%2){
            if(i%2){
                continue;
            }
        }
        else{
            if(!(i%2)){
                continue;
            }
        }

        if(f[i]!=2){
            cout << 0 << endl;
            return 0;
        }
    }

    int ans=1;
    REP(i, n/2){
        ans*=2;
        ans%=MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <bits/stdc++.h>
 
#define int long long

#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}
#define plus adsasa
#define minus asdadsgd 
using namespace std;
 
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}

ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;
 
const int N = 3e5 + 123;
int n , m , k;
int a[N];
string s;
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	int D , M , ans = 0;
	cin >> M >> D;
	rep(m , 1,  M + 1)
		rep(i , 2, 10)
			rep(j , 2 , 10)
				if(i * j == m and i * 10 + j <= D)
					ans++;


	cout << ans ;

}

Measured memory_bytes: 256
N, M = [int(_) for _ in input().split()]
PY = [[int(_) for _ in input().split()] for _ in range(M)]
PYI = sorted([PY[i] + [i] for i in range(M)], key=lambda xs:xs[1])
count_p = {}
ans = [None] * M
for p, y, i in PYI:
    count_p[p] = count_p.get(p, 0) + 1
    ans[i] = [p, count_p[p]]
[print(str(p).zfill(6)+str(x).zfill(6)) for p, x in ans]


Measured memory_bytes: 53104
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
void solve(){
	ll n;
	string s;
	cin>>n>>s;
	ll sum=0,res=n;
	for(ll i=0;i<n;i++)
		if(s[i]=='E')
			sum++;
	for(ll i=0;i<n;i++){
		if(s[i]=='E')
			sum--;
		res=min(res,sum);
		if(s[i]=='W')
			sum++;
	}
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++){
        solve();
    }
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 3936
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

#define MOD 1000000007


int n, x;
int s[200];

int dp[100001];

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

	cin >> n >> x;
	rep(i, n)cin >> s[i];


	dp[x] = 1;

	rep(i, n) {
		rep(v, x + 1) {
			if (dp[v] == 0)continue;

			int prev = dp[v];
			dp[v] = 0;
			rep(k, n) {
				int w = v % s[k];
				dp[w] = (dp[w] + prev) % MOD;
			}
			dp[v] = ((dp[v] - 1LL * i*prev) % MOD + MOD) % MOD;
		}
	}
	long long ans = 0;
	rep(i,x) {
		ans += 1LL * i*dp[i]%MOD;
	}
	ans %= MOD;
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    HashMap<Long, Long> map = new HashMap<Long, Long>();

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        long H = sc.nextLong();
        map.put(1l, 1l);
        System.out.println(solve(H));
    }

    long solve(long h) {
        if (map.containsKey(h)) {
            return map.get(h);
        } else {
            long cnt = solve(h / 2l) * 2l + 1;
            map.put(h, cnt);
            return cnt;
        }
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
bool check(vector<vector<bool> > data) {
    if (data[1][1]) {
        if (data[0][0] && data[2][2]) {
            return true;
        }
        if (data[0][2] && data[2][0]) {
            return true;
        }
        if (data[1][0] && data[1][2]) {
            return true;
        }
        if (data[0][1] && data[2][1]) {
            return true;
        }
    }
    if (data[0][0]) {
        if (data[1][0] && data[2][0]) {
            return true;
        }
        if (data[1][1] && data[1][2]) {
            return true;
        }
    }
    if (data[2][2]) {
        if (data[0][2] && data[1][2]) {
            return true;
        }
        if (data[2][0] && data[2][1]) {
            return true;
        }
    }
    return false;
}


int main() {
    int64_t N;
    vector<vector<int> > data(3,vector<int>(3));
    vector<vector<bool> > checklist(3,vector<bool>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            checklist[i][j] = false;
        }
    }
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> data.at(i).at(j);
        }
    }
    cin >> N;
    int a;
    for (int c = 0; c < N; c++) {
        cin >> a;
        for (int i = 0; i < 3; i++) {
            for (int b = 0; b < 3; b++) {
                if (data[i][b] == a) {
                    checklist[i][b] = true;
                }
            }
        }
    }
    if (check(checklist)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#define maxArr 200009

int temp[maxArr];
int Arr[maxArr];
long long count=0;

void mergeSort(int l, int r){
	if(l>=r) return;
	int mid =(l+r)/2;

	mergeSort(l, mid);
	mergeSort(mid+1, r);
	
	int left=l;
	int toLeft=mid;
	int right=mid+1;
	int toRight=r;
	int tempIdx=l;
	
	while(left<=toLeft && right<=toRight){
		if(Arr[left]<=Arr[right]){
			temp[tempIdx++]=Arr[left++];
		}
		else{
			temp[tempIdx++]=Arr[right++];
			count+=(mid+1)-left;
		}
	}
	while(left<=toLeft){
		temp[tempIdx++]=Arr[left++];
	}
	while(right<=toRight){
		temp[tempIdx++]=Arr[right++];
	}
	for(int i=l;i<=r;i++){
		Arr[i]=temp[i];
	}
}

int main(){
	int n;
	scanf("%d", &n);
	count=0;
	
	for(int i=0;i<n;i++){
		scanf("%d", &Arr[i]);	
	}
	
	mergeSort(0,n-1);
	printf("%lld\n", count);
	
	return 0;
}


Measured memory_bytes: 4268
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
typedef long long ll;

using namespace std;

// 1-indexed
template<typename T>
struct BIT{
    int n;
    vector<T> bit;
    BIT(int n_=0):n(n_),bit(n+1){}
    T sum(int i){
        T res=0;
        for(;i>0;i-=(i&-i))res+=bit[i];
        return res;
    }
    void add(int i,T a){
        if(i==0)return;
        for(;i<=n;i+=(i&-i)){bit[i]+=a;}
    }
    int lower_bound(T k){ // k<=sum(res)
        if(k<=0)return 0;
        int res=0,i=1;
        while((i<<1)<=n)i<<=1;
        for(;i;i>>=1){
            if(res+i<=n&&bit[res+i]<k)k-=bit[res+=i];
        }
        return res+1;
    }
};

vector<int> v[200200],g[200200];

int id=1;

int in[200200],out[200200];

void dfs(int s,int p){
    in[s]=id;
    id++;
    for(int t:g[s]){
        if(t==p)continue;
        dfs(t,s);
    }
    out[s]=id;
}

ll cal(ll n){
    return n*(n+1)/2;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    for(int i=0;i<n;i++){
        int c; cin >> c;
        c--;
        v[c].push_back(i);
    }
    for(int i=1;i<n;i++){
        int x,y; cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    BIT<int> bit(n+1);
    dfs(0,-1);
    for(int i=1;i<=n;i++){
        bit.add(i,1);
    }
    for(int i=0;i<n;i++){
        ll res=cal(n);
        sort(v[i].begin(), v[i].end(),[](auto a,auto b){
            return in[a]>in[b];
        });
        vector<pair<int,int>> vv;
        for(int s:v[i]){
            int u=1;
            for(int t:g[s]){
                if(in[t]<in[s])continue;
                int d=bit.sum(out[t]-1)-bit.sum(in[t]-1);
                res-=cal(d);
                u+=d;
            }
            vv.push_back({in[s],u});
            bit.add(in[s],-u);
        }
        res-=cal(bit.sum(n));
        printf("%lld\n",res);
        for(auto p:vv){
            bit.add(p.first,p.second);
        }
    }
}

Measured memory_bytes: 34400
# coding: utf-8
# Your code here!
def main():
    k = int(input())
    
    if k % 7 == 0:
        l = 9 * k / 7
    else:
        l = 9 * k
        
    if l % 2 == 0 or l % 5 == 0:
        print("-1")
        return 0
        
    for i in range(1, 10**6):
        if i == 1:
            tmp = 10 % l
        else:
            tmp = (tmp * 10) % l
            
        if tmp == 1:
            print(i)
            return 0
    
main()

Measured memory_bytes: 9072
n=int(input())
a=[]
for _ in range(n):
    a.append(int(input()))
     
if n==2:
    print(abs(a[0]-a[1]))
    exit()

a=sorted(a)
turn=(n-1)//2
pre=a[0]*2
ans=0
for i in range(turn):
    if i%2==0:
        p=a[n-i-1]
        q=a[n-i-2]
        new=p+q
        ans += new-pre
        m=p-a[n-i-3]
    else:
        p=a[i]
        q=a[i+1]
        new=p+q
        ans += pre-new
        m=a[i+2]-p
    pre=new

if n%2==0:
    ans += m

a=sorted(a,reverse=True)
pre=a[0]*2
ans1=0
for i in range(turn):
    if i%2==0:
        p=a[n-i-1]
        q=a[n-i-2]
        new=p+q
        ans1 += pre-new
        m=a[n-i-3]-p
    else:
        p=a[i]
        q=a[i+1]
        new=p+q
        ans1 += new-pre
        m=p-a[i+2]
    pre=new

if n%2==0:
    ans1 += m

las=max(ans,ans1)
print(las)

Measured memory_bytes: 8304
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 3000000000000000
#define mod 1000000007
using namespace std;

int main()
{ 
  fast;
   ll n,w;
   cin>>n>>w;

   ll wt[n],val[n];
   for(ll i=0;i<n;i++)
   	cin>>wt[i]>>val[i];

   vector<ll> dp(100009,inf);
   dp[0]=0;

   for(ll i=0;i<n;i++)
   	for(ll j=100008;j>-1;j--)
   		if(j>=val[i])
   			dp[j]=min(dp[j],dp[j-val[i]]+wt[i]);

   		for(ll i=100008;i>-1;i--)
   			if(dp[i]<=w)
   			{
   				cout<<i<<endl;
   				return 0;
   			}
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    if((n+1)/2>=k){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iterator>
#include<cmath>
#include<vector>
using namespace std;

int main()
{
    int a, b, c, K;
    cin>>a>>b>>c>>K;
    if(K<=a)
    {
        cout<<K<<endl;
    }
    else if(a<K && K<=a+b)
    {
        cout<<a<<endl;
    }
    else
    {
        cout<<2*a+b-K<<endl;
    }
    
}

Measured memory_bytes: 3596
h, w = map(int, input().split())
n = int(input())
A = tuple(map(int, input().split()))

M = [[0] * w for _ in range(h)]
ii = 0
ij = 0
for i, a in enumerate(A):
    i += 1
    for _ in range(a):
        M[ij][ii] = i

        if ij%2 == 0:
            ii += 1
            if ii == w:
                ij += 1
                ii = w-1
        else:
            ii -= 1
            if ii == -1:
                ij += 1
                ii = 0
for l in M:
    print(*l)

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

int main(){
	double a;
	while (cin >> a, !cin.eof()){
		double ans[10] = {};
		double sum = 0;
		ans[0] = a;
		for (int i = 1; i < 10; i++){
			if (i % 2 == 0){
				// 奇数番目
				ans[i] = ans[i - 1] / 3.0;
			}
			else{
				// 偶数番目
				ans[i] = ans[i - 1] * 2.0;
			}
		}
		for (int i = 0; i < 10; i++){
			sum += ans[i];
		}
		printf("%.9lf\n", sum);
	}

	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define th third
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a)  (a).begin(),(a).end()
#define elif else if

const int dx[8]={1,1,1,0,0,-1,-1,-1};
const int dy[8]={-1,0,1,-1,1,-1,0,1};
int H,W;
V<V<int>> field;

void dfs(int h,int w){
  field[h][w]=0;
  fo(dir,8){
    int nh=h+dx[dir];
    int nw=w+dy[dir];
    if(nh<0||nw<0||nh>=H||nw>=W)
      continue;
    if(field[nh][nw]==0)
      continue;
    dfs(nh,nw);
  }
}
signed main(){
  while(cin>>W>>H){
    if(H==0||W==0)
      break;
    field.assign(H,V<int> (W,0));
    fo(h,H){
      fo(w,W){
        cin>>field[h][w];
      }
    }
    int ans=0;
    fo(h,H){
      fo(w,W){
        if(field[h][w]==0)
          continue;
        dfs(h,w);
        ++ans;
      }
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3248
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] MainCard = new int[4][13];
        for(int num=0;num<n;num++){
       	 String Mark = sc.next();
        	int a = sc.nextInt();
        	int i = 0;
       	 if(Mark.equals("S")){
           	 i = 0;
       	 }else if(Mark.equals("H")){
           	 i = 1;
        	}else if(Mark.equals("C")){
           	 i = 2;
      	  }else{
        	 i = 3;
       	 }
       		 int j = a-1;
       	 MainCard[i][j] = 1;
       	 }
        	for(int i=0;i<4;i++){
                for(int j=0;j<13;j++){
                    if(MainCard[i][j] == 0){
                        if(i == 0){
                            System.out.println("S " + (j+1));
                        }else if(i == 1){
                            System.out.println("H " + (j+1));
                        }else if(i == 2){
                            System.out.println("C " + (j+1));
                        }else{
                            System.out.println("D " + (j+1));
                        }
                    }
                }
            }
                    
    }
    
}
  


Measured memory_bytes: 26356
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>

using namespace std;

int main(void){
    int A,B,C;
    cin>>A>>B>>C;
    int ans=C-(A-B);
    if(ans<=0){
        cout<<0<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}

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

int a;
int b;
int product=1;

int main()
{
    cin>>a>>b;

    for (int i=a; i<=b; i++)
    {
        if (i<0)
        {
            product=product*-1;
        }

        if (i==0)
        {
            cout<<"Zero"<<endl;
            return 0;
        }
    }

    if (product>0)
    {
        cout<<"Positive"<<endl;
    }

    else 
    {
        cout<<"Negative"<<endl;
    }
    
}

Measured memory_bytes: 3624
n=int(input())
l=list(map(int,input().split()))

max=0
flag=0
for i in range(n):
    if l[i] >= max:
        max=l[i]
    else:
        if max-l[i] == 1:
            continue
        else:
            flag=1
            break

if flag == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define  rep(i,n) for(li i = 0; i < (n); ++i)
#define  red(i,n) for(li i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;


int main()
{
    string s;
    cin>>s;
    int a=0;
    for(char c:s)a+=c-'0';
    cout<<(stoi(s)%a?"No":"Yes")<<endl;

    return 0;
}



Measured memory_bytes: 256
H,W = gets.split.map(&:to_i)
S = [
  ("." * (W+2)),
  *((0...H).map{
    "."+gets.chomp+"."
  }),
  ("." * (W+2)),
]  

puts (1..H).any?{ |i|
  (1...W).any?{ |j|
    S[i][j] == "#" && S[i-1][j] == "." && S[i+1][j] == "." && S[i][j-1] == "." && S[i][j+1] == "."
  }
} ? "No" : "Yes"


Measured memory_bytes: 1788