akhauriyash/Code-Regression huggingface dataset:
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.trim().split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    if a + b == 15 {
        println!("+");
    } else if a * b == 15 {
        println!("*");
    } else {
        println!("x");
    }
}


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

int main(){
	int h, w;
	for(;;){
		cin >> h >> w;
		if(h == 0) return 0;
		for(int i = 0; i < h; i++){
			if(i == 0 || i == h-1){
				string str(w, '#');
				cout << str << endl;
			}else{
				string str(w-2, '.');
				cout << '#' << str << '#' << endl;
			}

		}
		cout << endl;
	}
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define vi vector<int>
#define Vi vector<vector<int>>
#define ll long long
#define P pair<int,int>
#define vp  vector<P>
#define vb vector<bool>
#define mod 1000000009
using namespace std;
int x[]={0,-1,0,1};
int y[]={1,0,-1,0};
int util(int u,int v,vector<string>&arr){
	int n=arr.size();
	int m=arr[0].size();
	queue<P>Q;
	int cur_val=0;
	Q.push({u,v});
	Vi visited(n,vi(m,0));
	visited[u][v]=1;
	while(!Q.empty()){
		int S=Q.size();
			for(int i=0;i<S;i++){
				P tp=Q.front();
				Q.pop();
				for(int k=0;k<4;k++){
					int newX=tp.first+x[k];
					int newY=tp.second+y[k];
					if(newX>=0 && newX<n && newY>=0 && newY<m && !visited[newX][newY] && arr[newX][newY]=='.'){
						Q.push({newX,newY});
						visited[newX][newY]=1;
					}
				}
			}
			if(!Q.empty())
				cur_val++;;
	}
	return cur_val;
}
int main(){
	int n,m;
	cin>>n>>m;
	vector<string>arr(n);
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	int res=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(arr[i][j]=='.'){
				int temp=util(i,j,arr);
				// cout<<i<<" "<<j<<" "<<temp<<endl;
				res=max(res,temp);
			}
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 510000;
const int INF = 1e9;
const double pi=acos(-1);

int main(){
  rep(l,MOD){
    int n,x;
    cin >> n >> x;
    if(n==0 && x==0) return 0;
    int sum=0;
    for(int i=1;i<=n;i++){
      for(int j=i+1;j<=n;j++){
        for(int k=j+1;k<=n;k++){
          if(i+j+k==x) sum++;
        }
      }
    }
    cout << sum << endl;
  }
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main() {
	scanf("%d%d%d",&a,&b,&c);
	if(a==b){
		if(a==c) cout<<"No";
		else cout<<"Yes";
	}else if(c==b){
		if(a==c) cout<<"No";
		else cout<<"Yes";
	}else if(a==c){
		if(a==b) cout<<"No";
		else cout<<"Yes";
	}
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
/*
I just got lost in thought. It was unfamiliar territory.
- Steven Wright
*/

#include <algorithm>
#include <bitset>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <vector>
//#include <boost/math/common_factor.hpp>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 1000000000;
const int MAX = 100005;
const int MAX1 = 2007;
const int MAX2 = 4007;
const int LEN = 21;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1234567891;
//g++ -std=c++11 your_file.cpp -o your_program

int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ifstream in("");
    ofstream out("");
    int n;
    cin >> n;
    set<string> S;
    char last;
    REP(i, n){
        string tmp;
        cin >> tmp;
        S.insert(tmp);
        if (i == 0) {
            last = tmp[SZ(tmp) - 1];
            continue;
        }
        else {
            if (tmp[0] != last) {
                cout << "No" << endl;
                return 0;
            }
            last = tmp[SZ(tmp) - 1];
        }
    }
    if (SZ(S) == n) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
list = [int(input()) for i in range(5)]
t = 0
cnt_l = []
for i in range(5):
    cnt = 0
    while list[i] % 10 != 0:
        list[i] += 1
        cnt += 1
    t += list[i]
    if cnt != 0:
        cnt_l.append(cnt)
if not cnt_l:
    cnt_l.append(0)
print(t - max(cnt_l))

Measured memory_bytes: 3060
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

DIV = (10**9) + 7
#DIV = 998244353

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    N = iRaw()
    As = isRaw()
    isUP=[False]*N
    lastDifVal=As[-1]
    for n in range(N-1,0,-1):
        #print(n)
        if As[n]!=As[n-1]:
            lastDifVal=As[n]
            isUP[n-1] = lastDifVal>As[n-1]
    money = 1000
    stock = 0
    for n in range(N):
        a = As[n]
        if isUP[n]:
            stock += money//a
            money = money%a
        else:
            money +=stock*a
            stock=0
    
    print(money+stock*As[-1])

main()


Measured memory_bytes: 67508
#include <iostream>

using namespace std;

int main (void)
{
    int n;
    long long k, num[100001];

    for (int i = 1; i < 100001; i++) {
        num[i] = 0;
    }

    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        num[a] += b;
    }

    for (int i = 1; i < 100001; i++) {
        k -= num[i];
        if (k <= 0) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, h, w;
    cin >> n >> h >> w;
    ll ans = 0;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        if (h <= a && w <= b) ans++;
    }
    cout << ans << endl;
}

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

val pw = PrintWriter(System.out)

fun solve(N: Int, u: IntArray, v: IntArray, w: IntArray) {
    val uf = WeightedUnionFind(N)
    repeat(N - 1) {
        uf.unite(u[it] - 1, v[it] - 1, w[it].toLong())
    }
    pw.println(1)
    for (i in 1 until N) {
        if (uf.getDiff(0, i) % 2L == 0L) {
            pw.println(1)
        } else {
            pw.println(0)
        }
    }
    pw.flush()
    return
}

class WeightedUnionFind(n: Int) {
    data class Node(var parent: Int, var size: Int, var weight: Long)

    private val nodes = Array(n) { Node(parent = it, size = 1, weight = 0) }
    fun findRoot(x: Int): Int {
        if (x == this.nodes[x].parent) return x
        val root = findRoot(nodes[x].parent)
        nodes[x].weight += nodes[nodes[x].parent].weight
        nodes[x].parent = root
        return root
    }

    fun unite(x: Int, y: Int, weight: Long): Boolean {
        // nodes[x].weight + weight = nodes[y].weightとなるようにする
        val xRoot = findRoot(x)
        val yRoot = findRoot(y)
        if (xRoot == yRoot) return false
        val (smaller, bigger, newWeight) = when (getSize(xRoot) >= getSize(yRoot)) {
            true -> Triple(yRoot, xRoot, nodes[x].weight - nodes[y].weight + weight)
            else -> Triple(xRoot, yRoot, nodes[y].weight - nodes[x].weight - weight)
        }
        nodes[smaller].parent = bigger
        nodes[bigger].size += nodes[smaller].size
        nodes[smaller].weight = newWeight
        return true
    }

    fun getWeight(x: Int): Long {
        findRoot(x)
        return nodes[x].weight
    }

    fun getDiff(x: Int, y: Int) = getWeight(y) - getWeight(x)
    fun getSize(x: Int) = nodes[findRoot(x)].size
    fun isSame(x: Int, y: Int) = findRoot(x) == findRoot(y)
}




fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val u = IntArray(N - 1)
    val v = IntArray(N - 1)
    val w = IntArray(N - 1)
    for (i in 0 until N - 1) {
        u[i] = sc.next().toInt()
        v[i] = sc.next().toInt()
        w[i] = (sc.next().toLong() % 2L).toInt()
    }
    solve(N, u, v, w)
}


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

void dfs(int s,vector<int> &vis,vector<vector<int>> &graph){
    vis[s]=true;
    for(auto x:graph[s]){
        if(!vis[x])
            dfs(x,vis,graph);    
    }
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,m,a,b,i,ans=0;
	cin>>n>>m;
	vector<vector<int>> graph(n+1);
	for(i=0;i<m;i++){
	    cin>>a>>b;
	    graph[a].push_back(b);
	    graph[b].push_back(a);
	}
	vector<int> vis(n+1,false);
	for(i=1;i<=n;i++){
	    if(!vis[i]){
	        ans++;
	        dfs(i,vis,graph);
	    }
	}
	
	cout<<ans-1<<endl;
	
	return 0;
}


Measured memory_bytes: 10020
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    long long int dp[n];
    fill(dp,dp+n,1e9);
    dp[0]=0;
    for(int i=0;i<n-1;i++)
    {
        for(int j=1;j<=min(k,n-i-1);j++)
        {
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int h, w, n;
	cin >> h >> w >> n;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int c[101][101];
	int now = 0;
	rep(i, h) {
		if (i % 2 == 0) {
			int j = 0;
			while (j < w) {
				if (a[now] == 0) {
					now++;
				}
				c[i][j] = now + 1;
				a[now]--;
				j++;
			}
		}
		else {
			int j = w - 1;
			while (j >= 0) {
				if (a[now] == 0) {
					now++;
				}
				c[i][j] = now + 1;
				a[now]--;
				j--;
			}
		}
	}
	rep(i, h) {
		rep(j, w) {
			cout << c[i][j] << " ";
		}
		cout << "" << endl;
	}
}

Measured memory_bytes: 3756
from sys import stdin
import math
import fractions
import heapq

k, s = [int(x) for x in stdin.readline().rstrip().split()]

cnt = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if z >= 0 and z <= k:
            cnt += 1

print(cnt)

Measured memory_bytes: 5048
#pragma GCC optimize("03")
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n, a[100100], s;

int main(){
	//ifstream cin("date.in");
	//ofstream cout("date.out");
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i], s += abs(a[i] - a[i - 1]);
	s += abs(a[n]);

	for (int i = 1; i <= n; i++){
		cout << s - abs(a[i + 1] - a[i]) - abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i - 1]) << "\n";
	}

	return 0;
}

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

