akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main implements Runnable {

    private void solve() throws IOException {

        long N = nextLong();
        long M = nextLong();

        long low = 0L;
        long high = 1_000_000_000_000_00L;

        long best = 0L;
        while(low <= high) {
            long mid = low + ( high - low ) / 2L;
            if(can(mid, N , M)) {
                best = Math.max(best, mid);
                low = mid + 1;
            } else high = mid - 1;
        }
        writer.println(best);
    }

    private boolean can(long packs, long n, long m) {
        if(m / 2 < packs) return false;
        m -= packs * 2L;
        if(n >= packs) return true;
        long need = 0L;
        if(n < packs) {
            need += (packs - n) * 2L;
        }
        return m >= need;
    }

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

    BufferedReader reader;
    //    BufferedReader reader2;
    StringTokenizer tokenizer;
    PrintWriter writer;
    //    BufferedWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
//            reader = new BufferedReader(new FileReader("highcard.in"));
            //            reader2 = new BufferedReader(new FileReader("1.in"));
            tokenizer = null;
            writer = new PrintWriter(System.out);
//            writer = new     PrintWriter("highcard.out");
//                                                    writer = new BufferedWriter(System.out);
            //                        writer = new BufferedWriter(new OutputStreamWriter(System.out));
            solve();
            reader.close();
            //            reader2.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    short nextShort() throws IOException {
        return Short.parseShort(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }

        return tokenizer.nextToken();
    }

}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int MAXN = 100005;

int n, m;
vector<pi> gph[MAXN];
bool vis[MAXN], bad;
int col[MAXN];

void dfs(int x, int c){
	if(vis[x]){
		if(col[x] != c) bad = 1;
		return;
	}
	vis[x] = 1;
	col[x] = c;
	for(auto &i : gph[x]) dfs(i.second, c + i.first);
}
int main(){
	scanf("%d %d",&n,&m);
	for(int i=0; i<m; i++){
		int s, e, x; scanf("%d %d %d",&s,&e,&x);
		gph[s].emplace_back(x, e);
		gph[e].emplace_back(-x, s);
	}
	for(int i=1; i<=n; i++){
		if(!vis[i]){
			dfs(i, 0);
		}
	}
	puts(!bad ? "Yes" : "No");
}


Measured memory_bytes: 11136
from collections import defaultdict
import sys
input = sys.stdin.readline

