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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll n;
    cin >> n;
    n = n%10;
    if ( n == 2 || n == 4 || n == 5 || n == 7 || n == 9 ) {
        cout << "hon" << endl;
    } else if ( n == 0 || n == 1 || n == 6 || n == 8 ) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
    return 0;
}


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

using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, a, b) for (int64_t i = (a); i < (b); ++i)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int total = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    total += a[i];
  }
  int ave = total / n;
  int ans = 0, ans2 = 0, ans3 = 0;
  for (int i = 0; i < n; i++) {
    ans += pow(a[i] - ave, 2);
  }
  for (int i = 0; i < n; i++) {
    ans2 += pow(a[i] - ave - 1, 2);
  }
  for (int i = 0; i < n; i++) {
    ans3 += pow(a[i] - ave + 1, 2);
  }
  cout << min(ans, min(ans2, ans3)) << endl;
}

Measured memory_bytes: 256
from collections import Counter as c

N = int(input())
V = list(map(int,input().split()))
ev = c(V[::2]).most_common(2)
od = c(V[1::2]).most_common(2)

if ev[0][0] == od[0][0]:
    if len(ev) == 1 and len(od) == 1:
        print(N//2)
    else:
        print(N-max(ev[0][1]+od[1][1],ev[1][1]+od[0][1]))
else:
    print(N-ev[0][1]-od[0][1])

Measured memory_bytes: 15588
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int H, W;
    string S[60];
    cin >> H >> W;

    string empty = ".";
    for (int i = 0; i < W+2; i++){
        S[0] += empty;
        S[H + 1] += empty;
    }
    string tmp;
    for (int i = 1; i <= H; i++){
        cin >> tmp;
        tmp = "." + tmp + ".";
        S[i] = tmp;
    }

    for (int i = 1; i <= H; i++){
        for (int j = 1; j <= W; j++){
            int counter = 0;
            if (S[i][j] == '.'){
                if (S[i - 1][j - 1] == '#') counter++;
                if (S[i - 1][j] == '#') counter++;
                if (S[i - 1][j + 1] == '#') counter++;
                if (S[i][j - 1] == '#') counter++;
                if (S[i][j + 1] == '#') counter++;
                if (S[i + 1][j - 1] == '#') counter++;
                if (S[i + 1][j] == '#') counter++;
                if (S[i + 1][j + 1] == '#') counter++;
                S[i][j] = '0' + counter;
            }
        }
        cout << S[i].substr(1, W) << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long int LL;
LL t[2][100005];
vector<pair<LL,int> > v1;
int main(){
	int n;
	int i,j,k;
	LL a=0,b=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>t[0][i]>>t[1][i];
		a=t[1][i]+t[0][i];
		v1.push_back(make_pair(a,i));
	}
	sort(v1.rbegin(),v1.rend());
	a=0,b=0;
	for(i=0;i<n;i++){
		k=v1[i].second;
		if(i%2==0)a+=t[0][k];
		else b+=t[1][k];
	}
	a-=b;
	cout<<a<<endl;
	return 0;
}
	


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,P;
  cin >> N >> P;
  vector<int> poz (P,0);
  for ( int i = 0; i<P ; i++ ) {
    cin >> poz[i];
  }
  sort ( poz.begin(),poz.end());
  vector<int> bds (N+P,0);
  for ( int i = 1; i<P ; i++ ) {
    bds[i] = poz[i] - poz[i-1];
  }
  sort (bds.begin(),bds.end());
  reverse ( bds.begin(),bds.end());
  int fld = 0;
  for (int i = 0; i < N-1 ; i++ ) {
    fld += bds[i];
  }
  cout << (poz[P-1]-poz[0]) - fld << endl;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string str, od;
	int q, a, b;
	cin >> str >> q;
	for (int i = 0; i < q; i++) {
		cin >> od >> a >> b;
		if (od == "print") {
			cout << str.substr(a, b-a+1) << "\n";
		}else if (od == "reverse") {
			string tmp = str.substr(a, b-a+1);
			reverse(tmp.begin(), tmp.end());
			str.replace(a, b-a+1,tmp);
		}else if (od == "replace") {
			string p;
			cin >> p;
			str.replace(a, b-a+1, p);
		}
	}
	return 0;
}



Measured memory_bytes: 3220
/* kadai 3_2
   nabe9393 */
 
#include<stdio.h>
 
int main(void){
  int num_pen;
  scanf("%d", &num_pen); //入力
  if (num_pen % 10 == 3){ //１のくらいが３の時はBON
    printf("bon\n");
  }
  else if (num_pen % 10 == 0 || num_pen % 10 == 1 || num_pen % 10 == 6 || num_pen % 10 == 8){ //1のくらいが0,1,6,8の時はPON
    printf("pon\n");
  }
  else{ //それ以外はHON
    printf("hon\n"); 
  }
return 0;
}