#define ALL(c) (c).begin(),(c).end()
#define EACH(i, c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const long long MOD = 1000000007;

int dp[210][100010];
int inv[210];

int powmod(int a, int k) {
    int r = 1;
    while (k > 0) {
        if (k & 1) {
            r = (r * a) % MOD;
        }
        a = (a * a) % MOD;
        k /= 2;
    }
    return r;
}

int invmod(int a) {
    return powmod(a, MOD - 2);
}

void solve(long long N, long long X, std::vector<long long> &S) {
    for (int i = 1; i <= 200; ++i) {
        inv[i] = invmod(i);
    }
    dp[0][X] = 1;
    sort(ALL(S));
    reverse(ALL(S));
    for (int i = 0; i < N; ++i) {
        for (int x = 0; x <= X; ++x) {
            dp[i + 1][x] = dp[i][x] * inv[N - i] % MOD * (N - i - 1) % MOD;
        }
        for (int x = 0; x <= X; ++x) {
            int t = x % S[i];
            dp[i + 1][t] = (dp[i + 1][t] + (dp[i][x] * inv[N - i]) % MOD) % MOD;
        }
    }
    int res = 0;
    for (int i = 0; i <= X; ++i) {
        res = (res + (dp[N][i] * i) % MOD) % MOD;
    }
    for(int i = 1; i <= N; ++i) {
        res = (res * i) % MOD;
    }
    cout << res << endl;
}

