akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  ll na, nb, nc, nd;

  ll max_water = 0;
  ll max_sugar = 0;
  ll count = 0;
  double max_noudo = 0;
  for (na = 0; na <= 30; na++) {
    for (nb = 0; nb <= 30; nb++) {
      ll nwater = na * A + nb * B;
      for (nc = 0; nc * C <= nwater * E; nc++) {
        for (nd = 0; ;nd++) {
          ll nsugar = nc * C + nd * D;
          if (nsugar > E * nwater) break;
          if (nsugar + nwater * 100 > F) break;
          count++;
          if (max_water == 0 || max_sugar * (nwater * 100 + nsugar) < nsugar * (max_water * 100 + max_sugar)) {
//            cout << "nwater=" << nwater << " nsugar=" << nsugar << endl;
            max_water = nwater;
            max_sugar = nsugar;
          }
        }
      }
    }
  }
//  cout << "count=" << count << endl;
  cout << max_sugar + max_water * 100 << " " << max_sugar << endl;

  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "string"

using namespace std;

int main() {
    string s, p;

    getline(cin, s);
    getline(cin, p);

    string::size_type pos = 0;
    bool res = false;
    if ((pos = s.find(p, pos)) != string::npos) {
        res = true;
    }
    else {
        string::size_type spos = 0;
        while ((pos = s.find(p[0], spos)) != string::npos) {
            int i = 0;
            spos = pos + 1;             // ?¬????????´¢???????????????   

            for (; i < p.length(); i++) {
                if (p[i] != s[pos++]) {
                    break;              //  ?????´???????????£???
                }
                if (pos == s.length()) {
                    pos = 0;
                }
            }

            if (i == p.length()) {
                res = true;         //  ?????´????????????
                break;
            }
        }
    }
        
    if (res) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3192
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val X = nextIntList()
    val Y = X.mapIndexed { i, v -> Pair(i, v) }.sortedBy { it.second }
    val a = Y[(N - 1) / 2].second
    val b = Y[N / 2].second
    val Z = Y.mapIndexed { i, p -> Pair(p.first, if (i < N / 2) b else a) }.sortedBy { it.first }
    for (z in Z) {
        println(z.second)
    }
}

Measured memory_bytes: 153720
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

inline bool valid(int x, int n) {
    return 0 <= x && x < n;
}

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

template <typename T>
inline T pop(queue<T>& q) {
    T front = q.front();
    q.pop();
    return front;
}

template <typename T>
inline T gcd(T a, T b) {
    for (; b; a %= b, swap(a, b));
    return a; 
}

template <typename T>
tuple<T, T, T> xgcd(T a, T b) {
    if (b == 0) return {1, 0, a};
    T x, y, g;
    tie(x, y, g) = xgcd(b, a%b);
    return {y, x-(a/b)*y, g};
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    ll n, k; cin >> n >> k;
    vi a(n+1); for (int i = 1; i <= n; i++) cin >> a[i];

    vvi sptree(61, vi(n+1));
    for (int i = 1; i <= n; i++) sptree[0][i] = a[i];
    for (int i = 1; i <= 60; i++) {
        for (int j = 1; j <= n; j++) {
            sptree[i][j] = sptree[i-1][ sptree[i-1][j] ];
        }
    }

    int t = 1;
    for (int i = 0; i < 61; i++) {
        if (k & (1ll << i)) {
            t = sptree[i][t];
        }
    }

    cout << t;
}


Measured memory_bytes: 52568
my $n = <>;
my @w = split(/ /, <>);

my $val = 9999999999;
my $l = 0;
my $r = 0;
for(my $i=0; $i<$n; $i++) {
    $l = 0;
    for(my $j=0; $j<$i; $j++) {
        $l += int($w[$j]);
    }
    $r = 0;
    for(my $j=$i; $j<$n; $j++) {
        $r += int($w[$j]);
    }
    my $tmp = abs($r - $l);
    if($tmp < $val) {
        $val = $tmp;
    } else {
        print($val);
        exit;
    }
}
print($val);


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  long long int a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;

  if (v > w) {
    if (abs(b - a) <= (v - w) * t) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n, m;
struct edge{int to, cost;};
vector<vector<edge>> g(200000+5);


vector<ll> dijkstra(int s, int n, vector<vector<edge>>& g){
    priority_queue<plli, vector<plli>, greater<plli>> que;
    vector<ll> d(n, LLONG_MAX / 10); d[s] = 0;
    que.push(plli(0, s));

    while (!que.empty()){
        plli p = que.top();que.pop();
        int fr = p.second;
        if (d[fr] < p.first) continue;
        for (edge e: g[fr]){
            if (d[e.to] > d[fr] + e.cost){
                d[e.to] = d[fr] + e.cost;
                que.push(plli(d[e.to], e.to));
            }
        }
    }
    return d;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].pb(edge{b, 1});
        g[b].pb(edge{a, 1});
    }
    vector<int> dist = dijkstra(0, n, g);
    if (dist[n - 1] == 2) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 18912
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cmath>

