akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::{BTreeMap,BTreeSet};
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

#[allow(unused_macros)]
macro_rules! tf {
    ($c:expr, $t:expr, $f:expr) => {{
        if $c { $t } else { $f }
    }};
}

fn main() {
    let n = read_i64() as usize;
    let xs = read_vec_i64();
    let even_sum = xs.iter().enumerate().filter(|&(i,&_)| i % 2 == 0).fold(0i64, |s,(_,&x)| s + x);
    let odd_sum  = xs.iter().enumerate().filter(|&(i,&_)| i % 2 == 1).fold(0i64, |s,(_,&x)| s + x);
    if n % 2 == 0 {
        println!("{} {}", max(even_sum, odd_sum), min(even_sum, odd_sum));
    }
    else {
        let mut lower = 0;
        let mut upper = 1i64 << 30;
        while upper - lower != 1 {
            let x = (lower+upper)/2;
            let mut l = 0;
            let mut r = n;
            let mut offset = 0;
            while r - l != 1 {
                if xs[l] + offset >= x && xs[l+1] >= xs[l] + offset {
                    l += 2;
                    offset = 0;
                }
                else {
                    offset = xs[l] + offset - xs[l+1];
                    l += 2;
                }
            }
            let yes = xs[l] + offset >= x;
            if yes {
                lower = x;
            }
            else {
                upper = x;
            }
        }
        let black = lower + odd_sum;
        let white = even_sum + odd_sum - black;
        println!("{} {}", black, white);
    }
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    //ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 12016
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    long ans = 0;
    for (int i = 0; i < N-1; i++) {
      int p = (A[i]+A[i+1])/2;
      int tmp = A[i];
      A[i] = Math.max(A[i]-2*p, 0);
      A[i+1] -= 2*p-(tmp-A[i]);
      ans += p;
    }
    ans += A[N-1]/2;
    System.out.println(ans);
  }
}

Measured memory_bytes: 50888
s = list(x for x in input())
temp = 0
ans = []
for i in range(len(s)):
  if s[i] == 'A' or s[i] == 'C' or s[i] =='G' or s[i] =='T':
    temp += 1
    if i == len(s) - 1:
      ans.append(temp)
  else:
    ans.append(temp)
    temp = 0
print(max(ans))


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

#define int long long


signed main()
{
    string s;
    cin >> s;
    stack<char> st;
    for(int i=0; i<s.size(); ++i) {
        char c = s[i];
        if(c=='S') st.push(c);
        else {
            if(st.empty()||st.top()=='T') st.push(c);
            else st.pop();
        }
    }
    cout << st.size() << endl;
    return 0;
}



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

#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define bitcount    __builtin_popcountll
#define si(x)       scanf("%d",&x)
#define su(x)       scanf("%u",&x)
#define sll(x)      scanf("%lld",&x)
#define sl(x)       scanf("%ld",&x)     
#define sc(x)       scanf("%c",&x)
#define ss(x)       scanf("%s",x)
#define sf(x)       scanf("%f",&x)
#define slf(x)      scanf("%lf",&x)
#define pri(x)      printf("%d\n",x)
#define prl(x)      printf("%lld\n",x)
#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<long long,long long>
#define pil         pair<int,long long>
#define pli         pair<long long,int>
#define vi          vector<int>
#define vl          vector<long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<=b;i++)
#define repl(i,a,b) for(long long i=a;i<=b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define rrepl(i,a,b) for(long long i=a;i>=b;i--)
#define M           1000000007

const int maxn=1e6+100;
map<int,int>m1;
map<int,int>m3;
vector<pii> v;
int countA[maxn];
int countC[maxn];

bool compare(const pii&a,const pii&b){
    if(a.F!=b.F) return a.F<b.F;
    return a.S<b.S;
}

void solve(){
    int n,p,m,k,z,y,x;
    //si(n); si(k); si(m);
    si(n);
    
    rep(i,1,n){
        si(x);
        v.pb(mp(x,0));
        m1[x]++;
    }
    
    rep(i,1,n){
        si(x);
        v.pb(mp(x,1));
    }
    
    rep(i,1,n){
        si(x);
        v.pb(mp(x,2));
        m3[x]++;
    }
    
    sort(v.begin(),v.end(),compare);
    
    rep(i,0,sz(v)-1){
        if(v[i].S==0) countA[i]=((i==0)?1:1+countA[i-1]);
        else countA[i]=((i==0)?0:countA[i-1]);
    }
    
    rrep(i,sz(v)-1,0){
        if(v[i].S==2) countC[i]=((i==(sz(v)-1))?1:1+countC[i+1]);
        else countC[i]=((i==(sz(v)-1))?0:countC[i+1]);
    }
    ll ans=0;
    int t1,t2;
    rep(i,0,sz(v)-1){
        if(v[i].S!=1) continue;
        t1=countA[i]-m1[v[i].F];
        t2=countC[i]-m3[v[i].F];
        ans+=(1ll*t1*t2);
    }
    prl(ans);
}
int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1;
    //si(t);
    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 28396
import math

def input_number():
    return int(input())

def input_1line_list(number_of_input):
    return [input() for i in range(number_of_input)]

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