Measured memory_bytes: 1616
n, a, b = map(int, input().split())
mod = 10**9 + 7

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
            result %= mod

    return result % mod



ans = pow(2, n, mod) - cmb(n, a) - cmb(n, b) - 1
#Sprint("{}, {}, {}".format(pow(2, n, mod), cmb(n, a), cmb(n, b)))
print(ans % mod)


Measured memory_bytes: 108236
local mod = 998244353
local function bmul(x, y) return (x * y) % mod end
local function modpow(src, pow)
  local res = 1
  while 0 < pow do
    if pow % 2 == 1 then
      res = bmul(res, src)
      pow = pow - 1
    end
    src = bmul(src, src)
    pow = pow // 2
  end
  return res
end

local function modinv(src)
  return modpow(src, mod - 2)
end

local n = io.read("*n")
local t = {}
for i = 1, n do
  t[i] = 0
end
local tmp = true
local maxlen = 0
for i = 1, n do
  local a = io.read("*n")
  if i == 1 then
    tmp = a == 0
  end
  maxlen = math.max(maxlen, a + 1)
  t[a + 1] = t[a + 1] + 1
end
if not tmp then print(0) os.exit() end
for i = 1, maxlen do
  if t[i] == 0 then
    print(0)
    os.exit()
  end
end
if t[1] ~= 1 then
  print(0)
  os.exit()
end
local ret = 1
for i = 2, maxlen do
  ret = bmul(ret, modpow(t[i - 1], t[i]))
end
print(ret)


Measured memory_bytes: 2424
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

int main() {
	ll n, sum1 = 0, sum2 = 0;
	cin >> n;
	vector<int>a(n);
	for (ll i = 0;i < n;i++) {
		cin >> a[i];
		sum2 += a[i];
	}
	ll ans = 10000000000;
	for (ll i = 0;i < n-1;i++) {
		sum1 += a[i];
		sum2 -= a[i];
		ans = min(ans, abs(sum1 - sum2));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"sort"
)

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

	s := map[string]int{}
	max := 1
	for i := 0; i < n; i++ {
		var tmp string
		fmt.Scan(&tmp)
		_, exists := s[tmp]
		if !exists {
			s[tmp] = 1
		} else {
			s[tmp]++
			if max < s[tmp] {
				max = s[tmp]
			}
		}
	}

	var ans []string
	for k, v := range s {
		if v == max {
			ans = append(ans, k)
		}
	}
	sort.Strings(ans)
	for _, a := range ans {
		fmt.Println(a)
	}

}


Measured memory_bytes: 35072
#include <stdio.h>

int min(int x, int y)
{
  if(x < y) {
    return x;
  }
  else {
    return y;
  }
}

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

  for(int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
  }
 
  long long int sum = 0;

  for(int i = 0; i < n; i++) {
    sum += min(a[i],b[i]) + min(a[i+1], b[i] - min(a[i],b[i]));
    a[i+1] -= min(a[i+1], b[i] - min(a[i],b[i]));
  }
        


  printf("%lld\n", sum);

  return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
int main (void){

int r, c, i[3], j[3],S,l;

scanf("%d %d", &r, &c);

int A[ r * c ];

for( i[1] = 1; i[1] <= r; i[1]++ ){
	for( j[1] = 1; j[1] <= c; j[1]++){
		scanf("%d", &A[ ( ( i[1] - 1 ) * c ) + j[1] ]);
	}
}


for( i[2] = 1; i[2] <= r; i[2]++){
	S = 0;
	for( j[2] = 1; j[2] <= c; j[2]++){
		printf("%d ",A[ ( ( i[2] - 1 ) * c ) + j[2] ] );
		S = S + A[ ( ( i[2] - 1 ) * c ) + j[2] ];
	}
	printf("%d\n",S);

}
for( j[3] = 1; j[3] <= c; j[3]++){
	S = 0;
	for( i[3]= 1; i[3] <= r; i[3]++ ){
		S = S + A[ ( ( i[3] - 1 ) * c ) + j[3] ];
	}
	printf("%d ", S );
}
S = 0;
for( l =1; l <= (r * c); l++){
	S = S + A[ l ];
}
printf("%d\n", S );
return 0;
}

Measured memory_bytes: 1864
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;




