akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))
#define MAX(x,y) ((x)<(y)?(y):(x))

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

#define INF 1000000000

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return (ret);
}
int main()
{
	ll mod = 1000000007;
	ll N,K;
	ll i,j,k;
	ll A[2010]={0},B[2010]={0},C[2010]={0},D[2010]={0};
	cin >> N>>K;
	ll ans=0;
	for(i=0;i<N;++i)
	{
		cin>>A[i];
		for(j=A[i]+1;j<=2000;++j)
		{
			ans += C[j];
		}
		C[A[i]]++;
	}
	ans = (((ll)ans%mod)*K)%mod;
	for(i=2000;i>0;--i)
	{
		C[i-1] += C[i];
	}
	k = ((ll)K*(K-1)/2)%mod;
	for(i=0;i<N;++i)
	{
		ans += (k*C[A[i]+1])%mod;
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}




















Measured memory_bytes: 256
import Data.Char
import Text.Printf
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as C

m :: Int
m = 2019

main :: IO ()
main = do
  s <- C.getLine
  let acc (a, mp, pp, total) c =
        let a' = (a * 10 + digitToInt c) `mod` m
            pp' = pp * 202 `mod` m
            k = a' * pp' `mod` m
            increment Nothing = Just 1
            increment (Just x) = Just (x + 1)
            mp' = M.alter increment k mp
            total' = total + M.findWithDefault 0 k mp
        in (a', mp', pp', total')
      (_, _, _, ans) = C.foldl' acc (0, M.fromList [(0, 1)], 1, 0 :: Int) s
  printf "%d\n" ans

Measured memory_bytes: 86748
#include<stdio.h>

int main(void)
{
  int S;
  int h, m, s;
  
  scanf("%d", &S);

  h = S / 3600;
  m = (S - h * 3600) / 60;
  s = S - h * 3600 - m * 60;
    
  printf("%d:%d:%d\n", h, m, s);
  
  return 0;
}



Measured memory_bytes: 2144
//region #include <cp_helper>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vii vector<ii>
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define pin(n) in(n.first) >> n.second
#define vin(a, n) for (ll i=0; i<n; ++i) in(a[i])
#define viin(a, n) for (ll i=0; i<n; ++i) in2(a[i].first, a[i].second);
#define out(n) cout << n
#define outs(n) out(n) << ' '
#define outn(n) out(n) << '\n'
#define out2(n, m) cout << n << ' ' << m
#define out2s(n, m) out2(n, m) << ' '
#define out2n(n, m) out2(n, m) << '\n'
#define pout(n) out2(n.first, n.second)
#define pouts(n) pout(n) << ' '
#define poutn(n) pout(n) << '\n'
#define vout(a) for (auto i : a) outs(i)
#define viout(a) for (auto i : a) out2n(i.first, i.second)
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pp(a, b) emplace_back(make_pair(a, b))
#define fori(i, n) for (ll i=0; i<n; ++i)
#define foris(i, a, b) for (ll i=a; i<b; ++i)
#define ford(i, n) for (ll i=n-1; i>=0; --i)
#define fords(i, a, b) for (ll i=a; i>=b; --i)
#define forr(i, a) for (auto &i : a)
const int mod = (int)(1e9) + 7;
//endregion


int main() {
    io();
    ll n, total=0, maxi=0;
    in(n);
    vector<int> arr(n);
    vin(arr, n);
    fori (i, n) total += arr[i]-1;
   	out(total);
    
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)   for(signed i=0; i<n; i++)
#define FOR(i, k, n)    for(signed i=k; i<n; i++)
#define yn(b)   cout << ((b)?"Yes":"No") << endl
#define YN(b)   cout << ((b)?"YES":"No") << endl
#define pr(r)   cout << r << endl
#define min(x,y)    (x<y)?x:y
#define max(x,y)    (x>y)?x:y
#define ll  long long
int main(void){
    int n, m, c, i, j, s;
    ll r=0;
    cin >> n >> m >> c;
    int a[n][m], b[m];
    rep(i, m) cin >> b[i];
    rep(i, n) rep(j, m) cin >> a[i][j];
    rep(i, n){
        s = 0;
        rep(j, m){
            s += a[i][j]*b[j];
        }
        if(s+c > 0) r++;
    }
    pr(r);
}

Measured memory_bytes: 384
N, Q = map(int, input().split())
S = input()
mLst = [0] * N
for i in range(N - 1):
    if S[i: i + 2] == 'AC':
        mLst[i + 1] = mLst[i] + 1
    else:
        mLst[i + 1] = mLst[i]

lLst = [list(map(int, input().split())) for i in range(Q)]

for i in range(Q):
    print(mLst[lLst[i][1] - 1] - mLst[lLst[i][0] - 1])

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

int main() {
  string S;
  cin >> S;
  bool f = false, g = false;

  int a = (S[0] - '0') * 10 + (S[1] - '0');
  int b = (S[2] - '0') * 10 + (S[3] - '0');

  if (1 <= a && a <= 12) f = true;
  if (1 <= b && b <= 12) g = true;

  if (f && g) {
    cout << "AMBIGUOUS" << endl;
  } else if (f) {
    cout << "MMYY" << endl;
  } else if (g) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
}

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

class UnionFind{
private:
    vector<int> data;
public:
    UnionFind(int size) {
        data = vector<int>(size, -1);
    }
    bool unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x != y){
            if (data[y] < data[x]) swap(x,y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find(int x, int y){
        return root(x) == root(y);
    }
    int root(int x) {
        if (data[x] < 0) {
            return x;
        } else {
            return data[x] = root(data[x]);
        }
    }
    int size(int x){
        return -data[root(x)];
    }
    int count(){
        int cnt = 0;
        for (int i=0;i<data.size();i++){
            if (data[i]<0) cnt++;
        }
        return cnt;
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> Xi(M), Yi(M), Zi(M);
    for (int i=0;i<M;i++){
        cin >> Xi[i] >> Yi[i] >> Zi[i];
        Xi[i]--;
        Yi[i]--;
    }
    UnionFind uf = UnionFind(N);
    for (int i=0;i<M;i++){
        uf.unite(Xi[i],Yi[i]);
    }
    cout << uf.count() << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  if(n==1)
    cout<<"1";
  else if(n%2==0)
    cout<<"0.5000000000";
   else
     {
       double a=n/2;
       a=a+1;
       cout<<a/n;
     }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
	
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = ""; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
 
using namespace std;
 
const ll inf = 1e9;
const ll inf2 = 1e18 + 10;
const int mod = 1e9 + 7;
const ld eps = 1e-4;
 
const int logn = 19;
const int maxn = 2e5 + 5;

int fac[maxn], ifac[maxn];

int mul(int a, int b) {
	return (ll) a * b % mod;
}

int sub(int a, int b) {
	return (a - b + mod) % mod;
}

int bc(int n, int k) {
	if (n < 0 || k < 0 || k > n) return 0;
	return mul(fac[n], mul(ifac[k], ifac[n - k]));
}

int bp(int a, int b) {
	int res = 1;
	while(b) {
		if (b & 1) res = mul(res, a);
		b >>= 1;
		a = mul(a, a);
	}
	return res;
}

int inv(int a) {
	return bp(a, mod - 2);
}

int f(int a, int b) {
	return bc(a + b, b);
}

int main() {
	FAST;
	
	fac[0] = ifac[0] = 1;
	for (int i = 1; i < maxn; i++) {
		fac[i] = mul(fac[i - 1], i);
		ifac[i] = inv(fac[i]);
	}

	int n, h, w;
	cin >> h >> w >> n;
	vector<pair<int, int>> a;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		a.emplace_back(x - 1, y - 1);
	}
	a.emplace_back(h - 1, w - 1);
	sort(a.begin(), a.end(), [&] (const pair<int, int> &x, const pair<int, int> &y) {
		return x.first + x.second < y.first + y.second;
	});

	vector<int> dp(n + 1);

	for (int i = 0; i <= n; i++) {
		int tmp = f(a[i].first, a[i].second);
		for (int j = 0; j < i; j++) {
			if (a[j].first <= a[i].first && a[j].second <= a[i].second) {
				tmp = sub(tmp, mul(dp[j], f(a[i].first - a[j].first, a[i].second - a[j].second)));
			}
		}
		dp[i] = tmp;
	}

	cout << dp[n];
}	

Measured memory_bytes: 5248
#include <cstdio>
#include <cctype>

int main()
{
    char s[1200];
    scanf("%[^\n]", s);

    for(int i = 0;s[i] != '\0'; i++){
        if(isupper(s[i])) s[i] = tolower(s[i]);
        else s[i] = toupper(s[i]);
    }
    printf("%s\n", s);
    return 0;
}

Measured memory_bytes: 952
A,B,C = list(map(int,input().split()))

if A == B == C:
    print('No')
elif A == B and B != C:
    print('Yes')
elif A != B and A == C:
    print('Yes')
elif A != B and B ==C:
    print('Yes')
elif A != B and A != C:
    print('No')
else:
    print('No')


Measured memory_bytes: 2940
MAX_INT = int(10e10)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def cnt(c,d):
    if (0 <= c < H) and (0 <= d < W):
        return grid[c][d]
    else:
        return MAX_INT
def tami(a,b):
    num = min(cnt(a+1,b),cnt(a,b+1),cnt(a-1,b),cnt(a,b-1))
    return num+1

H,W = IL()
A = [[i for i in S()] for i in range(H)]

grid = [[MAX_INT]*W for i in range(H)]

for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            grid[i][j] = 0

for i in range(H):
    for j in range(W):
        if grid[i][j] != 0:
            grid[i][j] = tami(i,j)

for i in range(H-1,-1,-1):
    for j in range(W-1,-1,-1):
        if grid[i][j] != 0:
            grid[i][j] = tami(i,j)

ans = 0
for i in range(H):
    ans = max(ans,max(grid[i][:]))

print(ans)


Measured memory_bytes: 101468
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll;
int main ()
{
ll  N  , sum=0 ;
cin >> N ;
ll w= N ;
while (w>0)
{
    sum=sum+w%10 ;
    w=w/10;
}
if(N %sum==0 )
cout << "Yes";
else
cout <<  "No";


return 0 ;
}



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

int main()
{
 int ans=0,R=0;
  string s;
  cin>>s;
  for(int i=0;i<3;i++)
    if(s[i]=='R') {ans++; if(R<ans) R=ans; }
  else ans=0;
  
  cout<<R;
}

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

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

    int ans = 0;
    for (int i = 0; i < S.length(); i++)
    {
        if(S[i] != S[S.length()-i-1]){
            ans++;
        }
    }

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

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
s=input()
k=int(input())
cnt=0
tmp=0
flag=0

for i in range(len(s)):
    if s[0]==s[i]:
        flag+=1
if flag==len(s):
    print(len(s)*k//2)
    quit()

for i in range(len(s)-1):
    if s[i]==s[i+1]:
        tmp+=1
    else:
        cnt+=(tmp+1)//2
        tmp=0
cnt+=(tmp+1)//2
hoka=0
# print(cnt)
left=0
right=0
if s[0]==s[-1]:
    for i in range(len(s)):
        if s[0]==s[i]:
            left+=1
        else:
            break
    for i in range(len(s)):
        if s[-1]==s[-1-i]:
            right+=1
        else:
            break
    if right%2==1 and left%2==1:
        hoka=1

print(cnt*k+hoka*(k-1))

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

int main() {
	int N, T;
	cin >> N >> T;
	vector<pair<long long, long long> > VA;
	vector<long long> VB;
	for (int i = 0; i < N; i++) {
		long long A, B;
		cin >> A >> B;
		if (A == 0) {
			VB.push_back(B);
		}
		else {
			VA.push_back({ A, B });
		}
	}
	sort(VA.begin(), VA.end(), [](pair<long long, long long> P1, pair<long long, long long> P2) {return P1.first * (P2.second + 1) > P2.first * (P1.second + 1); });
	sort(VB.begin(), VB.end());
	long long INF = T + 1;
	vector<vector<long long> > DP(VA.size() + 1, vector<long long>(30, INF));
	DP[0][0] = 0;
	for (int i = 0; i < VA.size(); i++) {
		for (int j = 0; j < 29; j++) {
			if (DP[i][j] < INF) {
				long long NT = DP[i][j];
				long long Next = (NT + 1) * (VA[i].first + 1) + VA[i].second;
				if (Next <= T) {
					DP[i + 1][j + 1] = min(DP[i + 1][j + 1], Next);
				}
				DP[i + 1][j] = min(DP[i + 1][j], NT);
			}
		}
	}
	vector<long long> COUNT(VB.size() + 1, 0);
	for (int i = 0; i < VB.size(); i++) {
		COUNT[i + 1] = COUNT[i] + VB[i] + 1;
	}
	int ANS = 0;
	for (int i = 0; i < 30; i++) {
		if (DP[VA.size()][i] > T) break;
		for (int j = 0; j <= VB.size(); j++) {
			if (DP[VA.size()][i] + COUNT[j] <= T) {
				ANS = max(ANS, i + j);
			}
		}
	}
	cout << ANS << endl;
}

Measured memory_bytes: 58348
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i=n-1 ; i > =0; i--)
#define all(a) a.begin(),a.end()
#define pb push_back
using namespace std;
typedef long long int ll;
struct pair_hash {
    inline std::size_t operator()(const std::pair<int,int> & v) const {
        return v.first*31+v.second;
    }
};
void solve(){

	ll q,sum=0;
	cin>>q;
	std::vector<ll> v(q);
	rep(i,q)cin>>v[i],v[i]-=i+1;
	sort(all(v));
	ll m=q/2;
	rep(i,q)sum+=abs(v[m]-v[i]);
	cout<<sum;

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

	solve();
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  int N;
  while (cin >> N) {
    vector<int> V(N), C(N);
    for (int &x : V) cin >> x;
    for (int &x : C) cin >> x;
    int res = 0;
    for (int i = 0; i < N; i++) res += max(V[i] - C[i], 0);
    cout << res << endl;
  }
  return 0;
}


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

typedef long long ll;

void solve() {
    bool ok = 1;
    ll ans = 1, ub = 1e18;
    int n; cin >> n;
    while (n--) {
        ll a; cin >> a;
        if (!a) {
            cout << "0\n";
            return;
        }
        if (ans > ub / a)
            ok = 0;
        ans *= a;
    }
    cout << (ok ? ans : -1) << '\n';
}

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

    solve();
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 7;

int main(){
    ll h, h2, m, m2, k;
    cin >> h >> m >> h2 >> m2 >> k;
    ll ans = h2 - h;
    ans *= 60;
    ans += m2;
    ans -= m;
    ans -= k;
    cout << ans;
    return 0;
}
 

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

int main()
{
	int a,b;
	int i,j=0;
	vector<int> ans;
	char c;
	
	while(1)
	{
	cin>>a>>c>>b;
	if(c=='?') break;
	else if(c=='+') ans.push_back(a+b);
	else if(c=='-') ans.push_back(a-b);
	else if(c=='*') ans.push_back(a*b);
	else if(c=='/') ans.push_back(a/b);
	j++;
	}
	
	for(i=0;i<j;i++)
	{
		cout<<ans[i]<<endl;
	}
}



Measured memory_bytes: 3160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int n = Integer.parseInt(chr[0]);
			int r = Integer.parseInt(chr[1]);
			 System.out.println(n>=10 ? r : r+(100*(10-n)));
		}
	}
}

