akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(4100000)

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    A, B = [int(x) for x in sys.stdin.readline().split()]

    if A == B:
        print(0)
    else:
        if (A - B) % 2 == 0:
            if A > B:
                print(int((A-B) / 2) + B)
            else:
                print(int((B-A) / 2) + A)
        else:
            print("IMPOSSIBLE")



if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる



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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  ll a,b;
  char op;
  cin>>a>>op>>b;
  if (op == '+') cout << a+b << endl;
  else cout << a-b << endl;
}

int main()
{
  solve();
  return 0;
}


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

int main() {
  uint32_t N = 0;
  std::cin >> N;
  uint32_t A = 0;
  std::vector<uint32_t> a(N, 0);
  for (auto &&a_i : a){
    std::cin >> a_i;
    A ^= a_i;
  }

  for (uint32_t i = 0; i < N; i++){
    std::cout << (A ^ a[i]);
    if(i + 1 < N) std::cout << " ";
  }

  std::cout << std::endl;

  return 0;
}

Measured memory_bytes: 3992
n = int(input())
left = []
mid = []
zero = []
midminus = []
right = []
L = []
R = []

for i in range(n):
    s = input()
    l = 0
    r = 0
    for x in s:
        if x == '(':
            l += 1
        else:
            if l > 0:
                l -= 1
            else:
                r += 1
    if l > 0 and r == 0:
        left.append((l, r))
    elif l > 0 and r > 0:
        if l > r:
            mid.append((r, l))  # a,b-a
        elif l == r:
            zero.append((r,l))
        else:
            midminus.append((r, l))
    elif l == 0 and r > 0:
        right.append((l, r))
    L.append(l)
    R.append(r)

if sum(L) != sum(R):
    print('No')
    exit()

A = 0
B = 0
for x in left:
    A += x[0]
for x in right:
    B += x[1]

mid = sorted(mid, key=lambda x: (x[0], -x[1]))
midminus = sorted(midminus, key=lambda x: -x[1])
mid += zero + midminus

l = A
r = 0
for a, b in mid:
    if l < a:
        print('No')
        exit()
    l -= a
    l += b

print('Yes')


Measured memory_bytes: 227984
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>      // std::setprecision
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor_ct.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
using namespace std;
using namespace boost::math;