# def print_unique_length(input_list):
#     print(len(set(input_list)))

def f(a, b, x):
    return (a*(x%b))//b 

def main():
    a, b, n = input_1line()
    x = min(b-1, n)
    ans = f(a, b, x)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9080
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0

for i in range(N):
    c = input()
    
    if c == "AC":
        ac = ac + 1
    elif c == "WA":
        wa = wa + 1
    elif c == "TLE":
        tle = tle + 1
    elif c == "RE":
        re = re + 1

print(f'AC x {ac}\nWA x {wa}\nTLE x {tle}\nRE x {re}\n')

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

using namespace std;

typedef long long ll;
typedef long double ld;
int n, x;
const int mod = (int)1e9 + 7;
const int maxN = 2 * (int)1e5 + 100;
int q;
char tp[maxN];
char t[maxN], d[maxN];
signed main() {
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> q;
    string s;
    cin >> s;
    for (int j = 0; j < n; j++) tp[j + 1] = s[j];
    for (int i = 0; i < q; i++) {
        cin >> t[i] >> d[i];
    }
    reverse(t, t + q);
    reverse(d, d + q);
    int l = 0;
    for (int i = 0; i < q; i++) {
        if (l == n) continue;
        if (d[i] == 'L' && tp[l + 1] == t[i]) l++;
        if (l > 0 && d[i] == 'R' && tp[l] == t[i]) l--;
    }
    int r = n + 1;
    for (int i = 0; i < q; i++) {
        if (r == 1) continue;
        if (d[i] == 'R' && tp[r - 1] == t[i]) r--;
        if (r <= n && d[i] == 'L' && tp[r] == t[i]) r++;
    }
    int cnt = n;
    for (int i = 1; i <= n; i++) {
        if (i <= l || i >= r) cnt--;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define lscan(x) scanf("%I64d", &x)
#define lprint(x) printf("%I64d", x)

int main()
{
	int n,i,a[3333],u,v,f[3333] = {},d[3333] = {};
	cin >> n;
	for (i = 0; i < n;i++)
		cin >> a[i];
	vector<int> ins[3333];
	for (i = 0; i < n - 1; i++){
		cin >> u >> v;
		u--;
		v--;
		if(a[u]<a[v]){
			d[v]++;
			ins[u].pb(v);
		}
		else if (a[u] > a[v]){
			d[u]++;
			ins[v].pb(u);
		}
	}
	queue<int> que;
	for (i = 0; i < n;i++)
		if(d[i]==0)
			que.push(i);
	while(!que.empty()){
		int now = que.front();
		que.pop();
		for(auto &e:ins[now]){
			d[e]--;
			if(f[now]==0)
				f[e] = 1;
			if(d[e]==0)
				que.push(e);
		}
	}
	for (i = 0; i < n;i++)
		if(f[i])
			cout << i + 1 << " ";
}

Measured memory_bytes: 3768
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long inf = 1ll << 62;
typedef pair<double, int> P;
typedef pair<P, int> PP;
const double eps=1e10;

double a[40005], b[40005], c[40005];
double ca[40005], cb[40005], cc[40005];

struct BIT {
	int n;
	vector<int>bit;
	void init(int N) {
		n = N;
		bit.resize(N+1);
	}
	int sum(int i) {
		int s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i&-i;
		}
		return s;
	}
	void add(int i, int x) {
		while (i <= n) {
			bit[i] += x;
			i += i&-i;
		}
	}
};

signed main() {
	int n; cin >> n;
	vector<P>V;

	rep(i, n) {
		cin >> a[i] >> b[i] >> c[i];
		V.push_back(P((c[i] + a[i] *eps) / b[i], i));
	}
	sort(V.begin(), V.end());
	rep(i, n) {
		int e = V[i].second;
		ca[i] = a[e];
		cb[i] = b[e];
		cc[i] = c[e];
	}
	rep(i, n) {
		a[i] = ca[i];
		b[i] = cb[i];
		c[i] = cc[i];
	}
	double lb = -eps, ub = eps;
	
	int AP = (n*(n - 1) / 2+1)/2;
	rep(z, 300) {
		double mi = (lb + ub) / 2;
		vector<P>V2;
		rep(i, n) {
			V2.push_back(P((c[i] - a[i] * mi) / b[i], i));
		}
		sort(V2.begin(), V2.end());
		BIT B;
		int cnt = 0;
		B.init(n + 1);
		rep(i, n) {
			int e = V2[i].second;
			cnt += B.sum(n)-B.sum(e);
			B.add(e + 1, 1);
		}
		if (cnt < AP)lb = mi;
		else ub = mi;
	}
	double ax = ub;


	V.clear();
	rep(i, n) {
		V.push_back(P((c[i] + b[i] *eps) / a[i], i));
	}
	sort(V.begin(), V.end());
	rep(i, n) {
		int e = V[i].second;
		ca[i] = a[e];
		cb[i] = b[e];
		cc[i] = c[e];
	}
	rep(i, n) {
		a[i] = ca[i];
		b[i] = cb[i];
		c[i] = cc[i];
	}

	lb = -eps, ub = eps;

	rep(z, 300) {
		double mi = (lb + ub) / 2;
		vector<P>V2;
		rep(i, n) {
			V2.push_back(P((c[i] - b[i] * mi) / a[i], i));
		}
		sort(V2.begin(), V2.end());
		BIT B;
		int cnt = 0;
		B.init(n + 1);
		rep(i, n) {
			int e = V2[i].second;
			cnt += B.sum(n) - B.sum(e);
			B.add(e + 1, 1);
		}
		if (cnt < AP)lb = mi;
		else ub = mi;
	}

	double ay = ub;
	printf("%.13lf %.13lf\n", ax, ay);
}


Measured memory_bytes: 4456
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
const int MOD=1e9+7;
const double eps=1e-8;
typedef long long ll;
//orz yht
using namespace std;
int n,a[105],ans=INF;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=-100;i<=100;i++){
		int sum=0;
		for(int j=1;j<=n;j++){
			sum+=(a[j]-i)*(a[j]-i);
		}
		ans=min(ans,sum);
	}
	cout<<ans; 
	return 0;
}