Measured memory_bytes: 25384
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
from decimal import Decimal
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
q,r = 0,0
A =[]
for i in range(15):
    if N < 26:
        r = N
        break
    q = N//26
    r = N%26
    if r == 0:
        q -= 1
        r = 26
    #print(f"{N} = {q} * 26 + {r}")
    A.append(string.ascii_lowercase[r-1])
    #print(A)
    N = q
if r > 0:
    A.append(string.ascii_lowercase[r-1])
print("".join(A[::-1]))

Measured memory_bytes: 27168
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    vector<int> A(3);
    int even = 0, odd = 0;
    rep(i, 3) {
        cin >> A[i];
        if(A[i] % 2 == 0) even++;
        else odd++;
    }
    int ans = 0;
    sort(ALL(A), greater<int>());

    if(even == 3 || odd == 3) {
        ans = 0;
    } else if(even == 2) {
        rep(i, 3) {
            if(A[i] % 2 == 0) A[i]++;
        }
        ans++;
    } else {
        rep(i, 3) {
            if(A[i] % 2 != 0) A[i]++;
        }
        ans++;
    }
    ans += (2 * A[0] - A[1] - A[2]) / 2;

    cout << ans << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector <int64_t> a(n+1);
  vector <int64_t> b(n);
  for (int i = 0; i < n+1; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> b.at(i);
  }
  int64_t ans = 0;
  for (int i = 0; i < n; i++) {
    if (b.at(n-1-i) >= a.at(n-i)) {
      b.at(n-1-i) -= a.at(n-i);
      ans += a.at(n-i);
      a.at(n-i) = 0;
      if (b.at(n-1-i) >= a.at(n-1-i)) {
        b.at(n-1-i) -= a.at(n-1-i);
        ans += a.at(n-1-i);
        a.at(n-1-i) = 0;
      } else {
        a.at(n-1-i) -= b.at(n-1-i);
        ans += b.at(n-1-i);
        b.at(n-1-i) = 0;
      }
    } else {
        a.at(n-i) -= b.at(n-1-i);
        ans += b.at(n-1-i);
        b.at(n-1-i) = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <numeric>

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

using namespace std;

template<class T>
struct edge{
	int v;
	T cost;
};

template<class T>
pair<T,int> dfs_diam(int u,int pre,const vector< edge<T> > *G){
	pair<T,int> res(0,u);
	rep(i,G[u].size()){
		const edge<T> &e=G[u][i];
		if(e.v!=pre){
			pair<T,int> tmp=dfs_diam(e.v,u,G);
			tmp.first+=e.cost;
			res=max(res,tmp);
		}
	}
	return res;
}

template<class T>
T tree_diameter(const vector< edge<T> > *G){
	pair<T,int> tmp=dfs_diam(0,-1,G);
	return dfs_diam(tmp.second,-1,G).first;
}

int main(){
	for(int n;scanf("%d",&n),n;){
		vector< edge<int> > T[800];
		int p[800],d[800];
		rep(i,n-1) scanf("%d",p+i), p[i]--;
		rep(i,n-1) scanf("%d",d+i);
		rep(i,n-1){
			int u=i+1,v=p[i];
			T[u].push_back((edge<int>){v,d[i]});
			T[v].push_back((edge<int>){u,d[i]});
		}

		int id=0;
		int f[800];
		rep(u,n) if(T[u].size()>1) f[u]=id++;

		vector< edge<int> > S[800]; // reduced tree
		int S_cost=0;
		rep(u,n) if(T[u].size()>1) rep(i,T[u].size()) {
			int v=T[u][i].v,cost=T[u][i].cost;
			if(T[v].size()>1){
				int uu=f[u],vv=f[v];
				S[uu].push_back((edge<int>){vv,cost});
				S_cost+=cost;
			}
		}
		S_cost/=2;

		printf("%d\n",accumulate(d,d+n-1,0)+2*S_cost-tree_diameter(S));
	}

	return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define MAX_V 110
#define INF 10000000000000
#define int long long

struct edge { int to, cap, rev; };

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap) {
  G[from].push_back((edge){to, cap, G[to].size()});
  G[to].push_back((edge){from, 0, G[from].size() - 1});
}

int dfs(int v, int t, int f) {
  if (v == t) return f;
  used[v] = true;
  for (int i = 0; i < G[v].size(); i++) {
    edge &e = G[v][i];
    if (!used[e.to] && e.cap > 0) {
      int d = dfs(e.to, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s, int t) {
  int flow = 0;
  for ( ; ; ) {
    fill(used, used + MAX_V, false);
    int f = dfs(s, t, INF);
    if (f == 0) return flow;
    flow += f;
  }
}

signed main() {
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 1; i < n + 1; i++) {
    cin >> a[i];
  }
  int pos_sum = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] > 0) pos_sum += a[i];
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] <= 0) add_edge(0, i, -a[i]);
    else add_edge(i, n + 1, a[i]);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + i; j <= n; j += i) {
      add_edge(i, j, INF);
    }
  }
  cout << pos_sum - max_flow(0, n + 1) << endl;
  return 0;
}


