akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#include <set>
#include <iterator>
using namespace std;
using namespace __gnu_pbds;


#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF INT_MAX

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

typedef tree<pll, null_type, less<pll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
const int N=1e5+10, M=(ll)1e6+10 ;
const int mod = 1e9+7 ;
vl g[N];
vl vis(N,0);
// vl compute(string s){
//         vl has(s.length());
//         ll i;

//         for(i=0;i<s.length();i++){
//             if(i==0){
//                 has[i]=((s[i]-'a'+1))%mod;
//             }
//             else
//                 has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod;
//         }
//         return has;
// }
ll dfs(ll x){
  // cout << x << endl;
    vis[x]=1;
    ll c=1;
    for(auto &it:g[x]){
      if(!vis[it])
        c+=dfs(it);
    }
    return c;
 }

ll po(ll a,ll x,ll m){
    if(x==0)
      return 1;
    if(x==1)
      return a%m;
    ll z=po(a,x/2,m)%m;
    if(x&1)
      return (((z%m)*(z%m))%m*(a%m))%m;
    return (((z%m)*(z%m))%m)%m;
}
int main(){
 ios_base::sync_with_stdio(0);
 ll n,i;
 cin >> n;
 vl a(n);
for(i=0;i<n;i++)
  cin >> a[i];
ll ok=1;
for(i=0;i<n;i++){
    if(a[i]>i+1){
        ok=0;
        break;
    }
}
if(!ok){
    cout << -1;
    return 0;
}
 
 ll j;
 vl ans;
 vl b(n,0);
while(!a.empty()){
    for(j=a.size()-1;j>=0;j--){
          if(a[j]==j+1){
            ans.pb(j+1);
            // cout << j+1 << " ";
            a.erase(a.begin()+j);
            break;
        }
    }
}
 
for(i=0;i<n;i++){
    cout << ans[n-i-1] << "\n";
}
   return 0;
}

Measured memory_bytes: 3328
# -*- coding: utf-8 -*-

H, W = map(int, input().split())
HW = []
for i in range(H):
    HW.append(list(input()))

# 8方向を見に行く用の配列を準備しておく
dx = [1, 0, -1, 0, 1, -1, -1, 1]
dy = [0, 1, 0, -1, 1, 1, -1, -1]

# 各マスを周回
for i in range(H):
    for j in range(W):
        # 今いるマスが#なら何もしない
        if HW[i][j] == "#":
            continue
        # 8方向について#を数えていく
        cnt = 0
        for k in range(8):
            # 各方向にずらした位置を保持
            ni = i + dy[k]
            nj = j + dx[k]
            # index範囲外の時も何もしない
            if ni < 0 or ni >= H:
                continue
            if nj < 0 or nj >= W:
                continue
            
            if HW[ni][nj] == "#":
                cnt += 1
        HW[i][j] = cnt
# 1行ずつ文字列に変換して出力
for i in range(H):
    print("".join(map(str, (HW[i]))))

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

int main(){
  char a;
  cin >> a;
  if(a=='A'){
    cout << 'T' << endl;
  }
  else if(a=='C'){
    cout << 'G' << endl;
  }
  else if(a=='G'){
    cout << 'C' << endl;
  }
  else if(a=='T'){
    cout << 'A' << endl;
  }
}

Measured memory_bytes: 3492
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <map>

using namespace std;

#define int long long

long long MAX_PRIME = 5000;
vector<long long> primes;

typedef pair<vector<int>, int> Num;

vector<Num> nums;

void addNum(long long x)
{
	Num num = {vector<int>(0), 0};
    for (long long p : primes) {
        if (x % p) continue;
        int r = 0;
        while (x % p == 0) {
            x /= p;
            ++r;
        }
		r %= 3;
		if (r > 0) {
            num.first.push_back(p);
            num.second = num.second * 2 + (r - 1);
		}
    }

    int y = sqrt(x);
    if (x == 1) {
		nums.push_back(num);
		return;
    }
    if (y * y == x) {
		num.first.push_back(y);
        num.second = num.second * 2 + 1;
        nums.push_back(num);
    } else {
		num.first.push_back(x);
        num.second = num.second * 2;
        nums.push_back(num);
    }
}

void printNum(Num n)
{
    for (int ch : n.first) cerr << ch << ' ';
    cerr << "; " << n.second << endl;
}