int main(){
    int h,w;cin >> h >> w;
    vector<string> S(h);
    for (int i = 0; i < h; i++) {
        cin >> S[i];
    }
    int ans = 0;
    for (int i = 0; i < w-1; i++) {
        vector<vector<int>> dp(h+2,vector<int> (h+2,INF));
        vector<vector<int>> cuma(h+2,vector<int> (h+2,0));
        vector<vector<int>> ca(h+2,vector<int> (h+2,0));
        vector<vector<int>> cost(h+2,vector<int> (h+2,0));
        auto cb = ca;
        auto cumb = cuma;
        for (int k = 0; k <= h; k++) {
            for (int j = 0; j < h - k; j++) {
                if(S[j+k][i] == S[j][i+1]) ca[k][h-(j+k)-1] = 1; 
                if(S[j][i] == S[j+k][i+1]) cb[k][h-(j+k)-1] = 1; 
            }
        }
        for (int k = 0; k <= h; k++) {
            for (int j = 0; j <= h; j++) {
                cuma[k][j+1] = cuma[k][j] + ca[k][j];
                cumb[k][j+1] = cumb[k][j] + cb[k][j];
            }
        }
        for (int j = 0; j <= h; j++) {
            for (int k = 0; k <= h; k++) {
                if(j>=k) cost[j][k] = cuma[j-k][h] - cuma[j-k][h-j];
                else cost[j][k] = cumb[k-j][h] - cumb[k-j][h-k];
            }
        }
        dp[h][h] = 0;
        for (int j = h; j >= 0; j--) {
            for (int k = h; k >= 0; k--) {
                if(j==h&&k==h) continue;
                dp[j][k] = min(dp[j][k+1] + cost[j][k+1],dp[j+1][k] + cost[j+1][k]);
            }
        }
        ans += dp[0][0];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2664
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val ints: Seq[Int] = Seq(-1, 0, 1).map(_ + (n / 1.08).toInt)
  println {
    ints.find(i => (i * 1.08).toInt == n).getOrElse(":(")
  }
}


Measured memory_bytes: 27204
n = int(input())
p = list(map(int,input().split()))

s = p[:3]
ans = 0
for i in range(n-2):

    if s[1]>min(s) and s[1]<max(s):
        ans += 1
    if i == n-3:
        break
    s = s[1:]+[p[i+3]]
print(ans)

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  int a, b;
  while (cin >> a >> b) {
    if (0 < a) {
      cout << "Positive" << endl;
    } else if (a <= 0 && 0 <= b) {
      cout << "Zero" << endl;
    } else {
      if (a < 0 && (b - a) % 2 == 0) {
        cout << "Negative" << endl;
      } else {
        cout << "Positive" << endl;
      }
    }
  }
  return 0;
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int N, L; cin >> N >> L;
    int t = INF, sum = 0;
    REP( i, N ){
        int taste = L + i;
        sum += taste;
        chmin( t, abs( taste - 0 ) );
    }

    if( L + N - 1 >= 0 )cout << sum - t << endl;
    else cout << sum + t << endl;
}


Measured memory_bytes: 256
import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions

import sys
def input():
	return sys.stdin.readline().strip()

N, M = list(map(int, input().split()))

graph = [[] for _ in range(N)]

for i in range(M):
	A, B = list(map(int, input().split()))
	A -= 1
	B -= 1
	graph[A].append(B)


for start in range(N):
	parent = [-1] * N
	depth = [0] * N
	que = deque([])
	que.append(start)
	depth[start] = 1
	while len(que) > 0:
		node = que.popleft()
		judge = 0
		if len(graph[node]) > 0:
			for node_next in graph[node]:
				if depth[node_next] == 1:
					judge = 1
				if depth[node_next] == 0:
					depth[node_next] = depth[node] + 1
					que.append(node_next)
					parent[node_next] = node
		if judge == 1:
			last = node
			break
	if judge == 1:
		break


if judge != 1:
	print(-1)
	exit()

node_list = deque([last])
while True:
	loc = parent[node_list[0]]
	if loc == -1:
		break
	else:
		node_list.appendleft(loc)

node_set = set([node_list[0]])


for i in range(1, len(node_list)):
	max_depth = -1
	for edge in graph[node_list[i]]:
		if edge in node_set:
			for j in range(i):
				if edge == node_list[j]:
					max_depth = max(max_depth, j)
	if max_depth >= 0:
		start = max_depth
		end = i
		break
	node_set.add(node_list[i])

#print(node_set, node_list, depth)
print(end + 1 - start)
for node in range(start, end + 1):
	print(node_list[node] + 1)