Measured memory_bytes: 384
N , N_point = map(int,input().split())
list_point = input().split()

for i in range(len(list_point)):
  list_point[i] = int(list_point[i])

#点と点との距離を記録
distance = []
for i in range(len(list_point)):
  if i == 0:
    distance.append(list_point[i] + N-list_point[len(list_point)-1])
    distance.append(list_point[i+1]-list_point[i])
    continue
  if i == len(list_point)-1:
    break
  distance.append(list_point[i+1]-list_point[i])


distance.sort()

distance.remove(max(distance))


print(sum(distance))

Measured memory_bytes: 20276
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
        int table[] = new int[128];
 
        for(int i = 0; i < table.length; i++){
            table[i] = 0;
        }
 
        StringBuilder sb = new StringBuilder();
 
        while(scanner.hasNext()){
            sb.append(scanner.nextLine());
        }
 
        String line = sb.toString();
 
        for(int i = 0; i < line.length(); i++){
            table[line.charAt(i)]++;
        }
 
        for(int i = 0; i < 26; i++){
            System.out.printf("%c : %d\n", 'a'+i,table['a'+i]+table['a'+i-32]);
        }
    }
}


Measured memory_bytes: 26320
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> Black(N+1,0);
    for(int i=0; i<S.size(); i++){
        Black[i+1]=Black[i];
        if(S[i]=='#'){
            Black[i+1]++;
        }
    }
    
    int ans=Black[N];
    for(int i=0; i<N+1; i++){
        ans=min(ans,N-i-Black[N]+2*Black[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1412
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
	cin >> N >> M;
	if(N == 1 && M == 1) cout << 1;
	else if(N == 1 || M == 1) cout << max(N, M) - 2;
	else cout << N*M - (2*N + 2*M - 4);
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    char a,b;
    cin >> a >> b;
    
    if(a == b && a == 'H'){
        cout << 'H' << endl;
    }
    else if(a == b && a == 'D'){
        cout << 'H' << endl;
    }
    else if(a != b && a == 'H'){
        cout << 'D' << endl;
    }
    else if(a != b && a == 'D'){
        cout << 'D' << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
        int i;
        int m,f,r;
        while(1){
                scanf("%d %d %d",&m,&f,&r);
                if(m==-1 && f==-1 && r==-1)
                        break;
                if(m==-1 || f ==-1)
                        puts("F");
                else if(m+f >= 80)
                        puts("A");
                else if(m+f >= 65)
                        puts("B");
                else if(m+f >= 50)
                        puts("C");
                else if(m+f >= 30){
                        if(r >= 50)
                                puts("C");
                        else
                                puts("D");
                }else
                        puts("F");
        }
        return 0;
}


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

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void test_case() {
    int n, k, s;
    cin >> n >> k >> s;
    vector<int> A(n + 1);
    for (int i = 1; i <= k; ++i) {
        A[i] = s;
    }
    for (int i = k + 1; i <= n; ++i) {
        if (s == int(1e9)) {
            A[i] = 1;
        } else {
            A[i] = 1e9;
        }
    }
    for (int i = 1; i <= n; ++i) {
        cout << A[i] << " ";
    }
    cout << "\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    test_case();
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h> 

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

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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;


//cost to merge [i,j]
ll DP[401][401];

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int n;
	cin >> n;
	vll slime(n);
	vll sum(n+1);
	M00(i, n) cin >> slime[i];
	sum[0] = 0;
	MOO(i, 1, n+1) sum[i] = slime[i-1] + sum[i-1];


	//DP[i][j] = [i,j]  sum[j+1] - sum[i];
	M00(i,n) DP[i][i] = 0;
	for(int len = 1; len <= n-1; len++) {
		for(int start = 0; start <= n-1-len; start++) {
			DP[start][start + len] = 1e15;
			for(int i = 0; i < len; i++) {
				DP[start][start + len] = min(DP[start][start + i] + DP[start+i+1][start + len] + sum[start+len+1] - sum[start], DP[start][start+len]);
			}
		}
	}
	finish(DP[0][n-1]);
}


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

int main(){
  string str;
  std::cin >> str;

  int size;
  size = str.size();

  if (size == 2){
    std::cout << str << '\n';
  }

  else if (size == 3){
    std::cout << str.at(2) ;
    std::cout << str.at(1) ;
    std::cout << str.at(0) << '\n';
  }
}


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

int main() {
  int S;
  cin >> S;
  int ue = S/100;
  int sita = S%100;
  //cout << ue << " " << sita << endl;
  if(ue<=12 && 1<=ue && 1<=sita && sita<=12) cout << "AMBIGUOUS" << endl;
  else if(sita<=12 && 1<=sita) cout << "YYMM" << endl;
  else if(ue<=12 && 1<=ue) cout << "MMYY" << endl;
  else cout << "NA" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		while (true) {
			int n = scanner.nextInt();
			int x = scanner.nextInt();
			
			if (n == 0 && x == 0)
				break;
			
			int c = 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)
							c++;
					}
				}
			}
			
			System.out.println(c);
		}

	}

}