#define mst(a,b)memset(a, b, sizeof(a))
#define repi(a,b)for(ll i = a; i < b; i++)
#define repj(a,b)for(ll j = a; j < b; j++)
#define pii pair<int,int>

#ifdef LOCAL
#define fre()freopen("in.txt","r",stdin)
#endif
#ifndef LOCAL
#define fre()
#endif

//static int x = []() {
//	std::ios::sync_with_stdio(false);
//	std::cin.tie(NULL);
//	return 0;
//}();

#define FASTIO
#ifdef FASTIO
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//#define scanf abcabc
//#define printf abcabc
#endif
//#ifndef FASTIO
//#define cin abcabc
//#define cout abcabc
//#endif

typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;

using namespace std;


const int mod = 1000000007;
int a[100010], vis[100010];
int rifa(int x) {
	if (a[x])return 0;
	if (vis[x])return vis[x];
	if (x == 1)return 1;
	else if (x == 2)return rifa(x - 1) + 1;
	int tmp = (rifa(x - 1) + rifa(x - 2)) % mod;
	vis[x] = tmp;
	return tmp;
}
int main() {
	fre(); IOS;
	int n, m; cin >> n >> m;
	repi(0, m) {
		int tmp; cin >> tmp;
		a[tmp] = 1;
		if (a[tmp - 1] || a[tmp + 1]) {
			cout << "0\n";
			return 0;
		}
	}
	cout << rifa(n) << endl;
	return 0;
}




Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

ll dp[105][105][2];
char s[105][105];

int main(){
	ll h,w; cin >> h >> w;
	rep(i,h) rep(j,w) cin >> s[i][j];
	rep(i,h) rep(j,w) rep(k,2) dp[i][j][k] = inf;
	//queue<pair<ll,P>> q;
	if(s[0][0] == '.'){
		dp[0][0][0] = 0;
		//q.emplace(0,P(0,0));
	}
	else{
		dp[0][0][1] = 1;
		//q.emplace(1,P(0,0));
	}
	/*while(!q.empty()){
		auto t = q.front(); q.pop();
		ll y = t.second.first;
		ll x = t.second.second;
		if(s[y][x] == '.'){

		}else{

		}
	}*/
	rep(i,h){
		rep(j,w){
			if(i==0 && j==0) continue;
			if(s[i][j] == '.'){
				if(i>0){
					chmin(dp[i][j][0],dp[i-1][j][0]);
					chmin(dp[i][j][0],dp[i-1][j][1]);
				}
				if(j>0){
					chmin(dp[i][j][0],dp[i][j-1][0]);
					chmin(dp[i][j][0],dp[i][j-1][1]);
				}
			}else{
				if(i>0){
					chmin(dp[i][j][1],dp[i-1][j][1]);
					chmin(dp[i][j][1],dp[i-1][j][0]+1);
				}
				if(j>0){
					chmin(dp[i][j][1],dp[i][j-1][1]);
					chmin(dp[i][j][1],dp[i][j-1][0]+1);
				}
			}
		}
	}
	cout << min(dp[h-1][w-1][0],dp[h-1][w-1][1]) << endl;
}

Measured memory_bytes: 384
// Tue May 26 19:06:02 IST 2020 
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)        for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long    
#define MOD                998244353 
#define pb                 push_back
#define f1                 first 
#define s1                 second    
#define all(x)             (x).begin(),(x).end() 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
#define tough_nut          numeric_limits<int64>::min()

const double pi = 3.141592653589793238;
using namespace  std ;       
using namespace __gnu_pbds;
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
const int N = 3e5+7; 
const int INF = INT_MAX;
struct comp{
    bool operator()(const pair<int,int> A,const pair<int,int>& B )const{
        if(A.first == B.first)
            return A.second < B.second ;
        return A.first > B.first;
    } 
};   
int tests(){ 
    string S,T ;
    cin >> S >> T ;
    int c = 0 ;
    int n = S.size();
    for (int i = 0 ; i < n ;i ++ )
        c +=(S[i]!= T[i]);
    cout << c << '\n';
    return 0 ;
    // cout << (n+1-min(a,b)+max(a,b)-1)/max(a,b) << '\n';
} 
int32_t main(){
    I__O ;     
    int cases = 1 ;  
    // cin >> cases ;  
    while(cases--) 
        tests(); 
     
    return 0 ; 
}
 // g++ -std=c++17 -O2 -Wall test.cpp  