signed main() {
    long long N;
    scanf("%lld", &N);
    long long X;
    scanf("%lld", &X);
    std::vector<long long> S(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &S[i]);
    }
    solve(N, X, S);
    return 0;
}

Measured memory_bytes: 157184
#include<bits/stdc++.h>
    #define int ll
    #define M 1000000007
    #define hell 998244353
    #define inf 1e18
    #define pb push_back
    #define pi 3.1415926536
    #define mp make_pair
    #define ub upper_bound
    #define lb lower_bound
    #define all(a) a.begin(),a.end()
    #define ll long long
    #define vec vector <int>
    #define pii pair<int,int>
    #define endl "\n"
    #define gcd __gcd
    using namespace std;
    int power(int x, unsigned int y, unsigned int m) 
    { 
        if (y == 0) 
            return 1; 
        int p = power(x, y/2, m) % m; 
        p = (p * p) % m; 
  
        return (y%2 == 0)? p : (x * p) % m; 
    } 
    int modInverse(int a, int m) 
    {   
        return power(a, m-2, m);
    }
    int nCrModPFermat(int n, int r, int p) 
    { 
           if (r==0) 
              return 1; 
  
        int fac[n+1]; 
        fac[0] = 1; 
        for (int i=1 ; i<=n; i++) 
            fac[i] = fac[i-1]*i%p; 
  
        return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
    } 
    signed main()
    {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        ll t=1;
        // cin >> t;
        /*SAARE INPUTS LENA*/
        /*VARIABLES KI RANGE DEKHLENA*/
        /*EXPONENT RANGE OF OUTPUT KA DHYAN RAKHNA*/
        while(t-->0)
        {
            string x,y;
            cin>>x>>y;
            int n=x.length(),m=y.length();
            int dp[n+1][m+1];
            for (int i = 0; i <=n; ++i)
            {
                dp[i][0]=0;
            }
            for (int i = 0; i <=m; ++i)
            {
                dp[0][i]=0;
            }
            for (int i = 1; i <=n; ++i)
            {
                for (int j = 1; j <=m ; ++j)
                {
                    if(x[i-1]==y[j-1])
                        dp[i][j]=dp[i-1][j-1]+1;
                    else 
                    {
                        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                    }
                }
            }
            int i=n,j=m;
            string s="";
            while(i>0 && j>0)
            {
                if(x[i-1]==y[j-1])
                {    
                    s=x[i-1]+s;i--;j--;
                }
                else
                {
                    if(dp[i-1][j]>dp[i][j-1])
                        i--;
                    else
                        j--;
                }
            }
            cout<<s;
        }
        return 0;
    }

Measured memory_bytes: 73932
//54
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int e;cin>>e,e;){
    int m=1<<30;
    for(int z=0;z*z*z<=e;z++){
      for(int y=0;z*z*z+y*y<=e;y++){
	m=min(m,e-z*z*z-y*y+y+z);
      }
    }
    cout<<m<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, i;
  int x;
  int sum=0;
  int a,b,c,d=0;
  cin >> A >> B;
  for(i=A;i<=B;i++){
    if((i/10000==i%10)&&(i%10000/1000==i%100/10)){
      sum = sum +1;
    }
  }
cout << sum << endl;
}

