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

using namespace std;

#define ll long long
const int nmax=100000;
ll n,v[nmax+5];

int ok(ll val)
{
    for(int i=1;i<=n;i++)
        val-=val%v[i];
    if(val==2)
        return 1;
    if(val>2)
        return 2;
    if(val<2)
        return 3;
}
ll st,dr,pas;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>v[i];
    pas=(1LL<<50);
    while(pas)
    {
        if(ok(st+pas)==3)
            st+=pas;
        if(ok(dr+pas)==3 || ok(dr+pas)==1)
            dr+=pas;
        pas/=2;
    }
    if(st+1>dr)
        cout<<-1;
    else
        cout<<st+1<<" "<<dr;
    return 0;
}
/**
**/


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

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int A, B;
  cin >> A >> B;
  cout << max(A + B, max(A - B, A * B)) << endl;
  return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define sim template < class c
#define ris return *this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", ", d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; it++)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int N = 410;
const ll INF = 1e18;
int n, a[N];
ll dp[N][N], pref[N];

ll solve(int left, int right) {
	if (left == right) {
		return 0;
	}
	if (dp[left][right] != -1) {
		return dp[left][right];
	}
	dp[left][right] = INF;
	for (int i = left; i < right; i++) {
		dp[left][right] = min(dp[left][right], solve(left, i) + solve(i + 1, right));
	}
	dp[left][right] += (pref[right] - pref[left - 1]);
	return dp[left][right];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		pref[i] = pref[i - 1] + a[i];
	}
	memset(dp, -1, sizeof(dp));
	ll ans = solve(1, n);
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005;
const ll INF=1LL<<60;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    ll x=A[0]+A[1],y=0;
    for(int i=2;i<N;i++) y^=A[i];
    
    if((x&1LL)!=(y&1LL)||x<y){
        cout<<-1<<endl;
        return 0;
    }
    
    ll z=(x-y)/2;
    
    ll ans=z,ans2=z;
    
    for(int i=60;i>=0;i--){
        if(z&(1LL<<i)) continue;
        if(!(y&(1LL<<i))) continue;
        
        if(ans+(1LL<<i)<=A[0]){
            ans+=(1LL<<i);
        }else{
            ans2+=(1LL<<i);
        }
    }
    
    if(ans==0||ans>A[0]||ans+ans2!=x) cout<<-1<<endl;
    else cout<<A[0]-ans<<endl;
}


Measured memory_bytes: 3580
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<char> vc;
typedef vector<vector<char> > vvc;
typedef vector<double> vd;
typedef vector<vector<double> > vvd;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) {
        s << vv[i] << endl;
    }
    return s;
}

int main() {
    int a, b;
    cin >> a >> b;
    if ( a <= 0 && b >= 0 ) {
        printf("Zero\n");
        return 0;
    }
    if ( b < 0 && (b-a) % 2 == 0 ) {
        printf("Negative\n");
        return 0;
    }
    printf("Positive\n");
    return 0;
}


Measured memory_bytes: 888
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    let N = parseInt(arg[0]);
    
    let answer = "";
    
    while(N !== 0) {
        if(N % 2 !== 0) {
            N--;
            answer = "1" + answer;
        } else {
            answer = "0" + answer;
        }
        
        N /= -2;
    }
    
    if(answer === "") {
        answer = 0;
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

int main(){
  int n;
  ll x,y; scanf("%d",&n);
  scanf("%lld%lld",&x,&y);
  REP(i,n-1){
    ll p,q; scanf("%lld%lld",&p,&q);
    ll z = (x+p-1)/p,a=(y+q-1)/q;
    z=max(z,a);
    x=z*p,y=z*q;
  }
  printf("%lld\n",x+y);
  return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int k = 0; k < K; k++) {
    vector<int> B(N, 0);
    for (int i = 0; i < N; i++) {
      if (A[i] > 0) {
        B[max(0, i - A[i])]++;
        if (i + A[i] + 1 <= N - 1) B[i + A[i] + 1]--;
      }
    }
    bool flag = true;
    for (int i = 0; i < N; i++) {
      if (i + 1 < N) B[i + 1] += B[i];
      if (A[i] == 0) B[i]++;
      if (B[i] != N) flag = false;
    }
    swap(A, B);
    if (flag) break;
  }
  for (auto &v : A) {
    cout << v << (&v == &A.back() ? '\n' : ' ');
  }
  return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for(auto &a : A) cin >> a;
	int minv = INT_MAX, maxv = INT_MIN;
	int minp = -1, maxp = -1;
	for(int i=0;i<N;i++) {
		if(minv > A[i]) {
			minp = i;
			minv = A[i];
		}
		if(maxv < A[i]) {
			maxp = i;
			maxv = A[i];
		}
	}
	vector<pair<int,int>> ans;
	if(abs(minv) < abs(maxv)) {
		for(int i=0;i<N;i++) {
			if(A[i] < 0) {
				ans.push_back({maxp ,i});
				A[i] += maxv;
			}
		}
		for(int i=1;i<N;i++) {
			A[i] += A[i-1];
			ans.push_back({i-1, i});
		}
	} else {
		for(int i=0;i<N;i++) {
			if(A[i] > 0) {
				ans.push_back({minp ,i});
				A[i] += minp;
			}
		}
		for(int i=N-2;i>=0;i--) {
			A[i] += A[i+1];
			ans.push_back({i+1, i});
		}
	}
	cout << ans.size() << endl;
	for(auto &a : ans) cout << a.first+1 << " " << a.second+1 << endl;

	return 0;
}