Measured memory_bytes: 3772
N = gets.chomp.to_i
vn = gets.chomp.split(" ").map(&:to_i).sort

loop {
  a = vn[0]
	b = vn[1]
	vn.shift(2)

	c = (a + b) / 2.0

	i = vn.index{|v| v > c }

	if i.nil? then
		vn.push(c)
	elsif i == 0 then
		vn.unshift(c)
	else
		vn.insert((i - 1), c)
	end

	break if vn.length == 1
}

puts vn[0]

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdlib>
using namespace std;

char letters[] = {
	'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
	'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
	's', 't', 'u', 'v', 'w', 'x', 'y', 'z',' '
};

int index(char c){
	if(c == ' ') return 26;
	return (int)c - 97;
}

int affine(int a, int b, char c){
	return (a * index(c) + b) % 26;
}

int raffine(int a, int b, char c){
	if(c == ' ') return 26;
	int k = 0;
	for(;;k++){
		if(((index(c) - b) + k * 26) % a == 0)
			break;
	}
	return (((index(c) - b) + k * 26) / a) % 26;
	return c;
}

bool is_sosu(int a){
	for(int i = 2; i < a; i++){
		if(a % i == 0) return false;
	}
	return true;
}

bool find_s(string s, string t, int a, int b){
	string t2;
	for(string::iterator iter = t.begin(); 
		iter != t.end(); iter++)
	{
		t2.push_back(letters[affine(a,b,*iter)]);
	}
	string::iterator iter = search(s.begin(), s.end(), t2.begin(), t2.end());
	if(iter != s.end()) return true;
	else return false;
}