class UnionFind:
    def __init__(self, N):
        self.parent = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def find(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
            self.size[y] += self.size[x]
        else:
            self.parent[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

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

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

N, M = map(int, input().split())
a = list(map(int, input().split()))
uf = UnionFind(N)
for _ in range(M):
    x, y = map(int, input().split())
    uf.unite(x, y)
group = defaultdict(list)
for i in range(N):
    group[uf.find(i)].append(a[i])
if len(group) == 1:
    print(0)
    exit()
ans = 0
rem = []
for k, v in group.items():
    v.sort()
    ans += v[0]
    rem += v[1:]
if len(rem) < len(group) - 2:
    print('Impossible')
else:
    rem.sort()
    ans += sum(rem[:len(group) - 2])
    print(ans)

Measured memory_bytes: 93112
chomp($n=<>);
@a=split//,$n;
%hash=();
foreach (@a){
    $hash{$_}++;
}

foreach (keys %hash){
    if($hash{$_} % 2 == 1){
        $flg=1;
    }
}
if($flg==1){
    print "No";
}else{
    print "Yes";
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main() {
	int n;
	cin >> n;

	cout << n / 2 + n % 2 << endl;

	return 0;
}

Measured memory_bytes: 3628
/*
* author: pavveu
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int,int>;
using graph = vector<vi>;

#define FOR(name__, upper__) for (int name__ = 0; name__ < (upper__); ++name__)
#define all(x) begin(x), end(x)
#define mp make_pair
#define mt make_tuple

using T = int;
struct pt {
	T x, y;
	pt(T xx, T yy) : x(xx), y(yy) {}

};
pt operator+(pt a, pt b) { return pt(a.x + b.x, a.y + b.y); }
pt operator-(pt a, pt b) { return pt(a.x - b.x, a.y - b.y); }

void go() {
	int n; cin >> n;
	vector<pt> points;

	FOR(i, n) {
		T x, y;
		cin >> x >> y;
		points.emplace_back(x, y);
	}

	struct manhattan_comp1 {
		bool operator()(pt a, pt b) {
			return a.x + a.y < b.x + b.y;
		}
	};

	struct manhattan_comp2 {
		bool operator()(pt a, pt b) {
			return a.x - a.y < b.x - b.y;
		}
	};

	vector<pt> sorted1(points);
	sort(all(sorted1), manhattan_comp1());

	vector<pt> sorted2(points);
	sort(all(sorted2), manhattan_comp2());

	T ans1 = abs(sorted1.front().x - sorted1.back().x) + abs(sorted1.front().y - sorted1.back().y);
	T ans2 = abs(sorted2.front().x - sorted2.back().x) + abs(sorted2.front().y - sorted2.back().y);

	cout << std::max(ans1, ans2) << endl;
}


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

	go();

	return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
//const ll INF = 1LL<<60;
int INF = numeric_limits<int>::max();

int main(int, char**) {
	string t; cin >> t;
	int n = t.size();
	int ret = INF;
	for (char c='a'; c<='z'; c++) {
		int ma = 0;
		int cnt = 0;
		for (int i=0; i<n; i++) {
			cnt++;
			if (t[i]==c) {
				ma = max(ma, cnt - 1);
				cnt = 0;
			} else if (i==n-1) {
				ma = max(ma, cnt);
			}
		}
		ret = min(ret, ma);
	}
	cout << ret << endl;
	return 0;
}


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

int main(){
    int a, b;
    cin>>a>>b;
    if(a==1){
        a=14;
    }
    if(b==1){
        b=14; 
    }
    if(a<b){
        cout<<"Bob"<<endl;
    }
    else if(a>b){
        cout<<"Alice"<<endl;
    }
    else{
        cout<<"Draw"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
use std::collections::BTreeMap;

const MOD: u64 = 1e9 as u64 + 7;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: u64 = sc.read();
    let mut map = BTreeMap::new();
    println!("{}", solve(n, n, &mut map));
}

fn solve(sum: u64, xor: u64, map: &mut BTreeMap<(u64, u64), u64>) -> u64 {
    if sum == 0 {
        return 1;
    }
    if let Some(&ans) = map.get(&(sum, xor)) {
        return ans;
    }
    let mut result = 0;

    // odd + odd
    if sum >= 2 {
        result += solve((sum - 2) >> 1, xor >> 1, map);
    }

    // even + even
    result += solve(sum >> 1, xor >> 1, map);

    // odd + even
    if sum > 0 {
        result += solve((sum - 1) >> 1, xor >> 1, map);
    }
    map.insert((sum, xor), result % MOD);
    result % MOD
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

#define INF int(1e9) 
#define rep(i,n) for(int i=0;i<(n);++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=2005;
int n,ans=INF,sum;
char s[maxn];
vector<int>edge[maxn];
int low[maxn],high[maxn],sz[maxn];

void dfs(int x,int p,int d){
	low[x]=high[x]=sz[x]=0;
	rep(i,edge[x].size()){
		int y=edge[x][i];
		if(y==p)continue;
		dfs(y,x,d+1);
		sz[x]+=sz[y];
		int nlow,nhigh;
		nhigh=high[x]+high[y]+sz[y];
		if(low[x]<=low[y]+sz[y]){
			if(high[x]>=low[y]+sz[y])nlow=nhigh&1;
			else nlow=low[y]+sz[y]-high[x];
		} 
		else{
			if(high[y]+sz[y]>=low[x])nlow=nhigh&1;
			else nlow=low[x]-(high[y]+sz[y]);
		}
		low[x]=nlow;
		high[x]=nhigh;
	}
	if(s[x]-'0'==1){
		sz[x]++;
		sum+=d;
	}
}

int main(){
	scanf("%d%s",&n,s+1);
	REP(i,n-1){
		int u,v;
		scanf("%d%d",&u,&v);
		edge[u].pb(v);
		edge[v].pb(u);
	}
	REP(i,n){
		sum=0;
		dfs(i,0,0);
		if(low[i]==0)ans=min(ans,sum/2);
	}
	printf("%d\n",ans==INF?-1:ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <vector>
using namespace std;
map<int, int> ct;
map<int, int> ct2;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPS 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define AFOR(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 100005
int n, m, l;
int a, b, c;
string s[MN];
string str;
string ans;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

/*
int N;
cin >> N;
vi vect(N);
FOR(i,N) cin >> vec.at(i);*/
//sort(vec.begin(),vec.end());
//vvi data(N,vi(4));


/*	int bfs(int x, int y,vvi &A,vvi flag) {
		queue<pii> que;
		que.push(pii(x, y));
		while (que.size()) {
			pii p = que.front(); que.pop();
			AFOR(i, 4) {
				int nx = p.first + dx[i]; int ny = p.second + dy[i];
				if (0 <= nx && nx < N && 0 <= ny && ny < N) {
					if (A.at(p.first).at(p.second) + flag.at(p.first).at(p.second) < A.at(nx).at(ny)) {
						A.at(nx).at(ny) = A.at(p.first).at(p.second) + flag.at(p.first).at(p.second);
						que.push(pii(nx, ny));
					}
				}
			}
		}
		return 0;
	}
	*/
	/*int gcd(int p, int q){
		while(q != 0){
		int r = p % q;
		p = q;
		q = r;
		}
	return p;
	}*/
int N;
int A[200100];
int L[200100];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int K;
	cin >> K >> N;
	
	AFOR(i, N) {
		cin >> A[i];
	}
	int ans = A[1]-A[0];
	AFOR(i, N - 2) {
		ans = max(A[i+2]-A[i + 1], ans);
	}
	ans = max(A[0] + K - A[N - 1], ans);

	cout << K-ans << endl;

	return 0;
}

Measured memory_bytes: 1792
from itertools import groupby
# from time import time

N, K = map(int, input().split())
S = input()
# N, K = 10**5, 10**5
# S = ['0', '1']*10**5
# start = time()
val_list = []
id_list = []
count = 0
for k, g in groupby(S):
    id_list.append(count)
    val_list.append(k)
    lg = len(list(g))
    count += lg
id_list.append(count)
# print(id_list)
num_sec = len(id_list)
if num_sec == 1:
    print(N)
else:
    m = 0
    end = 0
    for i in range(num_sec):
        if end == num_sec - 1:
            break
        if val_list[i] == '1':
            # print('1')
            end = min(i+2*K+1, num_sec - 1)
            v = id_list[end] - id_list[i]
            # print('  ', v)
            m = max(m, v)
        elif i == 0:
            # print('0')
            end = min(i+2*K, num_sec - 1)
            v = id_list[end] - id_list[i]
            # print('  ', v)
            m = max(m, v)
    print(m)
    # print(time() - start)


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

int main() {
    int n;
    cin >> n;

    set<int> s;
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;
        s.insert(d);
    }

    cout << s.size() << endl;
}

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

int N, L;
string s[110];

int main() {
  cin >> N >> L;
  for (int i=0; i<N; i++) cin >> s[i];
  // 文字列を昇順に並び替え、前から順に出力していく
  //sort(s, s+N);
  // バブルソートで文字列を昇順に並び替える
  for (int i=0; i<N-1; i++) {
    for (int j=N-1; j>i; j--) {
      if (s[j-1] > s[j]) {
        swap(s[j-1], s[j]);
      }
    }
  }
  // 昇順に並んでいるので、前から出力していく
  for (int i=0; i<N; i++) {
    cout << s[i];
  }
  cout << endl;
  return 0;
}


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

int n;
string s;

bool exists(int k) {
  map<string, vector<int>> mp;
  for (int i = 0; i <= n - k; ++i) {
    mp[s.substr(i, k)].push_back(i);
  }
  
  for (auto&& p : mp) {
    auto&& v = p.second;
    if (v.back() - v.front() >= k) return true;
  }
  return false;
}

int main() {
  cin >> n >> s;
  
  int lo = 0;
  int hi = n + 1;
  while (hi - lo > 1) {
    int mid = (lo + hi) / 2;
    if (exists(mid)) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  cout << lo << endl;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;



void solve(){
	ll a,b,c;
	cin>>a>>b>>c;
	ll x,y;
	cin>>x>>y;
	ll aa,bb,cc;
	aa=x*a+y*b;
	bb=max(x,y)*2*c;
	cc=min(x,y)*2*c+(max(x,y)==x)*(x-y)*a + (max(x,y)==y)*(y-x)*b;
	cout<<min({aa,bb,cc});
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	//ll t;cin>>t;while(t--)
	solve();

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a[4]={0};
	int b[4]={0};
	int p1,p2,p3,p4;
	p1=0;
	p2=0;
	p3=0;
	p4=0;
	for(int i=1;i<4;i++){
		cin>>a[i]>>b[i];
		if(a[i]==1){
			p1++;
		}
		else if(a[i]==2){
			p2++;
		}
		else if(a[i]==3){
			p3++;
		}
		else if(a[i]==4){
			p4++;
		}
		if(b[i]==1){
			p1++;
		}
		else if(b[i]==2){
			p2++;
		}
		else if(b[i]==3){
			p3++;
		}
		else if(b[i]==4){
			p4++;
		}


	}
	if(p1==0||p2==0||p3==0||p4==0){
		cout<<"NO"<<endl;
	}else if(p1>=3||p2>=3||p3>=3||p4>=3){
		cout<<"NO"<<endl;
	}
	else{
		cout<<"YES"<<endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 100000;
int main()
{
  int n,i,t=-1,res;
  long long a[N_MAX],s=0;
  cin >> n;
  for(i=0;i<n;i++)
    cin >> a[i];
  sort(a,a+n);
  for(i=0;i<n-1;i++){
    s+=a[i];
    if(s*2<a[i+1])
      t=i;
  }
  res=n-1-t;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long
#define  debug      printf("Come here!")
#define  inf        1000000000000000000
#define  pb         push_back
#define  mp         make_pair
#define  sz(a)      a.size()
#define  mem(a,b)   memset(a,b,sizeof(a))
#define  clr(x)     x.clear()
#define  ff         first
#define  ss         second
#define  case(x)    cout << "Case " << x <<": "

#define  md         1000000007
#define  pi         acos(-1.0)
#define  cos(a)     cos(a*pi/180)
#define  sin(a)     sin(a*pi/180)
#define  tan(a)     tan(a*pi/180)
#define  cosi(a)    acos(a)/(pi/180)
#define  sini(a)    asin(a)/(pi/180)
#define  tani(a)    atan(a)/(pi/180)

#define  vl         vector <ll>
#define  vs         vector <string>
#define  vc         vector <char>
#define  vpll       vector < pair <ll, ll> >
#define  vpsl       vector < pair <string, ll> >
#define  vpls       vector < pair <ll, string> >
#define  pql        priority_queue<ll>
#define  minpql     priority_queue<ll,vector<ll>,greater<ll> >

#define  setbits(x)     __builtin_popcountll(x)
#define  zerobits(x)    __builtin_ctzll(x)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}

/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/

int main()
{
    fastt;
    ll n, m, k, i, j, x, y, c, d, p=0, h, f=0, ff=0;
    cin>>n>>m;
    string s;
    vs v, a;
    for(i=0; i<n; i++){
        cin>>s;
        v.pb(s);
    }
    for(i=0; i<m; i++){
        cin>>s;
        a.pb(s);
    }

    for(i=0; i<n-m+1; i++){
        for(j=0; j<n-m+1; j++){
            f=0;
            for(k=i, c=0; c<m; k++, c++){
                for(h=j, d=0; d<m; h++, d++){
                    if(v[k][h]!=a[c][d]){
                        f=1;
                        break;
                    }
                }
                if(f==1)break;
            }
            if(f==0){
                ff=1;
                break;
            }
        }
        if(ff==1)break;
    }
    if(ff==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}



Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	char s[1001];
	int w;
	scanf("%s", s);
	scanf("%d",&w);

	for(int i=0;i<strlen(s);i++){
		if(i%w==0){
			printf("%c", s[i]);
		}
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

double dp[3010][3010];

void solve() {
  ll N;
  cin >> N;
  vector<double> p(N);
  rep (i, N) cin >> p[i];

  rep (i, 3010) rep (j, 3010) dp[i][j] = 0;
  dp[0][0] = 1;

  for (ll i = 0; i < N; i++) {
    for (ll j = 0; i + j < N; j++) {
      dp[i+1][j] += dp[i][j] * p[i + j];
      dp[i][j + 1] += dp[i][j] * (1.0 - p[i + j]);
    }
  }

  double ans = 0;
  for (ll i = N / 2 + 1; i <= N; i++) {
    ans += dp[i][N-i];
  }

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 71168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

ll MAX_H=1010;
ll MAX_W=1010;
vector<vector<ll>> Way(MAX_H, vector<ll>(MAX_W, INF));
vector<vector<char>> S(MAX_H, vector<char>(MAX_W));
ll CH, CW, DH, DW;
ll H, W;
priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> Q;

void init(ll h, ll w){
  rep(i,h){
    rep(j, w){
      Way[i][j]=INF;
    }
  }
}

void update(ll h, ll w, ll q){
  //if(h==1&&w==4)cout<<h<<" "<<w<<" "<<Q<<endl;
  if(S[h][w]!='.')return;
  if(Way[h][w]>q){
    Way[h][w]=q;
    Q.push(make_pair(q, h*W+w));
    //cout<<h<<" "<<w<<" "<<q<<endl;
    return;
  }
  return;
}


void calc(ll h, ll w){
  if(h>0){
    update(h-1, w, Way[h][w]);
  }
  if(w>0){
    update(h, w-1,Way[h][w]);
  }
  if(h<H-1){
    update(h+1, w, Way[h][w]);
  }
  if(w<W-1){
    update(h, w+1, Way[h][w]);
  }
  for(ll i=-2; i<=2; i++){
    for(ll j=-2; j<=2; j++){
      ll hh=h+i;
      ll ww=w+j;
      if(hh<0||hh>=H||ww<0||ww>=W)continue;
      update(hh, ww, Way[h][w]+1);
    }
  }
}


int main(){
  cin>>H>>W;
  cin>>CH>>CW>>DH>>DW;
  CH--; CW--; DH--; DW--;
  rep(i, H){
    rep(j, W){
      cin>>S[i][j];
    }
  }
  //init(H, W);
  	Q.push(make_pair(0, CH*W+CW));
  	Way[CH][CW]=0;
  	vector<ll> Used(H*W+10, INF);
   while(!(Q.empty())){
     pair<ll, ll> R=Q.top();
     Q.pop();
     calc(R.second/W, R.second%W);
   }
  
  
  
  if(Way[DH][DW]==INF){
    cout<<-1<<endl;
    return 0;
  }
  /*rep(i, H){
    rep(j, W){
      cout<<Way[i][j]<<" ";
    }
    cout<<endl;
  }*/
  cout<<Way[DH][DW]<<endl;
  return 0;
}

Measured memory_bytes: 20444
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, m, a;
long long s;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a;
        s += a;
    }
    if (s > n) cout << -1 << E;
    else {
        cout << n - s << E;
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>
int i,j,k,l[100],m,n;
int a[100];
int d;
int main(void){
while(scanf("%d%d",&m,&n),(m || n)){
for(i=0;i<n;i++)a[i]=i+1;
for(i=0;i<m*n;i++)if(scanf("%d",&j),j)l[i%n]++;
i=n;
while(i){
i--;
j=l[i];
m=a[i];
k=i;
//for(d=0;d<n;d++)printf("%d ",l[d]);
//putchar('\n');
//for(d=0;d<n;d++)printf("%d ",a[d]);
//putchar('\n');
while(k+1<n&&l[k+1]>j){
l[k]=l[k+1];
a[k]=a[k+1];
k++;
//for(d=0;d<n;d++)printf("%d ",l[d]);
//putchar('\n');
//for(d=0;d<n;d++)printf("%d ",a[d]);
//putchar('\n');
}
l[k]=j;
a[k]=m;
//for(d=0;d<n;d++)printf("%d ",l[d]);
//putchar('\n');
//for(d=0;d<n;d++)printf("%d ",a[d]);
//putchar('\n');
}
for(i=0;i<n;i++)printf("%d \0%d\n"+((n-i-1)?0:4),a[i]);
memset(l,0,sizeof(int)*n);
memset(a,0,sizeof(int)*n);
}
return 0;
}

Measured memory_bytes: 608
#[allow(dead_code)]
const MOD: usize = 1_000000000 + 7;

fn main() {
    let mut cin = Scanner::new();
    let n = cin.next_usize();
    let k = cin.next_usize();
    let mut p = vec![(0,0); n];
    for i in 0..n {
        let a = cin.next_i64();
        let b = cin.next_i64();
        p[i] = (a,b);
    }

    let mut ans = std::i64::MAX;
    p.sort();
    for i in 0..n {
        for j in 0..n {
            let b = std::cmp::min(p[i].1, p[j].1);
            let t = std::cmp::max(p[i].1, p[j].1);
            let mut l = 0;
            let mut r = 0;
            let mut cnt = 0;
            while r < n {
                while r < n && cnt < k {
                    if p[r].1 >= b && p[r].1 <= t {
                        cnt += 1;
                    }
                    r += 1;
                }
                if cnt < k { break; }
                ans = std::cmp::min(ans, (t-b)*(p[r-1].0-p[l].0));
                if p[l].1 >= b && p[l].1 <= t {
                    cnt -= 1;
                }
                l += 1;
            }
        }
    }
    println!("{}", ans);
}


struct Scanner {
    reader: std::io::Stdin,
    tokens: std::collections::VecDeque<String>,
}

impl Scanner {
    fn new() -> Self {
        Scanner {
            reader: std::io::stdin(),
            tokens: std::collections::VecDeque::new(),
        }
    }

    fn next(&mut self) -> String {
        if self.tokens.is_empty() {
            let mut s = String::new();
            loop {
                self.reader.read_line(&mut s).ok();
                let s = s.trim();
                if s.len() != 0 {
                    for it in s.split_whitespace() {
                        self.tokens.push_back(it.into())
                    }
                    break;
                }
            }
        }
        self.tokens.pop_front().unwrap()
    }

    fn next_generics<T>(&mut self) -> T where
        T: std::str::FromStr + std::marker::Copy,
        <T as std::str::FromStr>::Err: std::fmt::Debug
    {
        self.next().parse().unwrap()
    }
    
    #[allow(dead_code)] fn next_i32(&mut self) -> i32 { self.next_generics::<i32>() }
    #[allow(dead_code)] fn next_i64(&mut self) -> i64 { self.next_generics::<i64>() }
    #[allow(dead_code)] fn next_u64(&mut self) -> u64 { self.next_generics::<u64>() }
    #[allow(dead_code)] fn next_usize(&mut self) -> usize { self.next_generics::<usize>() }
    #[allow(dead_code)] fn next_isize(&mut self) -> isize { self.next_generics::<isize>() }
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  int n,m; cin>>n>>m;
  priority_queue<ll> a;
  rep(i,n){
    ll x; cin>>x;
    a.push(x);
  }
  rep(i,m){
    ll x=a.top();
    a.pop();
    a.push(x/2);
  }
  ll ans=0;
  rep(i,n){
    ans+=a.top();
    a.pop();
  }
  cout<<ans<<endl;
}


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

using namespace std;

const long long MOD = 1000000007;
const long long MAX = 2000000;

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

int main()
{
	long long N;
	cin >> N;
	vector<pair<long long, long long> >ll;
	for (int i = 0; i < N;i++){
		long long a, b;
		cin >> a >> b;
		ll.push_back(make_pair(a+b,max(a -b, (long long)0)));


	}
	sort(ll.begin(), ll.end());
	int sum = 0;
	int now = -1;
	for (int i = 0; i < N; i++)
	{
		if (now <= ll[i].second)
		{
			sum++;
			now = ll[i].first;
		}
	}
	cout << sum << endl;
}


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

bool is_acgt(char c) {
  if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
    return true;
  } else {
    return false;
  }
}

int main() {
  string s;
  cin >> s;

  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < (int)s.size(); i++) {
    char c = s.at(i);

    if (is_acgt(c)) {
      cnt++;
      ans = max(ans, cnt);
    } else {
      cnt = 0;
    }
  }

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

Measured memory_bytes: 3604
def tcalc(station):
  time = 0
  for i in range(station-1,n-1):
    f = l[i][2]
    s = l[i][1]
    c = l[i][0]
    time = max(((time-1)//f+1)*f, s)+c
  return time
n = int(input())
l = [tuple(map(int, input().split())) for _ in range(n-1)]
for j in range(1,n+1):
  print(tcalc(j))

Measured memory_bytes: 3064
function main(input) {
    var a = input[0].split(" ")[0]-0;
    var b = input[0].split(" ")[1]-0;
    console.log((a+b)%2==0?Math.abs(a+b)/2:"IMPOSSIBLE")
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


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

int main(){
  int n;
  cin>>n;
  for(int j=0;j<n;j++){
  string s;
  cin>>s;
  char u=' ', b=0;
  char p[]={' ','.', 'a','d','g','j','m','p','t','w'};
  string t="";
  for(int i=0; i<s.size();i++) {
    int x=s[i]-'0';
    if (x==0) {
      if (b>0) {
      if (u=='.') {
        char f[]={'.',',','!','?', ' '};
        t+=string(1, f[b-1]);
      } else {
        t+=string(1, (char)(u+b-1));
      }
      b = 0;
      }
    } else {
      u=p[x];
      b++;
      if (x==7||x==9) {
        if (b==5) b=1;
      } else if (x==1) {
        if (b==6) b=1;
      } else if (b==4) b=1;
    }
  }
  cout<<t<<endl;
}
  return 0;
}
  
  

Measured memory_bytes: 2980
#include<bits/stdc++.h> 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vv = vector<vector<int>>;
using P = pair<int,int>;

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

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

ull func( ull x, ull c, ull d ){
  ull l=lcm(c,d);
  return x - x/c - x/d + x/l;
}

int main(){
  ull a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << func(b,c,d) - func(a-1,c,d) << endl;
  return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    string S;
    cin >> S;

    if (S.back() != 's') {
        S += "s";
    } else {
        S += "es";
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

class C {
    static StreamWriter Out = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static void Main(string[] args) {
        long N, K;
        Input(out N, out K);
        long min1 = N % K;
        long min2 = Math.Abs(min1 - K);
        Print(Math.Min(min1, min2));
        Out.Flush();
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void Inputs<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
    static void Print<T>(T s) => Out.WriteLine(s);
    static void Print<T>(params T[] s) => Out.WriteLine(string.Join(" ", s));
    static void Print<T>(IEnumerable<T> e) => Out.WriteLine(string.Join(" ", e));
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;

int main(){
    int a, b;
    cin >> a >> b;
    cout << (abs(a-b) <= 1 ? "Yay!" : ":(") << endl;
}


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

int main()
{
    ll n, T;
    cin >> n >> T;
    vector<ll> t(n);
    for (int i = 0; i < n; i++)
    {
        cin >> t.at(i);
    }
    ll time = 0;
    ll count = 0;
    ll memo = 0;
    for (int i = 0; i < n; i++)
    {
        if (time >= t.at(i))
        {
            time = max(time, T + t.at(i));
        }
        else
        {
            count += time - memo;
            memo = t.at(i);
            time =(t.at(i)+T);
            //cout<<T<<endl;
        }
        if (i == n - 1)
        {
            count += (time - memo);
            //cout<<count<<endl;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <queue>
using namespace std;

int main(){
    vector<string> s(3);

    cin >> s[0];
    cin >> s[1];
    cin >> s[2];

    cout << s[0][0] << s[1][1] << s[2][2] << endl;
    return EXIT_SUCCESS;
}


Measured memory_bytes: 764
#include <iostream>
#define LL long long
using namespace std;

int main(int argc, char const *argv[])
{
	LL num;
	cin >> num;
	if (num & 1ll) cout << 0ll;
	else
	{
		LL k = num >> 1ll;
		LL fives = 0ll;
		while (k > 0ll)
		{
			k = k / 5ll;
			fives += k;
		}
		cout << fives;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
//4
//1 * f(1) + 2 * f(2) + 3 * f(3) + 4 * f(4)
      //1         2		   2		  3
//f(12) = f(1) + f(2) + f(3) + f(4) + f(6)

//12 = 2^2 3^1
	 //(2 2 2) (3 3) (4) (5 5 5 5)
	    //4      3    2      5  
	 //(2) (3) (4) (5)
const int N = 100 * 100000 + 4;
vector<int> hPrime(N);
void sieve() {
	for (int i = 1; i < N; i++) {
		hPrime[i] = i;
	}
	for (int i = 2; i * i < N; i++) {
		if (hPrime[i] != i) continue;
		for (int j = i; j < N; j += i) {
			hPrime[j] = i;
		}
	}
}
int main() {
	sieve();
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		int t = i;
		int divisors = 1;
		while(t != 1) {
			int pdiv = hPrime[t];
			int c = 0;
			while(t % pdiv == 0) {
				t /= pdiv;
				c++;
			}
			divisors *= (c + 1);
		}
		ans += 1LL * i * divisors;
	}
	cout << ans;	
}


Measured memory_bytes: 42160
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <array>
#include <tuple>
#include <utility>
#include <numeric>
#include <iomanip>
#include <cctype>
#include <cmath>
#include <assert.h>
#include <cstdlib>
#include <list>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s << "[";
    for (int i = 0; i < v.size(); i++) s << (i == 0 ? "" : ", ") << v[i];
    s << "]";
    return s;
}

#define ALL(a) (a).begin(), (a).end()

int main() {
    string s;
    cin >> s;

    string ss = "";
    for (char ch : s) {
        if (ch != 'x') ss.push_back(ch);
    }

    string rss = ss;
    reverse(ALL(rss));

    if (ss != rss) {
        cout << -1 << endl;
        return 0;
    }

    int L = 0, R = s.size() - 1;
    int ans = 0;
    while (L < R) {
        if (s[L] == s[R]) {
            L++;
            R--;
            continue;
        }
        if (s[L] != 'x' and s[R] == 'x') {
            R--;
        } else if (s[L] == 'x' and s[R] != 'x') {
            L++;
        } else {
            assert(false);
        }
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
n = int(input())
a = list(map(int,input().split()))
from collections import Counter
count = Counter(a)
allcnt = 0
for i in set(a):
    allcnt+= count[i]*(count[i]-1)/2
for i in range(n):
    print(int(allcnt-count[a[i]]+1))

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

int main() {
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> uf(N), sz(N, 1);
    iota(uf.begin(), uf.end(), 0UL);
    const auto& find = [&uf](unsigned long i) -> unsigned long {
        while(i != uf[i]) i = uf[i] = uf[uf[i]];
        return i;
    };
    const auto& unite = [&N, &uf, &sz, &find](unsigned long i, unsigned long j) -> void {
        i = find(i);
        j = find(j);
        if(i == j)return ;
        if(sz[i] < sz[j])swap(i, j);
        sz[i] += sz[j];
        uf[j] = i;
        --N;
    };
    unsigned long M;
    cin >> M;
    for(unsigned long i{0}, x, y, z; i < M; ++i){
        cin >> x >> y >> z;
        unite(x, y);
    }
    cout << N << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
  
int preOrder[40],inOrder[40];
 
void solve(int x,int y){
  int i;
  static int p=0;
  if(x>y) return;
  if(x==y){
    if(inOrder[x]==preOrder[0]) printf("%d",inOrder[x]);  
    else printf("%d ",inOrder[x]);
    p++;
    return;
  }
  int a=preOrder[p];
  p++;
  for(i=x;i<=y;i++){
    if(inOrder[i]==a) break;
  }
  solve(x,i-1);
  solve(i+1,y);
  if(a==preOrder[0]) printf("%d",a);
  else printf("%d ",a);
}
  
int main(){
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&preOrder[i]);
  for(i=0;i<n;i++) scanf("%d",&inOrder[i]);
  solve(0,n-1);
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
from collections import Counter

N, K = list(map(int,input().split()))
H = []
for i in range(N):
    H.append(int(input()))
H = sorted(H,reverse = False)
C = Counter(H)
CH = list(C.values()) 

cnt = 0
for i in range(len(CH)):
    if CH[i] >= K:
        cnt += 1
        break
ans = 999999999999999
for i in range(N-K+1):
    ans = min(ans,H[K-1+i] - H[i]) 

if cnt != 0:
    print('0')
else:
    print(ans)

Measured memory_bytes: 16560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;

ll sol(ll a){
  ll ans=1;
  for(int i=1;i<=a;i++){
    ans*=i;ans%=MOD;
  }
  return ans;
}

int main(){
  int N,M;
  cin>>N>>M;
  if(abs(N-M)>1)
    cout<<0<<endl;
  else{
    ll A=sol(N)*sol(M);
    if(N==M)
      A*=2;
    cout<<A%MOD<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define sortV(v) v.begin(),v.end()
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*ncr mod m
const int mod=1000000009;
int c[r+1];
void ncr(int n,int r){c[0]=1;repre(i,1,n)for(int j=min(i,r);j>0;j--)c[j]=((c[j-1]%mod)+(c[j]%mod))%mod;return c[r];}*/
int32_t main()
{
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  fastio
  int n;
  cin>>n;
  double sum=0;
  double arr[n];
  rep(i,n)
  {
    cin>>arr[i];
    sum+=(1.0/arr[i]);
  }
  sum=1.0/sum;
  cout<<fixed<<setprecision(6)<<sum<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		while (sc.hasNext()) {
			double v=sc.nextDouble();
			double y=4.9*(v/9.8)*(v/9.8);
			ln(1+(int)Math.ceil(y/5));
		}
	}

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

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 11000
#include <iostream>                      
                                         
int main()                               
{                                        
    int a, b;                            
    std::cin >> a >> b;                  
    if (a <= b) {                        
        std::cout << a << std::endl;     
    } else {                             
        std::cout << a - 1 << std::endl; 
    }                                    
    return 0;                            
}                                        


Measured memory_bytes: 256
n = int(input())
n = n%10
if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
    print('hon')
elif n == 1 or n == 6 or n == 0 or n == 8:
    print('pon')
elif n == 3:
    print('bon')

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

int main() {
	int N, A, B, C, D, i;
	string S;
	cin >> N >> A >> B >> C >> D >> S;
	S = '.' + S + '.';
	bool a = true;
	if (S.substr(A, C - A + 1).find("##") != string::npos) a = false;
	if (S.substr(B, D - B + 1).find("##") != string::npos) a = false;
	if (A < B && C > D) {
		for (i = B; i <= D; ++i) {
			if (S.substr(i - 1, 3) == "...") break;
		}
		if (D == i - 1) a = false;
	}
	if (A > B && C < D) {
		for (i = A; i <= C; ++i) {
			if (S.substr(i - 1, 3) == "...") break;
		}
		if (C == i - 1) a = false;
	}
	if (a) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 772
N = int(input())

def SumDigits(num):
    sum = 0
    while True:
        sum += num % 10
        num //= 10
        if num == 0:
            break
    return sum

infinity = float('inf')
min = infinity

for x in range(1, N//2 + 1):
    #print('============')
    #print(x, N - x)
    #print(SumDigits(x) + SumDigits(N - x))
    if SumDigits(x) + SumDigits(N - x) < min:
        min = SumDigits(x) + SumDigits(N - x)
print(min)


Measured memory_bytes: 3060
#include<iostream>
 
int main()
{
	char a, b, c;
  	char x, y, z;
	scanf(" %c %c %c", &a, &b, &c);
  	scanf(" %c %c %c", &x, &y, &z);
  	printf("%d\n", ((a == x) + (b == y) + (c == z)));
}

Measured memory_bytes: 256
//Volume0-0093
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//declare
		ArrayList<String> result = new ArrayList<String>();
		String[] s;
		int a,b,i;
		boolean exst;

        //input
        Scanner sc = new Scanner(System.in);
        while(true){
        	s = sc.nextLine().split("\\s");
        	a = Integer.parseInt(s[0]);
        	b = Integer.parseInt(s[1]);
        	if(a+b == 0){break;}

        	//calculate
        	exst = false;
        	for(i=a;i<=b;i++){
        		if((i%4==0 && i%100!=0) || (i%400==0)){
        			result.add(String.valueOf(i));
        			exst = true;
       			}
        	}
        	if(!exst){result.add("NA");}
        	result.add("");
        }

        //output
        for(i=0;i<result.size()-1;i++){
        	System.out.println(result.get(i));
       	}
	}
}

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

/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

using namespace std;

typedef long long ll;

string s;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    if(s.back() == 's')
        cout << s << "es\n";
    else
        cout << s << "s\n";
    return 0;
}



Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <time.h> //for clock
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
using ll = long long;

int main(){
    string s;
    cin >> s;

    map<char, int> m;
    int i;

    for(i = 0; i < s.size(); i++){
        if(m.find(s[i]) == m.end()){
            m[s[i]] = 1;
        }else{
            m[s[i]] += 1;
        }
    }

    for(auto itr = m.begin(); itr != m.end(); itr++){
        if(itr->second % 2 != 0){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define ll long long
    #define f(i, a, b) for(ll i=a; i<b; i++)
    #define pb push_back
    #define mp make_pair
    #define F first
    #define S second
    using namespace std;
    ll findSubarraySum(ll arr[], ll n, ll sum = 0) 
    {
        unordered_map<ll, ll> prevSum;
        ll res = 0;
        ll currsum = 0;
        for (ll i = 0; i < n; i++)
        {
            currsum += arr[i];
            if (currsum == sum) res++;
            if (prevSum.find(currsum - sum) != prevSum.end()) res += (prevSum[currsum - sum]);
            prevSum[currsum]++;
        }
        return res; 
    } 
    ll gcd(ll a, ll b) 
    { 
        if (a == 0) 
            return b; 
        return gcd(b % a, a); 
    } 
      
    ll findGCD(ll arr[], ll n) 
    { 
        ll result = arr[0]; 
        for (ll i = 1; i < n; i++)
            result = gcd(arr[i], result); 
      
        return result; 
    } 
    ll powmp(ll x, ll y, ll p) 
    { 
        ll res = 1;     x = x % p;   
        while (y > 0) 
        {  
            if (y & 1)  res = (res*x) % p; 
            y = y>>1; 
            x = (x*x) % p;   
        } 
        return res; 
    } 
     
    int main()
    {
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
        ll n; cin>>n;
      f(i,1,10)
      {
      ll x=n/i;
        if(x>=1 && x<=9 && n%i==0) {cout<<"Yes";return 0;}
      }
      cout<<"No";
      return 0;
    }

Measured memory_bytes: 256