Measured memory_bytes: 26400
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
const double pi = 3.141592653589793;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //cin,coutの高速化
    int n;
    cin>>n;
    vector<int> a(n);
    map<int,int> p;//あるかないかを高速判定
    set<int> sc;
    rep(i,n){
        cin>>a[i];
        p[a[i]]++;
        sc.insert(a[i]);
    }
    //all(a);
    int ans=0;
    rep(j,n){
        bool ok=true;
        if(p[a[j]]>=2){
            ok=false;
            continue;
        }
        //p[a[j]]--;
        sc.erase(a[j]);
        if(sc.count(1) || sc.count(a[j]/1)){
                ok=false;
                //p[a[j]]++
                sc.insert(a[j]);
                continue;
            }
        for(int64_t i=2;i*i<=a[j];i++){
            if(a[j]%i==0){
                if(sc.count(i) || sc.count(a[j]/i)){
                    ok=false;
                    break;
                }
            }
        }
        if(ok)ans++;
        //p[a[j]]++;
        sc.insert(a[j]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 22736
k,m = map(int, input().split())
a = list(map(int, input().split()))

# リストaの総投票数をsに格納する
s = sum(a)

# リストaを降順にソートする
a.sort(reverse=True)

if a[m-1] >= s*(1/4/m):
    print('Yes')
else:
    print('No')

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

using namespace std;

int main()
{
    int n;
    int casenum = 0;
    
    while (scanf("%d", &n) && n){
        printf("Case %d:\n", ++casenum);
        
        int mp[16][16];
        memset(mp, 0, sizeof(mp));
        
        int num = 1, posy = 1, posx = 1;
        int dy = -1, dx = -1;
        
        while (num <= n * n){
            mp[posy][posx] = num++;
            if (dy && dx){
                if (posy == 1 || posy == n){
                    dy = 0;
                    dx = 1;
                }
                if ((dy && dx && (posx == 1 || posx == n)) || (dx == 1 && posx + dx > n)){
                    dy = 1;
                    dx = 0;
                }
            }
            else if (dy + dx){
                if (posy == 1 || posx == n){
                    dy = 1;
                    dx = -1;
                }
                else {
                    dy = -1;
                    dx = 1;
                }
            }
            
            posy += dy;
            posx += dx;
        }
        
        for (int i = 1; i <= n; i++){
            for (int j = 1; j <= n; j++){
                printf("%3d", mp[i][j]);
            }
            printf("\n");
        }
    }
    
    return (0);
}

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

int main() {
    int N,K;
    map<int,int> cnt;

    cin >> N >> K;
    for(int i=0; i<N; ++i) {
        int a;
        cin >> a;
        cnt[a] += 1;
    }

    vector<int> A(0);
    for(auto itr = cnt.begin(); itr != cnt.end(); ++itr) A.push_back(itr->second);
    sort(A.begin(), A.end());

    int res = 0;
    int n = A.size();
    for(int i=0; i < n - K; ++i) {
        res += A[i];
    }
    cout << res << endl;
    return 0;
}

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

int main(void){
int c;
int n;
scanf("%d %d", &c, &n);
c = pow(100, c);
if(n%100){
    printf("%d\n", c * n);
}else{
    printf("%d\n", c * (n + n / 100));
}
return 0;
}

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

    typedef long long int ll;

    #define MOD (ll)(1e9+7)
    #define endl "\n"
    #define pb push_back
    #define TEST_CASES  ll t;cin >> t;while(t--)
    #define forn(i,n) for (int i = 0; i < n; ++i)
    #define f first
    #define s second
    #define all(x) x.begin(), x.end()
    
    ll powD(ll x,ll y){
      ll res = 1;
      while(y > 0){
        if(y & 1)
          res = (res*x)%MOD;
        x = (x*x)%MOD;
        y = y>>1;
      }
      return res;
    }
  

    int main()
    {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL); 
      ll a,b,c,k;
      cin>>a>>b>>c>>k;
      ll sum = 0;
      sum += min(a,k);
      k -= min(a,k);
      k -= min(b,k);
      sum -= min(c,k);
      k -= min(c,k);
      cout<<sum<<endl;
    }
    //read the question correctly (ll vs int)


Measured memory_bytes: 3652
n, w=gets.split.map(&:to_i)
wei, val=[], []
n.times do
  a, b=gets.split.map(&:to_i)
  wei<< a
  val<< b
end

item=Array.new(4){[]}
r=wei[0]
n.times{|i| item[wei[i]-r]<< val[i]}
item.each{|v| v.sort!{|a, b| b<=>a}}

sum=Array.new(4){[]}
4.times do |i|
  item[i].size.times do |j|
    if j.zero?
      sum[i]<< item[i][0]
    else
      sum[i]<< sum[i][j-1]+item[i][j]
    end
  end
end

ans=0
(item[0].size+1).times do |i|
  (item[1].size+1).times do |j|
    (item[2].size+1).times do |k|
      (item[3].size+1).times do |l|
        _w, _v=0, 0
        _w=r*i+(r+1)*j+(r+2)*k+(r+3)*l
        _v+=sum[0][i-1] if i.nonzero?
        _v+=sum[1][j-1] if j.nonzero?
        _v+=sum[2][k-1] if k.nonzero?
        _v+=sum[3][l-1] if l.nonzero?
        if _w<=w
          ans=[ans, _v].max
        end
      end
    end
  end
end

puts ans


Measured memory_bytes: 1916
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



void solve(){
    string s,t,u;
    ll a,b;
    cin>>s>>t>>a>>b>>u;
    if(s==u) cout<<a-1<<" "<<b<<endl;
    else cout<<a<<" "<<b-1<<endl;



}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    
     

    solve(); 


    return 0;
}


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