int main(){
	string s;
	string t1("that"), t2("this");
	string s1;
	int n;
	getline(cin, s1);
	n = atoi(s1.c_str());
	for(int i = 0; i < n; i++){
		getline(cin, s);
		int a = 2, b = 0;
		int c = 0;
		for(;;a++){
			b = 0;
			if(is_sosu(a)){
				for(; b < 26; b++){
					if(find_s(s,t1,a,b) || find_s(s,t2,a,b)){
						c = 1;
						break;
					}
				}
			}
			if(c) break;
		}
		for(string::iterator iter = s.begin();
			iter != s.end(); iter++)
		{
			cout << letters[raffine(a, b, *iter)];
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> t(n),x(n),y(n);
    for(int i=0; i<n;i++) cin >>t[i] >>x[i]>>y[i];
    int count=0;

    for(int i=0; i<n;i++){
        if(x[i]+y[i]<=t[i]&&(x[i]+y[i])%2==t[i]%2){
            count++;
        }
    }
    if(count==n){
        cout << "Yes";
    }else{
        cout <<"No";
    }
    return 0;
}

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

/*
 * bABa bABa           b                  AbaB AbaB  14
 * bABa bABa           bA                 AbaB AbaB  15
 * bABa bABa           bAB                AbaB AbaB  16
 * bABa bABa           bABa B             AbaB AbaB  17
 * bABa bABa           bABa aB            AbaB AbaB  18
 * bABa bABa           bABa baB           AbaB AbaB  19
 * bABa bABa bABa      b             AbaB AbaB AbaB  20
 * bABa bABa bABa      bA            AbaB AbaB AbaB  21
 * bABa bABa bABa      bAB           AbaB AbaB AbaB  22
 * bABa bABa bABa      bABa B        AbaB AbaB AbaB  23
 * bABa bABa bABa      bABa aB       AbaB AbaB AbaB  24
 * bABa bABa bABa      bABa baB      AbaB AbaB AbaB  25
 * bABa bABa bABa bABa b        AbaB AbaB AbaB AbaB  26
 * bABa bABa bABa bABa bA       AbaB AbaB AbaB AbaB  27
 * bABa bABa bABa bABa bAB      AbaB AbaB AbaB AbaB  28
 * bABa bABa bABa bABa bABa B   AbaB AbaB AbaB AbaB  29
 * bABa bABa bABa bABa bABa aB  AbaB AbaB AbaB AbaB  30
 */

vector<int> inv(vector<int> a) {
  int n = (int) a.size();
  vector<int> ret(n);
  for (int i = 0; i < n; i++) {
    ret[a[i]] = i;
  }
  return ret;
}

vector<int> mul(vector<int> a, vector<int> b) {
  int n = (int) a.size();
  vector<int> ret(n);
  for (int i = 0; i < n; i++) {
    ret[i] = a[b[i]];
  }
  return ret;
}

vector<int> power(vector<int> a, int b) {
  int n = (int) a.size();
  vector<int> ret(n);
  iota(ret.begin(), ret.end(), 0);
  while (b) {
    if (b & 1) {
      ret = mul(ret, a);
    }
    b >>= 1;
    a = mul(a, a);
  }
  return ret;
}

void output(vector<int> a) {
  for (int i = 0; i < (int) a.size(); i++) {
    if (i) {
      cout << " ";
    }
    cout << a[i] + 1;
  }
  cout << '\n';
  exit(0);
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    b[i]--;
  }
  if (k == 1) {
    output(a);
  }
  vector<int> A = inv(a);
  vector<int> B = inv(b);
  vector<int> bABa = mul(b, mul(A, mul(B, a)));
  vector<int> AbaB = mul(A, mul(b, mul(a, B)));

  vector<int> l[6];
  l[0] = b;
  l[1] = mul(b, A);
  l[2] = mul(b, mul(A, B));
  l[3] = mul(bABa, B);
  l[4] = mul(bABa, mul(a, B));
  l[5] = mul(bABa, mul(b, mul(a, B)));

  vector<int> f = power(AbaB, (k - 2) / 6);
  f = mul(l[(k - 2) % 6], f);
  f = mul(power(bABa, (k - 2) / 6), f);
  output(f);
  return 0;
}


Measured memory_bytes: 8184
// AOJ 2818: Imagawayaki Man
// 2017.11.23 bal4u@uu

#include <stdio.h>

#define N 10000
int p[N+N+2];
int a[N+1];

int main()
{
	int n, i, j, x;

	scanf("%d", &n);
	for (i = 2; i <= n; i++) {
		printf("? 1 %d\n", i), fflush(stdout);
		scanf("%d", a+i);
		if (a[i] == 1) j = i;
	}
	p[N] = 1, p[N-1] = j;
	for (i = 2; i <= n; i++) {
		if (i == j) continue;
		if      (p[N-a[i]]) p[N+a[i]] = i;
		else if (p[N+a[i]]) p[N-a[i]] = i;
		else {
			printf("? %d %d\n", j, i), fflush(stdout);
			scanf("%d", &x);
			if (x < a[i]) p[N-a[i]] = i;
			else          p[N+a[i]] = i;
		}
	}
	printf("!");
	for (i = 0; !p[i]; i++);
	for (j = 0; j < n; j++) printf(" %d", p[i++]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 3660
#include <stdio.h>

#define N 10


int main(void){
  int x, y, s, p[N][N];
  int i, j, zero = 0, Imax = 0;

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      p[i][j] = 0;
    }
  }
  while(scanf("%d,%d,%d", &x, &y, &s) != EOF){
    switch(s){
    case 3:
      if(x+2 < N)  p[y][x+2]++;
      if(x-2 >= 0) p[y][x-2]++;
      if(y+2 < N)  p[y+2][x]++;
      if(y-2 >= 0) p[y-2][x]++;
    case 2:
      if(x+1<N && y+1<N)   p[y+1][x+1]++;
      if(x+1<N && y-1>=0)  p[y-1][x+1]++;
      if(x-1>=0 && y+1<N)  p[y+1][x-1]++;
      if(x-1>=0 && y-1>=0) p[y-1][x-1]++;
    case 1:
      if(x+1 < N)  p[y][x+1]++;
      if(x-1 >= 0) p[y][x-1]++;
      if(y+1 < N)  p[y+1][x]++;
      if(y-1 >= 0) p[y-1][x]++;
      p[y][x]++;
    }
  }
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(p[i][j] == 0)  zero++;
      if(Imax < p[i][j])  Imax=p[i][j];
    }
  }
  printf("%d\n%d\n", zero, Imax);
  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

#define WIDTH 10
#define HEIGHT 10

int field[ WIDTH + 4 ][ HEIGHT + 4 ];
const int dx[ 3 ][ 4 ] = { { -1, 0, 1, 0 }, { -1, 1, -1, 1 }, { -2, 0, 2, 0 } };
const int dy[ 3 ][ 4 ] = { { 0, -1, 0, 1 }, { -1, -1, 1, 1 }, { 0, -2, 0, 2 } };

