akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
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_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);

int main(){
  int n; cin >> n;
  vector<int> nums(n);
  rep_i(i, n){
    cin >> nums[i];
  }
  vector<int>::iterator it = unique(nums.begin(), nums.end());
  nums.erase(it, nums.end());
  for (vector<int>::iterator itr = nums.begin(); itr != nums.end(); itr++){
    if(itr == nums.begin()){
      cout << *itr;
      continue;
    }
    cout << " " << *itr;
  }
  cout << endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define COUT(x) cout<<(x)<<endl
typedef long long ll;
template<class T> inline void chmax(T& a, T b) {
  if (a < b) a = b;
}

template<class T> inline void chmin(T& a, T b) {
  if (a > b) a = b;
}
const int MOD = 1000000007;
const long long INF = 1LL << 60;

int main() {
  string n;
  cin >> n;
  int s = n.size() - 1;
  if (n[s] == '2' || n[s] == '4' || n[s] == '5' || n[s] == '7' || n[s] == '9') cout << "hon" << endl; 
  else if (n[s] == '0' || n[s] == '1' || n[s] == '6' || n[s] == '8') cout << "pon" << endl;
  else if (n[s] == '3' ) cout << "bon" << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,L,R) for(i=L;i<R;i++)
#define REP(i,N) FOR(i,0,N)
int main(){
  ll A,B,C,D,E,F,i,j,k,p,q=0;cin>>A>>B>>C>>D>>E>>F;p=100*A;
  REP(i,F/(100*A)+1)REP(j,(F-100*A*i)/(100*B)+1){
    ll W=A*i+B*j,L=min(F-100*W,W*E);
    REP(k,L/C+1){
      ll S=C*k+(L-C*k)/D*D;
      if(q*(100*W+S)<p*S)p=100*W+S,q=S;
    }
  }
  cout<<p<<" "<<q<<endl;
  return 0;
}

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

int main() {
  int n, t;
  while (cin >> n, n) {
    int c[10] = {};
    while (n--) {
      cin >> t;
      c[t]++;
    }
    for (int i = 0; i < 10; i++) {
      if (c[i]) {
        string s(c[i], '*');
        cout << s << "\n";
      } else {
        cout << "-\n";
      }
    }
  }
}



Measured memory_bytes: 3072
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

int main() {
    int A, B, C, D;
    cin>>A>>B>>C>>D;
    int tak, ao;
    if(C%B==0) tak = C/B;
    else tak = C/B + 1;
    if(A%D==0) ao = A/D;
    else ao = A/D+1;
    if(tak <= ao) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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 int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main() {
    int n;
    cin >> n;
    vector<mint>a(n);
    rep(i,n) cin >> a[i].x;
    vector<mint>s(n+1);
    rep(i,n) {
        s[i+1] = s[i]+a[i];
    }
    mint ans = 0;
    rep(i,n-1) {
        ans += a[i]*(s[n]-s[i+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6420
#include<iostream>

using namespace std;

const int maxn = 1e5 + 5;

int a[maxn];

int main()
{
	int n;
	scanf("%d",&n);
	int four = 0;
	int two = 0;
	int one = 0;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
		if(a[i] % 4 == 0)
			four++;
		else if(a[i] % 2 == 0)
			two++;
	}
	if(n > 2 * four + two + 1 || (n == 2 * four + two + 1 && two != 0))
		cout << "No" << endl;
	else
		cout << "Yes" << endl; 
	return 0;
}

Measured memory_bytes: 640
N = int(input())
dp = [ [0]*(21) for _ in range(N) ]
lst = list(map(int,input().split()))
dp[0][0] = 1

for i in range(N-1):
  for j in range(21):
    a = lst[i]
    if i==j==a==0:
      dp[i+1][j] = 1
    else:
      if dp[i][j] > 0:
        if j-a >= 0:
          dp[i+1][j-a] += dp[i][j]
        if j+a <= 20:
          dp[i+1][j+a] += dp[i][j]

print(dp[-1][lst[-1]])



Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int H, W, N;

char world[1002][1002];

pair<int, int> S;


vector<pair<int, int> > getNeighbors(pair<int, int> xs){
    vector<pair<int, int> > v;
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    for(int i = 0; i < 4; i++){
        int nx = dx[i] + xs.first;
        int ny = dy[i] + xs.second;
        if (world[nx][ny] != 'X') {
            v.push_back(pair<int, int>(nx, ny));
        }
    }
    return v;
}

bool isAbnormal(vector<vector<bool> >& trails, const pair<int, int>& xs){
    if (trails[xs.first][xs.second]){
        return false;
    }else{
        trails[xs.first][xs.second] = true;
        return true;
    }
}

// pair<int, pair<int, int> > solve(char goal, const vector<pair<int, int> >& v, int depth){
//     vector<pair<int, int> > v2;
//     vector<vector<bool> > trails = vector<vector<bool> >(H + 2, vector<bool>(W + 2, false));

//     for(auto target: v){
//         vector<pair<int, int> > neighbors = getNeighbors(target);
//         for(auto x: neighbors){
//             if (world[x.first][x.second] == goal) {
//                 return pair<int, pair<int, int> >(depth + 1, x);
//             }
//             if (isAbnormal(trails, x)){
//                 v2.push_back(x);
//             }
//         }
//     }
//     return solve(goal, v2, depth + 1);
// }

pair<int, pair<int, int> > solve(char goal, pair<int, int> s){
    vector<pair<int, int> >  v2;
    vector<vector<bool> > trails = vector<vector<bool> >(H + 2, vector<bool>(W + 2, false));

    queue<pair<int, pair<int, int> > > q;
    q.push(pair<int, pair<int, int> >(0, s));

    pair<int, pair<int, int> > target;
    while(true){
        target = q.front();
        q.pop();
        
        int depth = target.first;
        pair<int, int> xy = target.second;
        
        vector<pair<int, int> > neighbors = getNeighbors(xy);
        for(auto neighbor: neighbors){
            int x = neighbor.first;
            int y = neighbor.second;
            if (world[x][y] == goal) {
                return pair<int, pair<int, int> >(depth + 1, neighbor);
            }
            if (isAbnormal(trails, neighbor)){
                q.push(pair<int, pair<int, int> >(depth + 1, neighbor));
            }
        }
    }
}

    


void input(){
    cin >> H >> W >> N;
    for(int i = 1; i < H + 1; i++){
        for (int j = 1; j < W + 1; j++) {
            cin >> world[i][j];
            if (world[i][j] == 'S') {
                S = pair<int, int>(i, j);
            }
        }
    }
}

void init(){
    for (int j = 0; j < W + 2; j++) {
        world[0][j] = 'X';
        world[H + 1][j] = 'X';
    }
    for (int i = 0; i < H + 2; i++) {
        world[i][0] = 'X';
        world[i][W + 1] = 'X';
    }
}

int main (int argc, char* argv[]){
    input();

    init();
    
    int sum = 0;
    for (char g = '1'; g < '1' + N; g++){
        pair<int, pair<int, int> > res = solve(g, S);
        sum += res.first;
        S = res.second;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 4104
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	int n;
	cin >> n;
	ll a[N];
	ll sum_x = 0;
	rep(i, n) {
		cin >> a[i];
		sum_x += a[i];
	}
	ll ans = sum_x;
	for(int i = 1; i < n; i += 2) ans -= 2 * a[i];
	cout << ans << ' ';
	for(int i = 0; i < n - 2; i++) {
		ans = 2 * a[i] - ans;
		cout << ans << ' ';
	}
	ans = 2 * a[n - 2] - ans;
	cout << ans << endl;
}


Measured memory_bytes: 2048
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int nCk(int n, int k) {
    int num = n, dem = 1;
    if (k > n) return 0;
    if (k == n || k == 0) return 1;
    k = min(n, k);
    for (int i = 1; i < k; ++i) {
        num = num * (n-i);
        dem = dem * (i+1);
    }
    return num/dem;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    cout << nCk(m,2) + nCk(n,2)  << '\n';
    return 0;
}



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

public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int n=scan.nextInt();
int m=60000;
int[] f=new int[m];

int i=0;
for(i=0;i<m;i++){
    f[i]=0;
}
int x=0;
int y=0;
int z=0;
int sum=0;
for(x=1;x<100;x++){
    for(y=1;y<100;y++){
        for(z=1;z<100;z++){
            sum=x*x+y*y+z*z+x*y+y*z+z*x;
            f[sum]=f[sum]+1;
        }
    }
}

for(i=1;i<n+1;i++){
    System.out.println(f[i]);
}

}
}

Measured memory_bytes: 39356
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{

    lli n, m;
    cin>>n>>m;
    lli a[n];
    priority_queue<lli> pq;
    for(int i = 0; i < n; i ++) {
        cin>>a[i];
        pq.push(a[i]);
    }

    while(m --) {
        lli x = pq.top();
        pq.pop();
        x /= 2;
        pq.push(x);
    }

    lli ans = 0;
    while(!pq.empty()) {
        lli x = pq.top();
        pq.pop();
        ans += x;
    }

    cout<<ans;

    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


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

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    n--;
    int A;
    cin >> A;
    vector<int> a(n);
    vector<vector<double>> b(3, vector<double>(n));
    REP(i, n) cin >> a[i] >> b[0][i] >> b[1][i] >> b[2][i];
    REP(i, n) b[0][i] /= 100, b[1][i] /= 100, b[2][i] /= 100;

    vector<double> dp(1 << n, -1);
    dp[0] = 1;
    function<double(int)> dfs = [&](int S) {
        if (dp[S] != -1) return dp[S];
        double ret = 0;
        bool ok = true;
        REP(i, n) {
            if ((S >> i & 1) && a[i] > A) ok = false;
        }
        REP(c, 3) {
            double acc = 0.0;
            double draw = 1.0;
            for (int T = S;; T = (T - 1) & S) {
                if (T == S) continue;
                double win = 1.0, lose = 1.0;
                REP(i, n) {
                    if ((S >> i & 1) == 0) continue;
                    win *= ((T >> i & 1) ? b[c][i] : b[(c + 2) % 3][i]);
                    lose *= ((T >> i & 1) ? b[(c) % 3][i] : b[(c + 1) % 3][i]);
                }
                acc += dfs(T) * win;
                draw -= win + lose;
                // acc += exp(dfs(T) + win);
                // draw -= exp(win) + exp(lose);
                if (T == 0) break;
            }
            if (ok) acc += draw;
            ret = max(ret, acc);
        }
        return dp[S] = ret;
    };
    int all = (1 << n) - 1;
    dfs(all);
    // REP(i, 1 << n) cout << i << " " << dp[i] << endl;
    cout << setprecision(20) << dp[all] << endl;
}




Measured memory_bytes: 3356
// https://atcoder.jp/contests/abc043/tasks/arc059_a

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

  int sum = 0;
  vector<int> a;
  REP(i, n)
  {
    int ai;
    cin >> ai;
    sum += ai;
    a.push_back(ai);
  }

  int m = round((double)sum / n);

  int csum = 0;
  REP(i, n)
  {
    csum += powf(m - a[i], 2);
  }

  cout << csum << '\n';

  return 0;
}


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

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

Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<algorithm>
int h,w;
int r[110],c[110];
char s[110][110];
int main()
{
    scanf("%d%d",&h,&w);
    for(int i=1;i<=h;i++)
    {
        scanf("%s",s[i]+1);
        for(int j=1;j<=w;j++)
        {
            if(s[i][j]=='.')
            {
                r[i]++;
                c[j]++;
            }
        }
    }
    for(int i=1;i<=h;i++)
    {
        if(r[i]==w) continue;
        for(int j=1;j<=w;j++)
        {
            if(c[j]==h) continue;
            printf("%c",s[i][j]);
        }
        printf("\n");
    }
}


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

const int mxN = 310;
int N, a[4];
double dp[mxN][mxN][mxN];
bool vis[mxN][mxN][mxN];

double rec(int x, int y, int z) {
	if (x < 0 || y < 0 || z < 0) {
		return 0;
	}
	if (x == 0 && y == 0 && z == 0) {
		return 0;
	}
	if (vis[x][y][z]) {
		return dp[x][y][z];
	}
	vis[x][y][z] = true;
	int rem = x + y + z;
	double val = N + x * rec(x - 1, y, z) + y * rec(x + 1, y - 1, z) + z * rec(x, y + 1, z - 1);
	return dp[x][y][z] = val / rem;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> N;
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		a[x]++;
	}
	double ans = rec(a[1], a[2], a[3]);
	cout << fixed << setprecision(12) << ans;
	
	return 0;
}


Measured memory_bytes: 129228
#include <stdio.h>

int main(void) {
	int a, b, c, i ,j;
	scanf("%d", &j);
	for(i= 1; i <= j ;i++){
		scanf("%d%d%d", &a, &b, &c);
		if (a*a + b*b == c*c || a*a + c*c == b*b || b*b + c*c == a*a){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 1008
N = int(input())
A = list(map(int, input().split()))
 
ans = float("inf")
for i in range(N):
  a = A[i]
  ans_tmp = 0
  while a%2==0:
    a = a//2
    ans_tmp += 1
  ans = min(ans_tmp, ans)
print(ans)

Measured memory_bytes: 9176
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int L = sc.nextInt();
    	sc.close();
    	BigDecimal bd = BigDecimal.valueOf(L);
    	BigDecimal three = BigDecimal.valueOf(3);;
    	BigDecimal ans = bd.divide(three, 7, RoundingMode.HALF_UP);
    	System.out.println(ans.pow(3));
    }

}

Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(1000000)

def check(x, y, flag):
	farm[x][y] = "$"
	if farm[x + 1][y] == flag : check(x + 1, y, flag)
	if farm[x - 1][y] == flag : check(x - 1, y, flag)
	if farm[x][y + 1] == flag : check(x, y + 1, flag)
	if farm[x][y - 1] == flag : check(x, y - 1, flag)
	return 1

while True:
	h,w = map(int, raw_input().split())
	if h == 0 and w == 0 : break

	farm = []
	farm.append(list("$" * (w + 2)))
	for i in range(0, h):
		farm.append(list("$" + raw_input() + "$"))
	farm.append(list("$" * (w + 2)))
	
	count = 0
	for i in range(0, h):
		for j in range(0, w):
			if farm[i + 1][j + 1] != "$":
				count += check(i + 1, j + 1, farm[i + 1][j + 1])
				
	print count

Measured memory_bytes: 14324
n, k = map(int, input().split())
snuke = [0] * (n+1)
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in a:
        snuke[j] += 1

ans = 0
for i in range(1, n+1):
    if snuke[i] == 0:
        ans += 1

print(ans)


Measured memory_bytes: 9188
import sys


class Node:
    __slots__ = ['key', 'parent', 'left', 'right']

    def __init__(self, key):
        self.key = key
        self.parent = self.left = self.right = None


def insert(root, z):
    if root is None:
        return z

    y = None
    x = root
    while x is not None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right

    z.parent = y

    if z.key < y.key:
        y.left = z
    else:
        y.right = z

    return root


def find(node, key):
    if not node:
        return False

    if key < node.key:
        return find(node.left, key)
    if key > node.key:
        return find(node.right, key)

    return True  # key == node.key


def inorder(node):
    if not node:
        return
    yield from inorder(node.left)
    yield node.key
    yield from inorder(node.right)


def preorder(node):
    if not node:
        return
    yield node.key
    yield from preorder(node.left)
    yield from preorder(node.right)


def print_tree(root):
    print(''.join(' ' + str(key) for key in inorder(root)))
    print(''.join(' ' + str(key) for key in preorder(root)))


root = None

n = int(sys.stdin.readline())
for _ in range(n):
    command, *args = sys.stdin.readline().split()
    if command == 'insert':
        root = insert(root, Node(int(args[0])))
    elif command == 'find':
        print('yes' if find(root, int(args[0])) else 'no')
    else:
        print_tree(root)



Measured memory_bytes: 78488
package main

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

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt64() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextInt() int {
	return int(nextInt64())
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	return int(max64(int64(x), int64(y)))
}

func min64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func min(x, y int) int {
	return int(min64(int64(x), int64(y)))
}

func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func abs(x int) int {
	return int(abs64(int64(x)))
}

func joinInt64s(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

func divUp64(x, y int64) int64 {
	return (x + y - 1) / y
}

func divUp(x, y int) int {
	return int(divUp64(int64(x), int64(y)))
}

func gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func gcd(x, y int) int {
	return int(gcd64(int64(x), int64(y)))
}

func lcm64(x, y int64) int64 {
	return x * y / gcd64(x, y)
}

func lcm(x, y int) int {
	return int(lcm64(int64(x), int64(y)))
}

func pow64(x, y int64) int64 {
	return int64(math.Pow(float64(x), float64(y)))
}

func pow(x, y int) int {
	return int(pow64(int64(x), int64(y)))
}

func main() {
	solve()
	writer.Flush()
}

func solve() {
	n := nextInt()
	b := make([]bool, 8)
	others := 0
	colors := 0
	for i := 0; i < n; i++ {
		a := nextInt()
		if a <= 3199 {
			if !b[a/400] {
				b[a/400] = true
				colors++
			}
		} else {
			others++
		}
	}
	out(strconv.Itoa(max(colors, 1)) + " " + strconv.Itoa(colors+others))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  int a,b;
  cin>>a>>b;
  if(a>9||b>9) dame;
  cout<<a*b<<endl;
}

Measured memory_bytes: 3616
function Main(input) {
    input.trim().split("\n").forEach(line => {
        var a = parseInt(line);
        for (var i = 1; i <= 9; i++) {
            if (a % i == 0 && a / i <= 9) {
                console.log("Yes");
                return;
            }
        }
        console.log("No");
    });
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
var globalInput = '';
process.stdin.on('data', function(chunk) {
    globalInput += chunk;
})
process.stdin.on('end', function() {
    Main(globalInput)
})

// Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner=new Scanner(System.in);

		BigDecimal a = BigDecimal.valueOf(scanner.nextLong());
		BigDecimal b = BigDecimal.valueOf(scanner.nextDouble());
		System.out.println(a.multiply(b).longValue());



		scanner.close();

	}

}


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

int main()
{


    string input;
    cin>>input;

    set<char> out;
    for(auto c : input)out.insert(c);

    if(out.size()==2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main(){

  long N, K;
  scanf("%ld", &N);
  if(N == 3 || N == 5 || N == 7){
    printf("YES");
  }else{
    printf("NO");
  }



  return 0;
}

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

int main(void)
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    if((abs(a - b) <= d) && (abs(c - b) <= d) || (abs(a-c) <= d))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
            
}


Measured memory_bytes: 256
#!/usr/bin/env python3


def main():
    X, K, D = map(int, input().split())

    X = abs(X)

    if X - (D * K) >= 0:
        print(X - D * K)
        return

    take = X // D
    rem = K - take
    if rem % 2 == 0:
        print(abs(X - D * take))
    else:
        print(abs(X - D * take - D))

    return


main()


Measured memory_bytes: 9168
n,m=map(int,input().split())

x=[input() for i in range(n)]
y=[input() for i in range(m)]

ans='No'

for i in range(n-m+1):
  for j in range(n-m+1):
    maze=[]
    for k in range(m):
      pin=''
      for l in range(m):
        pin+=x[i+k][j+l]
      
      maze.append(pin)

    if maze==y:
      ans='Yes'
      break


print(ans)

Measured memory_bytes: 72988
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }
        .reduce(::gcd)
    println(a)
}

fun gcd(a: Int, b: Int): Int {
    if (b == 0) return a
    return gcd(b, a % b)
}

Measured memory_bytes: 53484
import Control.Monad
thirdRoot :: Double -> Double
thirdRoot q = head . dropWhile ((> (q*threshold)) . abs . (q -) . (^3))
    $ iterate iter (q/2)
    where
        iter :: Double -> Double
        iter x = x - (x^3-q)/(3*x^2)

threshold = 0.00001

main = do
    n <- readLn
    unless (n == -1) $ do
        print . thirdRoot . fromIntegral $ n
        main

Measured memory_bytes: 4228
#include <stdio.h>

int r, c, p;

int main() {
  while((c = getchar_unlocked()) != '\n') {
    if (c == p) {
      p = 1;
    }
    else {
      r += 1;
      p = p == 1 ? 0 : c;
    }
  }
  printf("%d\n", r);
}


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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> a(N), b(N), c(M), d(M);
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> c[i] >> d[i];
	}
	for (int i = 0; i < N; i++) {
		int res, dis = 1000000000;
		for (int j = 0; j < M; j++) {
			int t = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (t < dis) {
				dis = t;
				res = j + 1;
			}
		}
		cout << res << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>

std::string toStr(int i) {
    std::stringstream ss;
    
    ss << i;
    
    return ss.str();
}

int toInt(const std::string& str) {
    int i;
    
    std::stringstream(str) >> i;
    
    return i;
}


int main() {
    int q, n;
    
    std::cin >> q;
    while(q--) {
        std::cin >> n;
        int cnt = 0;
        
        while(1) {
            if(n < 10) break;
            
            ++cnt;
            auto str = toStr(n);
            
            int max = 0;
            for(unsigned int i = 1; i < str.size(); ++i) {
                max = std::max(
                          toInt(str.substr(0, i)) * toInt(str.substr(i)),
                          max
                      );
            }
            n = max;
        }
        
        std::cout << cnt << std::endl;
    }
}

Measured memory_bytes: 3212
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

typedef long long ll;

int MOD=1000000007;

int main()
{
  string S,T;
  cin >> S >> T;
  ll s[30]={},t[30]={};
  for(ll i=0; i<S.size(); i++){
    s[S[i]-'a']+=1;
    t[T[i]-'a']+=1;
  }
  sort(s,s+26);
  sort(t,t+26);
   for(ll i=0; i<26; i++){
	     if(s[i]!=t[i]){
         cout << "No" << endl;
         return 0;
    }
  }
  cout <<"Yes" << endl;
}

Measured memory_bytes: 776
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
S = [input() for _ in range(H)]

dx = [0, -1, 0, 1]
dy = [1, 0, -1, 0]
search = [[0]*W for _ in range(H)]
max_num = 0
q = deque()

def BFS(point):  # point : (h, w)
	global max_num
	while q:
		point = q.popleft()
		for i in range(4):
			x = point[1] + dx[i]
			y = point[0] + dy[i]
			if 0 <= x <= W-1 and 0 <= y <= H-1 and S[y][x] != "#" and search[y][x] == -1:
				search[y][x] = search[point[0]][point[1]] + 1
				max_num = max(search[y][x], max_num)
				q.append((y, x))

ans = 0
for i in range(H):
	for j in range(W):
		if S[i][j] == "#":
			continue
		q = deque()
		search = [[-1]*W for _ in range(H)]
		search[i][j] = 0
		start = (i, j)
		q.append(start)
		max_num = 0
		BFS(start)
		# print(search)
		ans = max(ans, max_num)
print(ans)


Measured memory_bytes: 5712
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using ll_t = long long;
const int MAXN = 500;

int a[MAXN];
std::vector<int> divisor;

void get_divisor(int x) {
  int sqrt = std::sqrt(x + 0.5);
  for (int i = 1; i <= sqrt; ++i) {
    if (x % i == 0) {
      divisor.emplace_back(i);
      if (x / i != i) divisor.emplace_back(x / i);
    }
  }
  std::sort(divisor.begin(), divisor.end(), [](int a, int b) {
    return a > b;
  });
}

int calc_op_num(int d, int n) {
  std::vector<int> remainder;
  ll_t sum = 0;
  for (int i = 0; i < n; ++i) {
    int r = a[i] % d;
    if (r == 0) continue;
    remainder.emplace_back(r);
    sum += r;
  }
  int zero_num = (int)remainder.size() - sum / d;
  std::sort(remainder.begin(), remainder.end());
  int res = 0;
  for (int i = 0; i < zero_num; ++i) {
    res += remainder[i];
  }
  return res;
}

int solve(int n, int m) {
  int sum = 0;
  for (int i = 0; i < n; ++i) sum += a[i];
  get_divisor(sum);

  for (const auto &d : divisor) {
    if (calc_op_num(d, n) <= m) return d;
  }
  return -1;  // It will never happen
}

int main() {
  int n, m;
  std::cin >> n >> m;
  for (int i = 0; i < n; ++i) std::cin >> a[i];
  std::cout << solve(n, m) << std::endl;
  return 0;
}


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

using namespace std;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}init;
typedef long long LL;
const LL MOD=10007;

struct edge{
    int to;LL cost;
    bool operator<(const edge& o)const {return cost < o.cost;}
    bool operator>(const edge& o)const {return cost > o.cost;}
};

typedef vector<edge> E;
typedef vector<E> Graph;
typedef vector<LL> V;
const LL INF=1e15;
V dijkstra(int s, Graph &g){
    int N=g.size();
    V dist(N,INF);
    dist[s]=0;
    priority_queue<edge,E,greater<edge>> que;
    que.push(edge{s,0});
    while(que.size()){
        auto e=que.top();que.pop();
        if(e.cost>dist[e.to])continue;
        for(auto x:g[e.to]){
            int to=x.to;
            LL cost=x.cost+dist[e.to];
            if(dist[to]>cost){
                dist[to]=cost;
                que.push(edge{to,cost});
            }
        }
    }
    return dist;
}
const int C=1e6;
int main(){
    int N,M;
    cin>>N>>M;
    vector<map<int,int>> s(N);
    vector<int> p(M),q(M),c(M);
    for(int i=0;i<M;i++){
        cin>>p[i]>>q[i]>>c[i];
        p[i]--,q[i]--,c[i]--;
        s[p[i]][c[i]]=0;
        s[q[i]][c[i]]=0;
    }
    int cnt=N;
    for(auto &v:s)for(auto &u:v)u.second=cnt++;
    Graph g(cnt);
    for(int i=0;i<N;i++)
        for(auto &v:s[i]){
            g[i].push_back(edge{v.second,1});
            g[v.second].push_back(edge{i,0});
        }
    for(int i=0;i<M;i++){
        g[s[p[i]][c[i]]].push_back(edge{s[q[i]][c[i]],0});
        g[s[q[i]][c[i]]].push_back(edge{s[p[i]][c[i]],0});
    }
    auto d=dijkstra(0,g);
    if(d[N-1]==INF)cout<<-1<<endl;
    else
        cout<<d[N-1]<<endl;
}


Measured memory_bytes: 77936
N,M,q = map(int,input().split())
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1
    
def score(A):
    tmp = 0
    for ai,bi,ci,di in zip(a,b,c,d):
        if A[bi]-A[ai]==ci:
            tmp += di
    return tmp
    
def dfs(A):
    if len(A)==N:
        return score(A)
    res = 0
    prev_last = A[-1] if len(A)>0 else 0
    for v in range(prev_last,M):
        A.append(v)
        res = max(res,dfs(A))
        A.pop()
    return res
print(dfs([]))

Measured memory_bytes: 74388
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<set>
#include<iomanip>
#include<algorithm>
using namespace std;
 
int main() {
  int n,m,c,sum,cnt;cin >> n >> m >> c;
  sum = 0;
  cnt = 0;
  int b[m];
  for(int p=0;p<m;p++){
      cin >> b[p];
  }

  int a[n+1][m+1];

  for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
          cin >> a[i][j];
      }
  }


  for(int k=0;k<n;k++){
      for(int l=0;l<m;l++){
          sum += a[k][l]*b[l];
      }
      sum += c;
      if(sum>0){
          sum=0;
          cnt = cnt + 1;
      }else{
          sum=0;
          continue;
      }
  }


  cout << cnt << endl;
}