int length[3], length_max, n;

int main(void)
{
	std::cin >> n;

	while(n){
		std::cin >> length[0] >> length[1] >> length[2];

		length_max = *( std::max_element( length, length + sizeof( length ) / sizeof( length[0] )));

		std::cout << ( length_max * length_max == length[0] * length[0] + length[1] * length[1] + length[2] * length[2] - length_max * length_max ? "YES" : "NO" ) << std::endl;

		n--;
	}
	
	return 0;
}

Measured memory_bytes: 1152
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n, m;
            n = in.nextInt();
            m = in.nextInt();
            out.println((n - 1) * (m - 1));
        }

    }
}



Measured memory_bytes: 21844
using System;

class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split();
        int row = int.Parse(s[0]);
        int column = int.Parse(s[1]);

        int[,] sheet = new int[row + 1, column + 1];


        for(int i = 0;i < row; i++)
        {
            string[] data = Console.ReadLine().Split();
            for (int j = 0;j < column; j++)
            {
                sheet[i, j] = int.Parse(data[j]);
                sheet[i, column] += sheet[i, j];
            }
        }

        for(int i = 0;i < column + 1; i++)
        {
            for (int j = 0; j < row; j++)
            {
                sheet[row, i] += sheet[j, i];
            }
        }

        for(int i = 0;i < row + 1; i++)
        {
            for(int j = 0;j < column + 1; j++)
            {
                if (j == column)
                    Console.WriteLine("{0}", sheet[i, j]);
                else
                    Console.Write("{0} ", sheet[i, j]);
            }
        }
    }
}

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

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

    int ans = 1;
    while (ans <= n) {
        ans <<= 1;
    }

    cout << (ans>>1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
const double lim = 0.0001;
int n; double p[309], sq[309], a[309];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> p[i], sq[i] = sqrt(p[i]), a[i] = 0.03 / n;
	double ret = 1.0e+9; int cnt = 0;
	while (true) {
		double curval = 0.0;
		for (int i = 0; i < n; i++) curval += p[i] / a[i];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < i; j++) {
				double sa = a[i] + a[j], sp = sq[i] + sq[j];
				a[i] = sq[i] / sp * sa;
				a[j] = sq[j] / sp * sa;
				if (a[i] < lim) a[j] -= lim - a[i], a[i] = lim;
				if (a[j] < lim) a[i] -= lim - a[j], a[j] = lim;
			}
		}
		ret = 0.0;
		for (int i = 0; i < n; i++) ret += p[i] / a[i];
		if (abs(curval - ret) < 1.0e-8) break;
		cnt++;
	}
	cout << fixed << setprecision(15) << 300 * ret << endl;
	return 0;
}