Measured memory_bytes: 256
// AOJ 2793 Lost Graph
// 2018.4.18 bal4u

#include <stdio.h>
#include <string.h>

/*******************************************/
/* Dinic's Max Flow Algorithm 
/*******************************************/

#define INF 0x01010101
#define VMAX 105
typedef struct { int to; int cap; int rev; } EDGE;
EDGE edge[VMAX][VMAX]; int hi[VMAX];
int V;				// 頂点数
int level[VMAX], iter[VMAX];
int queue[2*VMAX], qtop;

void add_edge(int from, int to, int cap)
{
	int f, t;
	EDGE *e;

	f = hi[from]++, t = hi[to]++;
	e = &edge[from][f], e->to = to, e->cap = cap, e->rev = t; 
	e = &edge[to][t], e->to = from, e->cap = 0, e->rev = f;
}

void bfs(int s)
{
	int i, v;
	EDGE *e;
	
	memset(level, -1, V << 2);
	level[s] = 0;
	queue[0] = s, qtop =1;
	while (qtop) {
		v = queue[--qtop];
		for (i = 0; i < hi[v]; i++) {
			e = &edge[v][i];
			if (e->cap > 0 && level[e->to] < 0) {
				level[e->to] = level[v] + 1;
				queue[qtop++] = e->to;
			}
		}
	}
}
 
