akhauriyash/Code-Regression huggingface dataset:
import bisect

s = input()
t = input()
p = {}
for i in range(len(s)):
    c = s[i]
    if c not in p:
        p[c] = []
    p[c].append(i)

over = 0
ret = 0
for c in t:
    if c not in p:
        print(-1)
        exit(0)
    ind = bisect.bisect_left(p[c], ret)
    if ind < len(p[c]):
        ret = p[c][ind] + 1
    else:
        ret = p[c][0] + 1
        over += 1

print(over * len(s) + ret)

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

int main() {
  int n,k;
  cin >> n >> k;
  
  vector<int> h(n);
  ll ans = 0;
  rep(i,n) cin >> h[i];
  if(n<k){
      cout << 0 << endl;
      return 0;
  }
  sort(h.begin(),h.end());
  rep(i,k) h.pop_back();
  rep(i,h.size()) ans+=h[i];
  cout << ans << endl;
    return 0;
}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//library----------------------------------------------

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

const int NMAX = 100;
bool flag;

void check(string s){
    while (s.size()%2!=0){
        s.pop_back();
    }  
}

bool even_s(string s){
    bool ok=true;
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[s.size()/2+i]) ok=false;
        if(!ok) break;
    }
    return ok;
}

int main(){
    SCIN(s);
    s.pop_back();
    flag=false;
    while(!flag){
        check(s);
        flag=even_s(s);
        s.pop_back();
    }
    printf("%d\n",s.size());

    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

c = [1] * n
bl = [False] * n
bl[0] = True

for _ in range(m):
    x, y = (int(j) - 1 for j in input().split())
    c[x] -= 1
    c[y] += 1
    if bl[x]:
        if c[x] == 0:
            bl[x] = False
        bl[y] = True
    # print(x, y, c, bl)
print(bl.count(True))


Measured memory_bytes: 4596
n, m = map(int, input().split())
s = input()
t = input()

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

def lcm(x, y):
    return x // gcd(x, y) * y

g = gcd(n, m)
bl = True
for k in range(g):
    i, j = k * n // g, k * m // g
    if s[i] != t[j]: # s[i] != s[j] にしてた...
        bl = False

print(lcm(n, m)) if bl else print('-1')

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

int main(){
  int i,j,a,b,n,m,hn[100],rn[100],hm[100],rm[100],h[201],r[201],k[2],L[201],max;
  while(1){
    cin >> n;
    if(n == 0) break;
    for(i=0;i<n;i++) cin >> hn[i] >> rn[i];
    cin >> m;
    for(i=0;i<m;i++) cin >> hm[i] >> rm[i];

    a = 0;
    b = 0;
    h[0] = -1;
    r[0] = -1;
    for(i=1;i<=m+n;i++){
      if(a < n && b < m && hn[a] < hm[b] || a < n && b >= m){
	  h[i] = hn[a];
	  r[i] = rn[a++];
	}
      else{
	h[i] = hm[b];
	r[i] = rm[b++];
      }
    }

      k[0] = 0;
      L[0] = 0;
      for(i=1;i<=m+n;i++){
	max = 0;
	for(j=0;j<i;j++){
	  if(L[j] > max && h[j] < h[i] && r[j] < r[i]) max = L[j];
	}
	L[i] = max + 1;
	if(k[0] < L[i]) k[0] = L[i];
      }

      a = 0;
      b = 0;
    for(i=1;i<=m+n;i++){
      if(a < n && b < m && rn[a] < rm[b] || a < n && b >= m){
	  h[i] = hn[a];
	  r[i] = rn[a++];
	}
      else{
	h[i] = hm[b];
	r[i] = rm[b++];
      }
    }

      k[1] = 0;
      L[0] = 0;
      for(i=1;i<=m+n;i++){
	max = 0;
	for(j=0;j<i;j++){
	  if(L[j] > max && h[j] < h[i] && r[j] < r[i]) max = L[j];
	}
	L[i] = max + 1;
	if(k[1] < L[i]) k[1] = L[i];
      }

      if(k[0] > k[1]) cout << k[0] << endl;
      else cout << k[1] << endl;

  }
  return 0;
}

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

int main() {
    string S;
    int buf=0;
    vector<int> cnt;
    cin >>S;
    for(int i=0;i<S.size();i++){
        if(S.at(i)=='A'||S.at(i)=='C'||S.at(i)=='G'||S.at(i)=='T'){
            buf++;
        }else{
            cnt.push_back(buf);
            buf=0;
        }
    }
    cnt.push_back(buf);
    sort(cnt.begin(),cnt.end());
    reverse(cnt.begin(),cnt.end());
    cout << cnt.at(0) << endl;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    String res = "";
    if(a == b) {
      res = "Draw";
    } else {
      if(a == 1) {
        res = "Alice";
      } else if(b == 1) {
        res = "Bob";
      } else if(a > b) {
        res = "Alice";
      } else {
        res = "Bob";
      }
    }
    System.out.println(res);
  }
}