Measured memory_bytes: 3292
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 998244353;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vl b(n);
    rep(i, n) {
        cin >> b[i];
    }

    vl ans;
    while(!b.empty()) {
        ll m = b.size();
        bool ok = false;
        for(ll i = m-1; i >= 0; i--) {
            if(b[i] == i+1) {
                ans.pb(b[i]);
                b.erase(b.begin() + i);
                ok = true;
                break;
            }
        }
        if(ok == false) {
            out(-1);
            re0;
        }
    }

    reverse(all(ans));
    for(auto x : ans) {
        out(x);
    }
    
    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	lint D, A;
	lint ans = 0;
	lint c_damage = 0;
	queue<pair<lint, lint>> damage_range;
	cin >> N >> D >> A;

	vector<pair<lint, lint>> data(N);
	for (int i = 0; i < N; i++)
	{
		lint pos, hp;
		cin >> pos >> hp;
		data[i] = make_pair(pos, hp);
	}
	sort(all(data));

	for (int i = 0; i < N; i++)
	{
		for (; !damage_range.empty() && damage_range.front().first < data[i].first;)
		{
			pair<lint, lint> minus = damage_range.front();
			damage_range.pop();
			c_damage -= minus.second;
		}

		if (c_damage < data[i].second)
		{
			lint attack = data[i].second - c_damage;
			lint attack_count = (attack - 1 + A) / A;
			c_damage += attack_count * A;
			ans += attack_count;
			damage_range.push(make_pair(data[i].first + D * 2, attack_count * A));
		}
	}

	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  vector<int>A(N);
  vector<int>B(N);
  for(int X=0;X<N;X++){
    cin>>A[X]>>B[X];
  }
  long double K=0;
  for(int X=0;X<N-1;X++){
    for(int Y=X+1;Y<N;Y++){
      K+=sqrt((A[X]-A[Y])*(A[X]-A[Y])+(B[X]-B[Y])*(B[X]-B[Y]));
    }
  }
  cout<<fixed<<setprecision(10)<<K*2/N<<endl;
}