int dfs(int v, int t, int f)
{
	int *i, d;
	EDGE *e;
	
	if (v == t) return f;
	for (i = &iter[v]; *i < hi[v]; (*i)++) {
		e = &edge[v][*i];
		if (e->cap > 0 && level[v] < level[e->to]) {
			d = dfs(e->to, t, f <= e->cap? f: e->cap);
			if (d > 0) {
				e->cap -= d;
				edge[e->to][e->rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
 
int maxFlow(int s, int t)
{
	int f, flow = 0;
	while (1) {
		bfs(s);
		if (level[t] < 0) break;
		memset(iter, 0, V << 2);
		while ((f = dfs(s, t, INF)) > 0) flow += f;
	}
	return flow;
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int  a[52], b[52], sa, sb;
int  fr[102], fsz;
int  to[102], tsz;
char ans[52][52];

int main()
{
	int n, i, j;
	int source, sink;

	n = in();
	for (i = 0; i <= n; i++) a[i] = in();
	for (i = 0; i <= n; i++) b[i] = in();

	for (i = 0; i <= n; i++) {
		for (j = 0; j < a[i]; j++) fr[fsz++] = i, sa += i;
		for (j = 0; j < b[i]; j++) to[tsz++] = i, sb += i;
	}
	if (fsz != n || tsz != n || sa != sb) { puts("NO"); return 0; }

	source = n<<1, sink = source+1, V = sink+1;
	for (i = 0; i < n; i++) {
		add_edge(source, i, to[i]);
		for (j = 0; j < n; j++) add_edge(i, n+j, 1);
		add_edge(n+i, sink, fr[i]);
	}
	if (maxFlow(source, sink) < sb) { puts("NO"); return 0; }

	memset(ans, '0', sizeof(ans));
	for (i = 0; i < n; i++) for (j = 0; j < hi[i]; j++) {
		EDGE *ep = &edge[i][j];
		if (ep->to >= n && ep->to < source && ep->cap == 0) ans[i][ep->to - n] = '1';
	}
	puts("YES");
	for (i = 0; i < n; i++) {
		putchar(ans[i][0]);
		for (j = 1; j < n; j++) putchar(' '), putchar(ans[i][j]);
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 2100
<?php

fscanf(STDIN, "%d %d", $in_n, $in_k);
$ans = $in_n;
$arr_sunuke = array_fill(0, $in_n, false);

for($i = 0; $i < $in_k; $i++){
    fscanf(STDIN, "%d", $in_d[$i]);
    $in_a[$i] = trim(fgets(STDIN));
    $a[$i] = explode(" ", $in_a[$i]);
//    var_dump($in_a[$i]);
//    var_dump($a[$i]);
    for($j = 0; $j < $in_d[$i]; $j++){
        if($arr_sunuke[$a[$i][$j] - 1] == false){
            $arr_sunuke[$a[$i][$j] - 1] = true;
            $ans--;
        }
    }
}

echo "$ans\n";


Measured memory_bytes: 16684
from operator import itemgetter

# N = 仕事の数
N = int(input())
# AB[i][0] = 仕事iを終わらせるまでの時間
# AB[i][1] = 仕事の締め切りまでの時刻
AB = [list(map(int, input().split())) for _ in range(N)]

# 思考メモ
# 貪欲法1：締め切りの短いものから解いていく？

# Bで昇順にソートする
AB_sort = sorted(AB, key=itemgetter(1, 0))

out = "Yes"
count = 0
for i in range(N):
    count += AB_sort[i][0]
    if count > AB_sort[i][1]:
        out = "No"
        break

print(out)


Measured memory_bytes: 67884
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int diff = 0;
        for(int i = 1; i <= n; i++){
            if(i != sc.nextInt()){
                diff++;
            }
        }
        
        System.out.println(diff <= 2 ? "YES" : "NO");
    }
}


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

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int key) {
    Node *x = root;
    Node *y = NIL;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = key;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) x = x->left;
        else x = x->right;
    }

    z->parent = y;

    if (y == NIL) root = z;
    else if (z->key < y->key) y->left = z;
    else y->right = z;

    return;
}

void preParse(Node *u) {
    if (u == NIL) return;
    cout << " " << u->key;
    preParse(u->left);
    preParse(u->right);
    return;
}

void inParse(Node *u) {
    if (u == NIL) return;
    inParse(u->left);
    cout << " " << u->key;
    inParse(u->right);
    return;
}

void print() {
    inParse(root);
    cout << "\n";
    preParse(root);
    cout << endl;
    return;
}

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

    string command;
    int key;
    for (int i = 0; i < m; i++) {
        cin >> command;
        if (command == "insert") {
            cin >> key;
            insert(key);
        } else {
            print();
        }
    }

    return 0;
}


Measured memory_bytes: 26524
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a, b;
  cin >> N >> a >> b;

  int x1 = a * N;
  int x2 = b;
  int x = min(x1, x2);
  cout << x << endl;
 
  return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main{

	public static void main(String[] args){
		//入力
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		String s[] = new String[n];
		for(int i = 0; i < n; i++) s[i] = sc.nextLine();
		sc.close();

		//処理
		Map<String, Long> map = new HashMap<>(); 
		for(int i = 0; i < n; i++){
			char t[] = s[i].toCharArray();
			Arrays.sort(t);
			String str = String.valueOf(t);
			map.compute(str, (key, value) -> value == null ? 1 : value+1);
		}

		long ans = 0;
		for(long v : map.values()){
			ans += v * (v-1) / 2;
		}
		
		//出力
		PrintWriter out = new PrintWriter(System.out);
		out.println(ans);
		out.flush();
	}
}

Measured memory_bytes: 105176
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// ２つの円の交点を求める
type point struct {
	x, y float64
}

const eps = 1e-9

func circleCrossPt(p0, p1 point, r1, r2 float64) ([]point, int) {
	dx := p1.x - p0.x
	dy := p1.y - p0.y
	l2 := dx*dx + dy*dy
	a := (l2 + r1*r1 - r2*r2) / 2.0
	D := l2*r1*r1 - a*a
	if D < 0 || l2 == 0 {
		return []point{}, 0
	}
	D = math.Sqrt(D)
	return []point{
		point{(a*dx+D*dy)/l2 + p0.x, (a*dy-D*dx)/l2 + p0.y},
		point{(a*dx-D*dy)/l2 + p0.x, (a*dy+D*dx)/l2 + p0.y}}, 2
}

func abs(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

func equal(a, b float64) bool {
	return abs(a-b) < eps
}

func max(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	//out(circleCrossPt(point{0, -10}, point{0, 10}, 10, 10))
	//panic(-1)
	N, K := getInt(), getInt()
	p := make([]point, N)
	c := make([]float64, N)
	for i := 0; i < N; i++ {
		x, y, z := getInt(), getInt(), getInt()
		p[i] = point{float64(x), float64(y)}
		c[i] = float64(z)
	}

	//	out(N, K, p, c)

	L := float64(0)
	R := float64(400000)

	for n := 0; n < 100; n++ {
		T := (L + R) / 2.0
		ap := make([]point, 0)
		// 中心を登録
		for i := 0; i < N; i++ {
			ap = append(ap, p[i])
		}
		// 交点を登録
		for i := 0; i < N; i++ {
			for j := i + 1; j < N; j++ {
				pos, num := circleCrossPt(p[i], p[j], T/c[i], T/c[j])
				switch num {
				case 1:
					ap = append(ap, pos[0])
				case 2:
					ap = append(ap, pos[0])
					ap = append(ap, pos[1])
				}
			}
		}
		ans := false
		for _, v := range ap {
			cnt := 0
			for i := 0; i < N; i++ {
				dx := p[i].x - v.x
				dy := p[i].y - v.y
				r := math.Sqrt(dx*dx+dy*dy) * c[i]
				if r <= T+eps {
					cnt++
				}
			}
			if cnt >= K {
				ans = true
				break
			}
		}
		if ans == true {
			R = T
		} else {
			L = T
		}
		//		out(ans, L, R)
	}
	out(L)
}


Measured memory_bytes: 6656
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

char s[55][55];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h, w; cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			cin >> s[i][j];
		}
	}
	
	rep(i, h) {
		rep(j, w) {
			if (i == 0 || j == 0 || i == h - 1 || j == w - 1)continue;
			if (s[i][j]=='#'&&!(s[i - 1][j] == '#' || s[i + 1][j] == '#' || s[i][j - 1] == '#' || s[i][j + 1] == '#')) {
				cout << "No" << endl; return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
  int H, W, K;
  cin >> H >> W >> K;

  int x = W, y = H;
  bool res = false;
  for(int i = 0; i <= x; i++){
    for(int j = 0; j <= y; j++){
      if(i * H + j * W - 2*i*j == K){
        res = true;
      }
    }
  }

  if(res) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
k, n = map(int, input().split())
a = list(map(int, input().split()))
ans = k
for i in range(n):
    if (i == 0):
        tmp = a[-1] - a[0]
    else:
        tmp = k-a[i]+a[i-1]
    if (tmp < ans):
        ans = tmp
print(ans)

Measured memory_bytes: 25840
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <cstring>

const int maxn = 105;
long long P[maxn][maxn];
long long stat[maxn][maxn];
long long cur[maxn];
long long ret = -0x3f3f3f3f3f3f3f3f;
int n;
int main() {
    //  int n;
    std::cin >> n;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= 10; ++j) std::cin >> stat[i][j];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= 10; ++j) std::cin >> P[i][j];
    }
    int st = ((1ll) << 10) - 1;
    for (int i = 1; i <= st; ++i) {
        memset(cur,0,sizeof cur);
        long long cu = 0;
        int cnt = 0;
        for(int j = 0; j <= 9; ++ j){
            if (i & (1 << j)) {
                ++ cnt;
                for(int k = 1; k <= n; ++ k){
                    if (stat[k][j + 1]) cur[k] ++;
                }
            }
        }
        if(cnt == 0) continue;
        for(int j = 1; j <= n; ++ j) cu += P[j][cur[j]];
        ret = ret > cu ? ret : cu;
    }
    std::cout << ret << std::endl;
}

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

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

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


int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll t=1;
	// cin>>t;

	while(t--){
		ll d,s,ti;
		cin>>d>>s>>ti;

		if(s*ti >= d) cout<<"Yes\n";
		else cout<<"No\n";

	}	

	return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int K = sc.nextInt();
		sc.close();
		int n = s.length();
		int[] c = new int[n];
		int[] k = new int[n];
		for(int i = 0; i < n; i++) {
			char c0 = s.charAt(i);
			c[i] = (int)(c0 - 'a');
			int g = 26 - c[i];
			k[i] = g % 26;
		}

		int r = K;
		for(int i = 0; i < n; i++) {
			if(r - k[i] >= 0) {
				r -= k[i];
				c[i] = 0;
			}
		}
		c[n - 1] = (c[n - 1] + r) % 26;
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < n; i++) {
			char c0 = (char)(c[i] + (int)'a');
			sb.append(c0);
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 27268
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }
    let ans = s
        .windows(3)
        .map(|x| {
            (x.iter()
                .map(|x| *x)
                .collect::<String>()
                .parse::<i64>()
                .unwrap()
                - 753)
                .abs()
        })
        .min()
        .unwrap();
    println!("{}", ans);
}


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