Measured memory_bytes: 256
class SegTree:
    
    def __init__(self, A, intv, initialize = True):
        self.N = len(A)
        self.N0 = 2**(self.N-1).bit_length()
        self.intv = intv
        if initialize:
            self.data = [intv]*(self.N0-1) + A + [intv]*(self.N0 - self.N + 1)
            for i in range(self.N0-2, -1, -1):
                self.data[i] = self.segf(self.data[2*i+1], self.data[2*i+2]) 
        else:
            self.data = [intv]*(2*self.N0)
    
    def segf(self, a, b):
        return max(a, b)
    
    def update(self, k, x):
        k += self.N0-1
        self.data[k] = x
        while k >= 0 :
            k = (k-1)//2
            self.data[k] = self.segf(self.data[2*k+1], self.data[2*k+2])
    
    def query(self, l, r):
        L, R = l+self.N0, r+self.N0
        s = self.intv
        while L < R:
            if R & 1:
                R -= 1
                s = self.segf(s, self.data[R-1])
            if L & 1:
                
                s = self.segf(s, self.data[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return s

N = int(input())
H = list(map(int, input().split()))
A = list(map(int, input().split()))

dp = SegTree([0]*(max(H)+1), 0, False)

for h, a in zip(H, A):
    dp.update(h, a+dp.query(0, h))
print(dp.data[0])


Measured memory_bytes: 121168
#include<iostream>
#include <vector>
#include <numeric>
using namespace std;
int main(){
    vector<long long> A;
    int tmp;
    for(int i=0;i<3;i++){
        cin >> tmp;
        A.push_back(tmp);
    }
    if((long long)accumulate(A.begin(), A.end(), 0LL) > 21){
        cout << "bust\n";
    }else{
        cout << "win\n";
    }
    return 0;
}

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

string s;

int main(){
//      cin.tie(0);
//      ios::sync_with_stdio(false);
        cin >> s;
        cout << ((s.size()%2 + (s[0] == s[s.size()-1])) % 2 ? "First" : "Second") << "\n";
}

Measured memory_bytes: 512
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	boolean[] p = new boolean[10001];
	setP(p);
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    if(n!=0) solve(n, p);
	}
    }

    static void solve(int n, boolean[] p){
	int x = n;
	int y = x-2;
	while(!(p[x]&&p[y])){
	    x -= 1;
	    y = x-2;
	}
	System.out.println(y+" "+x);
    }

    static void setP(boolean[] p){
	Arrays.fill(p, true);
	p[0] = p[1] = false;
	int i, j;
	for(i=2; i<p.length; i++){
	    for(j=i+i; j<p.length; j+=i){
		if(p[i]) p[j] = false;
	    }
	}
    }
}

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

int main() {
  int X;
  cin >> X;
  if (X <= 599) {
    cout << 8 << endl;
  } else if (X <= 799) {
    cout << 7 << endl;
  } else   if (X <= 999) {
    cout << 6 << endl;
  } else if (X <= 1199) {
    cout << 5 << endl;
  } else if (X <= 1399) {
    cout << 4 << endl;
  } else if (X <= 1599) {
    cout << 3 << endl;
  } else if (X <= 1799) {
    cout << 2 << endl;
  } else {
    cout << 1 << endl;
  }
  
  
}