Measured memory_bytes: 256
N, X, Y = [int(x) for x in input().split()]
A = [0]*N
for n in range(1,N+1):
  for m in range(n+1,N+1):
    #print(m-n,abs(n-X)+1+abs(m-Y))
    A[min(m-n,abs(n-X)+1+abs(m-Y))]+=1
for n in range(1,N):
  print(A[n])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

// https://kenkoooo.hatenablog.com/entry/2016/11/30/163533
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}
__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < (int)s.length(); i++)
    if ('0' <= s[i] && s[i] <= '9')
      ret = 10 * ret + s[i] - '0';
  return ret;
}

int main(){
    using Int = __int128_t;
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    Int X1 = (Int)t1*a1;
    Int X2 = (Int)t2*a2;
    Int Y1 = (Int)t1*b1;
    Int Y2 = (Int)t2*b2;
    if(X1 + X2 == Y1 + Y2) {
        cout << "infinity" << endl;
        return 0;
    }
    if(X1 + X2 > Y1 + Y2) {
        swap(X1, Y1);
        swap(X2, Y2);
    }
    if(X1 < Y1) {
        cout << 0 << endl;
        return 0;
    }
    Int l = 0, r = 1;
    rep(i, 20) r *= (Int)10; 
    auto check = [&](Int m) {
        return m*(X1+X2)+X1 <= m*(Y1+Y2)+Y1;
    };
    while(r - l > 1) {
        Int m = (l + r) / (Int)2;
        // cout << m << endl;
        if(check(m)) r = m;
        else l = m;
    }
    Int ans = r*(Int)2-(Int)1;
    Int D = X1 - Y1;
    Int dif = Y1+Y2 - (X1+X2);
    if(D % dif == 0) ans += (Int)1;
    // cout << D << " " << dif << endl;
    cout << ans << endl;
    return 0;
}

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


def solve(N: int, M: int, P: "List[int]", Y: "List[int]"):
    tuple = list(zip(P, Y, [i for i in range(M)]))
    tuple.sort()
    numbers = [0 for _ in range(M)]
    index = 0
    pre = tuple[0][0]
    for t in tuple:
        if pre != t[0]:
            pre = t[0]
            index = 0
        index += 1
        numbers[t[2]] = f"{str(t[0]).zfill(6)}{str(index).zfill(6)}"
    for n in numbers:
        print(n)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = [int()] * (M)  # type: "List[int]"
    Y = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        P[i] = int(next(tokens))
        Y[i] = int(next(tokens))
    solve(N, M, P, Y)

if __name__ == '__main__':
    main()



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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

const ll mod=1000000007;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
 
 ll n;
  cin >> n;
 vll p(n);
  rep(i,0,n){
   ll q;
    cin >> q;
    q--;
    p[q]=i;
  }
  
  multiset<ll> s;
   s.insert(-1);
   s.insert(-1);
   s.insert(n);
   s.insert(n);
  
  
  ll res=0;
  s.insert(p[n-1]);
  
  repr(i,n-2,0){
    auto y=s.lower_bound(p[i]);
    auto x=y;
    x--;
    auto w=x;
    w--;
    auto z=y;
    z++;
    res+=((*x-*w)*(*y-p[i])+(*z-*y)*(p[i]-*x))*(i+1);    
    s.insert(p[i]);
  }
  
  
  cout << res << endl;
  
}


Measured memory_bytes: 5760
class PriorityQueue
  def initialize(&block)
    @heap = []
    @cmp = block || lambda{|a, b| a <=> b }
  end

  def add(elem)
    i = @heap.length
    while i > 0
      parent = (i - 1) / 2
      break if @cmp.call(@heap[parent], elem) != -1
      @heap[i] = @heap[parent]
      i = parent
    end
    @heap[i] = elem
  end

  def pop
    max = @heap[0]
    min = @heap.pop
    return max if @heap.empty?
    i = 0
    while i*2+1 < @heap.length
      left = i*2+1
      right = i*2+2
      if @heap[right].nil?
        child = left
      else
        child = @cmp.call(@heap[left], @heap[right]) >= 0 ? left : right
      end
      break if @cmp.call(min, @heap[child]) >= 0
      @heap[i] = @heap[child]
      i = child
    end
    @heap[i] = min
    return max
  end

  attr_reader :heap
  alias push :add
  alias :<< :add