int main() {
  vector<int> s,sodd;
  for(int i=1; i*(i+1)*(i+2)/6 < 1000000; ++i) {
    s.push_back(i*(i+1)*(i+2)/6);
    if((i*(i+1)*(i+2)/6)%2 == 1)
      sodd.push_back(i*(i+1)*(i+2)/6);
  }

  vector<int> table(1000001, 0);
  vector<int> otable(1000001, 0);

  for(int i=0; i<s.size(); ++i)
    table[s[i]] = 1;

  for(int i=0; i<sodd.size(); ++i)
    otable[sodd[i]] = 1;

  for(int j=1; j < 1000001; ++j) {
    for(int i=0; i < s.size(); ++i)
      if(table[j] != 0 && j+s[i] < 1000001) {
	table[j + s[i]] = (table[j+s[i]]==0) ? table[j]+1 : min( table[j+s[i]], table[j]+1 );
      }
  }

  for(int j=1; j < 1000001; ++j) {
    for(int i=0; i < sodd.size(); ++i)
      if(otable[j] != 0 && j+sodd[i] < 1000001) {
	otable[j + sodd[i]] = (otable[j+sodd[i]]==0) ? otable[j]+1 : min( otable[j+sodd[i]], otable[j]+1 );
      }
  }

  int d;
  for(;;) {
    cin>>d;
    if(!d) break;
    cout<<table[d]<<" "<<otable[d]<<endl;
  }

}

Measured memory_bytes: 8620
#include <bits/stdc++.h>
#define MAXN 100010
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const int mod = 1e9 + 7;