int main( void ) {
	int i, j, x, y, size, white, max;

	while ( scanf( "%d,%d,%d", &x, &y, &size ) == 3 ) {
		x += 2;
		y += 2;

		field[ x ][ y ]++;

		for ( i = 0; i < size; i++ )
			for ( j = 0; j < 4; j++ )
				field[ x + dx[ i ][ j ] ][ y + dy[ i ][ j ] ]++;
	}

	white = max = 0;
	for ( y = 2; y < HEIGHT + 2; y++ )
		for ( x = 2; x < WIDTH + 2; x++ )
			if ( !field[ x ][ y ] )
				white++;
			else if ( max < field[ x ][ y ] )
				max = field[ x ][ y ];

	printf( "%d\n%d\n", white, max );

	return 0;
}

Measured memory_bytes: 600
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <bitset>
#include <array>
#include <set>
#include <string>

#include <iterator>
#include <algorithm>
#include <numeric>

#include <ios>
#include <sstream>
#include <iostream>
#include <fstream>


#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define range(i,m,n) for(int i=m, i<n;i++)
#define each(i,n) for(auto i:n)
#define all(i) i.begin(),i.end()

#define makevv(i,j,k,l,m) vector<vector<i>> j(k,vector<i>(l,m))

using vi=std::vector<int>;
using vvi=std::vector<vi>;


template <typename T>
std::string printItr(T b, T e, std::string delim=" ")
{
    std::stringstream ss;
    std::ostream_iterator<decltype(*b)> out_it(ss, delim.c_str());
    std::copy(b,e - 1, out_it);
    ss<<*(e-1);
    return ss.str();
}
using namespace std;

int main(void){/*
    makevv(int,v,4,4,0);
    rep(i,4){
        iota(all(v[i]),i*4);
    }
    each(p,v){
        cout<<printItr(all(p),"+")<<"="<<accumulate(all(p),0)<<endl;
    }
    vi nv(3,0);
    each(&n,nv){
        n++;
    }
    cout<<printItr(all(nv))<<endl;
    each(n,nv){
        n++;
    }
    cout<<printItr(all(nv),",")<<endl;*/
    string s;
    cin>>s;
    cout<<s.substr(0,s.size()-8);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int n, v;

int main(){
    vector<double> h;
    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> v;
        h.push_back(v);
    }

    sort(h.begin(), h.end());

    for(int i = 1; i < n; i++){
        h[i] = (h[i] + h[i-1])/2;
    }

    cout << h[n-1];







}


//g++ -std=c++14 comp.cpp; ./a.exe


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, K, M;
string S[MAX_N];