end

require 'set'

x,y,z,k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i).sort.reverse
bs = gets.split.map(&:to_i).sort.reverse
cs = gets.split.map(&:to_i).sort.reverse

q = PriorityQueue.new {|a, b| a[0] <=> b[0] }
q.add([as[0]+bs[0]+cs[0], 0, 0, 0])

count = 0
alread_set = Set.new
while count < k
  ans = q.pop
  puts ans[0]
  [
    [ans[1]+1,ans[2],ans[3]],
    [ans[1],ans[2]+1,ans[3]],
    [ans[1],ans[2],ans[3]+1],
  ].each do |item|
    key = item.join(',')
    next if item[0]>=x || item[1]>=y || item[2]>=z || alread_set.include?(key)
    alread_set.add(key)
    q.add([as[item[0]]+bs[item[1]]+cs[item[2]], item[0], item[1], item[2]])
  end
  count += 1
end


Measured memory_bytes: 3832
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAX_T = 3000, MAX_M=300;

int M, start, goal,dice[6], N[MAX_M];

enum status{GOOD, SOSO, BAD};
bool isPositionValid(int p){return 0<=p && p<M;}

int* MakePath(int *path, int from){
	static bool visit[MAX_M] = {};
	static auto checkPath = [&path](int moveto)->int{
		if(!isPositionValid(moveto)){
			return 2*MAX_T;
		}
		else{
			int position = moveto+ N[moveto];
			if(!visit[position]) MakePath(path, position);
			return  path[position]+1;
		}
	};

	if(path==NULL){
		path = new int[M];
		for(int m=0; m<M; m++) path[m] = MAX_T+1;
	}

	visit[from] = true;
	int bestpath = MAX_T;
	if(from==goal)	bestpath = 0;
	else{
		for(int r=0; r<6; r++){
			bestpath = min(bestpath, checkPath(from + dice[r]));
			bestpath = min(bestpath, checkPath(from - dice[r]));
		}
	}
	path[from] = bestpath;
	return path;
}

int main(){
	// 入力
	scanf("%d", &M);
	scanf("%d%d%d%d%d%d", &dice[0], &dice[1], &dice[2], &dice[3], &dice[4], &dice[5]);
	scanf("%d%d", &start, &goal);
	for(int m=0; m<M; m++)	scanf("%d", &N[m]);
	start--;
	goal--;

	int* path = MakePath(NULL, start);
	
	//本番
	int position = start;
	for(int t=0; t<MAX_T; t++){
		if(position == goal) break;
	
		int r;
		scanf("%d", &r);
		int d = dice[r-1];

		static auto tryMove = [&path](int moveto, int path_before)->status{
			if(isPositionValid(moveto)){
				int path_new = path[moveto + N[moveto]];
				if(path_before > path_new) return GOOD;
				else if(path_before == path_new) return SOSO;
			}
			return BAD;
		};
	
		int output = 0;
		status forward_status, backward_status;
		forward_status  = tryMove(position + d, path[position]);
		if(forward_status == GOOD) output = 1;

		if(output==0){
			backward_status = tryMove(position - d, path[position]);
			if(backward_status == GOOD) output = -1;
		}

		if(output==0){
			if(forward_status==SOSO) output=1;
			else if(backward_status == SOSO)output=-1;
		}

		position = position + output*d  + (output==0?0:N[position + output*d]);
		printf("%d\n", output);
		fflush(stdout);
	}

	delete[] path;
	return 0;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()

int main(){
	int n=3;
	vector<string> v;
	for (int bit=0; bit<(1<<n); bit++){
		string s;
		for (int i=0; i<n; i++){
			if (bit &(1<<i)) s+="+";
			else s+="-";
		}
		v.push_back(s);
	}
	
	string x; cin>>x;
	for(int k=0; k<(int)v.size(); k++){
		int ans=x[0]-'0';
		string y=to_string(ans);
		string t=v[k];
		for(int i=1; i<4; i++){
			if(t[i-1]=='+'){ans+=x[i]-'0'; y+=t[i-1]+to_string(x[i]-'0');}
			else{ans-=x[i]-'0'; y+=t[i-1]+to_string(x[i]-'0');}
		}
		if(ans==7){cout<<y<<"=7"<<endl; return 0;}
	}
}

Measured memory_bytes: 3648
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979

int main()
{
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int x = x2 - x1;
	int y = y2 - y1;

	cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x << endl;
	return 0;
}

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

typedef long long ll;

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int k;
	cin >> k;
	for (int x = 0, i = 1; i <= k; ++i) {
		x = (10 * x % k + 7) % k;
		if (x == 0) {
			cout << i;
			return 0;
	    }
	}
	cout << -1;
    return 0;
}

Measured memory_bytes: 3628
package main

import "fmt"

func main() {
	var (
		x int
		a = 1000
		b int
	)
	fmt.Scan(&x)

	for {
		b = a - x
		if b < 0 {
			a += 1000
		} else {
			break
		}
	}
	fmt.Println(b)
}