Measured memory_bytes: 256
//
// Created by Tzyark on 2018/9/20.
//
#include <iostream>
using namespace std;
int N, T, A[100001];
int d, ans, mx[100001];
int main() {
    cin >> N >> T;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }
    mx[N] = A[N];
    for (int i = N-1; i >= 1; i--)
        mx[i] = max(mx[i+1], A[i]);
    for (int i = 1; i <= N; i++)
        if (d < mx[i] - A[i]) d = mx[i] - A[i], ans = 1;
        else if (d == mx[i] - A[i]) ans++;
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
using namespace std ; 
int main (){
int n , a , b ;
scanf("%d",&n) ;
switch (n){
case 1 : puts("Hello World") ; break ;
case 2 : scanf("%d%d",&a,&b) ; printf("%d\n",a+b) ; break ; 
}
return 0 ;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> seq(n);
	for(int i=0; i<n; i++)
		cin >> seq[i];
	int i=0, num=1;
	while(true){
		i++;
		while(seq[i-1]==seq[i] && i<n){
			i++;
		}
		if(i==n)
			break;
		else if(seq[i-1]<seq[i]){
			do{
				i++;
			}while(seq[i-1]<=seq[i] && i<n);
			if(i==n)
				break;
			num++;
		}else{
			do{
				i++;
			}while(seq[i-1]>=seq[i] && i<n);
			if(i==n)
				break;
			num++;
		}
	}
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

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

    string s,t;
    cin>>s>>t;
    int from[30],to[30];
    for(int i=0;i<26;i++){
        from[i]=-1;
        to[i]=-1;
    }
    bool f=true;
    for(int i=0;i<s.size();i++){
        int a=s[i]-'a',b=t[i]-'a';
        if(from[a]!=-1 || to[b]!=-1){
            if(from[a]!=b || to[b]!=a)f=false;
        }
        from[a]=b;
        to[b]=a;
    }
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
const int mod = 998244353;
int u[maxn], s[maxn];
int a[maxn], b[maxn], c[maxn];
int val[maxn];
int find(int x){
	if(x == u[x]) return x;
	return u[x] = find(u[x]);
}
void join(int x, int y){
	x = find(x);
	y = find(y);
	if(x^y){
		s[x] += s[y]; 
		s[y] = 0;
		u[y] = x;
	}
}
vector<pair<int,int> > e[maxn];
int main(){
	int n, m; scanf("%d %d", &n, &m);
	for(int i = 0; i < m; i++) scanf("%d %d %d", a + i, b + i, c + i);
	map<int,map<int,int>> rest;
	for(int i = 0; i < m; i++) rest[a[i]][b[i]] = c[i];
	auto get = [&](int i, int j){
		auto it = rest.find(i);
		if(it == rest.end()) return -1;
		auto it2 = it->second.find(j);
		if(it2 == it->second.end()) return -1;
		return it2->second;
	};
	long long pairs = 0;
	int ans = 1;
	for(int i = 1; i <= n; i++) pairs += n - i;
	set<pair<int,int>> seen;
	for(int i = 0; i < m; i++){
		int x = min(a[i], b[i]), y = max(a[i], b[i]);
		if(x == y) continue;
		int vxy = get(x, y), vyx = get(y, x);
		int nv = -1;
		if(vxy != -1 && vyx != -1) nv = (vxy + vyx)%2;
		else if(vxy == -1 && vyx == -1) assert(0);
		if(y - x >= 3 && (nv != -1 && nv != 0)) return !printf("0\n");
		rest[x][y] = nv;
		rest[y][x] = 0;
		seen.insert({x, y});
	}
	pairs -= seen.size();
	memset(val, -1, sizeof(val));
	for(int i = 1; i <= n; i++){
		int vii = get(i, i);
		if(vii != -1) {
			if(val[i] != -1 && val[i] != vii) return !printf("0\n");	
			val[i] = vii;
		}
		if(i + 2 > n) continue;
		int vij = get(i, i + 2);
		if(vij != -1) {
			if(val[i + 1] != -1 && val[i + 1] != vij) return !printf("0\n");
			val[i + 1] = vij;
		}
	}
	for(int i = 1; i <= n; i++) u[i] = i, s[i] = val[i] != -1;
	for(int i = 1; i < n; i++){
		int vij = get(i, i + 1);	
		int vji = get(i + 1, i);
		if(vij != -1 && vji != -1){
			int exp = (vij + vji) % 2;
			if(val[i] != -1 && val[i+1] != -1){
				int is = (val[i] + val[i + 1]) % 2;
				if(exp != is) return !printf("0\n");
			}
			e[i].push_back({i + 1, exp});
			e[i + 1].push_back({i, exp});
		} 
	}
	queue<int> q;
	for(int i = 1; i <= n; i++) if(val[i] != -1) q.push(i);
	while(!q.empty()){
		int cur = q.front(); q.pop();
		for(auto ee : e[cur]){
			int nval = val[cur] ^ ee.second;
			if(val[ee.first] == -1){
				val[ee.first] = nval;
				q.push(ee.first);
			} else if(val[ee.first] != nval) return !printf("0\n");
		}
	}
	int pk = 0;
	for(int i = 1; i <= n; i++) if(val[i] == -1){
		ans = (ans + ans) % mod;
		pk += e[i].size();
	}
	pairs -= pk / 2;
	int p2 = 1, b2 = 2;
	for(; pairs; b2 = 1ll * b2 * b2 % mod, pairs >>= 1) if(pairs&1) p2 = 1ll * p2 * b2 % mod;
	ans = 1ll * ans * p2 % mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 17920
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE Strict #-}
{-# LANGUAGE StrictData #-}
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.List
import Data.Char

main :: IO ()
main = do
    n <- readLn 
    s <- VU.unfoldrN n BS.uncons <$> BS.getLine
    print $ rgb n s 0 (0,0,0) - length [ () | i <- [0..n-3], j <- [1..(n-i-1)`div`2], s VU.! i /= s VU.! (i+j), s VU.! (i+j) /= s VU.! (i+j+j), s VU.! i /= s VU.! (i+j+j)]
    where rgb :: Int -> VU.Vector Char -> Int -> (Int,Int,Int) -> Int
          rgb n s cnt (r,g,b)
              | n == cnt          = r*g*b
              | s VU.! cnt == 'R' = rgb n s (cnt+1) (r+1,g,b)
              | s VU.! cnt == 'G' = rgb n s (cnt+1) (r,g+1,b)
              | s VU.! cnt == 'B' = rgb n s (cnt+1) (r,g,b+1)
              | otherwise         = undefined

Measured memory_bytes: 4112
#include<iostream>
#include<queue>
using namespace std;
#include<stdio.h>
int main(void)
{
	while (1)
	{
		int a, b, i,j, n, x, y, m[18][18] = { 0 }, u= 0;
		pair<int, int> g, h;
		queue<pair<int, int> > q;
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0)
		{
			break;
		}
		for (i = 0; i <= a + 1; i++)
		{
			for (j = 0; j <= b + 1; j++)
			{
				if(i==0||i==a+1||j==0||j==b+1)
				{
					m[i][j] = 1;
				}
			}
		}
		scanf("%d", &n);
		for (i = 0; i < n; i++)
		{
			scanf("%d%d", &x, &y);
			m[x][y] = 1;
		}
		g.first = a;
		g.second = b;
		h.first = 1;
		h.second = 1;
		q.push(h);
		while (!q.empty())
		{
			h = q.front();
			q.pop();
			if (m[h.first + 1][h.second] != 1)
			{
				h.first++;
				q.push(h);
				h.first--;
			}
			if (m[h.first][h.second + 1] != 1)
			{
				h.second++;
				q.push(h);
				h.second--;
			}
			if (h == g)
			{
				u++;
			}
		}
		printf("%d\n", u);
	}
	return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int main() {
  int n;
  cin >> n;
  vl a(n + 1);
  rep (i, n + 1) cin >> a[i];
  vl b(n);
  rep (i, n) cin >> b[i];

  ll ans = 0;
  rep (i, n) {
    if (b[i] <= a[i]) {
      a[i] -= b[i];
      ans += b[i];
    }
    else {
      ans += a[i];
      b[i] -= a[i];
      if (b[i] <= a[i + 1]) {
        a[i + 1] -= b[i];
        ans += b[i];
      }
      else {
        ans += a[i + 1];
        a[i + 1] = 0;
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;

#define LL long long

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

    LL tmp = n / 11;
    LL ans = tmp * 2;
    if (tmp * 11 < n) {
        if (tmp * 11 + 6 >= n) {
            ans++;
        } else {
            ans += 2;
        }
    }

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

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
all = 0
for i in range(n):
    all = all^a[i]
ans = []
for i in range(n):
    ans.append(all^a[i])
for i in range(n):
    ans[i] = str(ans[i])
print(" ".join(ans))

Measured memory_bytes: 114000
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Integer> countWord = new HashMap<>();
        Set<String> results = new TreeSet<>();
        int maxNum = 1;
        for(int i = 0; i < n; i++) {
            String str = sc.next();
            if(countWord.containsKey(str)) {
                int num = countWord.get(str) + 1;
                countWord.put(str, num);
                maxNum = Math.max(maxNum, num);
            }
            else countWord.put(str, 1);
        }
        for(String key : countWord.keySet()) {
            if(countWord.get(key) == maxNum) results.add(key);
        }

        for(String ans : results) System.out.println(ans);
    }
}

Measured memory_bytes: 89768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int i = Integer.parseInt(tokens[1]);

		System.out.println((N - i + 1));
		in.close();
	}
}


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



using namespace std;

int main(){

int n,x,l[n],b;
int s=0;
cin>>n>>x;
for(int i=0;i<n;i++){
    cin>>l[i];

}
int count=1;
//cout<<n<<x<<l[]<<endl;

for(int i=0;i<n;i++){

    s+=l[i];
   // cout<<s<<endl;
        if(s<=x){
            ++count;
  
        }
 }

cout<<count<<endl;
return 0;
}


Measured memory_bytes: 256
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int[] NK = readln.chomp.split.to!(int[]);
  int N = NK[0],
      K = NK[1];
  int[] A = readln.chomp.split.to!(int[]);
  int ans = 1;

  ans += (N - K) / (K - 1);
  if ((N - K) % (K - 1) != 0) {
    ans++;
  }

  writeln(ans);
}


Measured memory_bytes: 4412
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <set>
#include <map>
#include <numeric>

using LL = long long;

int query(int x)
{
    std::cout << x << std::endl;
    std::string s;
    std::cin >> s;
    if (s == "Male")
        return 0;
    else if (s == "Female")
        return 1;
    exit(0);
}

int main()
{
    int n;
    std::cin >> n;
    int x = query(0);
    int l = 1, r = n - 1;
    while (l <= r) {
        int mid = l + r >> 1;
        int z = query(mid);
        if ((mid - l + 1 & 1) ^ x ^ z)
            r = mid - 1;
        else
            l = mid + 1, x = z;
    }
    while (true);
}


Measured memory_bytes: 852
r, c = map(int, input().split())
matrix = [list(map(int, input().split())) for _ in range(r)]
for i in range(r):
    matrix[i].append(sum(matrix[i]))
matrix.append(list(map(sum, zip(*matrix))))
for row in matrix:
    print(' '.join(str(e) for e in row))


Measured memory_bytes: 5700