void solve() {
	string str;
	cin >> str >> K;
	N = sz(str);
	rep(i, 0, N) {
		string tmp = "";
		for(int j = 0; i + j < N && j < 5; j++) {
			tmp += str[i + j];
			S[M++] = tmp;
		}
	}
	sort(S, S + M);
	unique(S, S + M);
	// debug(vector<string>(S, S + M));
	cout << S[K - 1] << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 2944
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <list>
#include <math.h>
#include <string.h>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define INF (1LL<<60)
#define int long long
#define ll long long
#define mod 1000000007



signed main(){

	int N;
	vector<int> h;
	cin >> N;
	for (int i = 0; i<N; i++){
		int t; cin >> t;
		h.push_back(t);
	}

	int ans = 0;
	while (true){
		int f = 0;
		while (h[f] == 0){
			f++;
			if (f == N) goto last;
		}
		int g = f;
		while (g<N && h[g]>0) g++;
		for (int i = f; i < g; i++) h[i]--;
		ans++;
	}
last:
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

vector<ll>calc_divisor(ll n) {
	vector<ll>res;
	for (ll i = 1LL; i*i <= n; ++i) {
		if (n%i == 0) {
			res.push_back(i);
			ll j = n / i;
			if (j != i)res.push_back(j);
		}
	}
	sort(res.begin(), res.end());
	return res;
}
int main() {
	int N, M;
	cin >> N >> M;
	vector<ll>div = calc_divisor(M);
	ll res = 1;
	for (ll i = 0; i < div.size(); ++i) {
		if (div[i] * N <= M) {
			res = max(res, div[i]);
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






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


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int x, y, z ;
  cin >> x >> y >> z ;
  cout << z <<" " << x <<" " << y <<endl ;
  
  
  
  return 0 ;
}




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

int main(){
  int64_t a,b,c,d;
  cin >> a >> b >> c;
  d=c-a-b;
  if((d>0)&&(d*d>4*a*b)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;

ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}

const int N = 1e6+9;
// int a[N];

signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);    
    int n; cin >> n;
    vector<pair<int, int>> a(n);
    vector<int> v;
    for(int i = 0; i < n; i++) {
    	cin >> a[i].ft >> a[i].sd;
    	v.pb(i);
    }
    ld dist = 0;
    int k = 0;
    do {
    	for(int i = 0; i < n-1; i++) {
    		int x = (a[v[i]].ft - a[v[i+1]].ft);
    		int y = (a[v[i]].sd - a[v[i+1]].sd);
    		dist += sqrt(1.*x*x + y*y);
    	}
    	k++;

    } while(next_permutation(v.begin(), v.end()));
    cout << fixed << setprecision(20) << dist / k << endl;
    
    
    


    return 0;
    
}


Measured memory_bytes: 256
def main():
    from fractions import gcd
    a = int(input())
    l = list(map(int,input().split()))



    def lcm(a,b):
        return a*b//gcd(a,b)
    A= 1
    MOD = 10**9+7
    ans = 0
    t = 1
    for i in l:
        t = t* i //gcd(t,i)
    for i in l:
        ans +=t//i
    ans %=MOD
    print(ans)
main()

Measured memory_bytes: 6100
/*
Dont BLUNDER
*/
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize ("-ffloat-store")
#pragma GCC optimization ("unroll-loops")
//for n2 loops
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


 */
//#define d long double
#define int long long
#define pii pair<int,int>
#define pb push_back
#define endl '\n'
#define pi acos(-1)

#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod = 998244353;
int const mod1 = 1000000007;
#define l first
#define r second
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// * Using PBDS *
/*typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
               os; */



int modexp(int x, int n) {
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
	}
	else {
		return (modexp((x * x) % mod, n / 2) % mod);
	}
}

int modinv(int n)
{
	return modexp(n, mod - 2);
}

int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}
bool comp(pii a, pii b) {
	return a.second < b.second;

}
struct hash_pair {

	size_t operator()(const pair<int, int>& p) const
	{

		return ((  p.second ^ p.first) << 32);
	}
};
int r, c, k;
int arr[3001][3001];
int dp[3001][3001][4];

int go(int x, int y, int rowtaken) {
	//cout << x << " " << y << " " << rowtaken << endl;
	if (rowtaken > 3) {
		return -100000000000000;
	}
	if (x > r || y > c)
		return 0;
	if (dp[x][y][rowtaken] >= 0)
		return dp[x][y][rowtaken];

	if (arr[x][y] > 0 && rowtaken < 3) {

		int op1 = arr[x][y] + go(x, y + 1, rowtaken + 1);

		int op2 = arr[x][y] + go(x + 1, y, 0);
		int op3 = go(x, y + 1, rowtaken);
		int op4 = go(x + 1, y, 0);
		dp[x][y][rowtaken] = max(max(op1, op2), max(op3, op4));
		return dp[x][y][rowtaken];




	}
	else {

		int op3 = go(x, y + 1, rowtaken);
		int op4 = go(x + 1, y, 0);
		dp[x][y][rowtaken] = max(op3, op4);
		return dp[x][y][rowtaken];


	}





}




signed main()
{
	haha
// #ifndef ONLINE_JUDGE

// 	freopen("inp.txt", "r", stdin);

// 	freopen("out1.txt", "w", stdout);
// #endif
	cin >> r >> c >> k;
	init(arr, 0);
	for (int i = 0; i < k; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		arr[a][b] = c;
	}
	for (int i = 0; i <= r; i++) {
		for (int j = 0; j <= c; j++) {
			for (int k = 0; k <= 3; k++) {
				dp[i][j][k] = -1;
			}
		}
	}

	cout << go(1, 1, 0);


}

Measured memory_bytes: 355820
#include<bits/stdc++.h>
using namespace std;
int t,n,m,a[200005],l,r,i,f[200005],p;
bool check(int y)
{
	for(i=1;i<=2*n-1;++i)
		if(a[i]<=y)
			f[i]=0;
		else
			f[i]=1;
	if(f[n]==f[n+1]||f[n]==f[n-1])
		return f[n];
	for(i=n;i<2*n-1;++i)
		if(f[i]==f[i+1])
			break;
	int ansr=i;
	for(i=n;i>1;--i)
		if(f[i]==f[i-1])
			break;
	int ansl=i;
	if(ansl==1&&ansr==2*n-1)
		return f[n]^(n&1)^1;
	if(f[ansl]==f[ansr])
		return f[ansl];
	if(n-ansl<ansr-n)
		return f[ansl];
	else
		return f[ansr];
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<=2*n-1;++i)
		scanf("%d",&a[i]);
	l=1,r=2*n-1;
	while(l<r)
	{
		int mid=l+r>>1;
		if(check(mid))
			l=mid+1;
		else
			r=mid;
	}
	cout<<l;
}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }

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