Measured memory_bytes: 9680
/*
 *Author - Abhas Jain
 */
 
#include <bits/stdc++.h>
 
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define endl '\n'
#define pb push_back
 
 
typedef long long ll;
typedef long double ld;
 
using namespace std;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
 
const ld PI = 3.141592653589793;
const ll INF = 9223372036854775807ll;
const ll mod = 1e9 + 7;
 
void solve() 
{
	string s;
	cin >> s;
	int n = s.length();
	ll dp[n + 1][13];
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j < 13; ++j) {
			dp[i][j] = 0;
		}
	}
	dp[n][0] = 1;
	ll cur = 1;
	ll pr = 0;
	for (int i = n - 1; i >= 0; --i) {
		if (s[i] != '?') {
			ll now = s[i] - '0';
			ll add = (now * cur) % 13;
			for (int j = 0; j < 13; ++j) {
				dp[i][(j + add) % 13] += dp[i + 1][j];
				dp[i][(j + add) % 13] %= mod;
			}
		} else {
			for (int now = 0; now <= 9; ++now) {
				ll add = (now * cur) % 13;
				for (int j = 0; j < 13; ++j) {
					dp[i][(j + add) % 13] += dp[i + 1][j];
					dp[i][(j + add) % 13] %= mod;
				}
			}
		}
		cur *= 10;
		cur %= 13;
	}
	cout << dp[0][5] << endl;
}
 
int main( )
{   
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    solve();
    return 0;
}

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

n = inp()
s = input()
t = input()
for i in range(n):
    for j in range(n-i):
        if s[i+j] != t[j]:
            break
    else:
        print(n+i)
        break
else:
    print(n*2)

Measured memory_bytes: 10352
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 200100
using namespace std;

int n,a[N],b[N],M,l,r,mid,ans,an;

inline int find(int u)
{
	int l=1,r=n+1,mid;
	for(;l<r;)
	{
		mid=((l+r)>>1);
		if(b[mid]>=u) r=mid;
		else l=mid+1;
	}
	return l;
}

