akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        String s = stdIn.next();
        String t = stdIn.next();

        char[] cs = s.toCharArray();
        char[] ct = t.toCharArray();

        for(int i=0; i<cs.length; i++){
            if(cs[i] != ct[i]){
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
}

Measured memory_bytes: 35652
package main

import (
	"fmt"
	"sort"
)


func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int,n )
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Sort( sort.Reverse(sort.IntSlice(a)))
	ans := 0
	// t := n -1 // 何回足せるか
	for i := 0; i < n; i++ {
		if i == 0 {
			continue
		}
		ans += a[i / 2]
		// lim := 2
		// if i == 0 {
		// 	lim = 1
		// }
		// for j := 0; j < lim; j++ {
		// 	if t > 0 {
		// 		ans += a[i]
		// 		t--
		// 	}
		// }
	}

	fmt.Println(ans)
}


Measured memory_bytes: 6500
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vpii = vector<pii>;

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

int n, m, k;
vector<string> b;
int x, y, s, t;
vpii dist[4];
using node = pair<pii, pii>;
priority_queue<node, vector<node>, greater<node>> pq;
pii dxy[] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    
    cin >> n >> m >> k;
    cin >> x >> y >> s >> t;
    x--, y--, s--, t--;
    b.resize(n);
    for(string& a : b) cin >> a;

    if(b[x][y] == '@' || b[s][t] == '@')
    {
        cout << -1 << endl;
        return 0;
    }

    for(int i = 0; i < 4; i++)
        dist[i].assign(n * m, pii(INF<int>, INF<int>));

    for(int i = 0; i < 4; i++)
        dist[i][x * n + y] = {0, 0};
    pq.emplace(node(pii(0, 0), pii(x * m + y, 5)));

    while(!empty(pq))
    {
        auto [d, v] = pq.top();
        pq.pop();

        auto [dd, dk] = d;
        auto [p, dir] = v;
        int i = p / m, j = p % m;

        if(i == s && j == t)
        {
            cout << dd << endl;
            return 0;
        }

        for(int z = 0; z < 4; z++)
        {
            int i1 = i + dxy[z].first;
            int j1 = j + dxy[z].second;

            pii nd = z == dir ? pii(dd, dk + 1) : pii(dd + 1, 1);
            if(nd.second > k)
                nd.second = 1, nd.first++;

            if(i1 >= 0 && i1 < n && j1 >= 0 && j1 < m && b[i1][j1] == '.')
            {
                if(dist[z][i1 * m + j1] > nd)
                {
                    dist[z][i1 * m + j1] = nd;
                    pq.emplace(nd, pii(i1 * m + j1, z));
                }
            }
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 39880
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<climits>
using namespace std;
void File(){
	freopen("C.in","r",stdin);
	freopen("C.out","w",stdout);
}
#define REP(i,a,b) for(register int i=a;i<=b;++i)
#define DREP(i,a,b) for(register int i=a;i>=b;--i)
#define MREP(i,x) for(register int i=beg[x];i;i=E[i].last)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define inf INT_MAX
const int maxn=2e5+10;
int n;
ll a[maxn],ans;
int main(){
	//File();
	scanf("%d",&n);
	REP(i,1,n)scanf("%lld",&a[i]);
	a[0]=-1;
	REP(i,1,n)if(a[i]>a[i-1] && a[i]-a[i-1]>1){
		cout<<-1<<endl;
		return 0;
	}
	DREP(i,n,2){
		if(a[i]==a[i-1]+1)
			++ans;
		else ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009ll
#define INFL 1000000000000000018ll
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mk make_pair
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<pair<int, PA> , vector<pair<int, PA> >, greater<pair<int, PA> > >PQG;

int N;
vector<int> V[1000];

signed main()
{
    cin >> N;
    if(N == 1){
        printf("Yes\n2\n1 1\n1 1\n");
        return 0;
    }
    bool flag = true;
    int res;
    int ans;
    for(int i = 2; i * (i + 1) / 2 <= N; i++){
        if(i * (i + 1) / 2 == N){
            res = i;
            ans = i;
            flag = false;
        }
    }
    if(flag){
        printf("No\n");
        return 0;
    }
    else{
        printf("Yes\n");
    }
    int in1 = 0, in2 = 1;
    for(int i = 1; i <= N; i++){
        V[in1].pb(i);
        V[in2 + in1].pb(i);
        if(in2 % res == 0){
            res--;
            in1++;
            in2 = 1;
        }
        else in2++;
    }
    printf("%lld\n", ans + 1);
    for(int i = 0; i <= ans; i++){
        printf("%lld ", (int)V[i].size());
        for(int j = 0; j < (int)V[i].size(); j++){
            printf("%lld", V[i][j]);
            if(j < (int)V[i].size() - 1){
                printf(" ");
            }
        }
        printf("\n");
    }


    return 0;
}
/*



*/


Measured memory_bytes: 3200
import java.util.*;

class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	ArrayList<Integer> num1 = new ArrayList<Integer>(),
             	           num2 = new ArrayList<Integer>();
	int n, tmp, count = 0;

	n = sc.nextInt();
	for (int i = 0; i < n; i++) {
	    tmp = sc.nextInt();
	    num1.add(tmp);
	}
	n = sc.nextInt();
	for (int i = 0; i < n; i++) {
	    tmp = sc.nextInt();
	    num2.add(tmp);
	}

	for (int i = 0; i < n; i++) {
	    tmp = num2.get(i);
	    if (num1.indexOf(tmp) != -1) {
		count++;
	    }
	}

	System.out.println(count);
    }
}

Measured memory_bytes: 31572
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;
const int Maxn = 2e5 + 5;
typedef int arr[Maxn];
//ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n;
arr fa;
vector<pii> f[Maxn], son[Maxn], A, B;
ll lim, dis[Maxn];
void DFS(int x)
{
	if (son[x].empty())
		return;
	pii s0 = son[x][0], s1 = son[x][1];
	dis[s0.first] = dis[x] + s0.second;
	dis[s1.first] = dis[x] + s1.second;
	DFS(s0.first);
	DFS(s1.first);
}
vector<pii> Merge()
{
	rg int i = 0, j = 0;
	vector<pii> res;
	res.clear();
	while (i < A.size() && j < B.size())
	{
		if (dis[A[i].first] <= dis[B[j].first])
		{
			if (dis[A[i].first] == dis[B[j].first])
			{
				if (dis[A[i].second] > dis[B[j].second])
					A[i].second = B[j].second;
				j++;
			}
			if (res.empty() || dis[A[i].second] < dis[res.back().second])
				res.push_back(A[i]);
			i++;
		}
		else
		{
			if (res.empty() || dis[B[j].second] < dis[res.back().second])
				res.push_back(B[j]);
			j++;
		}
	}
	while (i < A.size())
	{
		if (res.empty() || dis[A[i].second] < dis[res.back().second])
			res.push_back(A[i]);
		i++;
	}
	while (j < B.size())
	{
		if (res.empty() || dis[B[j].second] < dis[res.back().second])
			res.push_back(B[j]);
		j++;
	}
	return res;
}
void DP(int x)
{
	f[x].clear();
	if (son[x].empty())
	{
		f[x].push_back(mp(x, x));
		return;
	}
	rg int sl = son[x][0].first, sr = son[x][1].first;
	DP(sl);
	DP(sr);
	A.clear();
	B.clear();
	rg bool mk;
	for (rg int i = 0, j = -1; i < f[sl].size(); i++)
	{
		mk = false;
		while ((j + 1 < f[sr].size()) && (dis[f[sl][i].second] + dis[f[sr][j + 1].first] - 2 * dis[x] <= lim))
		{
			++j;
			mk = true;
		}
		if (mk)
			A.push_back(mp(f[sl][i].first, f[sr][j].second));
	}
	for (rg int i = A.size() - 1; i >= 0; i--)
		B.push_back(mp(A[i].second, A[i].first));
	f[x] = Merge();
}
bool check()
{
	DP(1);
	return !f[1].empty();
}
ll Search(ll l, ll r)
{
	while (l < r)
	{
		lim = l + r >> 1;
		if (check())
			r = lim;
		else
			l = lim + 1;
	}
	return l;
}
int main()
{
	rg int a;
	rg ll sum = 0;
	cin >> n;
	for (int i = 2; i <= n; i++)
	{
		fa[i] = read();
		son[fa[i]].push_back(mp(i, a = read()));
		sum += a;
	}
	DFS(1);
	cout << Search(0, sum) << '\n';
	return 0;
}


Measured memory_bytes: 27256
N = int(input())
Mylist = input().split()
Mylist = [int(s) for s in Mylist]
ANS = 0
for i in range(1,N+1):
  if i % 2 == 1 and Mylist[i-1] % 2 == 1:
    ANS += 1
print(ANS)


Measured memory_bytes: 9160
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>

using namespace std;

#define ll long long

int main(void){
    int m, n;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for(int i = 0;i  < n;++i){
        cin >> a[i];
        sum += a[i];
    }

    int thre = (int)ceil((double)sum / (4.0 * (double)m));
    int ans = 0;
    for(int i = 0;i < n;++i){
        if(a[i] >= thre){
            ans++;
        }
    }

    if(ans >= m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;


struct Item
{
	int w;
	
	int v;
};
Item items[100010];

int n, w;

long long f[100010];	//当物品重量为i时，可以取得额最大价值 

bool compare(const Item &a, const Item &b)
{
	if (a.w == b.w)
		return a.v > b.v;
	else
		return a.w < b.w;
}

int main()
{
	scanf("%d%d", &n, &w);
	
	for (int i = 0 ; i < n ; i++)
		scanf("%d%d", &(items[i].w), &(items[i].v));
		
	sort(items, items + n, compare);
	f[0] = 0;
	for (int j = 0 ; j < n ; j++)
	{
		for (int i = w ; i >= 1 ; i--)
		{
			if (items[j].w > i)
				continue;
			
			long long newF = f[i - items[j].w] + items[j].v;
			if (f[i] < newF)
				f[i] = newF;
		}
	}
	
	long long max = 0;
	for (int i = 1 ; i <= w ; i++)
		if (f[i] > max)
			max = f[i];
	
	printf("%lld\n", max);
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
typedef pair<int,int>pii;
const int mxN=2e5,M=1e9+7;

int n,ans;
string c;
set<string>s;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>c;
        if(!s.count(c)){
            ans++;
            s.insert(c);
        }
    }

    cout<<ans;
}

Measured memory_bytes: 19124
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)*}
    };
}

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)*}
    };
}

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, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize,
        v: [usize; m]
    }
    let mut w = vec![n];
    for &x in &v {
        while let Some(&l) = w.last() {
            if l < x {
                break;
            }
            w.pop();
        }
        w.push(x);
    }
    let m = w.len();
    let mut mem = vec![0; m];
    let mut ss = vec![0; n];
    mem[m - 1] = 1;
    for i in (1..m).rev() {
        let mut q = w[i];
        mem[i - 1] += mem[i] * (q / w[i - 1]);
        q %= w[i - 1];
        let mut l = i - 1;
        let mut r;
        while l > 0 {
            r = l;
            l = 0;
            while l + 1 < r {
                let mi = (l + r) / 2;
                if w[mi] > q {
                    r = mi;
                } else {
                    l = mi;
                }
            }
            mem[l] += mem[i] * (q / w[l]);
            q %= w[l];
        }
        if q > 0 {
            ss[q - 1] += mem[i];
        }
    }
    ss[w[0] - 1] += mem[0];
    for i in (0..n - 1).rev() {
        ss[i] += ss[i + 1];
    }
    for &a in &ss {
        println!("{}", a);
    }
}