int32_t main(){
  DESYNC;
  int n, k;
  cin >> n >> k;
  int a[n], f[n];
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<n; i++) cin >> f[i];

  sort(a, a+n);
  sort(f, f+n, greater<int>());

  int l = 0, r = (int)(1e13);
  int ans = -1;
  while(l <= r){
    int m = (l+r)>>1;
    
    //check
    bool ok = false;
    int cnt = 0;

    for(int i=0; i<n; i++){
      int t = a[i]*f[i];
      int need = t - m;
      if(need <= 0) continue;
      cnt += (need + f[i]-1)/f[i];
    }

    if(cnt <= k) ok = true;

    if(ok){
      ans = m;
      r = m-1;
    }
    else l = m+1;
  }

  cout << ans << endl;
}




Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define pob pop_back
#define ff first
#define ss second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define debug(x) cout << x << endl;
#define int long long
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
/* 	1) order_of_key (k) : Number of items strictly smaller than k .
	2) find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace __gnu_pbds;
using namespace std;
using LD = long double;

const int N = 1e6+1;
const int mod = 1e9+7;
const int INF = 1e18;
int row[8] = {1,1,0,-1,-1,-1,0,1};
int col[8] = {0,-1,-1,-1,0,1,1,1};

void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int i = 0,j = s.length() - 1;
	int cnt = 0;
	while(i < j) {
		if(s[i] == 'W' and s[j] == 'R') {
			cnt++;
			swap(s[i],s[j]);
			i++;
			j--;
		} 
		if(s[i] == 'R')
			i++;
		if(s[j] == 'W')
			j--;
	}
	cout << cnt;
}
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t = 1,i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 3708
#include<stdio.h>
int main()
{
  int a, b, c, s,f, d;
  scanf("%d %d %d", &a, &b, &c);
  for (s=a;s <= b;s++){
    f=c%s;
    if(f == 0){
      d = d + 1;
        }
  }
  printf("%d\n", d);
  return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (!(line = br.readLine()).equals("0")) {
			char[] octs = Integer.toOctalString(Integer.parseInt(line))
					.toCharArray();
			for (int i = 0; i < octs.length; i++) {
				if (octs[i] >= '4')
					octs[i]++;
				if (octs[i] >= '6')
					octs[i]++;
			}
			System.out.println(new String(octs));
		}
	}
}

Measured memory_bytes: 32152
#素数列挙
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

q = int(input())
l = []
r = []
for i in range(q):
    L,R = map(int,input().split())
    l.append(L)
    r.append(R)

p = primes(max(r))
cnt = [0 for i in range(max(r)+1)]
for i in p:
    if (i + 1) // 2 in p:
        cnt[i]+=1

for i in range(1,len(cnt)):
    cnt[i]+=cnt[i - 1]

for i in range(q):
    print(cnt[r[i]] - cnt[l[i] - 1])

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

typedef long long ll;

const int MOD=1e9+7;

int N;
ll arr[22][22];
ll dp[22][1<<22];

ll solve(ll i,ll mask)
{
    ll &ret=dp[i][mask];
    if(ret!=-1)return ret;
    if(i==N)return 1LL;
    ret=0;
    for(ll j=0;j<N;j++){
        if(!(mask&(1<<j))&&arr[i][j])
           ret+=solve(i+1,mask|(1<<j));
    }
    return ret=ret%MOD;


}

int main()
{
    cin>>N;
    for(int i=0;i<N;i++)
        for(int j=0;j<N;j++)
            cin>>arr[i][j];
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,0);
}


Measured memory_bytes: 721152
import sys
import itertools
bbn=1000000007
	
#+++++

def iii(a,b):
	for i,j in zip(a,b):
		if i != j:
			return False
	return True
		
def main():
	n = int(input())
	al = list(map(int, input().split()))
	bl = list(map(int, input().split()))
	cl=al[:]
	cl.sort()
	p=0
	q=0
	i=0
	for ii in itertools.permutations(cl):
		i+=1
		if iii(ii, al):
			p=i
		if iii(ii,bl):
			q=i
		
	print(abs(p-q))
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

class Main{
	public static void main(String args[]){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			while(true){
					int n = Integer.parseInt(br.readLine());
					if(n == 0) return;

					String strs[] = br.readLine().split(" ");
					int num = (n * (n-1)) / 2;
					int sum = 0;
					for(int i = 0; i < num; i++){
						sum += Integer.parseInt(strs[i]);
					}
					sum = sum / (n - 1);
					System.out.println(sum);
			}
		} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
		}
	}
}

Measured memory_bytes: 31196
a = input().split()
H = int(a[0])
W = int(a[1])

ans = []
for i in range(H+2):
 ans.append([])
 for j in range(W+2):
   ans[i].append(0)

S = []
S.append([])
for j in range(W+2):
   S[0].append('.')
for i in range(H):
  s = input()
  s = list(s)
  s.insert(0,'.')
  s.append('.')
  S.append(s)
S.append([])
for j in range(W+2):
   S[-1].append('.')

for i in range(H+2):
  if((i != 0)and(i != H+1)):
   for j in range(W+2):
    if((j != 0)and(j != W+1)):
      if(S[i][j] == '#'):
        ans[i][j] = '#'
      else:
       if(S[i-1][j] == '#'):#上
        ans[i][j] += 1
       if(S[i+1][j] == '#'):#下
        ans[i][j] += 1
       if(S[i][j+1] == '#'):#右
        ans[i][j] += 1
       if(S[i][j-1] == '#'):#左
        ans[i][j] += 1 
       if(S[i-1][j+1] == '#'):#右上
        ans[i][j] += 1
       if(S[i-1][j-1] == '#'):#左上
        ans[i][j] += 1
       if(S[i+1][j+1] == '#'):#右下
        ans[i][j] += 1
       if(S[i+1][j-1] == '#'):#左下
        ans[i][j] += 1
        
for i in range(H+2):
  if((i != 0)and(i != H+1)):
   ans[i].pop(0)
   ans[i].pop(-1)
   for j in range(W):
    ans[i][j] = str(ans[i][j])
   print(''.join(ans[i]))




Measured memory_bytes: 3192
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  ll N,A,B;
  cin >> N >> A >> B;
  if(abs(A-B)%2==0){
    cout << "Alice" << endl;
  }
  else{
    cout << "Borys" << endl;
  }
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
ll X[101010];
ll Y[101010];
ll XS,YS,XS2,YS2;
ll mo=1000000007;


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,N) cin>>X[i];
	FOR(i,M) cin>>Y[i];
	
	for(i=N-1;i>=0;i--) {
		(XS2 += XS-X[i]*(N-1-i))%=mo;
		(XS+=X[i])%=mo;
	}
	for(i=M-1;i>=0;i--) {
		(YS2 += YS-Y[i]*(M-1-i))%=mo;
		(YS+=Y[i])%=mo;
	}
	cout<<XS2*YS2%mo<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 1792
#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 main(){

	int K,S;
	scanf("%d %d",&K,&S);

	int ans = 0;

	for(int x = 0; x <= min(S,K); x++){
		for(int y = 0; y <= min(S,K); y++){
			if(x+y > S)break;
			int z = S-(x+y);
			if(z <= K){

				ans++;
			}
		}
	}

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

	return 0;
}


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

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

    int n = pow(2, S.length()-1);
    ll eqs[n];

    REP(i, n)
    {
        eqs[i] = 0;
        ll tmp = S[0]-'0';
        FOR(j, 1, S.length())
        {
            if ((i >> (j-1)) & 1)
            {
                eqs[i] += tmp;
                tmp = S[j]-'0';
            }
            else
                tmp = tmp*10+(S[j]-'0');
        }
        eqs[i] += tmp;
    }

    ll ret = 0;
    REP(i, n) ret += eqs[i];

    cout << ret << endl;
    return 0;
}

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

public class Main{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        
        int n = in.nextInt();
        int taro_point = 0, hana_point = 0;
        for(int i = 0; i < n ; i++){
            int compared = in.next().compareTo(in.next());

            if(compared == 0){
                taro_point++;
                hana_point++;
            }
            else if(compared > 0) taro_point += 3;
            else hana_point += 3;
        }

        System.out.printf("%d %d\n", taro_point, hana_point);
    }
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll ans=0;
  rep(i,s.size()) if(s[i]=='2') ans++;
  cout<<ans<<endl;
}

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

using ll=long long;
using namespace std;

#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int a, b, c;
    int ans = 0;
    cin >> a >> b >> c;
    for (int i = a; i <= b; i++){
        if(c%i == 0){
            ans++;
        }
    }
    say(ans)
}


Measured memory_bytes: 3172
n = int(input())
s = list(input() for _ in range(n))
d = {}
for i in range(n):
    if s[i] in d:
        d[s[i]] += 1
    else:
        d[s[i]] = 1

m = max(d.values())
l=[]
for i in d:
    if d[i] == m:
        l.append(i)
for i in sorted(l):
    print(i)

Measured memory_bytes: 38580