int main() {
	int N, M;

	cin >> N >> M;
  
    multimap<int, int> adj;
  
    REP(i, M) {
      int x, y;
      
      cin >> x >> y;
      adj.emplace(x, y);
    }
  
    vector<int> dp(N + 1, -1);

    auto calc = [&](auto f, int current) {
      if (dp[current] >= 0)
        return dp[current];
      
      int r = 0;
      auto it = adj.lower_bound(current), ite = adj.upper_bound(current);
      while (it != ite) {
        r = max(r, f(f, (it++)->second) + 1);
      }
      
      dp[current] = r;
      return r;
    };

    int res = 0;
    for (auto i : boost::irange(1, N + 1))
      res = max(res, calc(calc, i));
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 6912
#include<stdio.h>
digit(int a)
{
    int rem,div,sum=0;
    while(1)
    {rem=a%10;
    div=a/10;
    sum=sum+rem;
    a=div;
    if(a==0)break;
    }
    return sum;

}
main()
{
    int n,i=1,sum=0,min=1000000,a,b;
    scanf("%d",&n);
    while(i<n)
    {a=i;
    b=n-i;

    sum=digit(a)+digit(b);
    if(sum<min)min=sum;
    i++;


    }
    printf("%d\n",min);
    return 0;
}


Measured memory_bytes: 128
def main():
    n = int(input())

    A=[int(i) for i in input().split()]
    k = sum(A)
    res = 10**9
    for i in range(1,n):
        s1 = sum(A[0:i])
        s2 = k-s1
        res = min(res, abs(s1-s2))
    print(res)




if __name__ == '__main__':
    main()


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

int main() {
  double a, b, c, d, e, f;
  double x, y;
  while( cin >> a >> b >> c >> d >> e >> f) {
    x = (c * e - b * f) / (a * e - b * d);
    y = (a * f - c * d) / (a * e - b * d);
    x *= 1000;
    x += 0.5;
    x = floor(x);
    x /= 1000;
    y *= 1000;
    y += 0.5;
    y = floor(y);
    y /= 1000;
    printf("%.3f %.3f\n", x, y);

  }
  return 0;
}

Measured memory_bytes: 0
import sys

n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = []

nh1 = n//2 - 1
nh2 = nh1 + 1

if a[nh1] == a[nh2]:
    print(0)
    sys.exit()
else:
    for i in range(a[nh1]+1,a[nh2]+1):
        ans.append(i)

print(len(ans))

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

int main() {
  int N; cin>>N;
  vector<string> Blue(N);
  for(int i=0; i<N; i++) cin>>Blue.at(i);

  int M; cin>>M;
  vector<string> Red(M);
  for(int i=0; i<M; i++) cin>>Red.at(i);
  
  int max=0;
  for(int i=0; i<N; i++){
    int temp=0;
    for(int j=0; j<N; j++) if(Blue.at(i)==Blue.at(j)) temp++;
    for(int j=0; j<M; j++) if(Blue.at(i)==Red.at(j)) temp--;
    if(temp>max) max=temp;
  }
  
  cout<<max<<endl;
}


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

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let h: usize = sc.read();
    let w: usize = sc.read();
    let n: usize = sc.read();
    let mut y_set = vec![vec![]; h + 1];
    for _ in 0..n {
        let x = sc.read::<usize>() - 1;
        let y = sc.read::<usize>() - 1;
        y_set[x].push(y);
    }
    y_set[h].push(0);
    for i in 0..h {
        y_set[i].sort();
    }

    let mut max_y = 0;
    for cur_x in 0.. {
        let upper = y_set[cur_x + 1]
            .binary_search_by_key(&(max_y * 2 + 1), |&y| y * 2)
            .err()
            .unwrap();
        if upper > 0 {
            println!("{}", cur_x + 1);
            return;
        }
        if y_set[cur_x + 1].binary_search(&(max_y + 1)).is_err() {
            max_y += 1;
        }
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .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: 16636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int,int> PII;

struct UnionFind{
  VI par;
  UnionFind(int N):par(N){
    rep(i,N) par[i]=i;
  }
  int root(int x){
    if(par[x]==x) return x;
    return par[x]=root(par[x]);
  }
  void unite(int x, int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry) return;
    par[rx]=ry;
  }
  bool same(int x, int y){
    int rx=root(x);
    int ry=root(y);
    return rx==ry;
  }
};
int main(){
  int N,M,K;
  cin>>N>>M>>K;
  VI A(M),B(M);
  rep(i,M) cin>>A[i]>>B[i];
  VI C(K),D(K);
  rep(i,K) cin>>C[i]>>D[i];
  UnionFind tree(N+1);
  rep(i,M) tree.unite(A[i]-1,B[i]-1);
  VI Q(N);
  rep(i,N) Q[tree.root(i)]++;
  VI TO(N),BU(N);
  rep(i,M){
    TO[A[i]-1]++;
    TO[B[i]-1]++;
  }
  rep(i,K){
    if(tree.root(C[i]-1)==tree.root(D[i]-1)){
      BU[C[i]-1]++;
      BU[D[i]-1]++;
    }
  }
  rep(i,N){
    if(i) cout<<" ";
    cout<<Q[tree.root(i)]-1-TO[i]-BU[i];
  }
  cout<<endl;
}



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

int main() {
	long long l, r, ans = 2018;
	cin >> l >> r;
	r = min(l + 2019, r);
	for (long long i = l; i <= r; ++i) {
		for (long long j = i + 1; j <= r; ++j) {
			ans = min(ans, i * j % 2019);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;


int n;
vector<vector<int>> g;

int solve(int isTraveled,int pos) {
	int cnt = 0;
	if (isTraveled == (1 << n) - 1) {
		return 1;
	}
	for (int i = 0; i < n; i++) {
		
		if (g[pos][i] == 1 && (isTraveled >> i & 1) == 0) {
			cnt += solve(isTraveled +( 1 << i), i);
		}
	}
	return cnt;
}

int main() {
	int m;
	cin >> n >> m;
	
	g = vector<vector<int>>(n, vector<int>(n));

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;

		b--;
		g[a][b] = 1;
		g[b][a] = 1;
	}

	int ans = solve(1, 0);
	cout << ans << endl;
	
}


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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    string ans = "Yes";
    while(a > 0 && c > 0){
        c -= b;
        if(c <= 0)break;
        a -= d;
    }
    if(a <= 0)ans = "No";

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

Measured memory_bytes: 3652
#include<stdio.h>

int main(void)
{
  int i, x;
  int temp = 1;

  scanf("%d", &x);
  while(1>x || x>100){
    scanf("%d", &x);
  }

  for(i=0; i<3; i++){
    temp *= x;
  }

  printf("%d\n", temp);

  return 0;
}

Measured memory_bytes: 1756
N, M = map(int, input().split())
l = 1
m = N
for i in range(M):
    l_i, m_i = map(int, input().split())
    l = max(l, l_i)
    m = min(m, m_i)
if m < l:
    print(0)
else:
    print(m - l + 1)

Measured memory_bytes: 3060
// This code wrote by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
const int MaxN=100050;
struct Edge
{
	int nxt,to;
}E[MaxN<<4];
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
int hd[MaxN],en,n,m;
int vis[MaxN];
inline void adde(int u,int v)
{
	++en;
	E[en]=(Edge){hd[u],v};
	hd[u]=en;
	return;
}
signed main(void)
{
	memset(hd,-1,sizeof hd);
	reg int u,v;
	cin>>n>>m;
	for(int i=1;i<=m;++i)
	{
		read(u);read(v);
		adde(u,v);
		adde(v,u);
	}
	queue<int> Q;
	Q.push(1);
	vis[1]=1e9;
	while(!Q.empty())
	{
		reg int u=Q.front();Q.pop();
		for(int i=hd[u];~i;i=E[i].nxt)
		{
			reg int v=E[i].to;
			if(vis[v])
				continue;
			vis[v]=u;
			Q.push(v);
		}
	}
	for(int i=2;i<=n;++i)
		if(!vis[i])
		{
			puts("No");
			return 0;
		}
	puts("Yes");
	for(int i=2;i<=n;++i)
		printf("%d\n",vis[i]);
	return 0;
}




Measured memory_bytes: 7700
#include <algorithm>
#include <cstdio>

#define REDIRECT(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
#define CLOSEALL() fclose(stdin), fclose(stdout)

using namespace std;

const int MAXN = 3e5 + 10;

int N;
pair <int, int> a[MAXN];

int main()
{
	//REDIRECT("sort");

	int cnt = 0;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++)
		scanf("%d", &a[i].first), a[i].second = i;
	sort(&a[1], &a[N + 1]);

	for(int i = 1; i <= N; i++)
		if((a[i].second % 2) != (i % 2))
			cnt++;

	printf("%d\n", cnt / 2);

	CLOSEALL();

	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

using ll = long long;
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
int main(){
    int a[5];
    int k;
    rep(i, 5) cin >> a[i];
    cin >> k;
    if(a[4]- a[0] > k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    
    sort(A.begin(), A.end());
    vector<int> M;
    vector<int> P;
    for(int i=0; i<N; i++){
        if(A[i]<0) M.push_back(A[i]);
        else P.push_back(A[i]);
    }

    
    
    vector<PII> Ans;
    if(P.size()==0){
        reverse(M.begin(), M.end());
        int cur = M[0];
        int K = (int)M.size();
        
        for(int i=1; i<K; i++){
            Ans.push_back({cur, M[i]});
            cur = cur - M[i];
        }
        cout << cur << endl;
        for(int i=0; i<(int)Ans.size(); i++){
            cout << Ans[i].fs << " " << Ans[i].sc << endl;
        }
        return 0;
    }
    
    if(M.size()==0){
        int cur = A[0];
        for(int i=1; i<N-1; i++){
            Ans.push_back({cur, A[i]});
            cur = cur - A[i];
        }
        
        Ans.push_back({A.back(), cur});
        cur -= A.back();
        cur *= -1;
        cout << cur << endl;
        for(int i=0; i<N-1; i++){
            cout << Ans[i].fs << " " << Ans[i].sc << endl;
        }
        return 0;
    }

    int cur = P.back();
    for(int i=0; i<(int)M.size()-1; i++){
        Ans.push_back({cur, M[i]});
        cur = cur - M[i];
    }
    int mx = cur;
    
    cur = M.back();
    for(int i=0; i<(int)P.size()-1; i++){
        Ans.push_back({cur, P[i]});
        cur = cur - P[i];
    }
    
    Ans.push_back({mx, cur});
    cout << mx - cur << endl;
    for(int i=0; i<(int)Ans.size(); i++){
        cout << Ans[i].fs << " " << Ans[i].sc << endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 3828
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
int main(){
    int x,a,b;
    cin >> x >> a >> b;
    x -= a;
    cout << x%b << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int H, W, M; cin >> H >> W >> M;
    vector<int> x(H), y(W);
    set<pair<int, int>> s;
    int h, w;
    rep(i, M) {
        cin >> h >> w;
        h--; w--;
        s.insert(make_pair(h, w));
        x[h]++; y[w]++;
    }
    vector<int> ansX, ansY;
    int mx=-1, my=-1;
    rep(i, H) {
        if (x[i] == mx) ansX.push_back(i);
        else if (x[i] > mx) {
            ansX.clear();
            ansX.push_back(i);
            mx = x[i];
        }
    }
    rep(i, W) {
        if (y[i] == my) ansY.push_back(i);
        else if (y[i] > my) {
            ansY.clear();
            ansY.push_back(i);
            my = y[i];
        }
    }
    int ans = mx+my-1;
    rep(i, ansX.size()) {
        rep(j, ansY.size()) {
            if (s.count(make_pair(ansX[i], ansY[j])) == 0) {
                cout << ans+1 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 23708
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int H, W;
            H = 3;
            W = 3;
            int[,] MP = new int[H, W];
            bool[,] F = new bool[H, W];
            for (int y = 0; y < H; y++)
            {
                var line = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
                for (int x = 0; x < W; x++)
                {
                    MP[y, x] = line[x];
                }
            }

            int N = int.Parse(Console.ReadLine());
            for (int i = 0; i < N; i++)
            {
                var a = int.Parse(Console.ReadLine());
                for (int y = 0; y < H; y++)
                {
                    for (int x = 0; x < W; x++)
                    {
                        if (MP[y, x] == a)
                            F[y, x] = true;
                    }
                }
            }
            
            // horizontal
            bool ans = false;
            if (F[0, 0] && F[0, 1] && F[0, 2]) ans = true;
            if (F[1, 0] && F[1, 1] && F[1, 2]) ans = true;
            if (F[2, 0] && F[2, 1] && F[2, 2]) ans = true;
            if (F[0, 0] && F[1, 0] && F[2, 0]) ans = true;
            if (F[0, 1] && F[1, 1] && F[2, 1]) ans = true;
            if (F[0, 2] && F[1, 2] && F[2, 2]) ans = true;
            if (F[0, 0] && F[1, 1] && F[2, 2]) ans = true;
            if (F[0, 2] && F[1, 1] && F[2, 0]) ans = true;
            
            Console.WriteLine(ans ? "Yes" : "No");

        }
    }
}

Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double


int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    ll n, k;
    cin >> n >> k; /// 2 2
    if (k > n){
            if (k >= 2 * n){cout << n << endl;}
            else {cout << abs (n - k) << endl;}
    }
    else {
        if (n % k == 0){
            cout << "0" << endl;
        }
        else {
            ll mul = (n / k) * k;
            ll temp = (n - mul);
            ll temp1 = abs (temp - k);
            cout << min (temp,temp1) << endl;
        }
    }

    return 0;
}


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

int main(){

  int n;

  while(cin>>n, n){
    int w, h, s, t;
    cin>>w>>h;
    bool p[101][101]={};
    for(int i=0;i<n;i++){
      int x, y;
      cin>>x>>y;
      p[y][x]=true;
    }
    cin>>s>>t;
    int cnt=0, ma=0;
    for(int i=1;i<=h-t+1;i++){
      for(int j=1;j<=w-s+1;j++){
	for(int y=i;y<=i+t-1;y++){
	  for(int x=j;x<=j+s-1;x++){
	    if(p[y][x]==true) cnt++;
	  }
	}
	ma=max(ma, cnt);
	cnt=0;
      }
    }
    cout<<ma<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3052
#include <iostream>
#include <string>
#include <queue>
using namespace std;
struct pro{
	string name;
	int time;
};

int main(){
	queue<pro> que;
	pro p;
	int n,q,count = 0;
	cin >> n >> q;
	for(int i = 0;i < n;i++){
		cin >> p.name >> p.time;
		que.push(p);
	}
	while(1){
		p =	que.front();
		que.pop();
		if(p.time <= q){
			count += p.time;
			cout << p.name << " " << count <<endl;
		}
		else{
			p.time -= q;
			count += q;
			que.push(p);
		}
		if(que.empty())break;
	}
	return 0;
}

Measured memory_bytes: 4404
a,b,c=map(int,raw_input().split())
if a%2==1 or b%2==1 or c%2==1:
    print 0
    exit()
if a==b==c:
    print -1
    exit()
tmpa=0;tmpb=0;tmpc=0;
ans=0
while 1:
    tmpa=b/2+c/2
    tmpb=a/2+c/2
    tmpc=a/2+b/2
    ans+=1
    if tmpa%2==1 or tmpb%2==1 or tmpc%2==1:
        break
    if tmpa==tmpb==tmpc:
        break
    a=tmpa;b=tmpb;c=tmpc;
print ans


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    i32 n;
    ld x, j = 0, b = 0;
    string s;
    cin >> n;
    rep(i,n) {
        cin >> x >> s;
        if(s=="JPY") j += x;
        else b += x;
    }

    cout << j + 380000 * b << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
  int n;
  cin >> n;
  vector<int> H(n);
  rep(i, n) cin >> H[i];
  int ans=0, ch=0;
  rep(i, n-1){
   if(H[i]>=H[i+1]){
     ch++;
     if(ch>ans) ans = ch;
   }
    else ch = 0;
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 768
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll H, W;
    cin >> H >> W;
    ll mat[52][52];
    rep(i, H+2) {
        rep(j, W+2) {
            mat[i][j] = 0;
        }
    }
    rep(i, H) {
        string s;
        cin >> s;
        rep(j, W) {
            if (s[j] == '#') mat[i+1][j+1] = 1;
        }
    }
    rep(i, H) {
        rep(j, W) {
            if (mat[i+1][j+1] == 1) {
                if (mat[i][j+1] + mat[i+1][j] + mat[i+2][j+1] + mat[i+1][j+2] == 0) {
                    no;
                    return 0;
                }
            }
        }
    }
    yes;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        sc.nextLine();
        boolean[][] map=new boolean[8][8];
        int c=1;
        while (n-->0) {
            for(int i=0;i<8;i++) {
                char[] s=sc.next().toCharArray();
                for(int j=0;j<8;j++) {
                    map[i][j]=s[j]=='1';
                }
            }
            Deque<int[]> stack=new ArrayDeque<>();
            stack.push(new int[] {sc.nextInt()-1,sc.nextInt()-1});
            int[] mx= {0,0,1,-1};
            int[] my= {1,-1,0,0};
            while(!stack.isEmpty()) {
                int[] p=stack.pop();
                map[p[1]][p[0]]=false;
                for(int i=0;i<4;i++) {
                    for(int j=1;j<=3;j++) {
                        int dx=p[0]+mx[i]*j;
                        int dy=p[1]+my[i]*j;
                        if(dx>=0&&dx<8&&dy>=0&&dy<8&&map[dy][dx]) {
                            map[dy][dx]=false;
                            stack.push(new int[] {dx,dy});
                        }
                    }
                }
            }
            System.out.println("Data "+c+++":");
            for(int i=0;i<8;i++) {
                for(int j=0;j<8;j++) {
                    System.out.print(map[i][j]?"1":"0");
                }
                System.out.println();
            }
        }
    }
}


Measured memory_bytes: 26020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
   int n;
   cin >> n;
   int sum = 0;
   rep(i, n)
   {
      sum += i + 1;
   }
   cout << sum << endl;
   return 0;
}


Measured memory_bytes: 256
while (vertical_number, horizontal_number, current_line = gets.split.map &:to_i) != [0, 0, 0]
    horizontal_lines = Hash.new { |h,k| h[k] = {} }
    horizontal_number.times {
        height, left, right = gets.split.map &:to_i
        horizontal_lines[height][left] = right
        horizontal_lines[height][right] = left
    }
    horizontal_lines = horizontal_lines.sort.reverse.to_h

    horizontal_lines.each { |height, lines|
        current_line = horizontal_lines[height][current_line] || current_line
    }

    puts(current_line)
end



Measured memory_bytes: 8228
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int a,b,c,d,e,f,ans1=1,ans2,water,sugar;
double ans_n;
inline void read(int &x)
{
	int data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=(data<<3)+(data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
int main()
{
	read(a);read(b);read(c);read(d);read(e);read(f);
	for(register int i=0;i<=(f/(100*a));++i)
		for(register int j=0;j<=(f/(100*b));++j)
		{
			water=i*100*a+j*100*b;
			if(water>f)continue;
			for(register int k=0;water+k*c<=f;++k)
				for(register int p=0;water+k*c+p*d<=f;++p)
				{
					sugar=k*c+p*d;
					if(sugar>(water/100)*e)continue;
					if(sugar*ans1>ans2*(water+sugar))
					{
						ans1=water+sugar;
						ans2=sugar;
					}
				}
		}
	if(ans1==1&&!ans2)printf("%d 0",100*a);
	else printf("%d %d\n",ans1,ans2);
	return 0;
}


Measured memory_bytes: 256
from collections import deque

DLL = deque()

n = int(input())

for i in range(n):
    Line = input().split()
    
    if Line[0] == "insert":
        DLL.appendleft(Line[1])
        
    elif Line[0] == "delete":
        try:
            DLL.remove(Line[1])
        except ValueError:
            None
    elif Line[0] == "deleteFirst":
        DLL.popleft()
    elif Line[0] == "deleteLast":
        DLL.pop()

print(" ".join(DLL))


Measured memory_bytes: 69732
/*
        |___________________________Arshit Mangukiya_____________________________|
        |_______________________________DA-IICT__________________________________|
        |_____________________________201801173__________________________________|
*/
        /*______________________WRITE  YOUR  CODE  HERE_________________________*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;            
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppl;
typedef vector<pll> vpl;
#define ff first
#define ss second
#define pi acos(-1)
#define mr_ad_0501 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define all(a)      a.begin(),a.end()
#define F(i,a,n) for(ll i=a;i<n;i++)
#define MOD 1000000007
#define MAX 200007
#define LM LLONG_MAX
#define sz size()
#define p(x) 		cout<< x << " ";
#define pe(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
const int N=1e5+5;
    	/*	bool fun(pair<int,int>a , pair<int,int>b)
			{
				if(a.ff == b.ff)	return a.ss < b.ss;
				else			return a.ff < b.ff;
			}*/
 /*void bfs(ll x)
 {
 	queue<ll> q;
	q.push(x);
    while(!q.empty())
    {
        ll k=q.front();
        q.pop();
        for(auto X:v[k])
        {
            if(!vis[X])
            {
            	l[X]=l[k]+1;
                vis[X]=1;
                q.push(X);
            }
        }
    }
 }*/

void solve()
{
	ll n;
	cin>>n;
	ll x =n%10;
	if(x==3){cout<<"bon";return;}
	else if(x==0|| x==1||x==6||x==8){cout<<"pon";return;}
	else {cout<<"hon";return;}
}
int32_t main(){
	mr_ad_0501;
	ll t=1;
	//cin >> t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,m,a,sum=0;
    cin>>n>>m;
    rep(i,m){
        cin>>a;
        sum+=a;
    }
    cout<<(sum<=n?n-sum:-1)<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iomanip>

using namespace std;
#define INF 1e9
#define MAX 100005
#define MOD 1000000007
#define Q queue
#define PQ priority_queue
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define FOR( i, L, U ) for(int i=(int)L ; i<(int)U ; i++ )
#define FORD( i, U, L ) for(int i=(int)U ; i>=(int)L ; i-- )
#define wa cout<<"Wa"<<endl
#define READ(filename)  freopen(filename, "r", stdin);
#define WRITE(filename)  freopen(filename, "w", stdout);

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int> > vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef map<int , vector<int> > mvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

void base(){
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
}


int main(){
//	base();
	int a,b,c;
	cin>>a>>b>>c;
	int total = a*100 + b*10 + c*1;
	if (total%4==0) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}



Measured memory_bytes: 256
import sys
from collections import deque

def main():
    N,K,C=map(int,input().split())
    S=input()

    Left=deque([])
    Right=deque([])

    counter=0
    while counter<N and len(Left)<K:
        if S[counter]=="o":
            if len(Left)<K:
                Left.append(counter)
                counter+=C
        counter+=1

    counter=N-1
    while counter>=0 and len(Right)<K:
        if S[counter]=="o":
            if len(Right)<K:
                Right.appendleft(counter)
                counter-=C
        counter-=1

    if len(Right)!=K or len(Left)!=K:
        sys.exit()
    for i in range(K):
        l=Left.popleft()
        r=Right.popleft()
        if l==r:
            print(l+1)

if __name__=="__main__":
    main()

Measured memory_bytes: 80256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	vector<int> N(4);
	vector<bool> b(4, false);
	rep(i, 4) {
		cin >> N[i];
		if (N[i] == 1) {
			b[0] = true;
		}
		if (N[i] == 9) {
			b[1] = true;
		}
		if (N[i] == 7) {
			b[2] = true;
		}
		if (N[i] == 4) {
			b[3] = true;
		}
	}
	rep(i, 4) {
		if (b[i] == false) {
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main( void ) 
{
	int card[53]={0};
	int n;
	int i,num;
	char pattern[2]={'\0'};
	
	scanf( "%d", &n );
	for( i=0; i<n; i++ ) {
		scanf( "%s%d", pattern, &num );
		pattern[1]='\0';
		switch( pattern[0] ) {
			case 'S':
					card[num-1]=1;
				break;
			case 'H':
					card[12+num]=1;
				break;
			case 'C':
					card[25+num]=1;
				break;
			case 'D':
					card[38+num]=1;
				break;
			default:
					;
		}
	}
	for( i=0; i<=52; i++ ) {
		if( 0 == card[i] ) {
			if( 0==i/13 ) {
				printf( "S %d\n", (i%13)+1 );
			} else if( 1==i/13 ) {
				printf( "H %d\n", (i%13)+1 );
			} else if( 2==i/13 ) {
				printf( "C %d\n", (i%13)+1 );
			} else if( 3==i/13 ) {
				printf( "D %d\n", (i%13)+1 );
			}
		}
	}
		
	
	return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;

#define rp(i,t) for(int i=0;i<(t);i++)
#define rep(i,s,t) for(int i=(s);i<=(t);i++)
#define rsp(i,s,t) for(int i=(s);i<(t);i++)
#define rrp(i,t,s) for(int i=(t);i>=(s);i--)
#define rcp(i,s,b,d) for(int i=(s);b;d)
#define mst(a,x) memset(a,x,sizeof(a))
#define INF 0x3f3f3f3f
#define N 100002
#define MOD 1000000007

#define Dp puts("")
#define Dw printf
#define Ds printf("#")

typedef long long ll;
char ch;
int n,m;
ll fac[N];

inline void read(int &x){x=0;do{ch=getchar();}while(ch<'0'||'9'<ch);do{x=x*10+ch-'0';ch=getchar();}while('0'<=ch&&ch<='9');}

int main(void)
{
	read(n),read(m);
	if(n<m)swap(n,m);
	fac[0]=1;
	rep(i,1,n)fac[i]=fac[i-1]*i%MOD;
	if(n-m>1)printf("0");
	else if(n-m==1)printf("%lld",fac[n]*fac[m]%MOD);
	else printf("%lld",((fac[n]*fac[m])<<1)%MOD);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>
#include <stack>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;
using Graph = Vvec<int>;
constexpr ll MOD = 1e9+7;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

// ax + by = d
template <class T>
T ext_gcd(T a, T b, T& x, T& y)
{
    x = 1; y = 0;
    T xb = 0, yb = 1;
    T xr, yr, q, r;
    while(b != 0){
        q = a/b;
        xr = x - q * xb;
        yr = y - q * yb;
        r = a - q * b;

        x = xb;
        y = yb;
        a = b;
        xb = xr;
        yb = yr;
        b = r;
    }
    return a;
}

ll modinv(ll a){
    ll x, y;
    ext_gcd(a, MOD, x, y);
    x = (x < 0) ? (MOD - (-x) % MOD) : x % MOD;
    if(x >= MOD) x -= MOD;
    return x;
}

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    for(auto& x: A) cin >> x;

    vector<ll> fact(N+2), ifact(N+2);
    fact[0] = 1;
    for(int i=1; i<=N+1; i++){
        fact[i] = fact[i-1] * i % MOD;
    }
    ifact[N+1] = modinv(fact[N+1]);
    for(int i=N+1; i>0; i--){
        ifact[i-1] = ifact[i] * i % MOD;
    }

    auto inv = [&](ll a){
        return fact[a-1] * ifact[a] % MOD;
    };

    ll p=0, ans=0;
    for(int i=1; i<=N; i++){
        p += inv(i); p %= MOD;
    } 
    for(int i=0; i<N; i++){
        ans += p * A[i];
        ans %= MOD;
        p += inv(i+2) - inv(N-i);
        if(p<0) p += MOD;
        p %= MOD;
    }

    for(int i=1; i<=N; i++){
        ans *= i;
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int n,m,a[200],b[200][3],mem[200][101];

int hot(int day,int bef){

  int ret = 0;
  if(day == n) return 0;
  if(mem[day][bef] != -1) return mem[day][bef];

  for(int i=0;i<m;i++){
    if(b[i][0]<=a[day] && b[i][1]>=a[day]){
      if(day == 0) ret = max(ret,hot(day+1,b[i][2]));
      else ret = max(ret, hot(day+1,b[i][2])+abs(bef-b[i][2]) );
    }
    
  }

  return mem[day][bef] = ret;

}
int main(){
  
  memset(mem,-1,sizeof(mem));

  scanf("%d %d",&n,&m);
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<m;i++) cin >> b[i][0] >> b[i][1] >> b[i][2];

  cout << hot(0,0) << endl;

  return (0);
}

Measured memory_bytes: 3228
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/lazysegtree>
#include <atcoder/modint>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000

struct Data{
	mint sum = 0;
	mint sz = 0;
};

Data op(Data a,Data b){
	a.sum += b.sum;
	a.sz += b.sz;
	return a;
}

Data e(){
	return Data();
}

Data mapping(mint a,Data b){
	if(a==100)return b;
	b.sum = b.sz * a;
	return b;
}

mint composition(mint a,mint b){
	if(a==100)return b;
	if(b==100)return a;
	return a;
}

mint id(){
	return 100;
}

int main(){

	int N,Q;
	cin>>N>>Q;
	
	vector<Data> V(N,{1,1});
	
	for(int i=N-2;i>=0;i--){
		V[i].sz = V[i+1].sz * 10;
		V[i].sum = V[i].sz;
	}
	
	lazy_segtree<Data,op,e,mint,mapping,composition,id> seg(V);
	
	rep(i,Q){
		int L,R,D;
		scanf("%d %d %d",&L,&R,&D);
		seg.apply(L-1,R,D);
		cout<<seg.all_prod().sum.val()<<endl;
	}
	
	
	return 0;
}


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

#define PI acos(-1)
#define int long long int
#define pb push_back
#define pi pair<int, int>
#define fir first
#define sec second
#define MAXN 2001
#define mod 1000000007

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> xx(n);
  vector<int> yy(n);
  for (int i = 0; i < n; i++)
  {
    cin >> x[i] >> y[i];
    xx[i] = (x[i] + y[i]);
    yy[i] = (x[i] - y[i]);
  }
  int a = *max_element(xx.begin(), xx.end());
  int b = *min_element(xx.begin(), xx.end());
  int c = *max_element(yy.begin(), yy.end());
  int d = *min_element(yy.begin(), yy.end());
  cout << max({a - b, c - d, c, d, b - a});
}


Measured memory_bytes: 9528
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

long long gcd (long long a , long long b) {
   if (b == 0) return a;
   return gcd(b, a % b);
}
long long lcm (long long a, long long b) {
   return gcd(a, b) * (a / gcd(a, b)) * (b / gcd(a, b));
}

int main() {
   int N;
   cin >> N;
   ll t;
   ll ans = 1;
   for (int i = 0; i < N; i++) {
      cin >> t;
      ans = lcm(ans, t);
   }
   cout << ans << endl;
   return 0;
}


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

int par[100001],ran[100001];

void init(int n)
{
  for(int i=0;i<n;i++){par[i]=i;ran[i]=0;}
}
int find(int x)
{
  if(par[x]==x)return x;
  else return par[x]=find(par[x]);
}
void unite(int x,int y)
{
  x=find(x),y=find(y);
  if(x==y)return;
  if(ran[x]<ran[y])par[x]=y;
  else {par[y]=x;if(ran[x]==ran[y])ran[x]++;}
}
bool same(int x,int y)
{
  return find(x)==find(y);
}
int main()
{
  int N,M;scanf("%d %d",&N,&M);init(N+1);
  int p[N+1],pi[N+1];
  for(int i=1;i<N+1;i++){scanf("%d ",&p[i]);pi[p[i]]=i;}
  for(int x,y,i=0;i<M;i++)
  {
    scanf("%d %d",&x,&y);
    unite(x,y);
  }
  int ans=0;
  for(int i=1;i<N+1;i++)if(same(i,pi[i]))ans++;
  printf("%d",ans);
}

Measured memory_bytes: 5288
import qualified Data.Map as M

main :: IO ()
main = do
  s <- getLine
  putStrLn $ if (solve s) then "Yes" else "No"

solve :: String -> Bool
solve = M.foldr (\n b -> b && n == 2) True
      . foldr (\c mp -> M.insertWith (+) c 1 mp) M.empty

Measured memory_bytes: 380
def main():
    S=input()
    
    ans = [S[0]]
    c = ""
    for i in range(1, len(S)):
        c += S[i]
        if ans[-1] != c:
            ans.append(c)
            c = ""
    print(len(ans))    

if __name__ == '__main__':
    main()

Measured memory_bytes: 8068
#include <iostream>

#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	int h,n;
	cin >> h >> n;
	int a[n];
	long long sum = 0;
	rep(i,n) { cin >> a[i]; sum+=a[i]; }
	
	if(sum < h) cout << "No";
	else cout << "Yes";
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 4000
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N;
	cin >> N;
	vector<long long>A;
	long long M;
	for (long long i = 0; i < N; i++) {
		cin >> M;
		if (M % 2 == 0) A.push_back(M);
	}
	for (long long i = 0; i < A.size(); i++) {
		if (A.at(i) % 3 != 0 && A.at(i) % 5 != 0) {
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
typedef long long int ll;
#define FOR(i,n,m) for (int i=(n);i<=(m);i++)
#define si(n) fscanf(in,"%d",&n)
#define NM 1005
#define MOD 1000000007
#define INF 0x7fffffff
//FILE *in=fopen("input.txt","r"), *out = fopen("output.txt", "w");
FILE *in = stdin, *out = stdout;
using namespace std;

int n, p[NM], X[NM], D[NM][2], cnt[NM], dp[NM * 5];
int flag = 1;
vector<int> son[NM];
void input() {
	si(n);
	FOR(i, 2, n) {
		si(p[i]);
		son[p[i]].push_back(i);
	}
	FOR(i, 1, n) si(X[i]);
}
void pro() {
	for (int x = n; x >= 1; x--) {
		int sum = 0;
		for (auto &y : son[x]) {
			cnt[x] += D[y][0] + D[y][1];
			sum += min(D[y][0], D[y][1]);
		}
		if (sum > X[x]) {
			fprintf(out, "IMPOSSIBLE\n");
			return;
		}
		int left = X[x] - sum;
		FOR(i, 0, left) dp[i] = 0;
		dp[0] = 1;
		for (auto &y : son[x]) {
			int v = abs(D[y][0] - D[y][1]);
			for (int i = left; i >= v; i--) dp[i] |= dp[i - v];
		}
		for (int i = left; i >= 0; i--) {
			if (dp[i]) {
				cnt[x] += left - i;
				break;
			}
		}
		D[x][0] = X[x];
		D[x][1] = cnt[x] - X[x];
	}
	fprintf(out, "POSSIBLE\n");
}
int main() {
	input();
	pro();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;


int main(){
  string S,T;
  cin >> S >> T;
  bool can = true;
  vector<int> S_table(26,-1),T_table(26,-1);
  for(int i=0; i<(int)S.size(); i++){
    int s,t;
    s = S[i] - 'a';
    t = T[i] - 'a';
    if(S_table[s] >= 0){
      if(t != S_table[s]){
        can = false;
        break;
      }
    }else{
    S_table[s] = t;
    }
    if(T_table[t] >= 0){
      if(s != T_table[t]){
        can = false;
        break;
      }
    }else{
    T_table[t] = s;
    }
  }
  if(can){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
#define st first
#define nd second

using ll = long long ;
using namespace std;
using pii = pair<int,int>;

int main(){
	int l, r, d;
	scanf("%d %d %d", &l, &r, &d);
	int x = (l + d - 1) / d, y = r / d;
	printf("%d", y - x + 1);


}

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

int main(){
int n;cin>>n;
vector<int>a(n);
rep(i,n)cin>>a[i];
ll ans=0;
for(int i=1;i<n;i++){
if(a[i]<a[i-1]){
    ans=ans+(a[i-1]-a[i]);
    a[i]=a[i-1];
}
}
cout<<ans;
}

Measured memory_bytes: 4052
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

int n, k;

int calc(vector<int> card){
  int ret = -1;
  for(int i = 0 ; i < n-k+1 ; i++){
    int t = 1;
    for(int j = i ; j < i+k ; j++){
      t *= card[j];
    }
    ret = max(ret, t);
  }
  return ret;
}

int main(){
  while(cin >> n >> k){
    if(n == 0 && k == 0) break;
    vector<int> card;
    int t;
    for(int i = 0 ; i < n ; i++){
      cin >> t;
      card.push_back(t);
    }
    
    int prev = -1, Max = -1;
    prev = calc(card);
    bool f = false;
    
    
    for(int i = 0 ; i < n ; i++){
      for(int j = i+1 ; j < n ; j++){
	swap(card[i], card[j]);
	t = calc(card);
	if(Max < t){
	  Max = t;
	  f = true;
	}
	swap(card[i], card[j]);
      }
    }
    //cout << prev << endl << Max << endl;
    
    if(!f) cout << "NO GAME" << endl;
    else cout << Max-prev << endl;
  }
  return 0;
}

Measured memory_bytes: 1220