Measured memory_bytes: 67564
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
// #define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a, int MOD) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b, int MOD) {
    int res = 1;
    while(b > 0){
        if(b&1) res = m(m(res, MOD)*m(a, MOD), MOD);
        a = m(m(a, MOD)*m(a, MOD), MOD);
        b >>= 1;
    }
    return res;
} 
signed main(){
    fast();
    int k;
    cin >> k;
    if(k%2 == 0){
        cout << -1 << endl;
        return 0;
    }
    int x = 0;
    int num = 0;
    vector<int> pre(1000000);
    for(int i=0; i<1000000; i++){
        pre[i] = m(m(7*p(10, i, k), k), k);
    }
    while(x < 1000000){
        num = m(m(m(num, k) + pre[x], k), k);
        // num %= k;
        x++;
        if(num == 0)    break;
    }
    if(num == 0)cout << x << endl;
    else cout << -1 << endl;
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

Measured memory_bytes: 11112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vvi g;
ll dfs(int i,int p){
    ll res=0;
    bool done=false;
    for(ll x:g[i])if(x!=p){
        ll k=dfs(x,i);
        res+=k;
        if(k==0){
            if(done)res++;
            else done=true;
        }
    }
    return res;
}
int main(){
    ll n;cin>>n;
    g=vvi(n);
    rep(i,n-1){
        ll a,b;cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
    }
    if(n==2)dame(1);
    int ne=0;
    while(ne<n&&g[ne].size()<=2)ne++;
    if(ne==n)dame(1);
    out(max(1ll,dfs(ne,-1)));
}


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

const int MAX_V = 1 << 17;
vector<int> G[MAX_V]; 
int V; 
queue<pair<int, int> > que;
int d[MAX_V][3];

void bfs(int i, int j) {
  que.push(make_pair(i, j));
  while (!que.empty()) {
    int a = que.front().first, b = que.front().second;
    que.pop();
    for (int k = 0; k < G[a].size(); k++) {
      if (!d[G[a][k]][(b + 1) % 3]) {
	d[G[a][k]][(b + 1) % 3] = d[a][b] + 1;
	que.push(make_pair(G[a][k], (b + 1) % 3));
      }
    }
  }
  return;
}

int main(int argc, char *argv[])
{
  int m;
  cin >> V >> m;
  int from, to;
  for (int i = 0; i < m; i++) {
    cin >> from >> to;
    from--; to--;
    G[from].push_back(to);
  }
  int s, t;
  cin >> s >> t;
  s--; t--;

  bfs(s, 0);

  if (!d[t][0]) cout << -1 << endl;
  else cout << d[t][0] / 3 << endl;

  return 0;
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	string s,t;
	cin >> s >> t;
	rep(i, s.size()) {
    	if(s[i] != t[i]) {
        	cout << "No\n";
          	return 0;
        }
    }
  	cout << "Yes\n" << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

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

int main() {
  i64 A, B, C, D;
  cin >> A >> B >> C >> D;
  A--;
  i64 a = A - (A / C - (A / (C * D / gcd(C, D))) + A / D);
  i64 b = B - (B / C - (B / (C * D / gcd(C, D))) + B / D);
  cout << b - a << endl;
}


Measured memory_bytes: 256
using DataStructures
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  N, K = readint()
  A = readint()

  for i in 1:N-K
    if A[i] < A[i+K]
      println("Yes")
    else
      println("No")
    end
  end

  

end

main()

Measured memory_bytes: 207680
// Author -- Frame

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-x))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<int,int> pl;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x7fffffffffffffff;