Measured memory_bytes: 1768
#include<bits/stdc++.h>
#define ll long long
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define f(i,s,e) for(ll i=s;i<e;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
char arr[1001][1001];
queue <pair<int,int> > q;

int main(){
    fast;

    int nei[4][2] = {{1,0},{0,1},{-1,-0},{0,-1}};

    int h,w,ans=0;
    cin>>h>>w;

    f(i,0,h){
        f(j,0,w){
            cin>>arr[i][j];
            if(arr[i][j]=='#')
                q.push(mp(i,j));
        }
    }

    while(!q.empty()){
        int siz = q.size();

        while(siz--){
            pair<int,int> p = q.front();
            //cout<<p.first<<" "<<p.second<<endl;
            q.pop();
            f(i,0,4){
                int nextx = p.first + nei[i][0];
                int nexty = p.second + nei[i][1];

                if(nextx>=0 && nextx<h && nexty>=0 && nexty<w && arr[nextx][nexty]=='.'){
                    arr[nextx][nexty]='#';
                    q.push(mp(nextx,nexty));
                }
            }
        }
        ans++;
    }
    cout<<ans-1;
}


Measured memory_bytes: 9488
s = input()
t = input()

dict_st = {}
dict_ts = {}

for x, y in zip(s, t):
    if x not in dict_st:
        dict_st[x] = y 
    else:
        if dict_st[x] != y:
            print("No")
            break

    if y not in dict_ts:
        dict_ts[y]=x
    else:
        if dict_ts[y]!=x:
            print("No")
            break
else:
    print("Yes")

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,i;
	int a[55]={0},b[55]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b,b+55);
//	for(i=0;i<55;i++){
//		printf("%d     %d\n",a[i],b[i]);
//	}
	int f=0;
	for(i=0;i<n;i++)
	{
		if(a[i]!=b[55-(n-i)])
		f++;
	}
	if(f==0||f==2) printf("YES");
	else printf("NO");
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

const int mod = 1e9 + 7;

int main()
{
    int n, a, b;
    std::cin >> n >> a >> b;

    int below_a = 0, between = 0, above_b = 0;
    for (int i = 0; i < n; i++) {
        int temp;
        std::cin >> temp;

        if (temp <= a) {
            below_a++;
        } else if (temp > a && temp <= b) {
            between++;
        } else {
            above_b++;
        }
    }

    int min = below_a;
    if (min > between) {
        min = between;
    }

    if (min > above_b) {
        min = above_b;
    }

    std::cout << min << std::endl;
}


Measured memory_bytes: 256
n = gets.to_i
t, a = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)

hh = h.map{|i| ((t-i*0.006)-a).abs }
minidx = 0
minval = 9999999999
hh.each_with_index{|i,idx|
    if i < minval
        minval = i
        minidx = idx
    end
}
puts minidx+1


Measured memory_bytes: 1788
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int n,m,x,a[200];
    scanf("%d%d%d",&n,&m,&x);
    int i;
    for(i=1;i<=m;i++)
        scanf("%d",&a[i]);
    a[i]=x;
        sort(&a[1],&a[2+m]);

    int left,right;
    left=right=0;
    for(i=1;i<=m+1;i++)
    {
        if(a[i]!=x)
            right++;
            else
                break;
    }
        for(i++;i<=m+1;i++)
    {

            left++;
    }
    if(right>left)
    printf("%d",left);
    else
          printf("%d",right);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		for(int i = A;i < A + K;i++) {
			if(i <= B) System.out.println(i);
		}
		for(int i = B - K + 1;i <= B;i++) {
			if(i >= A + K) System.out.println(i);
		}	
	}

}


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