Measured memory_bytes: 3844
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

const int mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0) :x(x%mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
};

mint dp[101010][3];

int senni(char c, int x, int y,int j) {
	if (x && y)return 2;
	if (c == '0') {
		if (j == 0) {
			if (!x && !y)return 0;
			else return 2;
		}
		else return 1;
	}
	else {
		if (j == 0) {
			if (!x && !y)return 1;
			else return 0;
		}
		else return 1;
	}
}

int main() {
	string l;
	cin >> l;
	reverse(all(l));
	dp[l.size()][0] = 1;
	for (int i = l.size() - 1; i >= 0; i--)for (int j = 0; j < 2;j++) {
		mint pre = dp[i+1][j];
		for (int x = 0; x < 2; x++)for (int y = 0; y < 2; y++)dp[i][senni(l[i],x,y,j)] += pre;
	}
	mint ans = dp[0][0] + dp[0][1];
	puts(ans.x);

	return 0;
}

Measured memory_bytes: 2816
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
using namespace std;
int main()
{
    
    int a,b,c,t,num=0;
    cin>>a>>b>>c;
    for (int i=0;i<a;i++)
    {
    	cin>>t;
    	if (t<b || t>=c)
    	num++;
	}
	cout<<num<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


signed main(){
  ll x,y;cin>>x>>y;
  if(x%y!=0)cout << x << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 256