int main()
{
	int i,j,p,q;
	cin>>n;
	for(i=1;i<=n;i++) scanf("%d",&a[i]);
	for(i=1;i<=n;i++) scanf("%d",&b[i]);
	for(M=(1 << 29),i=(1 << 28);M>=2;M>>=1,i>>=1)
	{
		an=0;
		for(j=1;j<=n;j++)
		{
			a[j]%=M;
			b[j]%=M;
		}
		sort(b+1,b+n+1);
		for(j=1;j<=n;j++)
		{
			an^=(((find(2*i-a[j])-find(i-a[j]))+(n-find(3*i-a[j])+1))&1);
		}
		an&=1;
		ans+=an*(M>>1);
	}
	cout<<ans;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<set>

using namespace std;

#define sz(x) (int)(x.size())
#define fr(i,a,b) for(int i=a;i<b;++i)
#define mp make_pair
typedef pair<int, int> pii;
//////////////////////

int const N = 2e5 + 41;
int const INF = 1e9 + 41;

pii t[N * 4];
int la[N * 4];
int p[N];
int n, invp[N];
int ans[N];

void push(int v){
	if(la[v]){
		la[v*2+1] ^= 1;
		la[v*2+2] ^= 1;
	}
	la[v] = 0;
}

pii getValue(int v){
	if(la[v]){
		return mp(t[v].second, t[v].first);
	}else return t[v];
}

void remin(int &a, int b){
	a = min(a, b);
}

void refresh(int v){
	t[v].first = min(getValue(v*2+1).first, getValue(v*2+2).first);
	t[v].second = min(getValue(v*2+1).second, getValue(v*2+2).second);
}

set<int> dp;

void build(int v, int tl, int tr){
	if(tl == tr){
		if(tl & 1) t[v] = mp(INF, p[tl]);
		else t[v] = mp(p[tl], INF);
	}else{
		int tm = (tl+tr)/2;
		build(v*2+1, tl, tm);
		build(v*2+2, tm+1, tr);
		refresh(v);
	}
}

void upd(int v, int tl, int tr, int l, int r){
	if(tl > r || tr < l) return;
	if(l <= tl && tr <= r){
		la[v] ^= 1;
		return;
	}
	push(v);
	int tm = (tl+tr)/2;
	upd(v*2+1, tl, tm, l, r);
	upd(v*2+2, tm+1, tr, l, r);
	refresh(v);
}

pii getMin(int v, int tl, int tr, int l, int r){
	if(tl > r || tr < l) return mp(INF, INF);
	if(l <= tl && tr <= r) return getValue(v);
	push(v);
	int tm = (tl+tr)/2;
	pii r1 = getMin(v*2+1, tl, tm, l, r);
	pii r2 = getMin(v*2+2, tm+1, tr, l, r);
	refresh(v);
	pii ret;
	ret.first = min(r1.first, r2.first);
	ret.second = min(r1.second, r2.second);
	return ret;
}

void rem(int v, int tl, int tr, int p){
	if(tl == tr){
		t[v] = mp(INF, INF);
	}else{
		push(v);
		int tm = (tl+tr)/2;
		if(p <= tm) rem(v*2+1, tl, tm, p);
		else rem(v*2+2, tm+1, tr, p);
		refresh(v);
	}
}

void solve(){
	cin >> n;
	fr(i, 0, n){
		cin >> p[i]; 
		--p[i]; 
		invp[p[i]] = i;
	}
	dp.insert(n);
	build(0, 0, n-1);
	fr(i, 0, n/2){
		int lv = getMin(0, 0, n-1, 0, n-1).first;
		int lp = invp[lv];
		int rb = (*dp.lower_bound(lp));
		int rv = getMin(0, 0, n-1, lp+1, rb-1).second;
		int rp = invp[rv];
		dp.insert(rp);
		dp.insert(lp);
		ans[i*2] = lv;
		ans[i*2+1] = rv;
		upd(0, 0, n-1, lp+1, rp-1);
		rem(0, 0, n-1, lp);
		rem(0, 0, n-1, rp);
	}
	fr(i, 0, n){
		if(i) cout << " ";
		cout << ans[i] + 1; 
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

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

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    bool ok = 0;
    rep(i, K + 1) {
        rep(j, K - i + 1) {
            int l = K - i - j;
            int a = A << i;
            int b = B << j;
            int c = C << l;
            if (a < b && b < c) {
                ok = 1;
            }
        }
    }
    cout << (ok ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 1e18;
const ll fact_table = 5000000;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
vector<pair<ll, double> > tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<"\n";
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 998244353;
//ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];
char s[500005];
vector <P> table[20];

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

    cin >> s;
    n = strlen(s);
    for(int i=0;i<n;i++){
        ll a = i;
        ll b = n - 1 - i;
        if(b >= a)continue;
        if(s[a] != s[b])ans++;
    }
    p(ans);
    return 0;
}
 

Measured memory_bytes: 26880
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    int ans;
    int mindiff = 1000000;
    int num;
    REP(i,s.length()-2){
        num = stoi(s.substr(i,3));
        //cout << num << endl;
        if(mindiff > abs(753-num))mindiff = abs(753-num);
    }
    cout << mindiff << endl;
    return 0;
}

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

int main(){
  int n,k,r,s,p;
  ll sum=0;
  char c;
  cin >> n >> k >> r >> s >>p;
  vector<char> a(k);
  for(int i=0;i<n;i++){
    cin >> c;
    if(c=='r'&&a[i]!='r') sum+=p;
    else if(c=='s'&&a[i]!='s') sum+=r;
    else if(c=='p'&&a[i]!='p') sum+=s;
    else c='x';
	a.push_back(c);
  }
  cout << sum <<endl;
}

Measured memory_bytes: 640
// This is my template for fast solving
 
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <memory>
#include <initializer_list>
#include <iomanip>
#include <stack>
#include <bitset>
#include <cstdio>
// #include <complex>
// #include <random>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;

// const ll INF = 1e18;
// const ld INF = 1e20;
const ll MOD = 998244353;
// const ld EPS = 1e-10;
// const ld PI = acos(-1);

template<typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
    os << p.first << " " << p.second;
    return os;
}

template<typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >>  p.second;
    return is;
}
 
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    bool first = true;
    for (const auto& x : v) {
        if (!first) {
            os << " ";
        }
        first = false;
        os << x;
    }
    return os;
}

template<typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& elem : v) {
        is >> elem;
    }
    return is;
}

template<typename T>
ostream& operator<<(ostream& os, const set<T>& s) {
    bool first = true;
    for (auto x : s) {
        if (!first) {
            os << " ";
        }
        first = false;
        os << x;
    }
    return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, const map<T1, T2>& m) {
    bool first = true;
    for (auto x : m) {
        if (!first) {
            os << "\n";
        }
        first = false;
        os << x;
    }
    return os;
}

void solve() {
    string s;
    cin >> s;
    if (s.length() > 5) {
        if (s[2] == s[3] && s[4] == s[5]) {
            cout << "Yes\n";
            return;
        }
    }
    cout << "No\n";
}
 
int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    // int t; // CodeJam style
    // cin >> t;
    // for (int i = 1; i <= t; ++i) {
    //     cout << "Case #" << i << ": ";
    //     solve();
    // }
 
    // int q;
    // cin >> q;
    // while (q--) {
    //     solve();
    // }

    solve();
 
    return 0;
}

Measured memory_bytes: 256
s = gets.chomp.split('')
n = s.length

num1 = ((n-1)/2)
num2 = ((n+3)/2)-1