int main() {
  int N,M;
  cin >> N;
  vector<string> aoi(N);
  for (int i=0 ; i < N ; i++){
    cin >> aoi.at(i);
  }
  cin >> M;
  vector<string> akai(M);
  for (int i=0 ; i < M ; i++){
    cin >> akai.at(i);
  }
  vector<int> count(N);
  int point=0;
  for (int i=0; i<N; i++){
    for (int j=0; j<N; j++){
      if (aoi.at(i)==aoi.at(j)){
        count.at(i)=count.at(i)+1;
      }
    }
    for (int j=0; j<M; j++){
      if (aoi.at(i)==akai.at(j)){
        count.at(i)=count.at(i)-1;
      }
    }
    if (point < count.at(i)){
      point=count.at(i);
    }
  }
  cout << point << endl;  

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
 
int main(){
  int N,A,B;
  cin>>N>>A>>B;
  int sum=0;
  for(int i=1;i<=N;i++){
    int n=i;
    int cnt=0;
    while(n!=0){
      cnt+=n%10;
      n/=10;
    }
    if(A<=cnt&&cnt<=B){
      sum+=i;
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3620
x,n = map(int,input().split())
if n == 0:
  print(x)
  exit()
p = list(map(int,input().split()))
if x not in p:
  print(x)
  exit()
p.sort()
for i in range(n):
  if p[i] == x:
    d = i
j = 1
while True:
  if d-j < 0:
    print(x-j)
    exit()
  if p[d-j] != x-j:
    print(x-j)
    exit()
  if d+j > n-1:
    print(x+j)
    exit()
  if p[d+j] != x+j:
    print(x+j)
    exit()
  j += 1

Measured memory_bytes: 61820
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

bool used[1001000];

void solve() {
	int n; cin >> n;
    rep(i, 1001000) {
        used[i] = 0;
    }
    set<int> se;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
        if(se.find(a[i]) != se.end()) {
            if(used[a[i]]) continue;
            used[a[i]] = 1;
            int x = a[i];
            for(int j = x; j < 1001000; j += x) {
                used[j] = 1;
            }
        }
        se.insert(a[i]);
    }
    sort(all(a));
    int ans = 0;
    rep(i, n) {
        int x = a[i];
        if(!used[x]) {
            ++ ans;
            for(int j = x; j < 1001000; j += x) {
                used[j] = 1;
            }
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 15048
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;

const int N = (int)2*1e5;
int a[N];
int n;

int main() {
	int a,b,t;
	cin>>a>>b>>t;
	cout << t / a * b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
 string s,t;
  cin>>s;
  cin>>t;
  ll cnt=0;
  ll n,m;
  n=s.size();
  m=t.size();
  
vector <ll> dis[27]{};
  
  char alp[27]={'0','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  
  rep(j, n){
    for(ll i=1;i<=26;i++){

  if(s[j]==alp[i]){
            dis[i].push_back(j+1);
    break;
    }
     
    }
  
    }
  

  ll loop=0;
  ll pre=0;
  rep(j, m){
    
       for(ll i=1;i<=26;i++){
         
  if(t[j]==alp[i]){
    ll si=dis[i].size();
    if(si==0){
      cout<<-1<<endl;
      return 0;}
      
    if(dis[i][si-1]<=pre){
      loop++;
      pre=dis[i][0];
    break;}
    if(dis[i][0]>pre){
      pre=dis[i][0];
    break;}
            
    ll li=0;
    ll re=si-1;
    for(ll k=0;k<=50;k++){
      ll aa=(li+re)/2;
    if(dis[i][aa]<=pre){
      li=aa;}
      else{
        re=aa;}
    }
    
    
    ll ke=(li+re)/2;
    
    if(dis[i][ke]<=pre){
      ke++;}
   
    pre=dis[i][ke];
    break;
  }//alp
    
    
    }
  }
    
    
    cnt=loop*n+pre;
    
    cout<<cnt<<endl;
    return 0;
    
    
 
}

Measured memory_bytes: 1724
<?php
$line = fgets(STDIN);
$symbols = preg_split('/ /', trim($line));

$stack = array();

foreach ($symbols as $symbol) {
    $val = 0;

    if (is_operator($symbol)) {
        $b = array_pop($stack);
        $a = array_pop($stack);

        $val = calculate($symbol, $a, $b);
    }
    else {
        $val = intval($symbol);
    }

    array_push($stack, $val);
}

$val = array_pop($stack);

echo "$val\n";

function is_operator($symbol)
{
    return in_array($symbol, array('+', '-', '*', '/'));
}

function calculate($op, $a, $b)
{
    switch ($op) {
    case '+':
        return $a + $b;
    case '-':
        return $a - $b;
    case '*':
        return $a * $b;
    case '/':
        return $a / $b;
    }
}

Measured memory_bytes: 6740
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;


int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    rep(i,n){
        cin >> a.at(i);
    }
    rep(j,n){
        cin >> b.at(j);
    }
    ll ans=0;
    vector<int> aa(n),bb(n);
    rep(ii,29){
        int u=pow(2,ii),k=0;
        rep(i,n) aa.at(i)=a.at(i)%(u*2);
        rep(i,n) bb.at(i)=b.at(i)%(u*2);
        sort(bb.begin(),bb.end());
        rep(i,n){
            int s=lower_bound(all(bb),u-aa.at(i))-bb.begin();
            int f=lower_bound(all(bb),2*u-aa.at(i))-bb.begin();
            (k+=f-s+2)%=2;
            int ss=lower_bound(all(bb),3*u-aa.at(i))-bb.begin();
            int ff=lower_bound(all(bb),4*u-aa.at(i))-bb.begin();
            (k+=ff-ss+2)%=2;
            //cout << f << s << ff << ss << endl;
        }
        ans+=k*u;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
// Template Headers {{{
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<long long>; using vvll = vector<vll>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}
// Preprocessing & "Global" variables {{{
struct Solver {
	Solver() {}
	int solve();
};
// }}}

int Solver::solve() {
	int h, w, k; cin >> h >> w >> k;
	vector<string> init(h);
	cin >> init;
	int ans = 0;
	for (int msx = 0; msx < 1 << h; msx++) for (int msy = 0; msy < 1 << w; msy++) {
		vector<string> noinit(init);
		for (int i = 0; i < h; i++) if ((msx >> i) & 1) {
			for (int j = 0; j < w; j++) noinit[i][j] = 'R';
		}
		for (int j = 0; j < w; j++) if ((msy >> j) & 1) {
			for (int i = 0; i < h; i++) noinit[i][j] = 'R';
		}
		int bcnt = 0;
		for (int i = 0; i < h; i++) for (int j = 0; j < w; j++)
			bcnt += noinit[i][j] == '#';
		ans += bcnt == k;
	}
	cout << ans << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	Solver solver;
	#ifdef JUDGE_MULTI_CASE
		int t; cin >> t; for (int i = 1; i <= t; i++)
	#endif
	solver.solve();
	// cout << "Case #" << i << ": ", solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 3664
a, v = map(int,input().split())
b, w = map(int, input().split())
t = int(input())
if a < b:
    A_dis = a + v*t
    B_dis = b + w*t
    if A_dis >= B_dis:
        print('YES')
    else:
        print('NO')
else:
    A_dis = a - v*t
    B_dis = b - w*t
    if A_dis <= B_dis:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 9184
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b, count = 0;
    
    cin >> a >> b;
    for(int i = a; i <= b; i++){
        string s = to_string(i);
        if(s[0] == s[4] && s[1] == s[3])
            count++;
    }
    
    cout << count << endl;
    
    return 0;
}


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

int main(int argc, char** argv)
{
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	while(true)
	{
		if((c -= b) <= 0)
		{
			puts("Yes");
			return 0;
		}
		if((a -= d) <= 0)
		{
			puts("No");
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		Reader in = new Reader();
		int n = in.nextInt();
		int m = in.nextInt();
		Graph g = new Graph(n);
		for(int i = 0; i<m; i++) {
			int a = in.nextInt()-1;
			int b = in.nextInt()-1;
			g.addEdge(a, b);
		}
		for(int i = 0; i<n; i++)g.dfs(i);
		System.out.println(g.ans);
	}

	static class Graph {
		ArrayList<Integer> con[];
		public int ans = 0;
		int[] dp;
		public Graph(int n) {
			con = new ArrayList[n];
			for (int i = 0; i < n; ++i)
				con[i] = new ArrayList();
			dp = new int[n];
			for(int i = 0; i<n; i++) dp[i] = -1;
		}

		public void addEdge(int v, int w) {
			con[v].add(w);
		}

		public int dfs(int c) {
			if(dp[c]!=-1) return dp[c];
			int max = 0;
			for (Integer v : con[c]) 
				max = Math.max(max, dfs(v)+1);
			ans = Math.max(max, ans);
			return dp[c]=max;
		}
	}

	static class Reader {
		static BufferedReader br;
		static StringTokenizer st;
		private int charIdx = 0;
		private String s;

		public Reader() {
			this.br = new BufferedReader(new InputStreamReader(System.in));
		}

		public int[] na(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public char nextChar() {
			if (s == null || charIdx >= s.length()) {
				if (st == null || !st.hasMoreTokens())
					try {
						readLine();
					} catch (Exception e) {
					}
				s = st.nextToken();
				charIdx = 0;
			}
			return s.charAt(charIdx++);
		}

		public long[] nl(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[] nca() {
			return next().toCharArray();
		}

		public String[] nS(int n) {
			String[] a = new String[n];
			for (int i = 0; i < n; i++)
				a[i] = next();
			return a;
		}

		public int nextInt() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Integer.parseInt(st.nextToken());
		}

		public double nextDouble() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Double.parseDouble(st.nextToken());
		}

		public Long nextLong() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Long.parseLong(st.nextToken());
		}

		public String next() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return st.nextToken();
		}

		public static void readLine() {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
			}
		}
	}
}

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

int main()
{
	string s;
	while(getline(cin,s)){
		for(size_t i=0;i<s.size();i++){
			s[i] = toupper(s[i]);
		}
		
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
int main(){
int q,w,e,r;
  cin >>q >>w >>e;
  vector<int> a(q);
  
  for(int s=0;s<q;s++){
  a.at(s)=0;
  }
for(int s=0;s<e;s++){
 cin >>r;
  a.at(r-1)++;
}e-=w;
  for(int s=0;s<q;s++){
if(a.at(s)>e){
cout <<"Yes"<<endl;}
    else { cout <<"No" <<endl;}
}


}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  float a,ansn,point;
  ansn=0;
  point=0;
  int B[n];
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>B[i];
    point=point+B[i];    
  }
  a=point/(4*m);
  for(int i=0;i<n;i++){
    if(B[i]>=a){
      ansn++;
    }
  }
  if(ansn>=m){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int flag=0;
  for(int i=s.size()-t.size();i>=0;i--){
    for(int j=0;j<t.size();j++){
      if(j==t.size()-1&&(s[i+j]=='?'||s[i+j]==t[j])){
	flag=1;
	//cout<<"!"<<endl;
	for(int k=0;k<t.size();k++)
	  s[i+k]=t[k];
	break;
      }
      if(s[i+j]=='?'){
	//cout<<"!"<<endl;
	continue;
      }
      if(s[i+j]!=t[j]){
	//cout<<s[i+j]<<endl;
	break;
      }
    }
    if(flag)
      break;
  }
  for(int i=0;i<s.size();i++)
    if(s[i]=='?')
      s[i]='a';
  if(flag)
    cout<<s<<endl;
  else
    cout<<"UNRESTORABLE"<<endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

ll mygcd(ll a, ll b){
    if(b == 0) return a;
    return mygcd(b, a % b);
}

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

    ll n;
    cin >> n;

    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> lg(n);
    lg[0] = a[0];
    for(int i = 1; i < n; i++){
        lg[i] = mygcd(a[i], lg[i-1]);
    }

    vector<ll> rg(n);
    rg[n-1] = a[n-1];
    for(int i = n - 2; i >= 0; i--){
        rg[i] = mygcd(a[i], rg[i+1]);
    }

    ll ans = max(rg[1], lg[n-2]);

    for(int i = 1; i <= n-2; i++){
        ans = max(ans, mygcd(lg[i-1], rg[i+1]));
    }

    cout << ans << endl;
}


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

int main() {
	string str;
        cin >> str;
        int a = 0;
        int b = 0;
        int c = 0;
        for(int i = 0; i < 3; i++){
             if(str[i] == 'a'){a +=1;}else if(str[i] == 'b'){b +=1;}else if(str[i] == 'c'){c +=1;}
        }
 
        if(a == c && b == c){
          printf("Yes\n");
        }else{printf("No\n");
        }
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dp[105][5][5][5];
signed main() {
    int N;
    cin >> N;
    for(int i = 0; i < 4; i++) {
        for(int j = 0; j < 4; j++) {
            for(int k = 0; k < 4; k++) {
                dp[2][i][j][k] = 1;
            }
        }
    }
    dp[2][0][1][2] = dp[2][0][2][1] = dp[2][1][0][2] = 0;
    for(int i = 3; i < N; i++) {
        for(int j = 0; j < 4; j++) {
            for(int k = 0; k < 4; k++) {
                int sum = dp[i-1][0][j][k]+dp[i-1][1][j][k]+dp[i-1][2][j][k]+dp[i-1][3][j][k];
                sum %= mod;
                for(int l = 0; l < 4; l++) {
                    if(j == 0 && k == 1 && l == 2) continue;
                    if(j == 0 && k == 2 && l == 1) continue;
                    if(j == 1 && k == 0 && l == 2) continue;
                    int cnt = 0;
                    if(j == 1 && k == 1 && l == 2) cnt += dp[i-1][0][1][1];
                    if(j == 3 && k == 1 && l == 2) cnt += dp[i-1][0][3][1];
                    if(j == 1 && k == 3 && l == 2) cnt += dp[i-1][0][1][3];
                    dp[i][j][k][l] = (sum+mod-cnt)%mod;
                }
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < 4; i++) {
        for(int j = 0; j < 4; j++) {
            for(int k = 0; k < 4; k++) {
                ans += dp[N-1][i][j][k];
                ans %= mod;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3668
#include<stdio.h>

void trace(int A[], int N) {
    int i;
    for ( i = 0; i < N; i++ ) {
        if ( i > 0 ) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N) {
    int j, i, v;
    for ( i = 1; i < N; i++ ) {
        v = A[i];
        j = i - 1;
        while ( j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        trace(A, N);
    }
}

int main(void){
    int N, i, j;
    int A[100];
    
    scanf("%d", &N);
    for ( i = 0; i < N; i++ ) scanf("%d", &A[i]);
    
    trace(A, N);
    insertionSort(A, N);
    
    return 0;
}



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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;


int main(){

    int num[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<num[k-1];

    return 0;

}
/*


*/


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string.h>
#define ON 1
int main() {
	int outCount=0,inningPoint=0;
	int base[3] = { 0 };
	int i,n;
	char Event[10];
	fscanf(stdin, "%d", &n),getchar();
	while (n) {
		memset(Event, '\0', sizeof(Event));
		fscanf(stdin, "%s", Event),getchar();
		if (strcmp(Event, "HOMERUN") == 0) {
			for (i = 0; i < 3; i++) inningPoint += base[i];
			inningPoint++;
			memset(base, 0, sizeof(base));
		}
		else if (strcmp(Event, "OUT") == 0) {
			 outCount++;
			 if (outCount == 3) {
				n--;
				memset(base, 0, sizeof(base));
				fprintf(stdout, "%d\n", inningPoint);
				outCount = inningPoint = 0;
			}
		}
		else if (strcmp(Event, "HIT") == 0) {
			if (base[2] == ON) inningPoint++;
			base[2] = base[1];
			base[1] = base[0];
			base[0] = ON;
		}
	}
	return 0;
}

Measured memory_bytes: 604
import itertools


n, m, x = [int(_) for _ in input().split()]
l = []
for i in range(n):
    l.append([int(_) for _ in input().split()])

# print(l)

p = []
for i in range(n):
    p.append(i)
ans = float('inf')
for i in range(1, n+1):
    for q in list(itertools.combinations(p, i)):
        flag = 0
        c = 0
        sum = [0] * m
        for j in range(len(q)):
            for k in range(m):
                # print('q[j]', q[j])
                # print('k', k)
                sum[k] += l[q[j]][k+1]
            c += l[q[j]][0]
        # print('sum', sum)
        # print('q', q)
        # print('c', c)
        for y in range(m):
            if sum[y] < x:
                flag = 1
        if flag == 0:
            ans = min(ans, c)
if ans == float('inf'):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 68444