akhauriyash/Code-Regression huggingface dataset:
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
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...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
ll ma, mi;

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

  cin >> h >> w;
  ans = LINF;
  if (h % 3 == 0)
    ans = 0;
  else
    ans = w;
  if (w % 3 == 0)
    ans = 0;
  else
    ans = min(ans, h);

  rep(i, w - 1) {
    a = h * (i + 1);
    b = (w - i - 1) * (h / 2);
    c = (w - i - 1) * ((h + 1) / 2);
    ma = max({a, b, c});
    mi = min({a, b, c});
    ans = min(ans, ma - mi);
  }

  rep(i, h - 1) {
    a = w * (i + 1);
    b = (h - i - 1) * (w / 2);
    c = (h - i - 1) * ((w + 1) / 2);
    ma = max({a, b, c});
    mi = min({a, b, c});
    ans = min(ans, ma - mi);
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    string s;
    cin >> s;
    cout << (s[0] - '0') + (s[1] - '0') + (s[2] - '0');
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long inf = 101234567891234567;
int n; long long a[200009];
int main() {
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	long long ret = -inf, m = a[0];
	for(int i = 1; i < n; i++) {
		ret = max(ret, a[i] - m);
		m = min(m, a[i]);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 4600
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll P=1000000007;
const int maxn=(1<<16)+4;
int n,m;
ll ans;
int v[20],cnt[maxn],Log[maxn];
ll f[17][maxn],jc[maxn],jcc[maxn],ine[maxn];
bool cmp(const int &a,const int &b)
{
	return a>b;
}
inline ll A(int a,int b)
{
	if(a<b)	return 0;
	return jc[a]*jcc[a-b]%P;
}
int main()
{
	scanf("%d%d",&n,&m);
	int i,S,T,j,a;
	for(i=1;i<=m;i++)	scanf("%d",&v[i]),v[i]--;
	sort(v+1,v+m+1,cmp);
	for(i=0;i<n;i++)	Log[1<<i]=i;
	for(i=1;i<(1<<n);i++)	cnt[i]=cnt[i-(i&-i)]+1;
	ine[0]=ine[1]=jc[0]=jc[1]=jcc[0]=jcc[1]=1;
	for(i=2;i<=(1<<n);i++)	ine[i]=P-(P/i)*ine[P%i]%P,jc[i]=jc[i-1]*i%P,jcc[i]=jcc[i-1]*ine[i]%P;

	f[0][0]=1;
	for(i=1;i<=m;i++)
	{
		f[i][0]=1;
		for(S=1;S<(1<<n);S++)
		{
			f[i][S]=f[i-1][S];
			for(j=S;j;j-=j&-j)
			{
				a=Log[j&-j],T=S^(1<<a);
				f[i][S]=(f[i][S]+f[i-1][T]*A((1<<n)-v[i]-1-T,(1<<a)-1)%P*(1<<a))%P;
			}
		}
	}
	for(S=0;S<(1<<n);S++)
	{
		ans=(ans+((cnt[S]&1)?-1:1)*f[m][S]*jc[(1<<n)-1-S])%P;
	}
	printf("%lld",(ans+P)*(1<<n)%P);
	return 0;
}//3 2 2 3


Measured memory_bytes: 10240
<?php
        do
        {
                $input = preg_split('//',trim(fgets(STDIN)),-1,PREG_SPLIT_NO_EMPTY);
                if(0 == $input[0])
                {
                        break;
                }
                $cnt = count($input);

//var_dump($input);
//var_dump($cnt);

                $sum = 0;
                for($loop_cnt = 0; $loop_cnt < $cnt; $loop_cnt++)
                {
                        $sum += $input[$loop_cnt];
                }
                echo $sum . "\n";
        }while(1);
?>


Measured memory_bytes: 9636
Scanf.scanf "%s" (fun s ->
    let n = String.length s in
    let b = Array.make (n + 1) (-1) in

    (*     0 1 2 3 4 5 n = 6
     * s:  > > > < < <
     * b: 3 2 1 0 1 2 3
     *    0 1 2 3 4 5 6
     *)

    let fill start =
        let rec left i cur =
            if b.(i) < cur then (
                b.(i) <- cur;
                if i > 0 && s.[i - 1] = '>' then (
                    left (i - 1) (cur + 1)
                )
            )
        in
        let rec right i cur =
            b.(i) <- cur;
            if i < n && s.[i] ='<' then (
                right (i + 1) (cur + 1)
            ) else i
        in
        left start 0;
        right start 0
    in

    let rec loop i =
        if i = n then (if b.(i) < 0 then fill i else 0) else
            if s.[i] = '>' then loop (i + 1) else
                loop (fill i)
    in
    let _ = loop 0 in
    Array.fold_left (+) 0 b |> Printf.printf "%d\n"
)

(*
   .         .           .     
 0 1 2 3 4 5 6 7 8 9 A B C D E F
 < > > > < < > < < < < < > > > <
0 3 2 1 0 1 2 0 1 2 3 4 5 2 1 0 0
0 1 2 3 4 5 6 7 8 9 A B C D E F 0
*)

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;

  deque<ll> q;
  ll a;

  if (N % 2 == 0) {
    REPI(i, 1, N + 1) {
      cin >> a;

      if (i % 2 == 0) {
        q.push_front(a);
      } else {
        q.push_back(a);
      }
    }
  } else {
    REPI(i, 1, N + 1) {
      cin >> a;
      if (i % 2 == 0) {
        q.push_back(a);
      } else {
        q.push_front(a);
      }
    }
  }

  REP(i, N) {
    cout << q.front() << " ";
    q.pop_front();
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3840
#include <iostream>
using namespace std;
long long n, a, mn=4e18;
int main() {
	cin>>n;
	for(int i=0; i<5; i++) {
		cin>>a;
		mn = min(mn, a);
	}
	cout << (n+mn-1) / mn + 4;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
cost = [0] * n
cost[1] = abs(h[1] - h[0])
for i in range(2, n):
  cost[i] = min(abs(h[i] - h[i - 1]) + cost[i - 1], abs(h[i] - h[i - 2]) + cost[i - 2])
print(cost[n - 1])


Measured memory_bytes: 13928
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

typedef vector<vector<int> > mat;
int M;

mat mul(mat &A, mat &B){
    mat C(A.size(), vector<int>(B[0].size()));
    rep(i, 0, A.size()){
        rep(k, 0, B.size()){
            rep(j, 0, B[0].size()){
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % M;
            }
        }
    }
    return C;
}
mat pow(mat A, int n){
    mat B(A.size(), vector<int>(A.size()));
    rep(i, 0, A.size()){
        B[i][i] = 1;
    }
    while(n > 0){
        if(n & 1) B = mul(B, A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, a[3] = {}, t;
    while(1){
        cin >> n >> m;
        rep(i, 0, 3) cin >> a[i];
        cin >> t;
        M = m;
        if(n == 0 && m == 0 && a[0] == 0 && a[1] == 0 && a[2] == 0 && t == 0) break;
        vector<int> s(n);
        rep(i, 0, n) cin >> s[i];
        mat A(n, vector<int>(n));
        rep(i, 0, n){
            rep(j, 0, n){
                if(i - 1 == j) A[i][j] = a[0];
                if(i == j) A[i][j] = a[1];
                if(i + 1 == j) A[i][j] = a[2];
            }
        }
        A = pow(A, t);
        vector<int> ans(n);
        rep(i, 0, n){
            rep(j, 0, n){
                ans[i] = (ans[i] + A[i][j] * s[j]) % m; 
            }
        }
        for(int ii = 0; ii < ans.size(); ii++){
            if(ii) cout << ' ';
            cout << ans[ii];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3148
//Print a frame
#include <stdio.h>
int main()
{
    int H, W, i, j;
    while (1)
    {
        scanf("%d%d", &H, &W);
        if (H + W == 0)
            break;

        for (i = 0; i < H; i++)
        {
            for (j = 0; j < W; j++)
            {
                if (i == 0 || i == H - 1)
                    putchar('#');
                else
                {
                    if (j == 0 || j == W - 1)
                        putchar('#');
                    else
                        putchar('.');
                }
            }
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2104
r, c = map(int, input().split())
data = [list(map(int, input().split())) for _ in [0]*r]

[print(*data[i], sum(data[i])) for i in range(r)]
[print(sum([row[j] for row in data]), end = ' ') for j in range(c)]

s = 0
for k in range(r):
    s += sum(data[k])
print(s)


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

int main(){
    ll n, m;
    cin >> n >> m;
    if(n < m/2){
        cout << (2*n + m) / 4 << endl;
    }
    else{
        cout << m/2 << endl;
    }
}

Measured memory_bytes: 3504
import java.util.*;
class Main{
    public static void main(String[] args){
        int a,b,c,count;
        count = 0;
        Scanner scan=new Scanner(System.in);
            a = scan.nextInt();
            b = scan.nextInt();
            c = scan.nextInt();

            for (int i = a; i <= b; i++)  {
                if((c % i) == 0){
                    count++;
                }
            } 
        System.out.println(count);
    }
}


Measured memory_bytes: 26312
import sys
sys.setrecursionlimit(100**3)

def search(i, h, dp):
	if i == 0 or i == 1:
		return dp[i]
	if dp[i] < float('inf'):
		return dp[i]
	a = search(i - 1, h, dp) + abs(h[i] - h[i-1])
	b = search(i - 2, h, dp) + abs(h[i] - h[i-2])
	dp[i] = min(a, b)
	return dp[i]

def resolve():
	N = int(input())
	H = list(map(int, input().split()))
	DP = [float('inf')]*N
	DP[0], DP[1] = 0, abs(H[0] - H[1])
	print(search(N-1, H, DP))
resolve()

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

using namespace std;

typedef long long ll;
typedef tuple<int, int, int> T;

struct SegmentTree {
    int n;
    vector<ll> data;

    static ll INITIAL_VALUE;
    static ll merge(ll x, ll y); 
    void updateNode(int k, ll x);
 
    SegmentTree(int size) {
        n = 1;
        while (n < size) n *= 2;
        data.resize(2 * n - 1, INITIAL_VALUE);
    }
 
    int getLeaf(int k) {
        return data[k + n - 1];
    }
    
    void update(int a, int b, ll x, int k, int l, int r) {
        if (r <= a || b <= l) return;
        if (a <= l && r <= b) updateNode(k, x);
        else {
            update(a, b, x, k * 2 + 1, l, (l + r) / 2);
            update(a, b, x, k * 2 + 2, (l + r) / 2, r);
        }
    }

    void update(int a, int b, ll x) {
        return update(a, b, x, 0, 0, n);
    }
 
    ll query(int k) {
        ll res = 0;
        k += n - 1; 
        res += data[k];
        while (k > 0) {
            k = (k - 1) / 2;
            res += data[k];
        } 
        return res;       
    }
};

ll SegmentTree::INITIAL_VALUE = 0;
 
ll SegmentTree::merge(ll x, ll y) {
    return x + y;
}
 
void SegmentTree::updateNode(int k, ll x) {
    data[k] += x;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}

	vector<T> hoge;
	for (int i = 1; i < n; i++) {
		hoge.emplace_back(a[i - 1], a[i] + m * (a[i - 1] > a[i]), i);
	}

	ll init_v = 0;
	for (int i = 1; i < n; i++) {
		init_v += (a[i] - a[i - 1] + m) % m;
	}

	SegmentTree st(2 * m + 1);
	for (T& t : hoge) {
		int L, R, idx;
		tie(L, R, idx) = t;
		if (L == R) continue;
		st.update(L + 2, R + 1, 1);
		st.update(R + 1, R + 2, -(R - L - 1));
	}

	vector<ll> imos(2 * m);
	for (int i = 0; i < 2 * m; i++) imos[i] = st.query(i);

	for (int i = 1; i < 2 * m; i++) imos[i] += imos[i - 1];

	ll d = 0;
	for (int i = 0; i < m; i++) {
		d = max(d, imos[i] + imos[i + m]);
	}
	cout << init_v - d << endl;
	return 0;
}

Measured memory_bytes: 7668
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	string s;
	cin >> s;
	if (s.at(2) == s.at(3) && s.at(4) == s.at(5))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3640
#-*-coding:utf-8-*-

def main():
    a = [1, 3, 5, 7, 8, 10, 12]
    b = [4, 6, 9, 11]
    c = [2]

    x, y = map(int, input().split())
    
    if all(i in a for i in [x, y]) or all(i in b for i in [x, y]) or all(i in c for i in [x, y]):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

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

using namespace std;

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

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

int main()
{
	for(string s;getline(cin,s),s[0]!='0';){
		istringstream iss(s);
		vi a;
		for(int n;iss>>n;)
			a.push_back(n);
		
		int res=0;
		rep(i,a.size())
			res+=min(a[i],10);
		int onesize=count(allof(a),1);
		rep(i,onesize)
			if(res+10<=21)
				res+=10;
		if(res>21)
			res=0;
		
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
local mfl = math.floor
local n, m = io.read("*n", "*n")
local v, p = io.read("*n", "*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
table.sort(a)

local function solve(x)
  local currank = n + 1 - x
  local has = m * (n - v)
  if m < a[n + 1 - p] - a[x] then
    return false
  end
  local need = 0
  local base = a[x]
  for i = x + 1, n + 1 - p do
    need = need + a[i] - base
  end
  -- print(x, need)
  return need <= has
end

if solve(1) then
  print(n)
else
  local min, max = 1, n
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if solve(mid) then
      max = mid
    else
      min = mid
    end
  end
  print(n + 1 - max)
end


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

#define fi first
#define se second
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pint;

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

	int n;
	cin >> n;
	n /= 200;
	cout << 10 - n;

	return 0;
}


Measured memory_bytes: 3644
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

string S;

signed main(){

    in(S);
    cout<<S.substr(0,4)<<" "<<S.substr(4)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
#include <unordered_map>
 
//#include <iostream>//POJ
//#include <vector>
//#include <string>
//#include <iomanip>
//#include <math.h>
//#include <algorithm>
//#include <cstring>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define repir(i,a,b) for(int i=(a)-1, i##_first=(b); i>=i##_first; --i)
#define repr(i,n) repir(i,n,0)
#define repir_(i,a,b) for(int i=(a), i##_first=(b); i>=i##_first; --i)
#define repr_(i,n) repir_(i,n,0)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
//template<typename T> T vpop(vector<T> *v) {
//	T res = v->back();
//	v->pop_back();
//	return res;
//}
//char vpop(string *v) {
//	char res = v->back();
//	v->pop_back();
//	return res;
//}
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()
 
#define pb push_back
#define pq priority_queue
#define np next_permutation
 
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);
 
typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<lint> lvec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;
 
const int
dx8[8] = { 0,1,1,1,0,-1,-1,-1 },
dy8[8] = { 1,1,0,-1,-1,-1,0,1 },
dx4[4] = { 0,1,0,-1 },
dy4[4] = { 1,0,-1,0 };
 
template<class T>inline bool maxi(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
 
int main(){
	setc;
 
	char in, sec;
	string s;cin>>s;
	lint k; cin>>k;--k;
	rep(i, s.length()){
		if (s[i] != '1'){
			co(s[i]);
			return 0;
		}
		if (i == k){
			co(1);
			return 0;
		}
	}
 
	gc();
}

Measured memory_bytes: 256
import sys
import math
from fractions import gcd
readline = sys.stdin.readline
INF = 10**9


def main():
  n = int(readline())
  A = list(map(int, readline().split()))
  ans = gcd(A[0], A[1])
  for i in A:
    ans = gcd(ans, i)
  print(ans)
  
  
  
  
if __name__ == "__main__":
  main()

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

int a,b,c,d ;

int main(){
  cin >> a >> b >> c >> d;
  if(a+b==c+d)
    cout << "Balanced" << endl;
  else if(a+b > c+d)
    cout << "Left" << endl;
  else if (a+b<c+d)
    cout << "Right" << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
ans = 0
while True:
    S = 0
    for i, a in enumerate(A):
        if a>=N:
            res = (a-N+1)//(N+1)+1
            A[i]-=res*(N+1)
            S+=res
    A = list(map(lambda x:x+S, A))
    ans+=S
    if all(a<N for a in A):
        break
print(ans)
    
            
    

    

Measured memory_bytes: 40048
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
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");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
   int a,b;
  cin>>a>>b;
  vector<int> c(a);
  rep(i,a)
    cin>>c[i];
  rep(i,a-b){
  if(c[i]<c[b+i])
    out("Yes");
    else
    out("No");
  }
}

Measured memory_bytes: 4980
#include<bits/stdc++.h>
using namespace std;
 
int main () {
  int n,m;
  cin >>n>>m;
  vector<int>a(n);
  int addvote =0;
  int cnt =0;
  for(int i=0;i<n;i++){
    cin >>a[i];
    addvote +=a[i];
  }

  int checkvote =0 ;
  if(addvote%(4*m) ==0){
    checkvote =(addvote/(4*m));
  }else{
    checkvote =(addvote/(4*m))+1;
  }
  for(int i=0;i<n;i++){
    if(checkvote <= a[i])cnt++;
  }
  if(cnt >= m){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }


return 0;
}


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

ll gcd(ll x, ll y)
{
	if (y == 0) return x;
	return gcd(y, x % y);
}

signed main(void)
{
	int n, k;
	vector<int> v;
	ll g;
	
	cin >> n >> k;
	rep(i, n)
	{
		int a;
		cin >> a;
		v.push_back(a);
	}
	sort(v.begin(), v.end());
	g = v[0];
	rep(i, n)
	{
		g = gcd(g, v[i]);
	}
	if (k <= v[n - 1] && k % g == 0)
		cout << "POSSIBLE" << endl;
	else
		cout << "IMPOSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 892
from collections import defaultdict

N=int(input())

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

dic=defaultdict(int)
max_dic=0

for i in range(N):
    if A[i] in dic:
        dic[A[i]]+=1
    else:

        dic[A[i]]=1
        max_dic=max(A[i],max_dic)

dic1=dic.copy()

for k in dic1:
    cn=k
    while cn<=max_dic:
        cn+=k
        if cn in dic:
            del dic[cn]

result=0

for m in dic:
    if dic[m]==1:
        result+=1

print(result)




Measured memory_bytes: 41024
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e5+10;
int a[maxn];
int cmp(const int a,const int b)
{
    return a>b;
}
int n,m,v,p;
int b[maxn];
bool judge(int mid){
    if(mid<=p)return true;
    if(a[mid]+m<a[p])return false;
    if(v<=p-1&&a[mid]+m>=a[p])return true;
    for(int i=1;i<=n;i++)b[i]=a[i];
    int temp=0;
    for(int i=1;i<=p-1;i++){
        b[i]+=m;
        temp+=m;
    }
    int inx=n,cnt=v-p+1;
    while(inx>mid&&cnt>1){
        temp+=m;
        inx--;
        cnt--;
        b[inx]+=m;
    }
    temp+=m;
    int now=a[mid]+m;
    int res=m*v-temp;
    for(int i=p;i<mid;i++){
        int add=min(m,max(now-a[i],0ll));
        if(add>res)add=res;
        res-=add;
        b[i]+=add;
    }
    return now>=b[p]&&res<=0;
}
signed main(){
    cin>>n>>m>>v>>p;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1,cmp);
    int low=1,high=n;
    int ans=0;
    while(low<=high){
        int mid=(low+high)>>1;
        if(judge(mid)){
            low=mid+1;
            ans=mid;
        }
        else{
            high=mid-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

void print_string(int s[], int n) {
  for (int i = 0; i < n; i++) {
    putchar('a' + s[i]);
  }
  putchar(10);
  return;
}

int main(){
  int n;
  scanf("%d", &n);
  //char c[10] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};
  int s[n];
  for(int i = 0; i < n; i++){
    s[i] = 0;
  }
  print_string(s, n);
  int i = n - 1;
  while (i > 0) {
    //printf("test %d ", i);
    //print_string(s, n);
    int flag = 0;
    for (int j = 0; j < i; j++) {
      if (s[j] == s[i]) {
        s[i]++;
        flag = 1;
        print_string(s, n);
        if (i == n - 1) {
          //print_string(s, n);
        } else {
          //print_string(s, n);
          i = n - 1;
        }
        break;
      }
    }
    if (flag == 1) {
      continue;
    }
    for (int j = i; j < n; j++) {
      s[j] = 0;
    }
    i--;
  }

  return 0;
}


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

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, m, a, b;
    cin >> n >> m;
    
    vector<int> v[n+1];
    vector<int> degree(n+1, 0);
    
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        v[a].push_back(b);
        degree[b]++;
    }
    
    vector<int> temp;
    queue<int> q;
    for(int i = 1; i <= n; i++){
        if(degree[i] == 0){
            q.push(i);
            temp.push_back(i);
        }
    }
    
    while(!q.empty()) {
        int cur = q.front();
        q.pop();
        
        for(auto x : v[cur]){
            degree[x]--;
            if(degree[x] == 0) {
                q.push(x);
                temp.push_back(x);
            }
        }
    }
    
    vector<int> dp(n+1, 0);
    
    for(auto cur : temp) {
        for(auto x : v[cur])
            dp[x] = max(dp[x], dp[cur] + 1);
    }
    
    int maxi = 0;
    for(int i = 1; i <= n; i++)
        maxi = max(maxi, dp[i]);
    
    cout << maxi ;
    return 0;
}

Measured memory_bytes: 11228
import statistics
import math
from decimal import *
N = int(input())

n =[]
m =[]

for i in range(N):
    a,b = list(map(int,input().split()))
    n.append(a)
    m.append(b)

nmean = Decimal(statistics.median(n))
mmean =Decimal(statistics.median(m))

if N%2 == 1:
    print(mmean - nmean + 1)
else:
    print(int((mmean - nmean)*2) +1 )

Measured memory_bytes: 28880
#include<bits/stdc++.h>
#define rep(i, x) for(int i = 0; i < (int)(x); i++)
#define reps(i, x) for(int i = 1; i <= (int)(x); i++)
#define UNIQUE(v) v..erase( unique(v.begin(), v.end()), v.end() );
#define Size(x) ((int)(x).size())
using namespace std;

vector<int> v;
vector<int> m;
int n, q, M;

bool dfs(int i, int sum){
	if(sum == M) return true;
	if(i == n) return false;
	else if(dfs(i + 1, sum + v[i])) return true;
	else if(dfs(i + 1, sum)) return true;
	return false;
}

int main(){
	cin >> n;
	v.resize(n);
	rep(i, n) cin >> v[i];
	cin >> q;
	m.resize(q);
	rep(i, q) cin >> m[i];

	rep(i, Size(m)){
		M = m[i];
		if(dfs(0, 0)) cout << "yes" << endl;
		else cout << "no" << endl;
	}

	return 0;
}



Measured memory_bytes: 3096
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    A, B, C = input().split()
    if A[-1] == B[0] and B[-1] == C[0]:
        print(YES)
    else:
        print(NO)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4456
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>

typedef long long ll;
typedef long l;
int return_max(int a,int b){
  if(a>b){
    return a;
  }else{
    return b;
  }
}

int return_min(int a,int b){
  if(a<b){
    return a;
  }else{
    return b;
  }
}

int main(void)
{
  int n;
  scanf("%d",&n);
  int start=0;
  while(start<n){
    start+=1000;
  }
  printf("%d\n",start-n);

  return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;

const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}



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

  vector<string> a(n);
  cin >> a;

  vector<tuple<bool, bool, ll>> fb_la_num(n);

  for (int i = 0; i < n; ++i) {
    ll count = 0;
    bool isfrontb = false;
    bool islasta = false;

    for (int j = 1; j < a[i].size(); j++) {
      if (a[i][j - 1] == 'A' && a[i][j] == 'B') {
        count++;
      }
    }

    if (a[i][0] == 'B')isfrontb = true;
    if (a[i][a[i].size() - 1] == 'A')islasta = true;

    fb_la_num[i] = make_tuple(isfrontb, islasta, count);

  }

  for (int i = 0; i < n; ++i){
    cerr << get<0>(fb_la_num[i]) << "   " << get<1>(fb_la_num[i]) << "   count:" << get<2>(fb_la_num[i]) <<endl;
  }

  ll ans = 0;

  ll lanum = 0;
  ll fbnum = 0;

  ll sameABnum = 0;


  for (int i = 0; i < n; ++i) {
    if (get<0>(fb_la_num[i]) == true )fbnum++;
    if (get<1>(fb_la_num[i]) == true )lanum++;
    if (get<0>(fb_la_num[i]) == true && get<1>(fb_la_num[i]) == true)sameABnum++;
    ans += get<2>(fb_la_num[i]);
  }




  if (fbnum != lanum) {
    ans += min(fbnum, lanum);
  } else {

    ans += fbnum;
    if (sameABnum == fbnum) {
      if (fbnum !=0)ans--;
    }

  }





  cout << ans << endl;

}







Measured memory_bytes: 1024
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    N = int(input())
    print(N) if N % 2 == 0 else print(N * 2)

main()


Measured memory_bytes: 4672
fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val h = sc.nextInt()
    val w = sc.nextInt()
    val a: List<IntArray> = sc.asSequence().take(h).map { it.toCharArray().map { c -> if (c == '#') -1 else 0 }.toIntArray() }.toList()

    for (y in 0 until a.size) {
        var x0 = 0
        var x1 = -1
        for (x in 0 until a[y].size) {
            if (a[y][x] == -1) {
                val d = x1 - x0 + 1
                if (d > 0) {
                    for (j in x0..x1) {
                        a[y][j] = d
                    }
                }
                x0 = x + 1
            } else {
                x1 = x
            }
        }
        x1 = a[y].size - 1
        val d = x1 - x0 + 1
        if (d > 0) {
            for (j in x0..x1) {
                a[y][j] = d
            }
        }
    }

    for (x in 0 until w) {
        var y0 = 0
        var y1 = -1
        for (y in 0 until h) {
            if (a[y][x] == -1) {
                val d = y1 - y0 + 1
                if (d > 0) {
                    for (j in y0..y1) {
                        a[j][x] += d
                    }
                }
                y0 = y + 1
            } else {
                y1 = y
            }
        }
        y1 = h - 1
        val d = y1 - y0 + 1
        if (d > 0) {
            for (j in y0..y1) {
                a[j][x] += d
            }
        }
    }

    var r = a.map { it.max() }.maxBy { it ?: 1 } ?: 1
    if (r == -1) r = 1

    println(r - 1)
}


Measured memory_bytes: 65904
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int cnt[55];
signed main(){
	ios_base::sync_with_stdio(0);
	int n,m;
	cin>>n>>m;
	while(m--){
		int a,b;
		cin>>a>>b;
		cnt[a]++;
		cnt[b]++;
	}
	for(int i=1;i<=n;i++) cout<<cnt[i]<<"\n";
	re 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
vector<ll> A, F;
ll N, K;
ll getMax(ll target){
  ll rem = K;
  //cout << target << endl;
  for(int i = 0; i < N; i++){
    ll x = max((ll)ceil(-1.0 * (double)target / (double)F[i] + (double)A[i]), (ll)0);
    //cout << A[i] << " " << F[i] << " "<<x << endl;
    rem -= x;
    //cout << A[i] << " " << F[i] << " "<<x << endl;
  }
  return rem;
}
int main(){
  cin >> N >> K;
  A = vector<ll> (N);
  F = vector<ll> (N);
  for(int i = 0; i < N; i++) cin >> A[i];
  for(int i = 0; i < N; i++) cin >> F[i];
  sort(A.begin(), A.end());
  sort(F.rbegin(), F.rend());
  ll r = 0;
  for(int i = 0; i < N; i++) r = max(r, A[i] * F[i]);
  ll l = 0;
  while(l < r){
    ll m = (l + r)/2;
    ll rem = getMax(m);
    //cout << m << " "<< rem << endl;
    //cout << l <<" "<< r <<" "<<m << " " << ma << endl;
    if(rem < 0){
      l = m + 1;
    }else if(rem >= 0 && getMax(m-1) < 0){
      cout << m << endl;
      return 0;
    }else{
      r = m - 1;
    }
  }
  cout << l << endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int ans=0;

    for(int i=1; i<=n; i++){
        string s = to_string(i);
        int count=0;
        for(int j=0; j<s.size(); j++){
            count += s[j] - '0';
        }
        if(a<=count && count<=b){
            ans+=i;
        }
    }

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

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char A[10],B[10];
    while((scanf("%s%s%", A, B))!=EOF)
    {


    if (A[0]==B[2] && A[1]==B[1] && A[2]==B[0])
        printf("YES\n");
    else
        printf("NO\n");
    }

}


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

int main() {
	int i, j, r, c, a[101][101], sr[101] = {}, sc[101] = {}, s = 0;
	cin >> r >> c;
	for (i = 1; i <= r; i++) {
		for (j = 1; j <= c; j++) {
			cin >> a[i][j];
		}
	}
	for (i = 1; i <= r; i++) {
		for (j = 1; j <= c; j++) {
			sr[i] += a[i][j];
		}
	}
	for (j = 1; j <= c; j++) {
		for (i = 1; i <= r; i++) {
			sc[j] += a[i][j];
		}
	}
	for (i = 1; i <= r; i++) {
		s += sr[i];
	}
	for (i = 1; i <= r; i++) {
		for (j = 1; j <= c; j++) {
			cout << a[i][j] << " ";
		}
		cout << sr[i] << endl;
	}
	for (j = 1; j <= c; j++) {
		cout << sc[j] << " ";
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 1196
# include <cstdio>
# include <algorithm>
# include <cstring>
# include <cmath>
# include <climits>
# include <iostream>
# include <string>
# include <queue>
# include <vector>
# include <set>
# include <map>
# include <cstdlib>
# include <stack>
# include <ctime>
using namespace std;

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define mct(a,b) memset(a,b,sizeof(a))
# define gc getchar()
typedef long long ll;
const int N=2e5+5;
const int inf=0x7fffffff;
const double eps=1e-7;
template <typename T> void read(T &x){
	x=0;int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
	x*=f;
}
int n,q;
int head[N],ecnt;
int cnt[N],pls[N],inde[N];

struct Edge{
	int to,next;
}e[N];

inline void add(int x,int y){
	e[++ecnt]=(Edge){y,head[x]},head[x]=ecnt;
}

inline void dfs(int u,int p){
	cnt[u]=pls[u]+p;
	for(int i=head[u];~i;i=e[i].next)
		dfs(e[i].to,p+pls[u]);
}

int main()
{
	memset(head,-1,sizeof(head));
	read(n),read(q);
	Rep(i,1,n-1){
		int x,y;
		read(x),read(y);
		add(x,y);
		inde[y]++;
	}
	Rep(i,1,q){
		int x,y;
		read(x),read(y);
		pls[x]+=y;
	}
	Rep(i,1,n)if(!inde[i]){
		dfs(i,0);
		break;
	}
	Rep(i,1,n)printf("%d ",cnt[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 11648
#include<stdio.h>

int main(){
int N;
scanf("%d",&N);
double X = N / 1.08;
int I = (int)(X);
if((int)(I*1.08) == N)	printf("%d" ,I); 
else if ( (int)((I+1)*1.08) == N  )printf("%d" ,I+1);
else   printf(":(");
return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.Map;
import java.util.HashMap;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> map = new HashMap<>();
		for (int i = 0; i < N; i++) {
			String s = sc.next();
			if (!map.containsKey(s)) {
				map.put(s, 1);
			} else {
				map.put(s, map.get(s) + 1);
			}
		}
		int M = sc.nextInt();
		for (int i = 0; i < M; i++) {
			String s = sc.next();
			if (!map.containsKey(s)) {
				map.put(s, -1);
			} else {
				map.put(s, map.get(s) - 1);
			}
		}
		int max = 0;
		for (Map.Entry<String, Integer> entry : map.entrySet()) {
			max = Integer.max(max, entry.getValue());
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int calc_digit(ll num){

	if(num == 0){

		return 1;
	}

	int ret = 0;

	while(num > 0){

		ret++;
		num /= 10;
	}

	return ret;
}

int main(){

	ll N;
	scanf("%lld",&N);

	int ans = calc_digit(N);

	for(ll i = 1; i*i <= N; i++){

		if(N%i != 0)continue;
		ans = min(ans,max(calc_digit(i),calc_digit(N/i)));
	}

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

	return 0;
}


Measured memory_bytes: 256
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

count = 0
for t in T:
    left = 0
    right = n
    while left < right:
        mid = (left + right) // 2
        if t == S[mid]:
            count += 1
            break
        elif t < S[mid]:
            right = mid
        else:
            left = mid + 1
print(count)


Measured memory_bytes: 16704
N, M = map(int, input().split())
d = [[1000000]*N for _ in range(N)]
d_dict = {}

inf = 0
for i in range(M):
  a, b, c = map(int, input().split())
  d[a-1][b-1] = c
  d[b-1][a-1] = c
  d_dict[(a-1, b-1)] = c
  
for k in range(N):
  for i in range(N):
    for j in range(N):
      d[i][j] = min(d[i][j], d[i][k] + d[k][j])
  
ans = 0
for key in d_dict:
  if d[key[0]][key[1]] < d_dict[key]:
    ans += 1
    
print(ans)


Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		if(a + b > c + d) {
			System.out.println("Left");
		} else if(a + b == c + d) {
			System.out.println("Balanced");
		} else {
			System.out.println("Right");
		}
	}
}

Measured memory_bytes: 22868
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    N = int(input())
    a = list(map(int, input().split()))

    a.sort(reverse=True)
    ans = 0
    for i in range(len(a)):
        ans += a[i]*(-1)**i
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
import math

while True:
	e = int(input())
	if e == 0:
		break
	r = 1<<30
	z = 0
	while z**3 <= e:
		c = int(math.sqrt(e-z**3))
		r = min(e-z**3-c**2+c+z, r)
		z += 1
	print(r)

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

  int i,j,H,W;

  while(1){

    scanf("%d %d", &H, &W);
    if ( H == 0 && W == 0 ) break;

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

      for ( j = 0 ; j < W ; j++ ){

	if ( (  i + j ) % 2 == 0 ) {
	  printf("#");
	} else {
	  printf(".");
	}
	
      }

      printf("\n");
      
    }

    printf("\n");
    
  }

  return 0;

}

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

int main(){
  int N;
  cin >> N;
  bool check = false;
  if(N % 10 == 7)
    check = true;
  if(N / 10 % 10 == 7)
    check = true;
  if(N / 100 == 7)
    check = true;
  if(check)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3628
#include <stdio.h>

#define MAX 200000

int max(int a,int b) { return a>b ? a: b;}
int min(int a,int b) { return a<b ? a: b;}

int main(void) {
    int R[MAX], i, n;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&R[i]);
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for( i=1; i<n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    printf("%d\n",maxv);

    return 0;
}


Measured memory_bytes: 2532
/* 実行時間1s制限の場合
  10^6 1,000,000   : 余裕をもって間に合う
  10^7 10,000,000  : おそらく間に合う
  10^8 100,000,000 : 非常にシンプルな処理でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}          // Least Commont Multiple オーバーフローしないように先に割る

const ll INF = LONG_MAX;
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; }

int main()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("b.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n,k;
    cin >> n >> k;

    vector<int> h(n);
    rep(i, n) {
        cin >> h[i];
    }

    int ans = 0;
    rep(i, n) {
        if (h[i] >= k)
        {
            ans++;
        }
    }

    cout << ans;

    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 640