str1 = s[0...num1]
str2 = s[num2..n]

print s == s.reverse && str1 == str1.reverse && str2 == str2.reverse ? 'Yes' : 'No'

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string>
#include <set>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    set<string> t;
    for(int i = 0; i < n; i++){
        cin >> s[i];
        t.insert(s[i]);
    }
    cout << t.size();
    return 0;
}

Measured memory_bytes: 24992
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let ch = Scanf.sscanf (read_line ()) "%c" ( fun ch -> ch)

let () =
        (
                if Char.is_lowercase ch then
                        'a'
                else
                        'A'
        ) |> Printf.printf "%c\n"


Measured memory_bytes: 5292
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int R, C, N; cin >> R >> C >> N;
    int x1, y1, x2, y2;
    vector<Pii> p1(0), p2(0), p3(0), p4(0);

    REP(i, N){
        cin >> x1 >> y1 >> x2 >> y2;
        if(!(x1 == 0 || x1 == R || y1 == 0 || y1 == C)) continue;
        if(!(x2 == 0 || x2 == R || y2 == 0 || y2 == C)) continue;
        if(x1 == 0) p1.push_back(Pii(y1, i));
        else if(x1 == R) p3.push_back(Pii(y1, i));
        else if(y1 == 0) p4.push_back(Pii(x1, i));
        else if(y1 == C) p2.push_back(Pii(x1, i));
        if(x2 == 0) p1.push_back(Pii(y2, i));
        else if(x2 == R) p3.push_back(Pii(y2, i));
        else if(y2 == 0) p4.push_back(Pii(x2, i));
        else if(y2 == C) p2.push_back(Pii(x2, i));
    }
    vec v(0);
    SORT(p1);
    SORT(p2);
    SORT(p3); REVERSE(p3);
    SORT(p4); REVERSE(p4);
    REP(i, p1.size()) v.push_back(p1[i].second);
    REP(i, p2.size()) v.push_back(p2[i].second);
    REP(i, p3.size()) v.push_back(p3[i].second);
    REP(i, p4.size()) v.push_back(p4[i].second);

    if(v.size() == 0){
        cout << "YES" << endl;
        return 0;
    }

    //REP(i, v.size()) cout << v[i] << endl;
    bool f = false;
    int n = v.size();
    vec s(0);
    REP(i, n){
        if(s.size() == 0 || v[i] != s[s.size() - 1]) s.push_back(v[i]);
        else s.pop_back();
    }
    ANS(s.size() == 0);
    
    return 0;
}

Measured memory_bytes: 7216
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
ul H, W;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ul N;
  cin >> N;
  vector<ul> A(N, 0);
  vector<ul> B(N, 0);
  vector<ll> diff(N, 0);
  ul sum = 0;
  ul sum_b = 0;
  REP(ii, N) {
    cin >> A[ii];
    sum += A[ii];
  }
  REP(ii, N) {
    cin >> B[ii];
    diff[ii] = A[ii] - B[ii];
    sum_b += B[ii];
  }
  if (sum_b > sum) {
    cout << -1 << endl;
    return 0;
  }
  sort(diff.begin(), diff.end());
  if (diff[0] >= 0) {
    cout << 0 << endl;
    return 0;
  }
  // マイナスすべてに配り終えられる正の値を評価する
  // REP(ii, N) { cout << diff[ii] << " "; }
  // cout << endl;
  ll minus_sum = 0;
  ul ans = 0;
  for (ll& tmp : diff) {
    if (tmp < 0) {
      minus_sum += tmp;
      ++ans;
    }
    if (tmp > 0) {
      break;
    }
  }
  // cout << ans << endl;
  for (auto tmp = diff.rbegin(); tmp != diff.rend(); ++tmp) {
    minus_sum += *tmp;
    ++ans;
    if (minus_sum > 0) {
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define maxn 100007
#define ll long long int
using namespace std;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}

inline void writ(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) writ(x/10);
	putchar(x%10+'0');
}
inline void write(int x){writ(x);putchar('\n');}

int main()
{
	int a=read(),b=read();
	if (abs(a-b)<=1) puts("Yay!");
	else puts(":(");
	return 0;
}

Measured memory_bytes: 256
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var s = Console.ReadLine();
		var t = s.ToArray();
		Array.Sort(t);
		var x = new string(t);
		s = Console.ReadLine();
		t = s.ToArray();
		Array.Sort(t, (a, b) => b.CompareTo(a));
		var y = new string(t);
		Console.WriteLine(x.CompareTo(y) < 0 ? "Yes" : "No");
	}
}


Measured memory_bytes: 13536
#include<cstdio>
#include<iostream>
using namespace std;
const int Maxn=110;
int n,m,ans;
bool vis[Maxn];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i)
	{
		int cnt;
		scanf("%d",&cnt);
		while(cnt--)
		{
			int x;
			scanf("%d",&x);
			vis[x]=1;
		}
	}
	for(int i=1;i<=n;++i)
	if(!vis[i])++ans;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3780
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n - 1):
        for m in range(s + 1, n):
            for e in range(m + 1, n + 1):
                if x == s + m + e:
                    count += 1

    print(count)