signed main()
{
	// Initialize
	vector<bool> isPrime(MAX_PRIME + 1, 1);
	for (long long i = 2; i <= MAX_PRIME; ++i) {
		if (isPrime[i]) {
			primes.push_back(i);
			for (long long j = i + i; j <= MAX_PRIME; j+=i) {
                isPrime[j] = 0;
			}
		}
	}

    int n;
    cin >> n;
    nums.reserve(n);
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        addNum(x);
    }

    sort(nums.begin(), nums.end());

//    for (Num n : nums) printNum(n);
//    cerr << endl;;

    int ans = n;
    for (int i = 0; i < (int)nums.size(); ++i) {
		int si = i, ei = i;
        while (ei+1 < (int)nums.size() && nums[si].first == nums[ei+1].first) ++ei;
        i = ei;
        int bitsum = (1 << nums[si].first.size()) - 1;
//        cerr << si << ' ' << ei << endl;

		if (nums[si].first.size() == 0) {
			ans -= (ei - si);
			continue;
		}

        while (1) {
            while (si < ei && nums[si].second + nums[ei].second != bitsum) {
                if (nums[si].second + nums[ei].second < bitsum) ++si;
                else --ei;
            }
            if (si >= ei) break;

            int lc = 1, rc = 1;
            while (nums[si].second == nums[si+1].second) {
				++si;
				++lc;
            }
            while (nums[ei].second == nums[ei-1].second) {
				--ei;
				++rc;
            }

            ans -= min(lc, rc);

            ++si; --ei;
        }
    }
	cout << ans << endl;
}


Measured memory_bytes: 7168
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#define PI acos(-1.0)
using namespace std;
int main(){
	int n;
	cin >> n;
	if(n&1) cout << n/2 + 1 << endl;
	else cout << n/2;
	return 0;
}

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

int h, w;
int a[52][52];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

bool check(int aa, int b) {
	for(int i = 0; i < 4; i++) {
		int x = dx[i] + aa;
		int y = dy[i] + b;
		if(x < 0 || y < 0|| y >= w || x >= h)
			continue;
		if(a[x][y])
			return true;
	}
	return false;
}