Measured memory_bytes: 3620
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    Q,H,S,D=pin()
    N=int(input())
    Q*=4
    H*=2
    s=min(Q,H,S)
    t=N%2
    ans=0
    if s*2>D:
        ans+=D*(N//2)
        #print(ans)
        N=t
    ans+=N*s
    print(ans)
#%%submit!
resolve()

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

int main(){
    char str[16];
    int st[100], sn = 0;
    while(scanf(" %s", str) != EOF){
        switch (*str) {
            case '+':
                sn--;
                st[sn - 1] += st[sn];
                break;
            case '-':
                sn--;
                st[sn - 1] -= st[sn];
                break;
            case '*':
                sn--;
                st[sn - 1] *= st[sn];
                break;
            default:
                st[sn++] = atoi(str);
                break;
        }
    }
    printf("%d\n", st[--sn]);
    return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<'\n'
using namespace std;

 
int main() {
	SPEED;
	//freopen("in.txt", "r", stdin);
	int n; cin >> n;
	int ans = 0;
	for(int ii = 1; ii <= n; ii += 2){
		int x = ii, cnt = 0;
		for(int i = 1; i * i <= x; ++i){
			if(x % i == 0){
				++cnt;
				if(x / i != i) ++cnt;
			}
		}
		if(cnt == 8) ++ans;
	}
	print(ans);
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int main() {
    ios::sync_with_stdio(false);
    double L[100000], p[100000], sol[100000];
    ll N, M, K;
    cin >> N;
    for (int i = 0;i < N;i++) cin >> L[i];
    cin >> M >> K;
    int o[100000], g[100000];
    for (int i = 0;i < M;i++) cin >> o[i];
    for (int i = 0;i < N - 1;i++) {
        g[i] = i;
        p[i] = L[i + 1] - L[i];
    }
    for (int i = 0;i < M;i++) {
        int k = o[i] - 1;
        swap(g[k - 1], g[k]);
    }
    // Calculate orbitz
    bool T[100000];
    memset(T, 0, sizeof(T));
    for (int i = 0;i < N - 1;i++) {
        if (T[i] == 0) {
            int e = i;
            int now = i;
            vector<int> P;
            P.push_back(i);
            T[i] = 1;
            while (g[now] != e) {
                P.push_back(g[now]);
                now = g[now];
                T[now] = 1;
            }
            int rem = (K % P.size());
            vector<int> t;
            for (int j = rem;j < P.size();j++) t.push_back(P[j]);
            for (int j = 0;j < rem;j++) t.push_back(P[j]);
            for (int j = 0;j < P.size();j++) sol[P[j]] = p[t[j]];
        }
    }
    double ans[100000];
    ans[0] = L[0];
    double now = ans[0];
    for (int i = 0;i < N - 1;i++) {
        now += sol[i];
        ans[i + 1] = now;
    }
    cout.precision(20);
    for (int i = 0;i < N;i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 5352
#include<iostream>
using namespace std;
int main(){
    string s;
    cin>>s;
    string result="";
    for(int i=0;i<s.length();i++)
    {
        if(i==5||i==13){
            result+=" ";
            continue;
        }
        result+=s[i];
    }
    cout<<result;
}

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

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        var output = "NO";

        if (input[0] * input[1] * input[2] == 5 * 7 * 5)
        {
            output = "YES";
        }

        Console.WriteLine(output);
    }
}


Measured memory_bytes: 2776
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int n;
vvi g;
map<pi,int> m;

void dfs(int v,int p,int c){
    int t=1;
    for(int u:g[v]){
        if(u==p){
            continue;
        }
        if(t==c)t++;
        m[{v,u}]=t;
        dfs(u,v,t);
        t++;
    }
}

void run(){
    cin>>n;
    g=vvi(n);
    vp e(n-1);
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].eb(b);
        g[b].eb(a);
        e[i].fi=a,e[i].se=b;
    }
    int k=0;
    rep(i,n){
        k=max(k,(int)g[i].size());
    }
    dfs(0,-1,0);
    cout<<k<<endl;
    rep(i,n-1){
        cout<<m[e[i]]<<endl;
    }
}

Measured memory_bytes: 14336
#include <stdio.h>
int main(){
	int S, s, m, h;
	scanf("%d",&S);
	h = S / (60 * 60);
	m = (S % (60 * 60)) / 60;
	s = S % 60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}
	

Measured memory_bytes: 1852
#include<iostream>
#include<vector>

using namespace std;

int main()
{
	int w, n;
	int a, b;
	int data[30][2];
	int data2[30][2];
	int temp;
	int i, j, k;
	int out[30];
	
	cin >> w >> n;
	
	for(i = 0; i < n; i++){
		scanf("%d,%d",&a,&b);
		data[i][0] = a;
		data[i][1] = b;		
	}
	
	for(i = 1; i < w+1; i++){
		
		//¡Ì}ÌÔ
		temp = i;
		
		for(j = 0; j < n; j++){
			if(data[j][0] == temp){
				temp = data[j][1];
			}
			else if(data[j][1] == temp){
				temp = data[j][0];
			}
		}
		
	//	printf("%dÍ%dÖ\n",i,temp);
		out[temp] = i;
	}
	
	for(int i = 1; i < w+1; i++){
		cout << out[i] << endl;
	}
}

Measured memory_bytes: 0
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

const p = 998244353

func Pow(a, b int) int {
  P := 1
  for i := 0; i < b; i++ {
    P = P * a % p
  }
  return P
}

func Solve(D *[]int, N int) int {
  if 0 < (*D)[0] { return 0 }
  L := make([][]int, N)
  for i := range L {
    L[i] = make([]int, 0)
  }
  for i, d := range (*D) {
    L[d] = append(L[d], i)
  }
  if 1 < len(L[0]) { return 0 }
  C := N
  P := 1
  for i, l := range L {
    n := len(l)
    if 0 < n && C < i { return 0 }
    if n == 0 { C = i }
    if 1 < i && i < C { P = P * Pow(len(L[i - 1]), n) % p }
  }
  return P
}

func main() {
  N := NextInt()
  D := NextIntVec()
  Write(Solve(&D, N))
  Output()
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  cout << a.back()-a.front() << endl;
}

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

signed main(){
	int N,K; cin>>N>>K;
	vector<int> p(N);
	vector<double> prob(N);
	vector<int> seki(N);
	for(int i=0;i<N;i++){
		cin>>p[i];
		prob[i]=(p[i]+1)/2.0;
		seki[i]=p[i];

		if(i!=0){
			prob[i]+=prob[i-1];
			seki[i]*=seki[i-1];
		}
	}
	double ans=(prob[K-1]);
	for(int i=0;i<N-K;i++){
		double tmp=(prob[i+K]-prob[i]);
		if(tmp>ans)ans=tmp;
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int a[5], k; rep(i, 5) cin >> a[i]; cin >> k;
  sort(a, a+5);
  if(a[4] - a[0] > k) cout << ":(";
  else cout << "Yay!";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
typedef long long int ll;
#define in insert 
#define rep(i,n) for (ll i = 0; i < n; i++)
#define  pb push_back
#define N 200001


 int main(){
  long double n;
  cin>>n;
  
  ll ans = ceil(n/1000);
  ll tek = ans*1000;
  cout<<tek-n;
  
 }

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

using P = pair<ll, ll>;

void update(vector<P>& v, P p) {
  while (!v.empty() && v.back().second >= p.first) {
    P b = v.back();
    p = P(min(b.first, p.first), max(b.second, p.second));
    v.pop_back();
  }
  v.push_back(p);
}

int main2() {
  int N = nextInt();
  ll X = nextLong();
  ll D = nextLong();
  if (D == 0) {
    if (X == 0) cout << 1 << endl;
    else cout << N+1 << endl;
    return 0;
  }
  if (D < 0) {
    X *= -1;
    D *= -1;
  }

  map<int, vector<P>> vps;

  ll Z = X - D;
  for (ll i = 0; i <= N; i++) {
    ll m = (i * Z) % D;
    m = (m % D + D) % D;
    if (vps.count(m) == 0) {
      vps[m] = vector<P>();
    }
    ll a = (i*Z)/D + (ll)i*(i+1)/2 ;
    ll b = (i*Z)/D - (ll)i*(i-1)/2 + i*N;
    if (a > b) swap(a, b);
    vps[m].push_back(P(a, b));
  }

  ll ans = 0;
  for (auto it = vps.begin(); it != vps.end(); ++it) {
    vector<P> v = it->second;
    sort(ALL(v));
    vector<P> u = vector<P>();
    for (auto p : v) {
      update(u, p);
    }
    for (auto p : u) {
      ans += p.second - p.first + 1;
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

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

inline void swap(int a, int b){ int tmp = a; a = b; b = tmp; }
int main()
{
    int N; cin >> N;
    vector<int> p(N + 9);
    for (int i = 1; i <= N; ++i)
        cin >> p[i];

    int ans = 0;
    for (int i = 1; i <= N; ++i){
        if (p[i] == i){
            p[i + 1] = i; // どうせ p[i] はもう見ないのだから
                          // swap しなくても、これだけでいい？
            ++ans;
        }
    }

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


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>
#include <fstream>

using namespace std;

long long A,B,T,ans,L,R;

int main()
{
	cin >> A >> B;
	if (A == B)
	{
		cout << 1 << endl;
		return 0;
	}
	for (int i = 59;i >= 0;i--)
		if ((A >> i & 1) != (B >> i & 1))
		{
			T = 1ll << i;
			break;
		}
	T = T + (T - 1);
	A &= T;
	B &= T;
	T = (T + 1) >> 1;
	ans = T - A + T - A;
	L = T + A;
	R = 2 * T - 1;
	A = 0;
	for (int i = 59;i >= 0;i--)
		if ((T | (1ll << i)) <= B)
			A |= (1ll << i);
	R = min(R,A);
	cout << ans + A - T + 1 - (R >= L ? R - L + 1 : 0) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int alice = 0;
        int bob = 0;
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
        }
        Arrays.sort(as);
        boolean a = true;
        for (int i = n - 1; i >= 0; i--) {
            if (a) {
                alice += as[i];
                a = false;
            } else {
                bob += as[i];
                a = true;
            }
        }
        System.out.println(alice - bob);
    }
}

Measured memory_bytes: 21844
import java.util.*;

public class Main {
	int N;
	List<Integer> X = new ArrayList<>();
	List<Integer> results = new ArrayList<>();

	private Main(Scanner in) {
		N = Integer.parseInt(in.nextLine());
		for (String token : in.nextLine().split(" ")) {
			X.add(Integer.parseInt(token));
		}
	}

	private void calc() {
		// Xをソートしたリストを作る
		List<Integer> vals = new ArrayList<>(X.size());
		vals.addAll(X);
		Collections.sort(vals);

		// 中央付近の2つの値をとる
		int littleMedium = vals.get(vals.size() / 2 - 1);
		int largeMedium = vals.get(vals.size() / 2);
		for (int i = 0; i < X.size(); ++i) {
			if (X.get(i) <= littleMedium) {
				results.add(largeMedium);
			} else {
				results.add(littleMedium);
			}
		}
	}

	private void show() {
		for (Integer result : results) {
			System.out.println(result);
		}
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Main ins = new Main(in);
		in.close();
		ins.calc();
		ins.show();
	}

}

Measured memory_bytes: 80660
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
int z=0;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
//ここから始めよう
signed main(){
    int n;cin>>n;
    int a[114514];rep(i,0,n)cin>>a[i];
    sort(a,a+n);
    int k=0,s=n-1;
    int ans=0;vector<int>v;
    rep(i,0,n-1){
        ans+=a[s]-a[k];v.ps(a[s]-a[k]);
        if(i!=n-2){
            if(i%2==0)k++;else s--;
        }
    }
    if(n%2==1){
        ans+=a[k]-a[0];v.ps(a[k]-a[0]);
    }else {
        ans+=a[s]-a[0];v.ps(a[s]-a[0]);
    }
    //cout<<ans<<endl;
    sort(v.begin(),v.end());ans-=v[0];
    int anss=0;vector<int>vv;
    s=n-1,k=0;
    rep(i,0,n-1){
        anss+=a[s]-a[k];vv.ps(a[s]-a[k]);
        if(i!=n-2){
            if(i%2==0)s--;else k++;
        }
    }
    //cout<<k<<" "<<s<<endl;
    if(n%2==1){
        anss+=a[n-1]-a[s];vv.ps(a[n-1]-a[s]);
    }else {
        anss+=a[n-1]-a[k];vv.ps(a[n-1]-a[k]);
    }
    //cout<<anss<<endl;
    sort(vv.begin(),vv.end());anss-=vv[0];
    //cout<<ans<<" "<<anss<<endl;
    cout<<max(ans,anss)<<endl;return 0;
}

Measured memory_bytes: 3316
import numpy as np

A, B = map(int, input().split())

ans = [A, B]

sub_max = np.max(ans)
sub_min = np.min(ans)
sub = sub_max 
sub_max -= 1
    
ans = [sub_max, sub_min]
sub_max = np.max(ans)
sub = sub + sub_max
print(sub)

Measured memory_bytes: 12508
#include <iostream>
int main()
{
  	int64_t Scorelist[3]{1,0,-1};
  	int64_t Num[3];
  	int64_t DrawNum;
	std::cin >> Num[0] >> Num[1] >> Num[2] >>  DrawNum;
  int64_t Score{0};
  int index =0;
  while(DrawNum > 0)
  {
  	if(DrawNum - Num[index] <= 0)
    {
		Score += Scorelist[index] * DrawNum;
      	break;
    }
	Score += Scorelist[index] * Num[index];
  	DrawNum -= Num[index];
    index++;
  }
  std::cout << Score << std::endl;;
  	
	return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define dump(x)  cerr << #x << " => " << (x) << endl
#define MIN(vec) *min_element(vec.begin(), vec.end())
#define MAX(vec) *max_element(vec.begin(), vec.end())
#define UNIQ(vec) vec.erase(unique(vec.begin(), vec.end()),vec.end()) //ソートの必要あり
#define IN(n,m)  (!(m.find(n) == m.end()))
#define FINDL(vec,x) (lower_bound(vec.begin(),vec.end(),x) - vec.begin())
#define FINDU(vec,x) (upper_bound(vec.begin(),vec.end(),x) - vec.begin())
#define EQ(a,b) (abs(a - b) < 1e-10)
using namespace std;
typedef long long LL;
constexpr int dx[4] = {0,1,0,-1};
constexpr int dy[4] = {1,0,-1,0};
constexpr long double pi = M_PI;
constexpr double eps = 1e-10;
constexpr long mod = 1000000007;
// LONG_MAX,LLONG_MAX
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class Key,class Value> ostream& operator << (ostream &s, map<Key,Value> M)
{ for ( auto itr = begin(M); itr != end(M); ++itr) { s << itr->first << ":" << itr->second; } return s;}

struct Node{
    long d,i,j;
};

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
    priority_queue<Node, vector<Node>, function<bool(Node,Node)>> que (
        [](const Node &a,const Node &b){return a.d > b.d;}
    );
    long H,W;
    cin >> H >> W;
    vector<string> A(H);
    vector<vector<long>> used(H,vector<long>(W,-1));
    REP(i,H) {
        cin >> A[i];
        REP(j,W) {
            if (A[i][j] == '#') {
                que.push(Node{0,i,j});
                used[i][j] = 0;
            }
        }
    }
    while (!que.empty()) {
        Node ret = que.top();
        long d = ret.d;
        long i = ret.i;
        long j = ret.j;
        que.pop();
        if (i > 0 && used[i-1][j] == -1) {
            used[i-1][j] = d+1;
            que.push(Node{ d+1, i-1,j});
        }
        if (i < H-1 && used[i+1][j] == -1) {
            used[i+1][j] = d+1;
            que.push(Node{ d+1, i+1,j});
        }
        if (j > 0 && used[i][j-1] == -1) {
            used[i][j-1] = d+1;
            que.push(Node{ d+1, i,j-1});
        }
        if (j < W-1 && used[i][j+1] == -1) {
            used[i][j+1] = d+1;
            que.push(Node{ d+1, i,j+1});
        }
    }
    long ans = 0;
    REP(i,H) {
        REP(j,W) {
            ans = max(ans,used[i][j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 34288
n = gets.to_i
a = gets.split.map(&:to_i)
a.sort!
gcds = [a[0]]
t = a[0]
(n-1).times do |i|
  t = t.gcd(a[i+1])
  gcds << t
end
ans = [gcds[-2]]
t = a[-1]
(n-2).downto(1) do |i|
  ans << t.gcd(gcds[i-1])
  t = t.gcd(a[i])
end
ans << t
p ans.max

Measured memory_bytes: 11764
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    a = list(map(int, input().split()))
    total = sum(a)
    b = total / (4*m)
    cnt = 0
    for i in a:
        if i >= b:
            cnt += 1
    if cnt>=m:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
int main()

{

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int x1,x2,x3,x4;
	cin>>x1>>x2>>x3>>x4;
	int area1=x1*x2;
	int area2=x3*x4;
	if(area1>=area2)
	{
		cout<< area1<<"\n";
	}
	else
	{
		cout<< area2<<"\n";
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void) {                                                                
    double x = 0, y = 0, v = 90;                                                
    int line, angle;                                                            
                                                                                
    while (scanf("%d,%d", &line, &angle), line || angle) {                      
        x += line * cos(M_PI * v / 180);                                        
        y += line * sin(M_PI * v / 180);                                        
        v -= angle;                                                             
    }                                                                           
    printf("%d\n%d\n", (int)x, (int)y);                                         
    return 0;                                                                   
}

Measured memory_bytes: 604
def resolve():

    n = int(input())
    d = list(map(int, input().split()))

    d = sorted(d)

    index_left = int((len(d) / 2) -1)
    index_right = int((len(d) / 2))

    num_left = d[index_left]
    num_right = d[index_right]

    print(num_right - num_left)
    
resolve()

Measured memory_bytes: 52684
#include <iostream>
using namespace std;
#define MAX 50100

bool isPrime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

int main(void){
    int d[MAX] = {0};
    for(int i = 2; i < MAX; i++) d[i] = isPrime(i);

    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        
        int c = 0;
        for(int i = 1; i <= n / 2; i++){
            if(d[i] == 1 && d[n - i] == 1) c++;
        }
        cout << c << endl;
    }
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    int n;
    cin >> n;
    int Max = -1;
    int ren = 0;
    
    rep(i,0,n){
        int a,b;
        cin >> a >> b;
        if(a==b){
            ren ++;
        }else{
            Max = max(ren,Max);
            ren = 0;
        }

    }
    Max = max(ren,Max);
    if(Max>=3){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3628
import java.util.*;
class Main{
	public static void main(String[]args){
      Scanner in = new Scanner(System.in);
      String n = in.nextLine();int c =0, d=0;
      for(int i = 0 ; i < n.length() ; i++){
      	if(n.charAt(i)=='A')
          c++;
      }
      for(int i = 0 ; i < n.length() ; i++){
      	if(n.charAt(i)=='B')
          d++;
      }
      if(c==2)
        System.out.println("Yes");
      else if(d==2)
         System.out.println("Yes");
      else
         System.out.println("No");
    }
}

Measured memory_bytes: 20820
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   int a,b;
   cin>>a>>b;
   if(a<b) cout<<"a < b"<<endl;
   else if(a==b) cout<<"a == b"<<endl;
   else cout<<"a > b"<<endl;
   //while(1);
   return 0;
 }
 
 
 

Measured memory_bytes: 3072
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
	int a;
	while(scanf("%d",&a),a){
		int ret=99999999;
		for(int i=0;i*i*i<=a;i++){
			int t=(sqrt(a-i*i*i)+0.0000001);
			ret=min(ret,i+t+(a-i*i*i-t*t));
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Itr(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define setp(n) fixed << setprecision(n)
#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define All(a) (a.begin()),(a.end())
#define rAll(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vll x(m), y(m-1);
	rep(i,m) cin>>x[i];
	if (n<m){
		sort(All(x));
		rep(i,m-1) y[i]=x[i+1]-x[i];
		sort(rAll(y));
		ll ans=x[m-1]-x[0];
		rep(i,n-1) ans-=y[i];
		cout<<ans<<endl;
	}else{
		cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    int ans = n;
    for(int i=0; i<=n; i++){
        int tmp = 0;
        int t = i;
        while(t>0){
            tmp += t%6;
            t /= 6;
        }
        t = n -i;
        while(t>0){
            tmp += t%9;
            t /= 9;
        }
        if(ans > tmp) ans = tmp;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256