Measured memory_bytes: 7712
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL<<60;
const int MOD = 1000000007;
#define rev(s) (string((s).rbegin(), (s).rend()))

double dp[3010][3010];

int main () {

    int n;cin>>n;

    double p[3010];

    rep(i,n) {
        cin>>p[i];
    }

    rep(i,n) {
        rep(j,n) {
            dp[i][j]=0.0;
        }
    }

    dp[0][0]=1.0;

    rep(i,n) {
        rep(j,i+1) {
            dp[i+1][j+1]+=dp[i][j]*p[i];
            dp[i+1][j]+=dp[i][j]*(1.0-p[i]);
        }
    }

    double ans=0.0;

    for (int i=(n/2)+1;i<n+1;i++) {
        ans+=dp[n][i];
    }

    cout << fixed << setprecision(10) << ans << endl;


}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n;
    cin >> n;

    vi a(n, 0);
    rep(i, 1, n) {
        int x;
        cin >> x;
        ++a[x - 1];
    }
    rep(i, 0, n) { cout << a[i] << endl; }

    return 0;
}

Measured memory_bytes: 3988
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

i32 min (i32 a, i32 b) {
  return a < b ? a : b;
}

i64 calc (i32 *a, i32 n) {
  static i32 *tmp = NULL;
  if (tmp == NULL) {
    tmp = (i32 *) calloc (n, sizeof (i32));
  }
  if (n == 1) {
    return a[0];
  }
  i32 m = n / 2;
  i64 ans = calc (a, m) + calc (a + m, n - m);
  i32 *b = tmp;
  i32 *c = b + m;
  for (i32 i = m - 1, x = 200000; i >= 0; --i) {
    x = min (x, a[i]);
    b[m - 1 - i] = x;
  }
  for (i32 i = m, x = 200000; i < n; ++i) {
    x = min (x, a[i]);
    c[i - m] = x;
  }
  i32 p = m - 1;
  i32 q = n - m - 1;
  while (p >= 0 && q >= 0) {
    if (b[p] <= c[q]) {
      ans += (i64) (q + 1) * b[p];
      --p;
    } else {
      ans += (i64) (p + 1) * c[q];
      --q;
    }
  }
  return ans;
}

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i32 *a = (i32 *) calloc (n, sizeof (i32));
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32, a + i);
  }
  i64 ans = calc (a, n);
  printf ("%" PRIi64 "\n", ans);
}

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


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

int main() {
  int n, m; cin >> n >> m;
  for (int i =0 ;i < m; i++) {
    int t; cin >> t;
    n-=t;
  }
  if (n<0) cout << -1;
  else cout << n;
  return 0;
}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
        }
        Arrays.sort(A);
        int[] d = new int[100001];
        for (int i = 0; i < N; i++) {
            d[A[i]] += 1;
        }
        List<Integer> list = new LinkedList<>();
        for (int i = 1; i <= 100000; i++) {
            if (1 < d[i]) {
                for (int j = 0; j < d[i] - 1; j++) {
                    list.add(i);
                }
            }
        }
        int remove = 0;
        while (!list.isEmpty()) {
            list.remove(0);
            if (!list.isEmpty()) {
                list.remove(list.size() - 1);
            }
            remove += 2;
        }
        int answer = N - remove;
        System.out.println(answer);
    }
}


Measured memory_bytes: 50692
#include<bits/stdc++.h>
#define N 1000
using namespace std;
typedef long long LL;
map<LL,int>my;
LL ma[N][N];
LL short_pa[N][N];
LL d[N];
LL prim(int n,int cnt);
int main(void)
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        my.clear();
        for(int i = 1; i <= n; i++)
        {
            for(int j = 1; j <= n; j++)
            {
                scanf("%lld",&ma[i][j]);
                short_pa[i][j] = ma[i][j];
            }
        }
        for(int i = 1; i <= n; i++)
        {
            for(int j = 1; j <= n; j++)
            {
                for(int s = 1; s <= n; s++)
                {
                    short_pa[j][s] = min(short_pa[j][s],short_pa[j][i] + short_pa[i][s]);
                }
            }
        }
        bool flag = false;
        for(int i = 1; i <= n; i++)
        {
            for(int j = i; j <= n; j++)
            {
                if(short_pa[i][j]!=ma[i][j])
                    flag  = true;
            }
        }
        if(flag)
        {
            printf("-1\n");
        }
        else
        {
            LL sum = 0;
            for(int i = 1; i <= n; i++)
            {
                for(int j = i+1; j <= n; j++)
                {
                    flag = false;
                    for(int s = 1; s <= n; s++)
                    {
                        if(i!=s&&j!=s)
                        {
                            if(short_pa[i][j] == short_pa[i][s]+short_pa[s][j])
                            {   //printf("%d %d %d\n",i,j,s);
                                flag = true;
                                break;
                            }
                        }
                    }
                    if(!flag)
                        sum += short_pa[i][j];
                }
            }
            printf("%lld\n",sum);
        }

    }
    return 0;
}