int main() {
	cin >> h >> w;
	for(int i = 0; i < h; i++) {
		string s;
		cin >>s;
		for(int j = 0; j < w; j++) {
			if(s[j] == '#')
				a[i][j] = 1;
		}
	}
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(a[i][j])
				if(!check(i, j))
					return cout << "No", 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
from collections import deque

def dfs(s):
    stack = deque([s])
    dist[s] = 0
    while stack:
        v = stack.pop()
        for d, u in E[v]:
            if dist[u] is None:
                dist[u] = dist[v] + d
                stack.append(u)
            else:
                if dist[u] != dist[v] + d:
                    return False
    return True

N, M = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
    l, r, d = map(int, input().split())
    E[l-1].append((d, r - 1))
    E[r-1].append((-d, l - 1))
dist = [None] * N
for i in range(N):
    if dist[i] is not None:
        continue
    if not dfs(i):
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 69912
#include <bits/stdc++.h>
using std::cerr;
using std::endl;

const int N = 3005;
int n, P, ans, C[N][N], S[N][N];

inline int fpow(int x, int y, int mod) {
  int ret = 1;
  for ( ; y; y >>= 1, x = 1ll * x * x % mod)
    if (y & 1) ret = 1ll * ret * x % mod;
  return ret;
}

int main() {
  std::cin >> n >> P;
  S[0][0] = C[0][0] = 1;
  for (int i = 1; i < N; ++i) {
    C[i][0] = 1;
    for (int j = 1; j <= i; ++j) {
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % P;
      S[i][j] = (S[i - 1][j - 1] + 1ll * j * S[i - 1][j]) % P;
    }
  }
  for (int i = 0; i <= n; ++i) {
    int sum = 0, pow = fpow(2, n - i, P);
    for (int j = 0, val = 1; j <= i; ++j) {
      sum = (sum + 1ll * S[i + 1][j + 1] * val) % P;
      val = 1ll * val * pow % P;
    }
    sum = 1ll * sum * fpow(2, fpow(2, n - i, P - 1), P) % P
      * C[n][i] % P * (i & 1 ? P - 1 : 1) % P;
    ans = (ans + sum) % P;
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 58860
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
n, m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)
print(max([uf.size(i)for i in range(n)]))

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;
int cnt[256];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	FORR(c,S) cnt[c]++;
	for(int a='a';a<='z';a++) {
		if(cnt[a]==0) {
			cout<<(char)a<<endl;
			return;
		}
	}
	cout<<"None"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    for (int i = 0; i < n - 2; i++) {
        if (s.substr(i,3) == "ABC") cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn main() {
    let mut aa = i::str();
    let mut bb = i::str();
    if (aa.len() > bb.len()){
        println!("GREATER");
        return;
    }
    if (aa.len() < bb.len()){
        println!("LESS");
        return;
    }


    for xx2 in 0..(aa.len()) {
        let num1=aa.chars().nth(xx2).unwrap();
        let num2=bb.chars().nth(xx2).unwrap();
        if (num1>num2){
            println!("GREATER");
            return;
        }
        if (num1<num2){
            println!("LESS");
            return;
        }
    }

    println!("EQUAL");
}


#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }
    pub fn strv(n: usize) -> Vec<String> {
        (0..n).map(|_| str()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 2128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <complex>
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
using namespace std;
typedef long long ll;

int main(){
    int n, l;
    cin >> n >> l;
    if(l >= 0){
        /* eat apple 1 */
        cout << n*(l-1) + n*(n+1)/2 - l << endl;
    }
    else if(l+n-1 >= 0){
        /* eat apple whose flavor is 0 */
        cout << n*(l-1) + n*(n+1)/2 << endl;
    }
    else{
        /* eat apple n */
        cout << (n-1)*(l-1) + (n-1)*n/2 << endl;
    }
    return 0;
}


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

int main(){
    int N, K, ans=0;
    cin >> N >> K;
    vector<int> a(N);
    for(int i=0; i<N; i++){
	cin >> a[i];
    }
    ans = (N-1)%(K-1)!=0? (N-1)/(K-1)+1: (N-1)/(K-1);
    cout << ans << endl;
    
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vll vector<long long>
#define INF 1000000000

ll modInverse(ll a, ll m);
ll gcd(ll a, ll b);
ll power(ll x, unsigned ll y, unsigned ll m);
ll logint(ll x,ll y);


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

ll power(ll x, unsigned ll y, unsigned ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;

    return (y%2 == 0)? p : (x * p) % m;
}

ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        // q is quotient
        ll q = a / m;
        ll t = m;

        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;

        // Update y and x
        y = x - q * y;
        x = t;
    }

    // Make x positive
    if (x < 0)
       x += m0;

    return x;
}

void pairsort(ll a[],ll b[], ll n)
{
    pair<ll, ll> pairt[n];

    // Storing the respective array
    // elements in pairs.
    for (ll i = 0; i < n; i++)
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }

    // Sorting the pair array.
    sort(pairt, pairt + n);

    // Modifying original arrays
    for (ll i = 0; i < n; i++)
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}

ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<x;i++)
    {
        if(x<=a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
vector<ll>v[100001];
bool vis[100001];
ll dp[100001];
void dfs(ll n){
    vis[n] = true;
    for(auto i:v[n]){
        if(!vis[i]){
        dfs(i);}
        dp[n] = max(1+dp[i], dp[n]);
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
   memset(dp, 0, sizeof(dp));
    memset(vis, false, sizeof(vis));
    ll n, m;
    cin>>n>>m;
    REP(i, 0, m){
        ll x, y;
        cin>>x>>y;
        v[x].pb(y);
    }
    REP(i, 1, n+1){
        if(vis[i]){continue;}
        else{
            dfs(i);
        }
    }
    ll ans=0;
    REP(i, 1, n+1){
        ans = max(ans, dp[i]);
    }
    cout<<ans;

}


Measured memory_bytes: 8704
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
N = int(input())
T = {}
for _ in range(N) :
  a = int(input())
  if a not in T :
    T[a] = ""
  else :
    T.pop(a)
    
print(len(T))



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

int abs(int x){
  if(x <= 0) return (-x);
  else return(x);
}

int gcd(int a,int b){
  int c;

  if(a<b){
    a+=b;
    b=a-b;
    a-=b;
  }
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int main(void){
  int n,start_point;
  cin >> n >> start_point;

  int points[n],dist[n];

  for(int i = 0;i < n;i++){
    cin >> points[i];
    dist[i] = abs(start_point - points[i]);
  }
  int tmp = dist[0];

  for(int i = 1;i < n;i++){
    tmp = gcd(dist[i],tmp);
  }

  cout << tmp << endl;

  return 0;
}


Measured memory_bytes: 1024
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
// #include<vector>
// #include<stdio.h>
// #include <cmath>
// #include <cstdlib>
// #include <cassert>
// #include <algorithm>
// #include <set>
// #include <deque>
// #include <numeric>
// #include<tuple>
// #include <utility>
#include <map>
using namespace std;
int main(){
	int l,r,d;
	cin >> l >> r >> d;
	cout << (r/d) - ((l-1)/d) << endl; 
}

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

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    int k;
    cin >> k;
    sort(a, a + 3);
    for (int i = 0; i < k; i++) {
        a[2] *= 2;
    }
    cout << a[0] + a[1] + a[2] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC094_B solver = new ABC094_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC094_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int x = in.nextInt();
            int cost0 = 0, costN = 0;

            for (int i = 0; i < m; i++) {
                int a = in.nextInt();
                if (a < x) {
                    cost0++;
                } else {
                    costN++;
                }
            }

            out.print(Math.min(cost0, costN));
        }

    }
}



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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

void compute() {

}

int main() {
  int n;
  cin >> n;
  vector<ll> A(n), B(n);
  rep(i,n) cin >> A[i];
  rep(i,n) cin >> B[i];
  ll need = 0;
  int ans = 0;
  rep(i,n) {
    if( A[i] < B[i] ) {
      need += ( B[i] - A[i] );
      ++ans;
    }
  }
  vector<ll> vec;
  rep(i,n) {
    if( A[i] > B[i] ) {
      vec.push_back(A[i]-B[i]);
    }
  }
  sort(ALL(vec),greater<ll>());
  rep(i,(int)vec.size()) {
    if( need > 0LL ) {
      ++ans;
      need -= vec[i];
    } else break;
  }
  if( need > 0LL ) {
    puts("-1");
  } else {
    cout << ans << endl;
  }
  compute();
  return 0;
}


Measured memory_bytes: 2428
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

sys.setrecursionlimit(1000000)
dire, dire8 = [[1, 0], [0, 1], [-1, 0], [0, -1]], [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets, ALPHABETS = "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD, INF = 1000000007, float("inf")

def main():
    N = I()
    X = LI()

    ans = INF

    for p in range(1, 101):
        tmp = 0
        for x in X:
            tmp += (x - p) ** 2
        ans = min(ans, tmp)

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 77412
a = input()
b = 0
count = 0
d = 0 
e = []
flag = False
for i in a:
     if i == "A" and d == 0:
          b = count
          flag = True
          d += 1
     if i == "Z":
          e.append(count)
     count += 1
print(e[-1]-b+1)



Measured memory_bytes: 7520
#include <bits/stdtr1c++.h>

using namespace std;
#define INP "solve"
#define OUT "solve"
const int QQ = 3e5 + 10;
const int maxN = 3e5 + 10;
const int maxM = 3e5 + 10;
const int oo = 1e9;
const int module = 1e9 + 7;

void doc() {
    freopen(INP ".inp","r",stdin);
    freopen(OUT ".out","w",stdout);

}

void solve() {
    int n;
    cin >> n;
    int a[n], F[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    F[n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0; i--) F[i] = max(F[i + 1], a[i]);
    int mx = 0;
    for (int i = 0; i < n; i++) {
        int vl = (i == n - 1 ? 0 : F[i + 1]);
        cout << max(mx, vl) << '\n';
        mx = max(mx, a[i]);
    }
}
int main(int argc,char *argv[]) {
    //srand(time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //doc();
    solve();
}


Measured memory_bytes: 3200
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

bool visited[10][10];

int main() {
  int h,w;
  while(cin>>w>>h,h||w) {
    string s;
    REP(i,h)REP(j,w) {
      char c;
      cin>>c;
      s += string(1,c);
    }
    
    typedef pair<string, int> psi;
    queue<psi> Q;
    Q.push(psi(s,0));
    int ans = -1;
    while(!Q.empty()) {
      psi p = Q.front(); Q.pop();
      string s = p.first;
      int d = p.second;

      // REP(i,h) {
      //   REP(j,w) cout << s[i*w+j];
      //   cout << endl;
      // }cout << endl;

      vector<pii> v;
      queue<pii> Q2;
      Q2.push(pii(0,0));
      memset(visited,0,sizeof(visited));
      visited[0][0] = 1;
      const int dy[] = {-1,0,1,0};
      const int dx[] = {0,1,0,-1};
      char col = s[0];
      set<char> st;
      while(!Q2.empty()) {
        pii q = Q2.front(); Q2.pop();
        v.push_back(q);
        REP(i,4) {
          int yy=q.first + dy[i];
          int xx=q.second+dx[i];
          if (yy<0||yy>=h||xx<0||xx>=w) continue;
          if (visited[yy][xx]) continue;
          if (s[yy*w+xx] == col) {
            visited[yy][xx] = 1;
            Q2.push(pii(yy,xx));
          } else {
            st.insert(s[yy*w+xx]);
          }
        }
      }
      if (st.size() == 0) {
        ans = d;
        break;
      }
      FOR(it, st) {
        FOR(jt, v) {
          s[jt->first*w+jt->second] = *it;
        }
        Q.push(psi(s,d+1));
      }
    }
    cout << ans << endl;
  }
  
}

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

int main() {
ull x,y,a,ans=1;
cin >> x >> y;
a=x;
while(1) {
  a*=2;
  if(a>y) {
    break;
  }
  ans++;
}
cout << ans << endl;
}

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

int dp[M][M];
int cum[M][M];

int main()
{
    int n;
    string str;

    cin>>n>>str;

    for(int i = 1; i <= n; i++) dp[1][i] = 1, cum[1][i] = i;

    for(int i = 2; i <= n; i++)
    {
        for(int j = 1; j <= i; j++)
        {
            if(str[i-2] == '<') dp[i][j] = cum[i-1][j-1];
            else dp[i][j] = (cum[i-1][i-1]-cum[i-1][j-1]+MOD)%MOD;

            cum[i][j] = (cum[i][j-1]+dp[i][j])%MOD;
        }
    }

    int ans = cum[n][n];
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 69504
#include<stdio.h>

void check(char s[])
{

    int i, len = 0;
    char b[128];


    for(i = 0; i < 128; i++)
        b[i] = s[i];

    while(s[len])
        len++;

    for(i = 0; i < len; i++)
        s[i] = b[len - i - 1];

    s[len] = '\0';
}

int main(void)
{

    char str[128];

    scanf("%s",  str);

    check(str);

    printf("%s\n", str);

    return 0;
}

Measured memory_bytes: 524
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define endl '\n'

const int max4 = 10004;
const int maxx = 100005;
const int max6 = 1000006;
const int lg5 = 17;

const int INF = 2 * 1000000007;
const long long INFLL = 4LL * 1000000000 * 1000000000;

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

int powmod (int a, int b, int mod) {
    int res = 1; a %= mod;
    for (; b; b >>= 1) {
        if (b & 1) {
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
    }
    return res;
}
#define ll long long
ll gcd (ll a, ll b) {
    while (b > 0) {
        ll t = a % b;
        a = b, b = t;
    }
    return a;
}

int lcm (int a, int b) {
    return (a / gcd (a, b)) * b;
}

int is_prime (int n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (int i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/******Don't forget to use long long when needed!!******/

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, x;
    cin >> n;
    if (n == 1) {
        cout << "YES" << endl;
        return 0;
    }
    int even = 0, odd = 0;
    for (int i = 1; i <= n; i++) {
        cin >> x;
        even += x % 2 == 0;
        odd += x % 2 == 1;
    }
    cout << (odd % 2 == 0 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <climits>
#include <cfloat>


using namespace std;

int main()
{
	int H, W;
	scanf("%d %d", &H, &W);
	int semi[100][100];
	memset(semi, 0, sizeof(semi));
	for (int y = 0; y < H; ++y)
		for (int x = 0; x < W; ++x)
			scanf("%1d", &semi[y][x]);

	int p[100][100];
	for (int y = 0; y < H; ++y)
		for (int x = 0; x < W; ++x)
			p[y][x] = 50*50*10;
	p[0][0] = 0;
	for (int y = 0; y < H; ++y)
	{
		for (int x = 0; x < W; ++x)
		{
			p[y][x+1] = min(p[y][x+1], p[y][x] + semi[y][x+1]);
			p[y+1][x] = min(p[y+1][x], p[y][x] + semi[y+1][x]);
		}
	}
	printf("%d\n", p[H-1][W-1]);

	return 0;
}

Measured memory_bytes: 0
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back

#define eb emplace_back
#define mod   1000000007
#define PI 2*acos(0.0)
#define all(r)(r).begin(),(r).end()
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define inf 1000000000000000000
#define N 20000
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};


//=============================================ASIFAZAD==============================================//

int32_t main()
{
    io;
    ll n, k;
    cin>>n>>k;
    vll inp(n);
    for(auto& x: inp) cin>>x;
    if(k >= n)
        return cout<<0, 0;
    sort(all(inp));
    ll ans = 0;
    for(int i= 0; i< n-k; i++)
        ans += inp[i];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4776
package main

import (
    "fmt"
    "strings"
    "os"
)


var pic [][]string
var outpic [][]string
var headfoot []string

func main() {
    var H,W int
    var A string

    fmt.Scan(&H,&W)

    pic = make([][]string,H)
    for i:=0; i<H; i++ {
      pic[i] = make([]string,W)
    }

    outpic = make([][]string,H+2)
    //for i:=0; i<H; i++ {
    //  outpic[i] = make([]string,W+2)
    //}

    for i := 0; i < H; i++ {
      fmt.Scan(&A)
      if len(A) != W {
        fmt.Println("Error size wrong")
        os.Exit(0)
      }

      pic[i] = strings.Split(A,"")
    }

    //fmt.Println(pic)

    for i:=0; i < W+2; i++ {
      headfoot = append(headfoot,"#")
    }

    outpic[0] = headfoot
    for i := 0; i < H; i++ {
      outpic[i+1] = append(outpic[i+1],"#")
      outpic[i+1] = append(outpic[i+1],pic[i]...)
      outpic[i+1] = append(outpic[i+1],"#")
    }
    outpic[H+1] = headfoot


    for i:=0; i < H+2; i++ {
      fmt.Println(strings.Join(outpic[i],""))
    }


}


Measured memory_bytes: 1280
def solve():
    n = int(input())
    ans = 0
    for i in range(1, n + 1, 2):
        divider = 0
        for j in range(3, n // 3 + 1, 2):
            if i % j == 0:
                divider += 1
        if divider == 6:
            ans += 1
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 2940
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    long long N;
    cin >> N;

    vector<long long> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    sort(A.begin(), A.end());
    A.push_back(A.back() + 1);

    long long sum = 0;
    long long count = 0;

    for (int i = 0; i < N; i++) {
        sum += A[i];
        if (sum * 2 >= A[i + 1]) {
            count++;
        } else {
            count = 0;
        }
    }

    cout << count << endl;

    return 0;
}




















































































Measured memory_bytes: 1920
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int[] s = new int[n];
		
		for (int i = 0; i < n; i ++) {
			s[i]  = scanner.nextInt();
		}
		
		int q = scanner.nextInt();
		int c = 0;

		for (int i = 0; i < q; i ++) if (Arrays.binarySearch(s, scanner.nextInt()) >= 0) c ++;
		
		scanner.close();
		
		System.out.println(c);
	}
} 



Measured memory_bytes: 68008
#include <iostream>

int main()
{
    int W = 0;
    int H = 0;
    int x = 0;
    int y = 0;
    int r = 0;

    std::cin >> W >> H >> x >> y >> r;
    
    int X = W-r;
    int Y = H-r;
    
    if (r<=x && x<=X && r<=y && y<=Y)
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 3104
A,B,M=map(int,input().split())
vecA=list(map(int,input().split()))
vecB=list(map(int,input().split()))
matX=[input().split() for k in range(M)]
price = 10**6
for i in range(0,M):
    pricecom = int(vecA[int(matX[i][0]) -1]) + int(vecB[int(matX[i][1]) -1]) - int(matX[i][2])
    if pricecom<= price:
        price=pricecom
    else:
        pass
price2=int(min(vecA)) + int(min(vecB))
if price2<=price:
    price=price2
print(price)

Measured memory_bytes: 45740
// One-stroke Path

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int n, m;
int cnt;

typedef struct NODE {
    vector<int> adj;
} Node;

Node *nodes;
char *visited;

int calc() {
    int sum = 0;
    for (int j = 1; j < n + 1; j++) {
        sum += visited[j];
    }
    return sum;
}

void walk(int id) {
    if (calc() == n) {
        cnt++;
        return;
    }

    for (int i = 0; i < nodes[id].adj.size(); i++) {
        int next = nodes[id].adj[i];

        // 既に訪れていた場合
        if (visited[next] == 1) {
            continue;
        } else {
            visited[next] = 1;
            walk(next);
            visited[next] = 0;
        }
    }
}

int main() {
    cin >> n >> m;
    cnt = 0;

    nodes = (Node *)malloc(sizeof(Node) * (n+1));
    visited = (char *)malloc(sizeof(char) * (n+1));

    for (int i = 0; i <= n; i++) {
        visited[i] = 0;
    }

    int a, b;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        nodes[a].adj.push_back(b);
        nodes[b].adj.push_back(a);
    }

    visited[1] = 1;
    walk(1);

    cout << cnt << endl;

    return 0;
}


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

int main(){
   int a,b;

    while(scanf("%d %d",&a,&b) != EOF){
      int i = 0;
      a = a + b;
      while(a > 0){
      	a = a/10;
      	i++;
      }
      cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 1208
// B.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int a, b, k;
	cin >> a >> b >> k;
	int n;
	for (n = a; n < a + k && n <= b; ++n) {
		cout << n << endl;
	}
	n = max(n, b - k + 1);
	for (; n <= b; ++n) {
		cout << n << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main(){
  int N;
  cin >>N;
  vector<string> shi(N);
  cin >> shi[0];
  rep(i, N-1){
  cin >> shi[i+1];
    if(shi[i][shi[i].size()-1]!=shi[i+1][0])
    {
    cout <<"No"<<endl;
      return 0;
    }
  }
  sort(ALL(shi));
  rep(i, N-1){
  if(shi[i]==shi[i+1])
  {
    cout << "No" << endl;
    return 0;
  }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp93 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            var A = new int[2, N];

            var dp = new int[N];

            for (int i = 0; i < 2; i++) {
                var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < N; j++) {
                    A[i, j] = st[j];
                }
            }

            for (int i = 0; i < N; i++) {
                dp[N - 1] += A[0, i];
            }
            dp[N - 1] += A[1, N - 1];

            for (int i = 1; i <= N - 1; i++) {
                dp[N - 1 - i] = dp[N - 1 - (i - 1)] - A[0, N - 1 - (i - 1)] + A[1, N - 1 - i];
            }

            Console.WriteLine(dp.Max());


        }
    }
}


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

int main() {
  int N;
  string S;
  cin>>N>>S;
  vector<int> dp(N);//dp[i]＝リーダーがiの時の向く方向を変える人数
  
  //dp[0]を計算する
  for(int i=1;i<N;++i){
    if(S[i]=='E') dp[0]++;
  }
  
  int ans=dp[0];
  for(int i=1;i<N;++i){
    dp[i]=dp[i-1];
    if(S[i-1]=='W') dp[i]++;
    if(S[i]=='E') dp[i]--;
    ans = min(ans,dp[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1796
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N, A[1<<18];
pair<int, int> dp1[1 << 18];
int dp2[1 << 18];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(msk, 0, 1 << N) cin >> A[msk];

    dp1[0] = { 0, 0 };

    rep(msk, 1, 1 << N) {
        vector<int> v;
        v.push_back(msk);
        rep(i, 0, N) if (msk & (1 << i)) {
            v.push_back(dp1[msk - (1 << i)].first);
            v.push_back(dp1[msk - (1 << i)].second);
        }
        sort(all(v));
        v.erase(unique(all(v)), v.end());
        sort(all(v), [&](int a, int b){ return A[a] > A[b]; });
        dp1[msk].first = v[0];
        dp1[msk].second = v[1];
    }

    rep(msk, 1, 1 << N) dp2[msk] = A[dp1[msk].first] + A[dp1[msk].second];
    rep(msk, 2, 1 << N) chmax(dp2[msk], dp2[msk - 1]);

    rep(msk, 1, 1 << N) printf("%d\n", dp2[msk]);
}


Measured memory_bytes: 7168
import java.math.*

fun main(args: Array<String>) {
    val (H, W) = readInputLine().split(" ").map { it.toInt() }
    val AArr = Array(H) { readInputLine().split(" ").map { it.toInt() }.toIntArray() }
    val BArr = Array(H) { readInputLine().split(" ").map { it.toInt() }.toIntArray() }

    val diffArr = Array(H) { h -> IntArray(W) { w -> Math.abs(AArr[h][w] - BArr[h][w]) } }
    
    val dp = Array(H) { Array(W) { BooleanArray(6500) }}
    dp[0][0][diffArr[0][0]] = true

    for (i in 0 until H) {
        for (j in 0 until W) {
            for (k in 0 until 6400) {
                if (!dp[i][j][k]) {
                    continue
                }
                if (i != H - 1) {
                    dp[i + 1][j][k + diffArr[i + 1][j]] = true
                    dp[i + 1][j][Math.abs(k - diffArr[i + 1][j])] = true
                }
                if (j != W - 1) {
                    dp[i][j + 1][k + diffArr[i][j + 1]] = true
                    dp[i][j + 1][Math.abs(k - diffArr[i][j + 1])] = true
                }
            }
        }
    }
    
    for (i in 0 until 6400) {
        if (dp[H - 1][W - 1][i]) {
            println(i)
            return
        }
    }
}

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


Measured memory_bytes: 87972
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]

def main():
    a, b = MII()
    cnt = 0
    for i in range(a, b+1):
        if str(i) == str(i)[::-1]: cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
j=0 ;bef=-1
for i in range(n):
    if bef!=A[i]:j=0
    if A[i]==B[i]:
        
        while j<n:
            if A[i]!=B[j] and A[i]!=A[j]:
                B[i],B[j]= B[j],B[i]
                break
            j+=1
        else:
            print("No");exit()
    bef=A[i]

print("Yes")
print(*B)


Measured memory_bytes: 114828
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define ROF(i,a,b) for (int i = (b-1); i >= a; --i)
#define REP(i,a,b) for (int i = a; i <= b; ++i)
#define PER(i,a,b) for (int i = b; i >= a; --i)
#define F0R(i,b) FOR(i,0,b)
#define R0F(i,b) ROF(i,0,b)
#define R1P(i,b) REP(i,1,b)
#define P1R(i,b) PER(i,1,b)
using namespace std;

const int N = 2e5+10;

int n, k, a[N], s[N];

signed main() {
	cin >> n >> k;
	FOR(i,0,n) cin >> a[i];
	FOR(_,0,min(k,50ll)) {
		FOR(i,0,n) s[i] = 0;
		FOR(i,0,n) s[max(0ll,i-a[i])]++, s[min(n+1, i+a[i]+1)]--;
		FOR(i,1,n) s[i] += s[i-1];
		FOR(i,0,n) a[i] = s[i];
	}
	FOR(i,0,n) cout << a[i] << ' '; cout << endl;
}

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

using namespace std;

using ll = long long;

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    for (int k = 1; k <= N; ++k) {
        ans += N/k*(1+N/k)*k/2;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
ll factorial(ll a){return a < 2 ? 1 : factorial(a - 1) * a;}
ll summation(ll a){return a < 1 ? 0 : (a * a + a) / 2;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const string ALPHABETS = "abcdefghijklmnopqrstuvwxyz";
ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
//ll dx[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
ll n, m, x, y, z, w, h;
string s, t;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> m){
        ll ans = 0, tmp = 0, cnt = 0, mx = -INF, mn = INF;
        ll a[] = {}, b[] = {}, c[] = {};
        vll v;
        if(n * m <= 0){
            print("Zero");
        }else{
            if(n < 0){
                print(abs(n - m) % 2 ? "Positive" : "Negative");
            }else{
                print("Positive");
            }
        }
    }
}


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

using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;

std::vector<u64> divisors(u64 n) 
{
	std::vector<u64> ret;
    for (u64 i=1; i<=std::sqrt(n); i++) 
    { 
        if (n%i == 0) 
        {
			ret.push_back(i);
            if (n/i == i)
			{
				ret.push_back(i);
			}
            else
			{
				ret.push_back(i);
				ret.push_back(n/i);
			}
        } 
    }

	return ret;
}

std::vector<u64> intersection(std::vector<u64> &v1,
                             std::vector<u64> &v2){
    std::vector<u64> v3;

    std::sort(v1.begin(), v1.end());
    std::sort(v2.begin(), v2.end());

	auto last1 = std::unique(v1.begin(), v1.end());
	v1.erase(last1, v1.end()); 

	auto last2 = std::unique(v2.begin(), v2.end());
	v2.erase(last2, v2.end()); 

    std::set_intersection(v1.begin(),v1.end(),
                          v2.begin(),v2.end(),
                          back_inserter(v3));
    return v3;
}

u64 gcd(u64 a, u64 b){
    return b == 0 ? a: gcd(b, a%b);
}

int main()
{
	std::ios_base::sync_with_stdio(0);
	
	u64 a, b;

	std::cin >> a >> b;

	std::vector<u64> divs_a = divisors(a);
	std::vector<u64> divs_b = divisors(b);

	std::vector<u64> common = intersection(divs_a, divs_b);

	u64 res = 0;

	for(u64 i=0; i<common.size(); i++)
	{
		for(u64 j=0; j<common.size(); j++)
		{
			if(i==j) continue;
			if(common[i] == 0 || common[j] == 0) continue;
			if(gcd(common[i], common[j]) == 1)
			{
			}
			else
			{
				common[j] = 0;
			}
		}
	}

	for(u64 i=0; i<common.size(); i++)
	{
		if(common[i] != 0) {
			res++;
		}
	}

	std::cout << res << "\n";
	
	return 0;
}

Measured memory_bytes: 512
def main():
    N, *XL = map(int, open(0).read().split())
    # print(N, XL)
    robots = [0]*N
    for i in range(N):
        X, L = XL[2 * i + 0], XL[2 * i + 1]
        robots[i] = (X - L, X + L)
    robots.sort(key=lambda x: x[1])
    # print(robots)
    ans = 0
    last = robots[0][0] - 1
    for robot in robots:
        if last <= robot[0]:
            last = robot[1]
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 26004