Measured memory_bytes: 9852
function main()
  
  (M, D) = map(x -> parse(Int, x), split(readline()))
  
  count = 0
  
  for i in 1:M
    for j in 1:D
      
      d1 = j % 10
      d10 = div(j,10)
      
      if d1 * d10 == i && d1 >= 2 && d10 >= 2
        count += 1
      end
      
    end
  end
  
  println(count)
  
end

main()

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

int main(){
  
  int W,H,N;
  cin >> W >> H >> N;
  
  int x,y,a;
  int lx=0,ly=0,rx=W,ry=H;
  for(int i=0; i<N; i++){
    cin >> x >> y >> a;
    
    if(a==1){
      lx = max(lx,x);
    }
    
    else if(a==2){
      rx = min(rx,x);
    }
    
    else if(a==3){
      ly = max(ly,y);
    }
    
    else if(a==4){
      ry = min(ry,y);
    }
  
  }

  int ans=0;
  if(lx > rx || ly > ry){
    ans = 0;
  }
  else{ 
    ans = (rx-lx) * (ry-ly);
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 3644
let a,n,x=Array.make(4*3*10)0,read_int(),10;;for _=1to n do Scanf.scanf"%d %d %d %d
"(fun b f r v->let y=3*x*(b-1)+x*f-x+r-1 in a.(y)<-a.(y)+v)done;for b=1to 4do for f=1to 3do for r=1to 10do Printf.printf" %d"a.(3*x*(b-1)+x*f-x+r-1)done;print_newline()done;if b<4then print_endline(Bytes.make 20'#')done

Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <cstring>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//

int main(){
    LLI a,b,c,k; cin>>a>>b>>c>>k;
    if(k%2) co(b-a);
    else co(a-b);
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    int K, A, B;
    cin >> K >> A >> B;
    for (int i = 1; i < 1000; i++)
    {
        int l = K * i;
        if (A <= l && l <= B)
        {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3636
#include <stdlib.h>
#include <stdio.h>

int main()
{   int n,m;
    scanf("%d%d",&n,&m);
    int a[m],b[m];
    int f[200001]={0},s[200001]={0};
    for(int i=0;i<m;i++){
        scanf("%d%d",&a[i],&b[i]);
        if(a[i]==1){
            f[b[i]]=1;
        }
        if(b[i]==n){
            s[a[i]]=1;
        }
    }
    for(int i=1;i<=n;i++){
        if(f[i]==1&&s[i]==1){
            printf("POSSIBLE");
            return 0;
        }
    }
    printf("IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 3328
n = int(input())
a = [int(i) for i in input().split()]

count = [0] * (10 ** 5 + 1)
ans = 0
for i in a:
    if i <= 10 ** 5:
        count[i] += 1
    else:
        ans += 1
for i,j in enumerate(count):
    if (j - i) >= 0:
        ans += j - i
    else:
        ans += j
print(ans)

Measured memory_bytes: 14492
n=int(input())
d,x=map(int,input().split())
A=[]
for i in range(n):
    a=int(input())
    A.append(a)
q=x
for i in range(n):
    q+=1
    for j in range(1,d+1):
        if 1+j*A[i] <= d:
            q+=1
print(q)

Measured memory_bytes: 64768
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;
int main(){
	int n;
	int a[100]={0};
	for(int i=1;i<=28;i++){
		cin>>n;
		a[n]=1;
	}
	for(int i=1;i<=30;i++){
		if(a[i]==0){
			cout<<i<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3088
#include <cstdio>
#include <queue>
#include <cstring>

using namespace std;

#define LL long long

const int maxn=510;
const int maxm=2e6+1e2;
const int INF=2e9;
const int T=maxn-1;

char str[200][200];
int head[maxn],cnt=1,cur[maxn]={0},d[maxn]={0};
bool vis[maxn]={0};
queue <int> q;

struct edge
{
    int v,flow,cap,next;
}e[maxm];

 
void ins(int t1,int t2,int t3)
{
    e[++cnt].v=t2;
    e[cnt].flow=0;
    e[cnt].cap=t3;
    e[cnt].next=head[t1];
    head[t1]=cnt;
}
 
void insert(int t1,int t2,int t3)
{
    ins(t1,t2,t3);
    ins(t2,t1,0);
}

bool bfs()
{
    memset(vis,0,sizeof(vis));
    d[0]=0;
    vis[0]=true;
    q.push(0);
    while(!q.empty())
    {
        int t=q.front();q.pop();
        for(int i=head[t];i;i=e[i].next)
        {
            if(!vis[e[i].v]&&e[i].flow<e[i].cap)
            {
                d[e[i].v]=d[t]+1;
                vis[e[i].v]=true;
                q.push(e[i].v);
            }
        }
    }
    return vis[T];
}
 
int dfs(int x,int a)
{
    if(x==T||a==0)return a;
    int flow=0;
    for(int &i=cur[x];i;i=e[i].next)
    {
        if(d[e[i].v]==d[x]+1)
        {
            int t=dfs(e[i].v,min(a,e[i].cap-e[i].flow));
            if(t>0)
            {
                e[i].flow+=t;
                e[i^1].flow-=t;
                flow+=t;
                a-=t;
                if(a==0)break;
            }
        }
    }
    return flow;
}
 
LL dinic()
{
    LL flow=0;
    while(bfs())
    {
        for(int i=0;i<maxn;i++)cur[i]=head[i];
        flow+=dfs(0,INF);
        //printf("%d ",flow);
    }
    return flow;
}

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%s",&str[i][1]);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(str[i][j]=='S')
			{
				insert(0,i,INF);
				insert(0,100+j,INF);
			}
			else if(str[i][j]=='T')
			{
				insert(i,T,INF);
				insert(100+j,T,INF);
			}
			else if(str[i][j]=='o')
			{
				insert(i,100+j,1);
				insert(100+j,i,1);
			}
		}
	}
	LL ans=dinic();
	if(ans>=INF)printf("-1\n");
	else printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 896
import java.util.*;
public class Main{

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.next());
        int min=0;
        int max=0;
        long sum=0;
        
        for(int i=0;i<n;i++){
            int a = Integer.parseInt(sc.next());
            if(i==0){
                min = a;
                max = a;
            }
            min = Math.min(min,a);
            max = Math.max(max,a);
            sum+=a;
        }
        
        System.out.println(min+" "+max+" "+sum);
    }

}



Measured memory_bytes: 40708
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a*n,b)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int a [1000000];
int o,N,K,i,b;
int main(){
cin>>N>>K;
o=0;
for(i=0;i<N;i++){
  cin>>N[a];

  if(N[a]>=K) o++;
}

cout<<o;
}
 

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc083/tasks/arc088_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(X, Y):
    ans = []

    while X <= Y:
        ans.append(X)
        X *= 2
    # print(*ans)
    return len(ans)


def main(args):
    X, Y = map(int, input().split())
    ans = solve(X, Y)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main()
{
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << (H * W) - (h*W + H*w - h*w);

	return 0;
}

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

const ll MOD = 998244353;
const int N = 2e5+10;

// 0-k
// n-1-k - n-1
//

ll powMod(ll a, ll n) {
    ll ans = 1;
    while (n) {
        if (n&1) ans = ans * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return ans;
}

ll fac[N], inv[N];

ll C(int n, int m) {
    return fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}

void solve() {

    fac[0] = inv[0] = 1;
    for (int i = 1; i < N; i++) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = powMod(fac[i], MOD-2);
        assert(fac[i] * inv[i] % MOD == 1);
    }

    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    k = n-1-k;

    ll ans = 0, t = 1;
    for (int i = 0; i < k; i++) t = t*(m-1)%MOD;
    for (int i = k; i < n; i++) {
        ans += t*C(n-1, i);
        ans %= MOD;
        t = t*(m-1)%MOD;
    }
    ans = ans * m % MOD;
    printf("%lld\n", ans);
}

int main(){

    solve();
	return 0;
}


Measured memory_bytes: 6988
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
void swap(long long *x, long long *y)
{
	long long temp=*x;
	*x=*y;
	*y=temp;
}
int main(void)
{
	int q;

	cin>>q;

	vll a(q), b(q);

	rep(i, q) cin>>a[i]>>b[i];

	rep(i, q){
		ll sc=a[i]*b[i], scp;
		
		scp=sqrt(sc);

		if(scp*scp==sc) scp--;

		if(a[i]>b[i]) swap(&a[i], &b[i]);

		if(a[i]==b[i]||a[i]+1==b[i]){
			cout<<2*a[i]-2<<endl;
		}else if(scp*(scp+1)>=a[i]*b[i]){
			cout<<2*scp-2<<endl;
		}else{
			cout<<2*scp-1<<endl;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
#include<string>
using namespace std;
int main(void){
	int i,j,k,N;
	cin >> N;
	int W[N];
	for(i=0;i<N;i++){
		cin >> W[i];
	}
	int S1=0;
	int S2=0;
	S1 = W[0];
	for(i=1;i<N;i++){
		S2 += W[i];
	}
	int absmin = (int)abs(S1-S2);
	for(i=1;i<=99;i++){
		S1 += W[i];
		S2 -=W[i];
		if(absmin>(int)abs(S1-S2)){
			absmin = (int)abs(S1-S2);
		}
	}
	cout << absmin;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch SecondSum | diff SecondSum.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address SecondSum.cpp && ./a.out

/*
 
 9/7/2019
 
 6:03-6:40 give up

 I iterated right boundary from left to right.
 Sounds like there is monotonic property though, I couldn't figure out how to compute in O(1) for each right boundary.
 
 9/8/2019
 
 14:50- read editorials
 
 https://youtu.be/VSeggcnxwrc?t=5634
 https://img.atcoder.jp/abc140/editorial.pdf
 
 */

const int MAX_N=1e6+1;
int P[MAX_N];
int N;

int pos[MAX_N];
void solve() {
  REP(i,N) pos[P[i]]=i;
  multiset<int> S; S.emplace(-1),S.emplace(-1),S.emplace(N),S.emplace(N);
  LL res=0;
  for(int a=N; a>=1; --a) {
    int i=pos[a];
    auto r=S.upper_bound(i),l=r; --l;
    int l2=*l; --l; int l1=*l;
    int r1=*r; ++r; int r2=*r;
    LL x=(r1-i)*(l2-l1),y=(r2-r1)*(i-l2);
    res+=+(x+y)*a;
    S.emplace(i);
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>P[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 9472
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Solve
{
    public Solve() { }
    public static int Main()
    {
        new Solve().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        string a = cin.next();
        string result = a.Substring(0, 3) + "8" + a.Substring(4);
        Console.WriteLine(result);
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair <int,int> PAIR;
const int N = 2e5+5;
const int M = 1e4;
const int INF = 0x3f3f3f3f;

int main() {
	string s;
	cin >> s;
	if(s == "ABC") cout << "ARC" << "\n";
	else cout << "ABC" << "\n"; 
    return 0;
}

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

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

int n, x, y;
char c;
vector<pair<int, int> > vec[4];
int ans;
vector<pair<int, int> > dat[200009], mi[800009];

void fun()
{
	for (int i = 0; i <= 200000; i++) dat[i].clear();
	int sz = vec[0].size();
	for (int i = 0; i < sz; i++) {
		dat[vec[0][i].se].pb({ vec[0][i].fi, 0 });
	}
	sz = vec[2].size();
	for (int i = 0; i < sz; i++) {
		dat[vec[2][i].se].pb({ vec[2][i].fi, 2 });
	}
	for (int i = 0; i <= 200000; i++) {
		sort(dat[i].begin(), dat[i].end());
		sz = dat[i].size();
		for (int j = 0; j < sz - 1; j++) {
			if (dat[i][j].se == 0 && dat[i][j + 1].se == 2) {
				ans = min(ans, (dat[i][j + 1].fi - dat[i][j].fi) * 5);
			}
		}
	}
}

void gun()
{
	for (int i = 0; i <= 200000; i++) dat[i].clear();
	int sz = vec[1].size();
	for (int i = 0; i < sz; i++) {
		dat[vec[1][i].fi].pb({ vec[1][i].se, 1 });
	}
	sz = vec[3].size();
	for (int i = 0; i < sz; i++) {
		dat[vec[3][i].fi].pb({ vec[3][i].se, 3 });
	}
	for (int i = 0; i <= 200000; i++) {
		sort(dat[i].begin(), dat[i].end());
		sz = dat[i].size();
		for (int j = 0; j < sz - 1; j++) {
			if (dat[i][j].se == 1 && dat[i][j + 1].se == 3) {
				ans = min(ans, (dat[i][j + 1].fi - dat[i][j].fi) * 5);
			}
		}
	}

}

void hun(int fx, int fy, vector<pair<int, int> >& f, int gx, int gy, vector<pair<int, int> >& g)
{
	vector<pair<int, int> > u, v;
	int fsz = f.size(), gsz = g.size();
	u.resize(fsz);
	v.resize(gsz);
	for (int i = 0; i <= 800000; i++) mi[i].clear();
	for (int i = 0; i < fsz; i++) {
		u[i] = { f[i].fi * fx, f[i].se * fy };
		mi[u[i].fi + u[i].se + 400000].pb({ u[i].fi, 0 });
	}
	for (int i = 0; i < gsz; i++) {
		v[i] = { g[i].fi * gx, g[i].se * gy };
		mi[v[i].fi + v[i].se + 400000].pb({ v[i].fi, 1 });
	}
	for (int i = 0; i <= 800000; i++) {
		sort(mi[i].begin(), mi[i].end());
		int sz = mi[i].size();
		for (int j = 0; j < sz - 1; j++) {
			if (mi[i][j].se == 0 && mi[i][j + 1].se == 1) {
				ans = min(ans, (mi[i][j + 1].fi - mi[i][j].fi) * 10);
			}
		}
	}
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	ans = 1e9;
	for (int i = 0; i < n; i++) {
		cin >> x >> y >> c;
		if (c == 'R') {
			vec[0].pb({ x, y });
		}
		else if (c == 'U') {
			vec[1].pb({ x, y });
		}
		else if (c == 'L') {
			vec[2].pb({ x, y });
		}
		else {
			vec[3].pb({ x, y });
		}
	}
	fun(); gun();
	hun(1, 1, vec[0], 1, 1, vec[1]);
	hun(1, -1, vec[0], 1, -1, vec[3]);
	hun(-1, 1, vec[2], -1, 1, vec[1]);
	hun(-1, -1, vec[2], -1, -1, vec[3]);
	if (ans == 1e9)
		cout << "SAFE\n";
	else
		cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 48268
#include<stdio.h>
 int main(void){
  int n,i,number;
  long long int sum=0;
  int min=0,max=0;

    scanf("%d",&n);

    for(i=0;i<n;i++){

   scanf("%d",&number);

      if(i==0){
    min=number;
    max=number;
   }
   if(number<min) min=number;
   if(number>max) max=number;
      sum+=number;
   }
  printf("%d %d %lld\n",min,max,sum);
    return 0;
 }

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = (a); i < (n); i++)
#define MP make_pair
#define all(s) (s).begin(), (s).end()
#define rev(s) (s).rbegin(), (s).rend()
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

void test(){freopen("test.txt", "r", stdin);}

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

	int change = 0;
	int color = s[0];
	FOR(i, 1, s.size()){
		if(s[i] != color){
			change++;
			color = s[i];
		}
	}
	int first = s[0];
	int last = s[s.size()-1];

	int win = 0;
	if(first == last && first == 'o') change++;


	cout << (change%2?'o':'x') << endl;

	return 0;
}

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

int H, W, h, w;

int main(){
  cin >> H >> W >> h >> w;
  cout << (H-h) * (W-w) << endl;
}


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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef unsigned long long ulli;
typedef pair<int, int> pii;

///---------------------------------------------------------------
///---------------------------------------------------------------

int h, w, dH[4] = {-1, 0, 1, 0}, dW[4] = {0, 1, 0, -1};
pii in, fin;
vector<vector<bool>> pared;

///---------------------------------------------------------------

void leerDatos()
{   _

    cin >> h >> w;
    cin >> in.fi >> in.se;
    cin >> fin.fi >> fin.se;
    pared.resize(h + 1, vector<bool>(w + 1));
    for (int i=1; i<=h; ++i)
    {
        for (int j=1; j<=w; ++j)
        {
            char ch;
            cin >> ch;
            pared[i][j] = (ch == '#');
        }
    }
}

bool ok(pii p)
{
    return (1 <= p.fi && p.fi <= h && 1 <= p.se && p.se <= w && !pared[p.fi][p.se]);
}

int bfs(pii o, pii destino)
{
    vector<vector<int>> dist(h + 1, vector<int>(w + 1, -1));

    dist[o.fi][o.se] = 0;

    deque<pii> cola;

    cola.push_front(o);

    while (!cola.empty())
    {
        pii a = cola.front();
        cola.pop_front();

        if (a == destino)
            return dist[a.fi][a.se];

        for (int i=0; i<4; ++i)
        {
            pii hijo = a;

            hijo.fi += dH[i];
            hijo.se += dW[i];

            if (ok(hijo))
            {
                if (dist[hijo.fi][hijo.se] == -1 || dist[a.fi][a.se] + 0 < dist[hijo.fi][hijo.se])
                {
                    dist[hijo.fi][hijo.se] = dist[a.fi][a.se] + 0;
                    cola.push_front(hijo);
                }
            }
        }
        for (int i=-2; i<=2; ++i)
        {
            for (int j=-2; j<=2; ++j)
            {
                pii hijo = a;

                hijo.fi += i;
                hijo.se += j;

                if (ok(hijo))
                {
                    if (dist[hijo.fi][hijo.se] == -1 || dist[a.fi][a.se] + 1 < dist[hijo.fi][hijo.se])
                    {
                        dist[hijo.fi][hijo.se] = dist[a.fi][a.se] + 1;
                        cola.push_back(hijo);
                    }
                }
            }
        }
    }
    return dist[destino.fi][destino.se];
}

int main()
{   _

    leerDatos();

    cout << bfs(in, fin) << endl;

    return 0;
}

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

int main(){
    ll n;
    cin >> n;
    ll a[200020];
    
    rep(i,n){
        cin >> a[i];
        a[i]=a[i]-(i+1);
    }
    sort(a,a+n);
    ll ans=0;
    ll med=a[n/2];
    rep(i,n)ans+=abs(a[i]-med);
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

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

  int n,m;
  cin>>n>>m;

  int res=0;
  res+=(n*(n-1))/2;
  res+=(m*(m-1))/2;
  
  cout<<res;

    
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

// computational complexity: o(log(max(a, b))) 
inline ull get_gcd(ull a, ull b)
{
	if (b == 0)
	{
		return a;
	}
	return get_gcd(b, a % b);
}

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

	ll N;
	cin >> N;

	vector<ll> as(N);
	for (ll i = 0; i < N; ++i) {
		cin >> as[i];
	}

	vector<ll> ceil_values(N + 1);
	ceil_values[0] = 0;
	ceil_values[1] = as[0];
	ceil_values[2] = max(as[0], as[1]);
	for (ll i = 3; i <= N; ++i) {
		if (i % 2 == 0) {
			ceil_values[i] = max(
				as[i - 1] + ceil_values[i - 2],
				as[i - 2] + ceil_values[i - 3]
			);
		}
		else {
			ceil_values[i] = as[i - 1] + ceil_values[i - 2];
		}

	}

	vector<ll> floor_values(N + 1);
	floor_values[2] = ceil_values[2];
	floor_values[3] = max(max(as[0], as[1]), as[2]);
	for (ll i = 4; i <= N; ++i) {
		if (i % 2 == 0) {
			floor_values[i] = ceil_values[i];
		}
		else {
			floor_values[i] = max(
				max(
					as[i - 1] + floor_values[i - 2],
					as[i - 2] + floor_values[i - 3]
				),
				as[i - 3] + ceil_values[i - 4]
			);
		}
	}

	cout << floor_values[N] << endl;

	return 0;
}


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

using namespace std;
typedef long long ll;

int main(int argc, char const *argv[])
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(((a+b)&1)==0){
      printf("%d\n",(a+b)>>1);
    }else{
      printf("%d\n",((a+b)>>1)+1);
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    vector<vector<pair<int,int>>> v(n);
    rep(i,n){
        int a;
        cin>>a;
        rep(j,a){  
            int x,y;
            cin>>x>>y;
            x--;
            v[i].push_back({x,y});
        }
    }

    int ans=0;
    rep(bit,1<<n){
        bool ok=true;
        int tmp=0;
        rep(i,n){
            if(bit & 1<<i){
                tmp++;
                rep(j,v[i].size()){
                    if(v[i][j].second==0 && (bit & 1<<v[i][j].first)) ok=false;
                    else if(v[i][j].second==1 && !(bit & 1<<v[i][j].first)) ok=false;
                }
            }
        }

        if(ok) ans=max(ans,tmp);
    }

    cout<<ans<<endl;
   
}



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

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

  int head = 0;
  int tail = S.size() - 1;
  int ans = 0;
  while(head < tail) {
    if(S[head] == S[tail]) {
      head++;
      tail--;
      continue;
    }
    if(S[head] == 'x' && S[tail] != 'x') {
      head++;
      ans++;
      continue;
    }
    if(S[tail] == 'x' && S[head] != 'x') {
      tail--;
      ans++;
      continue;
    }
    cout << -1 << endl;
    return 0;
  }

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
//#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define mod (1e9+7)
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int main()
{
    crap;
    int n;
    double s=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    double av=double(s)/n;
    if(ceil(double(s)/n)-av<=0.5)
    av=ceil(double(s)/n);
    else
    av=floor(double(s)/n);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        ans+=(a[i]-av)*(a[i]-av);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] commands;
		int num;
		ArrayDeque<Integer> deque = new ArrayDeque<Integer>();
		for (int i = 0; i < n; i++) {
			commands = br.readLine().split(" ");
			if (commands[0].endsWith("First")) {
				deque.removeFirst();
				continue;
			} else if (commands[0].endsWith("Last")) {
				deque.removeLast();
				continue;
			}
			num = Integer.parseInt(commands[1]);
			if (commands[0].startsWith("d")) {
				deque.remove(new Integer(num));
			} else {
				deque.addFirst(num);
			}
		}
		StringBuilder sb = new StringBuilder();
		sb.append(deque.poll());
		while (deque.size() > 0) {
			sb.append(" ");
			sb.append(deque.poll());
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 188488
from collections import deque
dd = [(-1, 0), (0, -1), (1, 0), (0, 1)]
while 1:
    w, h = map(int, raw_input().split())
    if w == 0:
        break
    C = [raw_input() for i in xrange(h)]
    cnt = 0
    mark = {}
    sx = sy = -1
    for i in xrange(h):
        for j in xrange(w):
            if C[i][j] == 'o':
                sx = j; sy = i
            elif C[i][j] == '*':
                mark[j, i] = cnt
                cnt += 1
    ALL = 2**cnt - 1
    dis = {(sx, sy, 0): 0}
    deq = deque()
    deq.append((sx, sy, 0))
    ans = -1
    while deq and ans == -1:
        x, y, state = key = deq.popleft()
        for dx, dy in dd:
            nx = x + dx
            ny = y + dy
            if 0 <= nx < w and 0 <= ny < h and C[ny][nx] != 'x':
                n_state = state
                if C[ny][nx] == '*':
                    n_state |= 1 << mark[nx, ny]
                if n_state == ALL:
                    ans = dis[key] + 1
                    break
                n_key = (nx, ny, n_state)
                if n_key not in dis:
                    dis[n_key] = dis[key] + 1
                    deq.append(n_key)
    print ans

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  char n;
  cin >> n;
  if(islower(n))
    cout << "a\n"; 
  else
    cout << "A\n";
  return 0;
}


Measured memory_bytes: 3636
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
#include <complex>
typedef complex<double> P;
double dot(P a, P b) {
	return (a.real() * b.real() + a.imag() * b.imag());
}
double cross(P a, P b) {
	return (a.real() * b.imag() - a.imag() * b.real());
}
int main() {
	double a, b, c, d;
	cin >> a >> b >> c >> d;
	int query;
	cin >> query;
	REP(i, query) {
		double e, f;
		cin >> e >> f;
		P A = P(c - a, d - b);
		P B = P(e - a, f - b);
		if (cross(A, B) > eps) {
			cout << "COUNTER_CLOCKWISE" << endl;
			continue;
		}
		if (cross(A, B) < -eps) {
			cout << "CLOCKWISE" << endl;
			continue;
		}
		if (dot(A, B) < -eps) {
			cout << "ONLINE_BACK" << endl;
			continue;
		}
		if (abs(A) < abs(B)) {
			cout << "ONLINE_FRONT" << endl;
			continue;
		}
		cout << "ON_SEGMENT" << endl;
	}
	return 0;
}


Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
#define rep(i, N) for(int i = 0; i < N; i++)
#define repr(i, N) for(int i = N - 1; i >= 0; i--)
typedef long long int ll;
ll K, A[100000];

void solve(){
    ll l, r;
    l = r = 2;
    repr(i, K){
        if(l % A[i] != 0)
            l = (l / A[i] + 1) * A[i];
        r = (r / A[i]) * A[i] + A[i] - 1;
    }
    if(l > r) cout<< -1 <<endl;
    else cout << l << ' ' << r << endl;
}

int main(){
    cin >> K;
    rep(i, K){
        cin >> A[i];
        if(i > 0 and A[i - 1] == A[i]){
            A[i] = 0;
            i--; K--;
        }
    }
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int a[3][3];
int b[10];
int main(void) {
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    int n;
    scanf("%d", &n);
    for (int k = 0 ; k < n; k++) {
        int b;
        scanf("%d", &b);
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (a[i][j] == b) {
                    a[i][j] = 0;
                }
            }
        }
    }

    for (int i = 0; i < 3; i++) {
        if (a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0) {
            goto YES;
        }
        if (a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0) {
            goto YES;
        }
    }
    if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) {
        goto YES;
    }
    if (a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0) {
        goto YES;
    }
    printf("No");
    return 0;

    YES:
    printf("Yes");
    return 0;
}

Measured memory_bytes: 128