Measured memory_bytes: 8064
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 2e5 + 10;

ll a[N];
ll pref[N], suff[N], sup_pref[N], sup_suff[N];

ll solve(int n, ll l);

int main() {
	fast_cin();
	ll l; int n;
	cin >> l >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	ll ans = solve(n, l);
	for (int i = 1; i <= n; ++i) {
		a[i] = l - a[i];
	}
	reverse(a + 1, a + n + 1);
	ans = max(ans, solve(n, l));
	cout << ans << endl;
}

ll solve(int n, ll l) {
	pref[0] = suff[n + 1] = 0;
	for (int i = 1; i <= n; ++i) {
		pref[i] = a[i];
	}
	for (int i = n; i >= 1; --i) {
		suff[i] = l - a[i];
	}
	sup_pref[0] = sup_suff[n + 1] = 0;
	for (int i = 1; i <= n; ++i) {
		sup_pref[i] = sup_pref[i - 1] + pref[i];
	}
	for (int i = n; i >= 1; --i) {
		sup_suff[i] = sup_suff[i + 1] + suff[i];
	}
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		ll temp = 0;
		if ((i % 2) == (n % 2)) {
			int x = i + (n - i) / 2;
			temp += 2 * (sup_pref[x - 1] - sup_pref[i - 1]) + pref[x];
			temp += 2 * sup_suff[x + 1];
		} else {
			int x = i + (n - i - 1) / 2;
			temp += 2 * (sup_pref[x] - sup_pref[i - 1]);
			temp += 2 * sup_suff[x + 1] - suff[x + 1];
		}
		ans = max(temp, ans);
	}
	return ans;
}

Measured memory_bytes: 8064
N = int(input())
A = list(map(int, input().split()))
ans = 0
i = 0
while i == 0:
    ans += 1
    for j in range(N):
        if A[j] % 2 == 0:
            A[j] = A[j] // 2
        else:
            i = 1
            break