int main (){
    string s;

    cin >> s;

    int n = s.size();

    for (int i=0; i<n-2; i++){
        if (s[i+1] == s[i] || s[i+2] == s[i]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }

    if (s[n-1] == s[n-2]){
        cout << n-1 << " " << n << endl;
    }
    else cout << "-1 -1" << endl;
    
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int a[n];

    int xr = 0;

    for(int i = 0; i < n; i++){
        cin >> a[i];
        xr ^= a[i];
    }
    for(int i = 0; i < n; i++){
        cout << (a[i]^xr) << " ";
    }
    return 0;
}


Measured memory_bytes: 4416
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
#define x1 qeerdx
#define y1 qeerdy
 
#define lb lower_bound
#define ub upper_bound
 
#define endl '\n'
#define fast_in ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
#define mp  make_pair
#define pb  push_back
 
#define fi first
#define se second
 
#define   sz(x)  (int)x.size()
#define  all(x)  x.begin(), x.end()
#define  bit(x)  __builtin_popcountll(x)

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
               
typedef pair <int,int> pii;
 
const int inf = (int) 1e9+99999, mod = (int)1e9+7;
const ll linf = (ll) 2e18+99999;
 
int kob (int x, int y) { return ((ll)x * y) % mod; } 
int aza (int x, int y) { x -= y; if (x < 0) return x + mod; return x; } 
int kos (int x, int y) { x += y; if (x >= mod) return x - mod; return x; }
 
const int maxn = (int) 3e6, maxn2 = (int) 1e6+55;
 
static long holdrand = 1L;                         
void srand(unsigned int seed){holdrand = (long) seed;} 
int rand() {return (((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff);}

void solve () {
	int n; cin >> n;
	for (int i = 1; i <= n; i ++) {
		int x;
		cin >> x;
		if (x % 2 == 0) {
			if (!(x % 3 == 0 || x % 5 == 0)) {
				cout << "DENIED";
				exit (0);
			}
		}
	}

	cout << "APPROVED";
}

main () { fast_in;
    int t = 1; //cin >> t;
    while (t --) {
    	solve ();    
    }
	return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{
		int N = nextInt();
		int[] h = nextInts();

		int[] dp = new int[N+1];

		dp[0]=0;
		dp[1]=Math.abs(h[1]-h[0]);
		if(N>2)
			dp[2]=Math.min(Math.abs(h[2]-h[1])+dp[1],Math.abs(h[2]-h[0])+dp[0]);
		for(int i=3;i<N;i++){
			dp[i]=Math.min(Math.abs(h[i]-h[i-1])+dp[i-1],Math.abs(h[i]-h[i-2])+dp[i-2]);
		}
		System.out.println(dp[N-1]);
	}


	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 33892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	int ans=0;
	while(true){
		bool flg=true;
		int len=0,sum=0,k=0,mi=1000000000,curmi=1000000000;
		rep(i,n){
			if(a.at(i)>0){
				sum++;
				curmi=min(curmi,a.at(i));
				flg=false;
			}
			else{
				if(sum>len){
					len=sum;
					k=i-1;
					mi=curmi;
				}
				curmi=1000000000;
				sum=0;
			}
		}
		if(sum>len){
			len=sum;
			k=n-1;
			mi=curmi;
		}
		if(flg) break;
		ans+=mi;
		for(int i=k-len+1;i<=k;++i){
			a.at(i)-=mi;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int n;cin>>n,n;){
		vvd cur(3,vd(3));
		pii barn;
		char s,t,b; cin>>s>>t>>b;
		cur[(s-'A')/3][(s-'A')%3]=1;
		barn=mp((b-'A')/3,(b-'A')%3);
		while(n--){
			vvd next(3,vd(3));
			rep(i,3) rep(j,3){
				int di[]={-1,1,0,0};
				int dj[]={0,0,-1,1};
				int stop=0;
				rep(k,4){
					int ni=i+di[k],nj=j+dj[k];
					if(ni<0 || 3<=ni || nj<0 || 3<=nj || mp(ni,nj)==barn)
						stop++;
					else
						next[ni][nj]+=cur[i][j]/4;
				}
				next[i][j]+=cur[i][j]*stop/4;
			}
			cur=next;
		}
		printf("%f\n",cur[(t-'A')/3][(t-'A')%3]);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;
const int qq = 1e5 + 10;
ll n, m;
char str[qq];
int vis[qq];
bool judge(){
//	for(int i = 1; i <= n; ++i)
//		printf("%d ", vis[i]);
//	printf("\n");
	for(int i = 2; i < n; ++i)
		if(vis[i] == 1){
			if(str[i] == 'o'){
				if(vis[i + 1] != vis[i - 1])	return false;
			}else{
				if(vis[i + 1] == vis[i - 1])	return false;
			}
		}else{
			if(str[i] == 'o'){
				if(vis[i + 1] == vis[i - 1])	return false;
			}else{
				if(vis[i + 1] != vis[i - 1])	return false;
			}
		}
	if(vis[1] == 1){
		if(str[1] == 'o'){
			if(vis[2] != vis[n])	return false;
		}else{
			if(vis[2] == vis[n])	return false;
		}
	}else{
		if(str[1] == 'o'){
			if(vis[2] == vis[n])	return false;
		}else{
			if(vis[2] != vis[n])	return false;
		}
	}
	if(vis[n] == 1){
		if(str[n] == 'o'){
			if(vis[n - 1] != vis[1])	return false;
		}else{
			if(vis[n - 1] == vis[1])	return false;
		}
	}else{
		if(str[n] == 'o'){
			if(vis[n - 1] == vis[1])	return false;
		}else{
			if(vis[n - 1] != vis[1])	return false;
		}
	}
	return true;
}

void print(){
	for(int i = 1; i <= n; ++i)
		if(vis[i] == 1)	printf("S");
		else	printf("W");
	puts("");
}

int main(){
	scanf("%lld", &n);
	scanf("%s", str + 1);
	int flag = false;
	vis[1] = 1;
	vis[2] = 1;
	for(int i = 2; i < n; ++i)
		if(vis[i] == 1){
			if(str[i] == 'o')	vis[i + 1] = vis[i - 1];
			else				vis[i + 1] = (vis[i - 1] == 1 ? 0 : 1);
		}else{
			if(str[i] == 'x')	vis[i + 1] = vis[i - 1];
			else				vis[i + 1] = (vis[i - 1] == 1 ? 0 : 1);
		}
	flag = judge();
	if(flag == true){
		print();
		return 0;
	}
	vis[1] = 0;
	vis[2] = 0;
	for(int i = 2; i < n; ++i)
		if(vis[i] == 1){
			if(str[i] == 'o')	vis[i + 1] = vis[i - 1];
			else				vis[i + 1] = (vis[i - 1] == 1 ? 0 : 1);
		}else{
			if(str[i] == 'x')	vis[i + 1] = vis[i - 1];
			else				vis[i + 1] = (vis[i - 1] == 1 ? 0 : 1);
		}
	flag = judge();
	if(flag == true){
		print();
		return 0;
	}
	vis[1] = 1;
	vis[2] = 0;
	for(int i = 2; i < n; ++i)
		if(vis[i] == 1){
			if(str[i] == 'o')	vis[i + 1] = vis[i - 1];
			else				vis[i + 1] = (vis[i - 1] == 1 ? 0 : 1);
		}else{
			if(str[i] == 'x')	vis[i + 1] = vis[i - 1];
			else				vis[i + 1] = (vis[i - 1] == 1 ? 0 : 1);
		}
	flag = judge();
	if(flag == true){
		print();
		return 0;
	}
	vis[1] = 0;
	vis[2] = 1;
	for(int i = 2; i < n; ++i)
		if(vis[i] == 1){
			if(str[i] == 'o')	vis[i + 1] = vis[i - 1];
			else				vis[i + 1] = (vis[i - 1] == 1 ? 0 : 1);
		}else{
			if(str[i] == 'x')	vis[i + 1] = vis[i - 1];
			else				vis[i + 1] = (vis[i - 1] == 1 ? 0 : 1);
		}
	flag = judge();
	if(flag == true){
		print();
		return 0;
	}
	printf("-1\n");
}


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

int main() {
	// your code goes here
	long long int n,w;
	cin>>n>>w;
	vector <long long int > dp(w+1);
	for(int i=0;i<w;i++)
	{
		dp[i]=0;
	}
	for(int i=0;i<n;i++)
	{
		long long int val,wei;
		cin>>wei>>val;
		for(int j=w;j>=wei;--j)
		{
			
			dp[j]=max(dp[j],dp[j-wei]+val);
		//	cout<<j<<" "<<dp[j]<<" ";
			
		
		
		}//cout<<endl;
	}

	int ans=0;
	cout<<dp[w];
	
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int N;
	cin >> N;
	int d[110];
	
	for(int i=0; i<N; i++){
		cin >> d[i];
	}
	
	int sum=0;
	for(int i=0; i<N-1; i++){
		for(int k=i+1; k<N; k++){
			sum = sum +(d[i]*d[k]);
		}
	}
	
	cout << sum << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
N = int(input())
a = [int(ai) for ai in input().split()]
b = []
x, y = 0, 0
forward = True
for i in range(N):
    for _ in range(a[i]):
        b.append(i + 1)
forward = True
for i in range(H):
    bi = list(map(str, b[i*W:(i+1)*W]))
    if forward:
        print(" ".join(bi))
        forward = False
    else:
        print(" ".join(bi[::-1]))
        forward = True


Measured memory_bytes: 3572
#include <stdio.h>

int main(void) {
	int N,i;
	int cnt=1;
	scanf("%d\n",&N);
	char d[N];
	scanf("%s",d);
	for(i=0;i<N-1;i++){
		if(d[i]!=d[i+1]){
			cnt++;
		}else{
			cnt=cnt;
		}
	}
	printf("%d",cnt);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int q;
	cin >> q;
	for(int i=0;i<q;++i){
		int c,a,n,counter=0;
		cin >> c >> a >> n;
		while(1){
			if(c>0 && a>0 && n>0){
				counter+=1;
				c-=1;
				a-=1;
				n-=1;
			}
			else if(c>=2 && a>0){
				counter+=1;
				c-=2;
				a-=1;
			}
			else if(c>=3){
				counter+=1;
				c-=3;
			}
			else{
				break;
			}
		}
		cout << counter << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<climits>

const int maxn = 3e5 + 10;
typedef long long LL;
using namespace std;
#define pb push_back
#define mp make_pair
#define x first
#define y second

int read()
{
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') f = 0; c = getchar(); }
	while(isdigit(c)) { x = (x * 10) + (c ^ 48); c = getchar(); }
	return f ? x : -x;
}

int n, a[maxn];
LL s[maxn];

int ck(LL x)
{
	int now = 0;
	if(s[n] - s[now] >= x) return 1;
	for(int i = 1; i <= n; ++i)
		if((i & 1) == 0 && s[i - 1] - s[now] >= x)
		{
			if(s[i] < s[now]) now = i;
			if(s[n] - s[i] >= x) return 1;
		}
	return 0;
}

int main()
{

	n = read();
	LL sumb = 0, sumw = 0;
	for(int i = 1; i <= n; ++i) a[i] = read(), sumb += (i & 1 ? a[i] : 0), sumw += (i & 1 ? 0 : a[i]);

	if(!(n & 1)) return cout << max(sumb, sumw) << ' ' << min(sumb, sumw) << endl, 0;

	for(int i = 1; i <= n; ++i)
	{
		s[i] += (i & 1 ? a[i] : 0);
		s[i] += (i & 1 ? 0 : -a[i]);
		s[i] += s[i - 1];
	}

	LL l = 0, r = sumb, ans = -LLONG_MAX;
	while(l <= r)
	{
		int mid = (l + r) >> 1;
		if(ck(mid)) l = mid + 1, ans = mid;
		else r = mid - 1;
	}

	cout << sumw + ans << ' ' << sumb - ans << endl;

	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
struct unionFind{
  vector<int>par;

  unionFind(int n):par(n){
    for(int i=0;i<n;i++)par[i] = i;
  }

  int find(int x){
    if(par[x]==x)return x;
    else return par[x] = find(par[x]);
  }

  void unite(int x,int y){
    int xx = find(x);
    int yy = find(y);
    if(xx==yy)return;
    else{
      par[xx]=yy;
      return;
    }
  }

  bool same(int x,int y){
    int xx = find(x);
    int yy = find(y);
    return xx == yy;
  }

};

int main(){
  int n,m;
  cin >> n >> m;
  vector<int>p(n);
  int i;
  for(i=0;i<n;i++){
    cin >> p[i];
  }
  int x,y;
  unionFind unif(n+1);
  for(i=0;i<m;i++){
    cin >> x >> y;
    unif.unite(x,y);
  }
  int ans = 0;
  for(i=0;i<n;i++){
    if(unif.same(p[i],i+1))ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
    int n,i;
    int p[16];
    int mxp=0,tp=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&p[i]);
        if(p[i]>mxp)mxp=p[i];
        tp+=p[i];
    }
    tp-=(mxp/2);
    printf("%d\n",tp);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define FOR(i, r, n) for (int i=(int)(r); i<=(int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF 2147483647
#define INF64 9223372036854775807
#define MOD 1000000007

int main(){

    int D; cin>>D;
    vector<int> c(26);
    vector<vector<int>> s(D, vector<int>(26));
    rep(i, 26) cin>>c[i];
    rep(i, D) rep(j, 26) cin>>s[i][j];

    vector<int> fuman(26, 0);
    rep(i, D){
        rep(j, 26) fuman[j]+=c[j];
        int t, fuman_max=0;
        rep(j, 26){
            if(fuman_max<fuman[j]-s[i][j]){
                t=j;
                fuman_max=fuman[j];
            }
        }
        
        cout<<t+1<<endl;
        fuman[t]=0;
    }

}

Measured memory_bytes: 3664
x = int(input())
A = [input() for i in range(x)]

ac=0
wa=0
tle=0
re=0

for a in A:
    if a=='AC':
        ac+=1
    if a=='WA':
        wa+=1
    if a=='TLE':
        tle+=1
    if a=='RE':
        re+=1

print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))

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

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

// ========================================================================= //

const int N = 100179;

int main() {
    ios::sync_with_stdio(false);

    int n;
    map<int,int> z;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        ++z[x];
    }
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (!z[x]) {
            cout << "NO\n";
            return 0;
        }
        --z[x];
    }
    cout << "YES\n";

    return 0;
}


Measured memory_bytes: 9600
// x is no need <=> there exists a sum S without x s.t. K-x <= S < K

#include <bits/stdc++.h>

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

using namespace std;

int main(){
	int n,k; scanf("%d%d",&n,&k);

	vector<int> a;
	rep(i,n){
		int x; scanf("%d",&x);
		if(x<k) a.emplace_back(x);
	}
	n=a.size();

	static bool dp1[5001][5001]; // dp1[i][w] := ( a[0,i) を使って w が作れるか )
	static bool dp2[5001][5001]; // dp2[i][w] := ( a[n-i,n) を使って w が作れるか )
	dp1[0][0]=dp2[0][0]=true;
	rep(i,n){
		rep(w,k+1){
			dp1[i+1][w]=dp1[i][w];
			dp2[i+1][w]=dp2[i][w];
		}
		for(int w=k;w>=a[  i  ];w--) dp1[i+1][w]|=dp1[i][w-a[  i  ]];
		for(int w=k;w>=a[n-i-1];w--) dp2[i+1][w]|=dp2[i][w-a[n-i-1]];
	}

	static int dp3[5001][5001]; // dp3[i][w] := (a[n-i,n) を使って作れる w 未満の数の種類 )
	rep(i,n+1){
		dp3[i][0]=0;
		rep(w,k) dp3[i][w+1]=dp3[i][w]+dp2[i][w];
	}

	int ans=0;
	rep(i,n){
		bool need=false;
		rep(w,k+1) if(dp1[i][w] && dp3[n-i-1][k-w]-(w<=k-a[i]?dp3[n-i-1][k-w-a[i]]:0)>0) need=true;
		if(!need) ans++;
	}
	printf("%d\n",ans);

	return 0;
}


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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define pb push_back

using namespace std;

const int N = 20010, M = 2e7 + 10;

int Begin[N], Next[M], to[M], e;

void add(int u, int v){
	if(u == v) return;
	to[++e] = v, Next[e] = Begin[u], Begin[u] = e;
}

struct Flag{
	int x, y;
}A[N];

int n, m, top, clk;
int dfn[N], low[N], bel[N], stk[N];

void Tarjan(int o){
	low[o] = dfn[o] = ++clk;
	stk[++top] = o;
	for(int i = Begin[o]; i; i = Next[i]){
		int u = to[i];
		if(!dfn[u]){
			Tarjan(u);
			low[o] = min(low[u], low[o]);
		}
		else if(!bel[u]) low[o] = min(low[o], dfn[u]);
	}
	if(low[o] == dfn[o]){
		bel[o] = ++m;
		while(stk[top] ^ o) bel[stk[top--]] = m;
		--top;
	}
}

vector<int> G[N], dif[N];
int deg[N], val[N];

bool Topsort(){
	queue<int> q;
	For(i, 1, m) if(!deg[i]) q.push(i);
	while(!q.empty()){
		int o = q.front(), sz; q.pop();
		sz = int(dif[o].size()) - 1;
		val[o] = 1;
		For(i, 0, sz) if(val[dif[o][i]] == 1){
			val[o] = 0;
			break;
		}
		if(!val[o]) For(i, 0, sz) if(val[dif[o][i]] == 0) return false;
		sz = int(G[o].size()) - 1;
		For(i, 0, sz){
			int v = G[o][i];
			if(!--deg[v]) q.push(v);
		}
	}
	return true;
}

struct Node{
	int x, o;

	bool operator < (const Node& B) const{
		return x ^ B.x ? x < B.x : o < B.o;
	}
}B[N];

int c;
int posx[N], posy[N];

bool check(int lim){
	e = m = top = 0;
	For(i, 2, n * 2 + 1) Begin[i] = dfn[i] = bel[i] = 0;
	For(i, 1, n){
		int j = posx[i];
		while(j > 1 && A[i].x - B[j - 1].x < lim && posx[i] - j < 20) --j, add(i << 1, B[j].o ^ 1), add(B[j].o, i << 1 | 1);
		j = posx[i];
		while(j < c && B[j + 1].x - A[i].x < lim && j - posx[i] < 20) ++j, add(i << 1, B[j].o ^ 1), add(B[j].o, i << 1 | 1);
		j = posy[i];
		while(j > 1 && A[i].y - B[j - 1].x < lim && posy[i] - j < 20) --j, add(i << 1 | 1, B[j].o ^ 1), add(B[j].o, i << 1);
		j = posy[i];
		while(j < c && B[j + 1].x - A[i].y < lim && j - posy[i] < 20) ++j, add(i << 1 | 1, B[j].o ^ 1), add(B[j].o, i << 1);
	}

	clk = 0;
	For(i, 2, n * 2 + 1) if(!dfn[i]) Tarjan(i);

	For(i, 1, m) G[i].clear(), dif[i].clear(), deg[i] = 0, val[i] = -1;
	For(i, 1, n){
		int u = bel[i << 1], v = bel[i << 1 | 1];
		if(u == v) return false;
		dif[u].pb(v), dif[v].pb(u);
	}

	For(i, 2, n * 2 + 1) for(int j = Begin[i]; j; j = Next[j])
		if(bel[i] ^ bel[to[j]]) G[bel[to[j]]].pb(bel[i]), deg[bel[i]]++;
	return Topsort();
}

int main(){
	scanf("%d", &n);
	For(i, 1, n){
		scanf("%d%d", &A[i].x, &A[i].y);
		if(A[i].x > A[i].y) swap(A[i].x, A[i].y);
		B[++c] = (Node){A[i].x, i << 1}, B[++c] = (Node){A[i].y, i << 1 | 1};
	}
	sort(B + 1, B + c + 1);
	For(i, 1, n){
		posx[i] = lower_bound(B + 1, B + c + 1, (Node){A[i].x, i << 1}) - B;
		posy[i] = lower_bound(B + 1, B + c + 1, (Node){A[i].y, i << 1 | 1}) - B;
	}

	int Maxd = 1e9;
	For(i, 1, n) For(j, i + 1, n) Maxd = min(Maxd, max(abs(A[j].y - A[i].x), abs(A[i].y - A[j].x)));

	int L = 0, R = Maxd;
	while(L < R){
		int mid = (L + R + 1) >> 1;
		if(check(mid)) L = mid;
		else R = mid - 1;
	}

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

	return 0;
}

Measured memory_bytes: 18176
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
dic = {i: i for i in range(1, 10**5 + 1)}
total = sum(A)
from collections import Counter
counter = dict(Counter(A))
for i in range(1, 1+10**5):
    if i not in counter:
        counter[i] = 0
for i in range(Q):
    b, c = map(int, input().split())
    dic[b] = c
    total += counter[b] * (c - b)
    counter[c] += counter[b]
    counter[b] = 0
    print(total)


Measured memory_bytes: 118608
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define N             (int)(1e6+5)
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,ans; string str;
map<string,int> m;
int solve(){
    cin>>n;
    while(n--){
        cin>>str;
        m[str]++;
    }
    for(auto it:m){
        ans=max(ans,it.sc);
    }
    for(auto it:m){
        if(ans==it.sc){
            cout<<it.fr<<"\n";
        }
    }
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 23808