Finline uint rnd()
{
	static uint seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>Finline _Tp max(const _Tp &a,const _Tp &b){return a<b?b:a;}
template <typename _Tp>Finline _Tp min(const _Tp &a,const _Tp &b){return a<b?a:b;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline void read(_Tp &x)
{
	char ch(getchar());
	bool f(false);
	while(ch<48||ch>57) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();
	while(ch>=48&&ch<=57) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	if(f) x=-x;
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args)
{
	read(t);read(args...);
}
Finline int read_str(char *s)
{
	char ch(getchar());
	while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;
	*tar=ch,ch=getchar();
	while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=100005;
void MAIN()
{
	#define int ll
	int a,b,c,d;
	read(a,b,c,d);
	int k=max((a+b)/(b+1),(a+b)/(a+1));
	auto check=[&](int x)->bool
	{
		bool flag=x%(k+1)==0;
		int qwq=x-x%(k+1);
		int c1=qwq/(k+1)*k;
		int c2=qwq/(k+1);
		c1+=x%(k+1);
		int A=a-c1;
		int B=b-c2;
		if(A<0||B<0) return false;
		if(flag)
		{
			return k-1+k*A>=B&&k*(B+1)>=A;
		}
		else
		{
			return k*(A+1)>=B&&k*(B+1)>=A;
		}
	};
	int l=0,r=a+b;
	while(l<r)
	{
		int mid=(l+r+1)>>1;
		if(check(mid)) l=mid;
		else r=mid-1;
	}
	int tot=a+b;
	int cnt=(tot-l)%(k+1);
	auto get=[&](int x)->char
	{
		if(x<=l)
		{
			if(!(x%(k+1))) return 'B';
			return 'A';
		}
		else
		{
			if(!cnt)
			{
				x-=l;
				if(!(x%(k+1))) return 'A';
				return 'B';
			}
			else
			{
				if(x-l<=cnt+1) return x-l<=cnt?'B':'A';
				else
				{
					x-=l;
					x-=cnt+1;
					if(!(x%(k+1))) return 'A';
					return 'B';
				}
			}
		}
	};
	for(int i=c;i<=d;++i)
	{
		putchar(get(i));
	}
	putchar('\n');
	#undef int
}
int main()
{
	int _;
	read(_);
	while(_--) MAIN();
	return 0;
}


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

using namespace std;

int main() {
    
    vector<int> c(9, 0);
    
    for (int i = 0; i < 9; ++i)
    {
        cin >> c[i];
    }
    
    int sum1 = c[0] + c[4] + c[8];
    int sum2 = c[1] + c[5] + c[6];
    int sum3 = c[2] + c[3] + c[7];
    
    if (sum1 == sum2 && sum1 == sum3)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
while line = gets
  n, r = line.split(" ").map(&:to_i)
  break if n == 0
  yama = [*1..n].reverse
  r.times {
    p, c = gets.split(" ").map(&:to_i)
    cut = yama[p-1, c]
    yama = cut + (yama - cut)
  }
  p yama[0]
end

Measured memory_bytes: 6260
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N;
  cin >> N;
  N %= 10;
  if(N==3){
    cout << "bon" << endl;
  }
  else if(N==0 || N==1 || N==6 || N==8){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" <<endl;
  }
 
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
map<int, int> mp;
map<int, int> :: iterator sit;
int a[N];

int main() {
  int n;
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    mp[a[i]]++;
  }
  int ans = 0;
  for(sit = mp.begin(); sit != mp.end(); ++sit) {
    int v = sit -> first, num = sit -> second;
    if(num >= v) {
      ans += num - v;
    } else {
      ans += num;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 5120
#include <iostream>
using namespace std;
int main()
{
	int x,y;
	while(cin>>x>>y)
	{
		if(x==0&&y==0)
			break;
		else
		{
			if(x<y)
				cout<<x<<" "<<y<<endl;
			else
				cout<<y<<" "<<x<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3032
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define x first
#define y second
#define int ll
#define pi pair <int, int>
#define pii pair <pi, pi>
#define vi vector <int>
#define in insert
#define er erase
#define fd find
int a, b, cnt, ans=0;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>a>>b;
    if(a==b) return cout<<a,0;
    if(a%2) ans^=a, a++;
    if(b%2==0) ans^=b, b--;
    if(a>b) return cout<<ans,0;
    //dbg(ans)
    cnt=(b-a+1)/2;
    ans^=(cnt%2);
    cout<<(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;
typedef vector< pll >   vpll;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(s,e)     ((s)+((e)-(s))/2) 

#define fo(i,a,b)     for(ll i = (ll)(a); i <= (ll)(b); i++)
#define rf(i,a,b)    for(ll i = (ll)(a); i >= (ll)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***




void solve()
{
    ll n;rd(n); ll ans = 0;
    fo(i,1,n){
        if(i%3!=0 and i%5!=0)ans+=i;
    }   
    pp(ans);
    
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 3460
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int maxi = max(a, max(b, c));
    for (int i = 0; i < k; i++) {
        maxi *= 2;
    }
    cout << a + b + c + maxi - max(a, max(b, c)) << endl;
}

Measured memory_bytes: 256
N, X, Y= map(int, input().split())
K = [0]*(N-1)
for i in range(1,N):
    for j in range(i+1, N+1):
        idx = min([j-i, abs(X-i)+ abs(j-Y)+1, abs(Y-i) + 1 + abs(X-j)])-1
        K[idx] +=1
for value in K:
    print(value)    

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
vi ind[N];
void solve(){
    int n;
    cin>>n;
    vi v(n);
    map<int, int>u;
    for(int i = 0; i < n; i++){
        cin>>v[i];
        ind[v[i]].pb(i);
    }
    int mn = INF, l = 0, cnt = 0, aft = 1;
    for(int i = 0; i < n; i++){
        for(auto it:ind[aft]){
            if(it>=l){
                l=it;
                cnt++;
                aft++;
                break;
            }
        }
    }  
    if(!cnt)cout<<"-1";
    else cout<<n-cnt;
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

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

int main(){
  int n;
  int sum=0;
  cin>>n;
  int A[n];
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  for(int i=1;i<n-1;i++){
    if(A[i-1]<A[i]&&A[i]<A[i+1]){
      sum++;
    }else if(A[i-1]>A[i]&&A[i]>A[i+1]){
      sum++;
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;
class Main{
   public static void main(String[] args){
     Scanner scanner = new Scanner(System.in);
     int a,b,c,x,y,z;
     a = scanner.nextInt();
     b = scanner.nextInt();
     c = scanner.nextInt();

     y = 0;

     if(a>b){
       x = a;
     }else x = b;

     if(x<c)x = c;

     if(a<b){
       z = a;
     }else z =b;

     if(z>c)z = c;

     if(a!=x&&a!=z)y = a;
     if(b!=x&&b!=z)y = b;
     if(c!=x&&c!=z)y = c;

     if(a==b||a==c||b==c){
       if((a==b&&a==x)||(a==c&&a==x)||(b==c&&b==x)){
         y = x;
       }else y = z;
     }


     System.out.println(z +" "+ y +" "+ x);

  }
}


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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T>
vector<vector<T> > make_v(size_t a,size_t b){
  return vector<vector<T> >(a,make_v<T>(b));
}
template<typename T>
vector<vector<vector<T> > > make_v(size_t a,size_t b,size_t c){
  return vector<vector<vector<T> > > (a,make_v<T>(b,c));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//INSERT ABOVE HERE
signed main(){
  Int n,m,k,s,p,q;
  cin>>n>>m>>k>>s>>p>>q;

  vector<Int> z(n,-1);
  for(Int i=0;i<k;i++){
    Int x;
    cin>>x;
    z[x-1]=0;
  }
  
  auto G=make_v<Int>(n,0);
  for(Int i=0;i<m;i++){
    Int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  {
    queue<Int> qu;
    for(Int i=0;i<n;i++)
      if(~z[i]) qu.emplace(i);

    while(!qu.empty()){
      Int v=qu.front();qu.pop();
      for(Int u:G[v]){
	if(~z[u]) continue;
	z[u]=z[v]+1;
	qu.emplace(u);
      }
    }
  }
  using P = pair<Int, Int>;
  priority_queue<P,vector<P>,greater<P> > pq;
  const Int INF = 1e15;
  vector<Int> dp(n,INF);
  dp[0]=0;
  pq.emplace(dp[0],0);

  while(!pq.empty()){
    Int d,v;
    tie(d,v)=pq.top();pq.pop();
    if(dp[v]<d) continue;
    for(Int u:G[v]){
      if(!z[u]) continue;
      Int c=dp[v]+(u!=n-1)*(z[u]<=s?q:p);
      if(dp[u]<=c) continue;
      dp[u]=c;
      pq.emplace(dp[u],u);
    }
  }

  cout<<dp[n-1]<<endl;
  return 0;
}



Measured memory_bytes: 13560
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        int[] nabcd = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nabcd[0];
        var a = nabcd[1];
        var b = nabcd[2];
        var c = nabcd[3];
        var d = nabcd[4];
        var s = Console.ReadLine();
        StringBuilder tmp = new StringBuilder(s);

        var ans = "Yes";
        if (c < d)
        {
            if (a < b)
            {
                //b
                for (int i = a - 1; i < d - 1; i++)
                {
                    if (tmp[i] == '#' && tmp[i + 1] == '#')
                    {
                        ans = "No";
                    }
                }
            }
            else
            {
                ans = "No";
                //抜かすことが出来るか
                for (int i = a - 2; i < c - 1; i++)
                {
                    if (tmp[i] == '.' && tmp[i + 1] == '.' && tmp[i + 2] == '.')
                    {
                        ans = "Yes";
                    }
                }

                for (int i = b - 1; i < d - 1; i++)
                {
                    if (tmp[i] == '#' && tmp[i + 1] == '#')
                    {
                        ans = "No";
                    }
                }

                for (int i = a - 1; i < d - 1; i++)
                {
                    if (tmp[i] == '#' && tmp[i + 1] == '#')
                    {
                        ans = "No";
                    }
                }
            }
        }
        else
        {
            if (b < a)
            {
                //a
                for (int i = a - 1; i < c - 1; i++)
                {
                    if (tmp[i] == '#' && tmp[i + 1] == '#')
                    {
                        ans = "No";
                    }
                }

                for (int i = b - 1; i < c - 1; i++)
                {
                    if (tmp[i] == '#' && tmp[i + 1] == '#')
                    {
                        ans = "No";
                    }
                }
            }
            else
            {
                ans = "No";
                //抜かすことが出来るか
                for (int i = b - 2; i < d - 1; i++)
                {
                    if (tmp[i] == '.' && tmp[i + 1] == '.' && tmp[i + 2] == '.')
                    {
                        ans = "Yes";
                    }
                }

                for (int i = a - 1; i < c - 1; i++)
                {
                    if (tmp[i] == '#' && tmp[i + 1] == '#')
                    {
                        ans = "No";
                    }
                }

                for (int i = b - 1; i < c - 1; i++)
                {
                    if (tmp[i] == '#' && tmp[i + 1] == '#')
                    {
                        ans = "No";
                    }
                }
            }
        }

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 12256
s = input()
if s == 'RRR':
    ans = 3
elif s == 'SRR':
    ans = 2
elif s == 'RRS':
    ans = 2
elif s == 'RSR':
    ans = 1
elif s == 'RSS':
    ans = 1
elif s == 'SRS':
    ans = 1
elif s == 'SSR':
    ans = 1
elif s == 'SSS':
    ans = 0
print(ans)

Measured memory_bytes: 9116
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int qpow(int x,int y){
	int res=1;
	for (;y;y>>=1,x=1LL*x*x%mod)
		if (y&1) res=1LL*res*x%mod;
	return res;
}
inline int upd(int x){return x+(x>>31&mod);}

int n,k;
int d[10000],dtot;
int f[10000];
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i*i<=n;i++)
		if (n%i==0){
			d[++dtot]=i;
			if (i*i!=n) d[++dtot]=n/i;
		}
	sort(d+1,d+dtot+1);
	int ans=0;
	for (int i=1;i<=dtot;i++){
		int x=d[i];
		f[i]=qpow(k,x+1>>1);
		for (int j=1;j<i;j++) if (d[i]%d[j]==0) f[i]=upd(f[i]-f[j]);
		if (x&1) ans=(ans+1LL*f[i]*x)%mod;
		else ans=(ans+1LL*(x/2)*f[i])%mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1720
mod = 998244353
N, M, K = list(map(int, input().split()))
ans = 0

def pow_mod(x, y):
    res = 1
    while y > 0:
        if y % 2:
            res *= x
            res %= mod
        x *= x
        x %= mod
        y //= 2
    return res

def inverse(x):
    return pow_mod(x, mod-2)

_N = 1
for i in range(1, N+1):
    _N *= i
    _N %= mod
kai = [0] * (N+1)
kai[0] = 1
for i in range(1, N+1):
    kai[i] = kai[i-1] * i % mod

for i in range(K+1):
    ans += pow_mod(M-1, N-1-i) * kai[N-1] * inverse(kai[i]) * inverse(kai[N-1-i]) % mod
    ans %= mod

ans *= M
ans %= mod
print(ans)


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





















vector<long long> divisor_array (long long N) {
    vector<long long> a;
    for (long long i = 1; i * i <= N; i++) {
        if (i * i == N) {
            a.push_back(i);
        }
        else if (N % i == 0) {
            a.push_back(i), a.push_back(N / i);
        }
    }
    return a;
}






 int main () {
    int N, M;
    cin >> N >> M;

    /* for (int i = N; ; i++) {
        if (M % i == 0) {
            cout << N / i << endl;
            break;
        }
    } */
    
    vector<long long> a = divisor_array(M);
    sort (a.begin(), a.end());

    auto dot = lower_bound(a.begin(), a.end(), N);
    long long result = *dot;
    cout << M / result << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define N 2011

using namespace std;

int h, w;
int arr[N][N];
int bnd[N][N][4];
int ver[N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	memset(ver, -1, sizeof ver);
	cin >> h >> w;
	for(int i=0; i<h; i++) {
		int hor = -1;
		string s;
		cin >> s;
		for(int j=0; j<w; j++) {
			if(s[j] == '#') {
				arr[i][j] = 1;
				ver[j] = i;
				hor = j;
			}
			bnd[i][j][0] = ver[j];
			bnd[i][j][1] = hor;
		}
	}
	for(int i=0; i<w; i++) ver[i] = h;
	for(int i=h-1; i>=0; i--) {
		int hor = w;
		for(int j=w-1; j>=0; j--) {
			if(arr[i][j]) {
				ver[j] = i;
				hor = j;
			}
			bnd[i][j][3] = ver[j];
			bnd[i][j][2] = hor;
		}
	}
	int ans = 0;
	for(int i=0; i<h; i++)
		for(int j=0; j<w; j++)
			if(!arr[i][j]) {
				int x = bnd[i][j][3] - bnd[i][j][0] - 1;
				int y = bnd[i][j][2] - bnd[i][j][1] - 1;
				ans = max(ans, x + y - 1);
			}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 79232
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    cin >> S;
    int N = S.size();

    ll ans = 0;

    rep(i, 1 << (N - 1)) {
        string subS = "";

        rep(j, S.size()) {
            subS += S[j];
            if (((i >> j) & 0x01) > 0) {
                ans += stol(subS);
                subS = "";
            }
        }
        ans += stoll(subS);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, C float64
	fmt.Scan(&a, &b, &C)
	rad := C * math.Pi / 180
	h := math.Sin(rad) * b
	S := a * h / 2
	L := a + b + math.Sqrt(a*a+b*b-2*a*b*math.Cos(rad))
	fmt.Printf("%f\n%f\n%f\n", S, L, h)
}



Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()

typedef long long int ll;

//ll num[50];
//ll num2[50];
ll num[11];
stack<char> stk;
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<string,ll>::iterator iter;
//deque<char> deq;


int main(void)
{
    double ans=0.0,d,d1,d2;
    //float f,g,h;
    long long int m,n,i,j,k=1;
    long long int a,a1=0,a2=0,a3=0;
    string s,s1,s2;
    char c,c1;
    a=a1=a2=a3=0;
    cin>>n;
    d=d1=d2=n/3.0;
    cout<<setprecision(15)<<d*d1*d2;
    return 0;
}





Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = 9
    val a = Array<Int>(n, {0})

    for(i in 0..2) {
        val (n1, n2, n3) = readLine()!!.split(" ")
        a[0 + i * 3] = n1.toInt()
        a[1 + i * 3] = n2.toInt()
        a[2 + i * 3] = n3.toInt()
    }

    val p1 = listOf(a[0], a[1], a[2])
    val p2 = listOf(a[3], a[4], a[5])
    val p3 = listOf(a[6], a[7], a[8])
    val p4 = listOf(a[0], a[3], a[6])
    val p5 = listOf(a[1], a[4], a[7])
    val p6 = listOf(a[2], a[5], a[8])
    val p7 = listOf(a[0], a[4], a[8])
    val p8 = listOf(a[2], a[4], a[6])

    val bingo = listOf(p1, p2, p3, p4, p5, p6, p7, p8)

    val inputN = readLine()!!.toInt()
    val b = Array<Int>(inputN, {0})
    for(i in 0..inputN - 1) {
        val num = readLine()!!.toInt()
        b[i] = num
    }

    for(i in 0..7) {
        if(b.toList().containsAll(bingo[i])) {
            println("Yes")
            return;
        }
    }

    println("No")
}

Measured memory_bytes: 37680
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<cstring>
#include<queue>
#include<iostream>
#include<map>
using namespace std;
typedef long long ll;
typedef double lf;
typedef unsigned un;
typedef int in;
#define mian main
#define maxn 10000+10
#define maxm 10000+10
#define _(a) read(a)
#define non void
#define inf 2147483647
#define bre break
#define con continue
#define prq priority_queue
#define re register
#define bu bool
#define cz char
#define cst const
#define ope operator
#define inl inline
#define upp upper_bound
#define low lower_bound
#define next_per next_permutation
cz obuf[1<<23],*O=obuf,buf[100000],*L=buf,*R=buf;
inl cz gc(){return L==R&&(R=(L=buf)+fread(buf,1,100000,stdin),L==R)?EOF:*L++;}
template<typename T>inl T Max(T a,T b){return a>b?a:b;}
template<typename T>inl T Min(T a,T b){return a<b?a:b;}
template<typename T>inl T Abs(T a){return a<0?-a:a;}
template<typename T>inl non read(T &a){a=0;T k=1;char c=gc();while(c<'0'||c>'9')k=c=='-'?-1:k,c=gc();while(c>='0'&&c<='9')a=a*10+(c^48),c=gc();if(c!='.'){a*=k;return;}T t=0.1;while(c<'0'||c>'9')c=gc();while(c>='0'&&c<='9')a+=t*(c^48),c=gc(),t*=0.1;a*=k;}
template<typename T>non print(T x){if(x>9)print(x/10);*O++=x%10+'0';}
template<typename T>non out(T a,cz t=' '){print(a);*O++=t;}
non fresh(){fwrite(obuf,O-obuf,1,stdout);}
in n,m,k;
in main()
{
	read(n),read(m),read(k);
	for(in i=0;i<=n;++i)
	{
        in t=m*i;
        for(in j=0;j<=m;++j)
		{
            if(t+(n-(i<<1))*j==k)
			{
                *O++='Y';*O++='e';*O++='s';fresh();
                return 0;
            }
        }
    }
    *O++='N';*O++='o';
    fresh();
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int> > a(H, vector<int>(W, 0));
    vector<pii> horz, vert;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> a[i][j];
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W - 1; j++) {
            if (a[i][j] & 1) {
                //cout << i+1 << " " << j+1 << " " << i+1 << " " << j+2 << endl;
                horz.push_back(make_pair(i+1, j+1));
                a[i][j]--;
                a[i][j+1]++;
            }
        }
    }

    for (int j = 0; j < W; j++) {
        for (int i = 0; i < H - 1; i++) {
            if (a[i][j] & 1) {
                // cout << i+1 << " " << j+1 << " " << i+2 << " " << j+1 << endl;
                vert.push_back(make_pair(i+1, j+1));
                a[i][j]--;
                a[i+1][j]++;
            }
        }
    }

    int cnt = horz.size() + vert.size();
    cout << cnt << endl;
    for (auto h : horz) {
        cout << h.first << " " << h.second << " " << h.first << " " << h.second+1 << endl;
    }
    for (auto h : vert) {
        cout << h.first << " " << h.second << " " << h.first+1 << " " << h.second << endl;
    }
    return 0;
}


Measured memory_bytes: 4212