print(ans-1)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define boost_this_bad_bitch            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll          long long int
#define pb          push_back
#define rm          pop_back
#define dis(a,b)    abs(a-b)
#define all(v)      v.begin(),v.end()
#define mp      make_pair
#define space   cout<<" "
#define line      cout<<endl
#define DEBUG    false
using namespace std;
ll a[1000][1000];
int main()
{
  ll n;
  cin>>n;
  vector<ll> v;
  ll i,a,grt=0,sum=0;
  for(i=0;i<n;i++)
  {
     cin>>a;
    if(grt<a) grt=a;
    v.pb(a);
    sum=sum+a;
  }
  if(sum-grt>grt)
    cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int X, Y;
    cin >> X >> Y;
    if(Y&1) cout << "No" << endl;
    else{
        if(Y >= 2*X && Y <= 4*X) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
//#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define S set<int>
#define itn int
bool dbg = false;
int N;
itn A[20], x[20][20], y[20][20];
void solve() {
    int ans = 0;
    for (int bit = 0; bit < ((1) << N); bit++) {
        bool flag = true;
        FOR(i, 0, N) {
            if (bit & (1 << i))
                FOR(k, 0, A[i]) {
                    if (bit & (1 << x[i][k])) {
                        if (y[i][k] == 0)
                            flag = false;
                    } else {
                        if (y[i][k] == 1)
                            flag = false;
                    }
                }
        }

        if (flag) {
            ans = max(ans, (int)bitset<16>(bit).count());
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(i, 0, N) {
        cin >> A[i];
        FOR(k, 0, A[i]) {
            cin >> x[i][k] >> y[i][k];
            x[i][k]--;
        }
    }
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
//typedef pair<double, double> dd;
#define mp make_pair
#define pb push_back
#define debug(x) cerr << #x << " = " << x << " "

/*
a+b+2(ab)^0.5 < c
(ab)^0.5 < c-a-b
c-a-b > 0 && 4ab < (c-a-b)^2

 */

int main()
{
  ll a, b, c;
  while (cin >> a >> b >> c)
    {
      bool ans = true;
      if (c-a-b>0 && 4*a*b < (c-a-b) * (c-a-b)) ans = true;
      else ans = false;
      cout << (ans?"Yes":"No") << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<tuple>
#include<functional>

using namespace std;

typedef long long ll;
typedef tuple<int, int, int> T3;

struct task {
	int a, b;
	task(int x, int y) { a = x, b = y; }
	task() = default;
};

int n, r;
vector<task> pos;
vector<T3> neg;

int main() {
	int N, K;
	cin >> N >> K;
	vector<ll> a(N);
	for (int i = 0; i < N; i++)cin >> a[i];

	vector<ll> csum(N + 1), poscsum(N + 1);
	for (int i = 0; i < N; i++)
		csum[i + 1] = csum[i] + a[i], 
		poscsum[i + 1] = poscsum[i] + (a[i] >= 0 ? a[i] : 0);

	ll ans = 0;
	for (int i = 0; i <= N - K; i++) {
		ans = max(ans, poscsum[i] + (poscsum[N] - poscsum[i + K]) + 
			(csum[i + K] - csum[i] > 0 ? csum[i + K] - csum[i] : 0));
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define MAX 128
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define bit(n) (1LL << (n))
#define int long long
const double PI = 3.141593;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double EPS = 1e-9;
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 * b / gcd(a, b); }     //最小公倍数
ll combination(ll n, ll r){if (r * 2 > n)r = n - r;ll dividend = 1;ll divisor = 1;for (ll i = 1; i <= r; ++i){dividend *= (n - i + 1);divisor *= i;}return dividend / divisor;}


signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int h, a;
  int cnt=0;
  cin >> h >> a;
  while(h>0){
    h -= a;
    cnt++;
  }
  cout << cnt << endl;

  return 0;
}

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

using namespace std;

typedef array<int, 2> duo;

const int I = INT32_MAX;

int h, w, k;
duo a, b, mv[] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

void operator += (duo& a, duo b) {a[0] += b[0], a[1] += b[1];}
void operator -= (duo& a, int v) {a[0] -= v, a[1] -= v;}

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

    cin >> h >> w >> k;
  	int dists[h + 5][w + 5];
  	char s[h + 5][w + 5];
    cin >> a[0] >> a[1] >> b[0] >> b[1];
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> s[i][j], dists[i][j] = I;
    a -= 1, b -= 1;
    queue<duo> q; q.push(a);
    dists[a[0]][a[1]] = 0;
    // BFS
    while (not q.empty()) {
        auto curr = q.front(); q.pop();
        for (int m = 0; m < 4; m++) {
            auto nxt = curr;
            int dist = dists[curr[0]][curr[1]] + 1;
            // For each Stroke
            for (int i = 1; i <= k; i++) {
                nxt += mv[m];
                // check bounds
                if (nxt[0] < 0 or nxt[0] >= h) break;
                if (nxt[1] < 0 or nxt[1] >= w) break;
                if (s[nxt[0]][nxt[1]] == '@') break;
                if (dist > dists[nxt[0]][nxt[1]]) break;
                if (dist == dists[nxt[0]][nxt[1]]) continue;
                dists[nxt[0]][nxt[1]] = dist, q.push(nxt);
            }
        }
    }
    cout << (dists[b[0]][b[1]] == I ? -1 : dists[b[0]][b[1]]) << '\n';

    return 0;
}

Measured memory_bytes: 8992
def partition(a, p, r):
  x = a[r]
  i = p-1
  for j in range(p, r):
    if a[j] <= x:
      i = i+1
      a[i], a[j] = a[j], a[i]
  a[i+1], a[r] = a[r], a[i+1]
  return i+1

n = int(input())
a = [int(i) for i in input().split()]
q = partition(a, 0, n - 1)
a[q] = f"[{a[q]}]"
print(*a)



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

using namespace std;

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif*/
    /*ios::sync_with_stdio(false);
    cin.tie(0);*/
    cout.precision(10);
    cout<<fixed;

    long double n,k,ans=0;cin>>n>>k;
    long double s=1/n,p=0.5;
    auto po=[&](int a,int b){
        int l=0,r=32;
        int res=1e9;
        while(l<=r){
            int mid=(l+r)>>1;
            if(a*pow(2,mid)>=b){
                res=min(res,mid);
                r=mid-1;
            }
            else {
                l=mid+1;
            }
        }
        return res;
    };
    for(int i=1;i<=n;i++){
        ans+=(pow(p,po(i,k)));
    }
    ans*=s;
    cout<<ans<<endl;
    //printf("%.10lf\n",ans);



    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
mod=1000000007
a=[0]*(10**5+1)
dp=[0]*(10**5+1)
for i in range(M):
    b=int(input())
    a[b]=1
dp[0]=1
for i in range(1,N+1):
    if a[i]==1:
        continue
    dp[i]+=dp[i-1]
    if i>1:
        dp[i]+=dp[i-2]
    dp[i]=dp[i]%mod
print(dp[N]%mod)


Measured memory_bytes: 13260
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> pi;
#define PI 3.14159265359
long long mod=1000000007;
//int count=INT_MAX;

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin>>t;
    //scanf("%d",&t);
    
    for(int l=0;l<t;l++){
        long long n;
        cin>>n;
        //cout<<n;
        if(n==1){
            cout<<"0";
            continue;
        }
        //int count=0;
        map<long long,int> m;
        while (n % 2LL == 0)  
        {  
            //cout << 2 << " ";  
            if(m.find(2)==m.end()) m[2]=1;
            else m[2]++;
            n = n/2LL; 
        }  
    
        for (long long i = 3; i <= sqrt(n); i = i + 2)  
        {  
            // While i divides n, print i and divide n  
            while (n % i == 0)  
            {  
                if(m.find(i)==m.end()) m[i]=1;
                else m[i]++;
                //cout << i << " ";  
                n = n/i;  
            }  
        }  
     
        if (n > 2){  
            if(m.find(n)==m.end()) m[n]=1;
            else m[n]++;
            //cout << n << " ";
        }
        int count =0;
        // for(auto it=m.begin(),it!=m.end();it++){

        // }
        for(auto x:m){
            long long v=x.first;
            int c=x.second;
            int i=1;
            //cout<<"("<<v<<" "<<c<<")";
            while(c>0){
                if(c>=i){
                    count++;
                }
                c=c-i;
                i++;
            }
        }
        cout<<count;
        m.clear();
    }
    
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
    int n;
    scanf("%d", &n);
    vector<vector<int>> a(n, vector<int>(n));
    for (auto &i: a) for (auto &j: i) scanf("%d", &j);
    vector<vector<int>> dp(n+1, vector<int>(1<<n, 0));
    dp[0][0] = 1;
    for (int i=1; i<=n; i++) {
        for (int j=0; j<(1<<n); j++) {
            int l = __builtin_popcount(j);
            if (l!=i) continue;
            for (int k=0; k<n; k++) {
                if ((j & (1<<k)) && (a[i-1][k])) {
                    int temp = j & (~(1<<k));
                    dp[i][j] += dp[i-1][temp];
                    if (dp[i][j]>=MOD) dp[i][j] -= MOD;
                }
            }
        }
    }

    printf("%d\n", dp[n][(1<<n)-1]);
}

Measured memory_bytes: 188800
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use proconio::input;
fn main() {
    input! {
        n: usize, m: i64,
        aa: [i64; n],
    }

    let bb: Vec<_> = aa.into_iter().map(|x| x/2).collect();
    // let zeros = bb[0].trailing_zeros();
    // if bb.iter().any(|&v| v.trailing_zeros() != zeros) {
    //     println!("0");
    //     return;
    // }

    let mut lcm = 1i64;
    for b in bb {
        let gcd = gcd(lcm, b);
        lcm = lcm / gcd * b;
        if (lcm / b) %2 == 0 {
            println!("0");
            return;
        }
    }
    // lcm * (2p-1) <= M  ...  p <= (M+lcm)/2lcm
    let ans = (m + lcm) / (lcm*2);
    println!("{}", ans);
}

fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

Measured memory_bytes: 4484
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n), c(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> c[i];
  rep(i,n) p[i]--;
  ll ans = -1e18;
  rep(si,n) {
    int x = si;
    vector<int> s;
    ll tot = 0;
    while (1) {
      x = p[x];
      s.push_back(c[x]);
      tot += c[x];
      if (x == si) break;
    }
    int l = s.size();
    ll t = 0;
    rep(i,l) {
      t += s[i];
      if (i+1 > k) break;
      ll now = t;
      if (tot > 0) {
        ll e = (k-(i+1))/l;
        now += tot*e;
      }
      ans = max(ans, now);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int R0, W0, C, R;
    long ans;

    while(true){
        cin >> R0 >> W0 >> C >> R;
        ans = 0;
        if(!(R0 || W0 || C || R)) break;
        while(true){
            if(R0 + ans*R - C*W0 >= 0) break;
            ans++;
        }

        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define mp make_pair
#define fi fisrt
#define se second

using namespace std;
const int N=1e6+5;
const int mod=1e9+7;
const int inf=0x3f3f3f3f3f3f3f;
int cnt;
int prim[N];
int vis[N];
int n,m;
int a[N],b[N];
int x,y;
signed main()
{
	int n;
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		int jyz,wzl;
		cin>>jyz>>wzl;
		if (jyz==wzl) a[i]=1;else a[i]=0;
	}
	for (int i=1;i<=n-2;i++) if (a[i]*a[i+1]*a[i+2]==1)
	{
		cout<<"Yes"<<endl;
		return 0;
}
cout<<"No"<<endl;
}


Measured memory_bytes: 3564
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int n, y;
int main() {
	cin >> n >> y;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			int t = n - i - j;
			if (t < 0) continue;
			if (i * 10000 + j * 5000 + t * 1000 == y) {
				cout << i << ' ' << j << ' ' << t << endl;
				return 0;
			}
		}
	}
	cout << -1 << ' ' << -1 << ' ' << -1 << endl;
	
	return 0;
}

Measured memory_bytes: 256