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

int main() {

	int N;
	cin >> N;

	string A, B, C;
	cin >> A >> B >> C;

	int t = 0;

	for (int i = 0; i < N; i++) {
		if (A[i] == B[i] && A[i] == C[i]) {
			t = t;
		}
		else if (A[i] == B[i]) {
			C[i] = A[i];
			t++;
		}
		else if (A[i] == C[i]) {
			B[i] = A[i];
			t++;
		}
		else if (B[i] == C[i]) {
			A[i] == B[i];
			t++;
		}
		else {
			B[i] = A[i];
			t++;
			C[i] = A[i];
			t++;
		}
	}

	cout << t << endl;

	return 0;
}

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

int main()
{
	int n = 0, m = 0;
	cin >> n >> m;
	int **vec_A = new int*[n], *vec_b = new int[m], *vec_c = new int[n];
	for (int i = 0; i < n; i++)	vec_A[i] = new int[m];
	for (int j = 0; j < n; j++){
		for (int k = 0; k < m; k++){
			cin >> vec_A[j][k];
		}
	}
	for (int i = 0; i < m; i++) cin >> vec_b[i];
	for (int i = 0; i < n; i++){
		vec_c[i] = 0;
		for (int j = 0; j < m; j++){
			vec_c[i] += vec_A[i][j] * vec_b[j];
		}
	}
	for (int i = 0; i < n; i++) cout << vec_c[i] << endl;
	return 0;
}

Measured memory_bytes: 1228
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int d[]=sc.nextIntArray(n);
        int c=d[0], r=0, ans=0;
        for (int i = 1; i < d.length; i++) {
			if(c>=d[i]) {
				r++;
			} else {
				r=0;
			}
			ans=max(r,ans);
			c=d[i];
		}
        
        out.println(ans);
     	out.flush();
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x, y;
//	P(int  x, int y) {
//	  this.x=x;
//	  this.y=y;
//	}
//}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//    	if(a==p.a) return b-p.b;
//        return -p.a+a;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 40092
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x; 
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x; 
        return true;
    }
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    int x, y; cin >> x >> y;

    const string YES="Yes";
    const string NO = "No";

    if (y - 2*x < 0) {
        cout << NO << endl;
        return;
    } else if (y - 4*x > 0) {
        cout << NO << endl;
        return;
    } else {
        FOR(i, 0, x+1) {
            if (y == 2*i + 4*(x-i)){
                cout << YES << endl;
                return;
            }
        }
   }
    cout << NO << endl;
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

int main()
{
    string s;
    cin >> s;
    for(int i = s.length() - 1; i >= 0; i--){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1172
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A_Frog1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ');
            var h = new int[100010];

            for (int i = 0; i < N; i++)
            {
                h[i] = int.Parse(input[i]);
            }

            var dp = new int[100010];
            for (int i = 0; i < 100010; i++)
            {
                dp[i] = int.MaxValue;
            }
            dp[0] = 0;
            dp = GiveInDP(dp, h, N);


            Console.WriteLine(dp[N - 1]);
        }

        public static int Chmin(int a, int b)
        {
            return a > b ? a = b : a;
        }

        /// <summary>
        /// 貰うDP
        /// </summary>
        /// <param name="dp"></param>
        /// <param name="h"></param>
        /// <param name="N"></param>
        /// <returns></returns>
        public static int[] GiveOutDP(int[] dp, int[] h, int N)
        {
            for (int i = 1; i < N; i++)
            {
                dp[i] = Chmin(dp[i], dp[i - 1] + Math.Abs(h[i - 1] - h[i]));
                if (i > 1)
                {
                    dp[i] = Chmin(dp[i], dp[i - 2] + Math.Abs(h[i - 2] - h[i]));
                }
            }
            return dp;
        }

        /// <summary>
        /// 配るDP
        /// </summary>
        /// <param name="dp"></param>
        /// <param name="h"></param>
        /// <param name="N"></param>
        /// <returns></returns>
        public static int[] GiveInDP(int[] dp, int[] h, int N)
        {
            for (int i = 0; i < N; i++)
            {
                dp[i + 1] = Chmin(dp[i + 1], dp[i] + Math.Abs(h[i + 1] - h[i]));
                dp[i + 2] = Chmin(dp[i + 2], dp[i] + Math.Abs(h[i + 2] - h[i]));
            }
            return dp;
        }
    }
}


Measured memory_bytes: 16864
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());

    let (w, h, n) = (io.read::<i64>(), io.read::<i64>(), io.read::<i64>());

    let mut mn2 = w;
    let mut mx1 = 0i64;
    let mut mx3 = 0i64;
    let mut mn4 = h;
    for _ in 0..n {
        let (x, y, a) = (io.read::<i64>(), io.read::<i64>(), io.read::<i64>());
        match a {
            1 => mx1 = max(mx1, x),
            2 => mn2 = min(mn2, x),
            3 => mx3 = max(mx3, y),
            _ => mn4 = min(mn4, y),
        }
    }
    if mx1 < mn2 && mx3 < mn4 {
        io.writeln((mx1 - mn2) * (mx3 - mn4));
    } else {
        io.writeln(0);
    }
}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  int p[n+1];
  for(int i=1;i<=n;++i){
    int v;
    cin>>v;
    p[v]=i;
  }
  set<int>s{0,n+1};
  long long a=0;
  for(int i=1;i<=n;++i){
    auto it=s.lower_bound(p[i]);
    long long l=*it--;
    long long r=*it;
    a+=(r-p[i])*(p[i]-l)*i;
    s.insert(p[i]);
  }
  cout<<a<<'\n';
}

Measured memory_bytes: 10496
#include<stdio.h>

int main(){
  int i, n, id, id_, max, max_;
  scanf("%d", &n);

  for(i=0; i<n; ++i){
    scanf("%d %d", &id_, &max_);

    if(i == 0 || max < max_){
      id = id_;
      max = max_;
    }else if(max == max_ && id > id_){
      id = id_;
    }
  }

  printf("%d %d\n", id, max);
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstdlib>
#include <cmath>

typedef long long ll;

#define reps(i, s, e) for (ll i = s; i < e; ++i)
#define rep(i, n) reps(i, 0, n)
#define rreps(i, s, e) for (ll i = e-1; i >= s; --i)
#define rrep(i, n) rreps(i, 0, n)

const ll LL_INF = 1LL<<60;

template <class T> inline void chmin(T& a, T b) {if (a > b) {a = b;}}
template <class T> inline void chmax(T& a, T b) {if (a < b) {a = b;}}

using namespace std;

template<class T> inline void sw(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

template<class T> inline ll selection_sort(vector<T>& a) {
    ll cnt = 0;
    ll n = a.size();
    rep(i, n-1) {
        ll argmin = i;
        reps(j, i+1, n) {
            if (a[j] < a[argmin]) argmin = j;
        }
        if (argmin != i) {
            sw<T>(a[i], a[argmin]);
            cnt++;
        }
    }
    return cnt;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll cnt = selection_sort(a);
    rep(i, n) {
        cout << a[i];
        if (i != n-1) cout << " ";
        else cout << "\n";
    }
    cout << cnt << endl;
}


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

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    vector<int> q(n);
    for (int i = 0; i < n; i++) cin >> q[i];
    int ans = 0;
    for (int l = 0; l <= k; l++) {
        for (int r = 0; r <= k - l; r++) {
            if (l + r > n) continue;
            int d = k - l - r;
            int cur = 0;
            vector<int> s;
            for (int i = 0; i < l; i++) {
                cur += q[i];
                s.push_back(q[i]);
            }
            for (int i = n-r; i < n; i++) {
                cur += q[i];
                s.push_back(q[i]);
            }
            sort(s.begin(), s.end());
            for (int i = 0; i < d; i++) {
                if (i >= s.size()) break;
                if (s[i] > 0) break;
                cur -= s[i];
            }
            ans = max(ans, cur);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,c,d;
int main(){
	cin>>n>>a>>b>>c>>d;
	for(int i=0;i<n;i++){if(c*(n-i-1)-d*i<=b-a&&d*(n-i-1)-c*i>=b-a){puts("YES");return 0;}}
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
    int a[5];
    int b,b_b=10;
    int last;
    int val; 
    int time=0;

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

    for(int i=0;i<5;i++){
        b = a[i]%10;
        if((b_b > b) && (b != 0)){
            b_b = b;
           last = 10 - b;
           }
           }

    for(int i=0;i<5;i++){
        val = a[i] % 10;
        if(val == 0){
            val = 0;
        }else{
            val = 10 - val;
            }
        val = a[i] + val;

        time = time + val;
        }

        time = time - last;
        cout << time << endl;

return 0;
        }


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

ll f(ll a, ll b) {
  if (a == 0) return 0;
  return b - 1 - (a - 1) % b;
}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];

  vector<ll> num_push(n, 0);
  num_push[n-1] = f(a[n-1], b[n-1]);
  ll sum_push = num_push[n-1];
  for (int i = n-2; i >= 0; --i) {
    a[i] += sum_push;
    num_push[i] = f(a[i], b[i]);
    sum_push += num_push[i];
  }
  cout << sum_push << endl;
  return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

void solve(){
	int n;
	cin >> n;
	cout << max(0, (n - 1) / 2);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())      
uf = UnionFind(N)
  
for i in range (0, M):
	A, B = map(int, input().split())
	uf.union(A-1, B-1)
    
C = []
for i in range (0, N):
	C.append(uf.size(i))

print(max(C))

Measured memory_bytes: 22316
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main(){
  string s;
  ll n,ans=0,cun;
  cin>>n>>s;
  for(ll i=1;i<n;i++){
    cun = 0;
    for(char c='a';c<='z';c++){
      bool a = false,b = false;
      for(ll j=0;j<i;j++){
        if(s[j]==c){
          a = true;
        }
      }
      for(ll j=i;j<n;j++){
        if(s[j]==c){
          b = true;
        }
      }
      if(a && b){
        cun++;
      }
    }
    ans = max(ans,cun);
  }
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int sum,a,b;
	while(cin>>a>>b){
		int count=1;
		sum=a+b;
		while(sum>=10){
			sum/=10;
			count++;
		}
		cout<<count<<endl;
	}
	return 0;
}

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

using namespace std;

using LL = long long;

int main() {
	
	LL a, b, c, k;
	cin >> a >> b >> c >> k;

	LL ans = 0;

	ans += min(a, k);
	k -= a;
	k -= b;

	if (k > 0) {
		ans -= k;
	}

	cout << ans << '\n';
 


	return 0;	
}


Measured memory_bytes: 3644
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve();

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

void solve() {
  string A, B;
  cin >> A >> B;

  if (A.size() > B.size()) {
    cout << "GREATER" << endl;
  } else if (A.size() < B.size()) {
    cout << "LESS" << endl;
  } else if (A > B) {
    cout << "GREATER" << endl;
  } else if (A < B) {
    cout << "LESS" << endl;
  } else {
    cout << "EQUAL" << endl;
  }
}


Measured memory_bytes: 256
import sys
N, Y = map(int, input().split())

if N*10000 < Y:
    print('-1 -1 -1')
    sys.exit()

for i in range( min(Y//10000, N) + 1):
    for j in range( min((Y-10000*i)//5000, N-i) +1):
        if 10000*i + 5000*j + 1000*(N-i-j) == Y:
            print(i, j, N-i-j)
            sys.exit()

print('-1 -1 -1')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;

int N;
int T[110];
int M;
int P, X;

signed main()
{
    cin >> N;
    int sum = 0;
    for (int i=1; i<=N; i++) {
        cin >> T[i];
        sum += T[i];
    }
    cin >> M;
    REP(i,M) {
        cin >> P >> X;
        cout << sum + (X - T[P]) << endl;
    }
}


Measured memory_bytes: 256
n, m, l = map(int, raw_input().split())
a = []
for _ in range(n):
	a.append(map(int, raw_input().split()))
b = []
for _ in range(m):
	b.append(map(int, raw_input().split()))

c = [[0 for j in range(l)] for i in range(n)]
for i in range(n):
	for j in range(l):
		for k in range(m):
			c[i][j] += a[i][k]*b[k][j]
	print ' '.join(map(str, c[i]))

Measured memory_bytes: 5364
/*
 *Author - Abhas Jain
 */
 
#include <bits/stdc++.h>
 
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define endl '\n'
#define pb push_back
 
 
typedef long long ll;
typedef long double ld;
 
using namespace std;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
 
const ld PI = 3.141592653589793;
const ll INF = 9223372036854775807ll;
const ll mod = 1e9 + 7;
 
void solve() 
{
    int n;
    cin >> n;
    vector<int> a(n + 1, 0);
    vector<int> b(n + 1, 0);
    int count = 0;
    for (int i = 1; i <= n; ++i) {
    	cin >> a[i];
    }
    for (int i = n; i >= 1; --i) {
    	int c = 0;
    	for (int j = 2; i * j <= n; ++j) {
    		c += b[i * j];
    	}
    	c %= 2;
    	if (c == a[i]) {
    		b[i] = 0;
    	} else {
    		b[i] = 1;
    		count++;
    	}
    }
    cout << count << endl;
    for (int i = 1; i <= n; ++i) {
    	if (b[i]) cout << i << " ";
    }
    cout << endl;
}
 
int main( )
{   
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    solve();
    return 0;
}

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

int main() {

    int N;
    cin >> N;

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

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

    cout << d[N/2] - d[N/2 - 1] << endl;

    return 0;
}


Measured memory_bytes: 892
<?php
list($n, $m) = explode(" ", trim(fgets(STDIN)));
 
for($i = 1; $i <= sqrt($m); $i++){
    if($m % $i == 0){
        $f[] = $i;
        $f[] = $m / $i;
    }
}
sort($f);
$max = 0;
foreach($f as $F){
    if($F <= $m/$n){
        $max = max($max, $F);
    }
}
echo $max;

Measured memory_bytes: 4728
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    int N,Ma,Mb;
    cin>>N>>Ma>>Mb;
    vector<int> a(N),b(N),c(N);
    REP(i,N){
        cin>>a[i]>>b[i]>>c[i];
    }
    auto dp=make_vec<int>(41,401,401);
    REP(i,41){
        REP(j,401){
            REP(k,401){
                dp[i][j][k]=INF;
                if(j==0&&k==0) dp[i][j][k]=0;
            }
        }
    }

    REP(i,N){
        REP(j,401){
            REP(k,401){
                dp[i+1][j][k]=dp[i][j][k];
                if(j-a[i]>=0&&k-b[i]>=0) dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j-a[i]][k-b[i]]+c[i]);
            }
        }
    }

    int ans=INF;
    REP(i,40){
        REP2(j,1,401){
            REP2(k,1,401){
                if(Mb*j==Ma*k){
                    ans=min(ans,dp[N][j][k]);
                }
            }
        }
    }
    if(ans==INF){
        cout<<-1<<endl;
    }else{
        cout<<ans<<endl;
    }
    

}

Measured memory_bytes: 27264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    ll x,y; cin>>x>>y;
    ll res=1;
    while(x*2<=y){
        x*=2; res++;
    }
    cout<<res<<endl;
    return 0;
}

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

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[][] graph = new int[n][n];
      String[] vInfo;
      int degree;

      for(int i=0,v=0; i<n; i++) {
        vInfo = br.readLine().split(" ");
        degree = Integer.parseInt(vInfo[1]);
        for(int j=0,k=2; j<degree; j++) {
          v = Integer.parseInt(vInfo[k++]);
          graph[i][--v] = 1;
        }
      }

      StringBuilder buf = new StringBuilder(n*n);
      for (int[] vertex : graph) {
        for (int v : vertex) {
          buf.append(v).append(" ");
        }
        buf.setLength(buf.length()-1);
        buf.append("\n");
      }

      System.out.print(buf);
    }
    catch (IOException e) {
      System.err.println(e);
    }
  }
}


Measured memory_bytes: 25368
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>
#define fr first
#define se second

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=200000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


unordered_map<ll,int> my;
int main()
{
  finp;
  my.reserve(1 << 18);
  my.max_load_factor(0.5);

  int n;
  cin>>n;
  my[0] = 1;
  ll curr = 0;
  ll ans = 0;
  afor(i,1,n)
  {
    ll val;
    cin>>val;
    curr+=val;
    ans+= my[curr];
    my[curr]++;
  }
  cout<<ans;
  
return 0;
}

Measured memory_bytes: 11136
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        List<Integer> b = new ArrayList<>();
        for(int i = 0;i < n;i++){
            a.add(sc.nextInt());
            b.add(sc.nextInt());
        }

        int ans = 0;
        for(int i = 0;i < n;i++){
            if(a.get(i) >= h && b.get(i) >= w){
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 26580
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


void solve(long long a, long long b){
	string s, r;
	REP(i, a) s += to_string(b);
	REP(i, b) r += to_string(a);
	vector<string> res(2);
	res[0] = s;
	res[1] = r;
	ASC(res);
	cout << res[0] << "\n";
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<cctype>
#include<ctime>

using namespace std;

typedef long long ll;
ll n=50;
int main()
{
    ll k;
    ll i=0;
    scanf("%lld",&k);
    printf("50\n");
    while(n--)
    {
        printf("%lld",49-i+((49-i+k)/50));
        i++;
        if(n)
            printf(" ");
        else
            printf("\n");
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())

al = []
for i in range(n):
	al.append(int(input()) - 1)

checker = {}
nxt = 0
count = 0
while(True):
    checker.setdefault(nxt, False)
    if nxt == 2 - 1:
        break
    elif not checker[nxt]:
        checker[nxt] = True
        count += 1
        nxt = al[nxt]
    else:
        count = -1
        break
    
print(count)


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

int main() {
    vector<int> vec(3);
    rep(i, 3) {
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end());
    if (vec[0] == vec[1] ^ vec[1] == vec[2]) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;

const int INF = 1e9;

struct Node {
    int vertex;
    int dist;
    
    Node(int vertex, int dist):vertex(vertex), dist(dist){}
    
    bool operator<(const Node& other) const {
        return dist > other.dist;
    }
};

struct Edge {
    int from, to;
    int weight;
    Edge(int from, int to, int weight):from(from), to(to), weight(weight){}
    
    int other(int u) {
        return from == u? to: from;
    }
};

struct Prim {
    int n;
    vector<Edge> edges;
    vector<vector<int>> g;
    vector<int> dists;
    
    Prim(int n):n(n) {
        g.assign(n + 1, vector<int>());
        dists.assign(n + 1, INF);
    }
    
    void addEdge(int from, int to, int w) {
        edges.push_back(Edge(from , to, w));
        g[from].push_back(edges.size() - 1);
        g[to].push_back(edges.size() - 1);
    }
    
    int solve(int s) {
        priority_queue<Node> q;
        vector<bool> visited(n + 1, false);
        dists[s] = 0;
        q.push(Node(s, 0));
        ll total = 0;
        while (!q.empty()) {
            Node u = q.top(); q.pop();
            if (visited[u.vertex]) {
                continue;
            }
            visited[u.vertex] = true;
            
            total += u.dist;
            
            for (int edgeId : g[u.vertex]) {
                Edge edge = edges[edgeId];
                int v = edge.other(u.vertex);
                if (!visited[v] && edge.weight < dists[v]) {
                    dists[v] = edge.weight;
                    q.push(Node(v, dists[v]));
                }
            }
        } 
        return total;
    }
    
};

int main() {
    int v, e;
    cin >> v >> e;
    Prim d(v);
    for (int i = 0; i < e; i++) {
        int from, to, w;
        cin >> from >> to >> w;
        d.addEdge(from, to, w);
    }
    int ans = d.solve(0);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 6120
from sys import exit
from collections import defaultdict as dd
h, w, m = map(int, input().split())

#dic[row, col] -> set(ids)
h_dic = dd(int)
w_dic = dd(int)
spot = set()

for i in range(m):
    h_c, w_c = map(int, input().split())
    h_dic[h_c] += 1
    w_dic[w_c] += 1
    spot.add((h_c, w_c))
#print(h_dic, w_dic)

#H_lis -> [i, num_spot(int)]
max_h_num = 0
for key, val in h_dic.items():
    max_h_num = max(max_h_num, val)
max_w_num = 0
W_lis = []
for key, val in w_dic.items():
    max_w_num = max(max_w_num, val)


#print(H_lis, W_lis)
#print(max_h)

ans = 0
max_h_lis = [key for key in h_dic if h_dic[key] == max_h_num]
max_w_lis = [key for key in w_dic if w_dic[key] == max_w_num]
for i in max_h_lis:
    for j in max_w_lis:
        if (i, j) not in spot:
            print(max_h_num + max_w_num)
            exit()
else:
    print(max_h_num + max_w_num - 1)

"""    
max_counter = 0
for i in h_dic.keys():
    for j in w_dic.keys():
        counter = len(h_dic[i] | w_dic[j])
        #print(i, j, h_dic[i] | w_dic[j],counter)
        max_counter = max(max_counter, counter)
print(max_counter)

"""

Measured memory_bytes: 185164
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

array<int, 4> dy{-1, 1, 0, 0}, dx{0, 0, -1, 1};
array<int, 6> A{3, 5, 6, 9, 10, 12};
struct Solution {
    int h, w, cnt;
    vector<vector<int>> G, used;
    Solution(int h, int w) : h(h), w(w), G(h, vector<int>(w, 0)), used(h, vector<int>(w, 0)), cnt(0) {};

    void dfs(int y, int x, int &cnt2){
        used[y][x] = 1;
        cnt2++;
        for (int k = 0; k < 4; ++k) {
            if(G[y][x] & (1 << k) && !used[y+dy[k]][x+dx[k]]){
                dfs(y+dy[k], x+dx[k], cnt2);
            }
        }
    }
    bool rec(int y, int x){
        if(y == h){
            for (int i = 0; i < h; ++i) {
                for (int j = 0; j < w; ++j) {
                    used[i][j] = 0;
                }
            }
            for (int i = 0; i < h; ++i) {
                for (int j = 0; j < w; ++j) {
                    if(G[i][j]){
                        int c = 0;
                        dfs(i, j, c);
                        return c == cnt;
                    }
                }
            }
            return false;
        }
        if(!G[y][x]){
            if(y && G[y-1][x] & 2) return false;
            if(x && G[y][x-1] & 8) return false;
            if(rec(y+(x == w-1), (x+1)%w)) return true;
        }else {
            for (int k = 0; k < 6; ++k) {
                if(y && ((G[y-1][x] >> 1)^A[k])&1) continue;
                if(x && ((G[y][x-1] >> 3)^(A[k] >> 2))&1) continue;
                if(!y && A[k]&1) continue;
                if(y == h-1 && A[k]&2) continue;
                if(!x && A[k]&4) continue;
                if(x == w-1 && A[k]&8) continue;
                G[y][x] = A[k];
                if(rec(y+(x == w-1), (x+1)%w)) return true;
            }
            G[y][x] = 1;
        }
        return false;
    }
};

void solve(int w, int h){
    Solution S(h, w);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> S.G[i][j];
            S.G[i][j] ^= 1;
            S.cnt += S.G[i][j];
        }
    }
    puts((S.rec(0, 0)) ? "Yes" : "No");
}

int main() {
    int w, h;
    while(cin >> w >> h, w){
        solve(w, h);
    }
    return 0;
}


Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    if(n > k) cout << x * k + (n - k) * y << endl; 
    else cout << x * n << endl;
    return 0;
}

Measured memory_bytes: 3680
while True :
    (a, op, b) = [int(i) if i.isdigit() else i for i in input().split()]
 
    if op == '?' :
        break
    elif op == '+' :
        print(a + b)
    elif op == '-' :
        print(a - b)
    elif op == '*' :
        print(a * b)
    elif op == '/' :
        print(a // b)

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

int n, k;
double divi;
double x, modify, sum;
P a;
priority_queue<P> que;

int main() {
  cin >> n >> k;
  vector<double> v(n);
  rep (i, n) {
    cin >> v[i];
  }
  sum = 0;
  rep (i, n) {
    sum += v[i];
  }
  rep (i, n) {
    divi = (k * v[i]) / sum;
    divi = floor(1+divi);
    que.push(make_pair(v[i]/divi, (int)divi));
    modify += divi - 1;
  }
  k -= modify;
  rep (i, k) {
    a = que.top();
    que.pop();
    a.first *= a.second;
    a.second++;
    a.first /= a.second;
    que.push(a);
  }
  a = que.top();
  cout << (int)ceil(a.first) << endl;
  return 0;
}


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

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static string Solve(string S, string T)
        {
            int N1 = S.Length;
            int N2 = T.Length;
            var list = new List<string>();
            for (int i = 0; i + N2 <= N1; ++i)
            {
                if (Enumerable.Range(0, N2).All(j => S[i + j] == '?' || S[i+ j] == T[j]))
                {
                    string s = S.Substring(0, i) + T + S.Substring(i + N2, N1 - N2 - i);
                    list.Add(s.Replace('?', 'a'));
                }
            }
            return (list.Count > 0) ? list.Min() : "UNRESTORABLE";
        }
        static void Main(string[] args)
        {
            string S = Read();
            string T = Read();
            Console.WriteLine(Solve(S, T));
        }
    }
}


Measured memory_bytes: 13408
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,x,y;
	cin>>n>>x>>y;
	vector<int> ans(n-1,0);
	rep1(i,n){
		for(int j=i+1;j<=n;j++){
			ans.at((min(abs(x-i)+abs(y-j)+1,j-i))-1)++;
		}
	}
	rep(i,n-1)cout<<ans.at(i)<<endl;;
}

Measured memory_bytes: 256
fn main() {
    let numbers = read();
    let iter: Vec<&str> = numbers.split_whitespace().collect();

    let a:i32 = iter[0].parse().unwrap();
    let b:i32  = iter[1].parse().unwrap();

    println!("{}", if ((a * b)%2 == 0) {
        "Even"
    } else {
        "Odd"
    });
}

fn read() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s);
    s.to_string()
}

Measured memory_bytes: 4352
import sys
input = sys.stdin.readline 
H, W, K = map(int, input().split())
dp = [[-1]*(W+1) for _ in range(H+1)]


def barcnt(n):
    if n == 0:
        return 1
    elif n == 1:
        return 1
    elif n == 2:
        return 2
    elif n == 3:
        return 3
    elif n == 4:
        return 5
    elif n == 5:
        return 8
    elif n == 6:
        return 13
    elif n == 7:
        return 21
    else:
        return 0
    
def f(H, K):
    if K < 1 or K > W:
        return 0
    else:
        if dp[H][K] != -1:
            return dp[H][K]
        elif H == 1:
            if K == 1:
                dp[H][K] = barcnt(W-1)
                return dp[H][K]
            elif K == 2:
                dp[H][K] = barcnt(W-2)
                return dp[H][K]
            else:
                dp[H][K] = 0
                return 0
        else:
            dp[H][K] = f(H-1, K-1)*barcnt(max(0, K-2))*barcnt(max(0, W-K))
            dp[H][K] += f(H-1, K)*barcnt(max(0, K-1))*barcnt(max(0, W-K))
            dp[H][K] += f(H-1, K+1)*barcnt(max(0, K-1))*barcnt(max(0, W-K-1))
            dp[H][K] %= 10**9+7
            return dp[H][K]

print(f(H, K))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define MOD (int)(1e9+7)
#define INF 123456789
#define MAX 12

int n, m;
int temp[MAX][MAX];

int hoge(int flag[MAX][MAX],int ii, int jj){
  bool f = false;
  int count = 0;

  if(flag[ii][jj] == true) return 0;
  if(temp[ii][jj] != 0) flag[ii][jj] = true;
  else return 0;

  //cout<<ii<<" "<<jj<<" "<<temp[ii][jj]<<endl;
  
  queue<pair<int,int>> Q;
  Q.push(make_pair(ii,jj));
  
  while(!Q.empty()){
    pair<int,int> p = Q.front(); Q.pop();
    int y = p.first, x = p.second;
    //cout<<"+++++"<<temp[y][x] <<" "<<temp[ii][jj]<<endl;
    if(temp[y][x] == temp[ii][jj]){
      count++;//cout<<ii<<" "<<jj<<" "<<y<<" "<<x<<" "<<temp[y][x]<<endl;
    }
    for(int i = -1; i <= 1; i++){
      for(int j = -1; j <= 1; j++){
	if(j == i*-1) continue;//cout<<ii<<" "<<jj<<" "<<ny<<" "<<nx<<" "<<temp[ny][nx]<<endl;
	//cout<<i<<" "<<j<<endl;
	int ny = y + i, nx = x + j;
	if(!(1 <= ny && ny <= n && 1 <= nx && nx <= ny))continue;
	if(flag[ny][nx] == true) continue;
	if(temp[y][x] == temp[ny][nx]){//cout<<ii<<" "<<jj<<" "<<ny<<" "<<nx<<" "<<temp[ny][nx]<<endl;
	  flag[ny][nx] = true;
	  Q.push(make_pair(ny,nx));
	} else if(temp[ny][nx] == 0){
	  //cout<<ii<<" "<<jj<<" "<<ny<<" "<<nx<<" 0"<<endl;
	  f = true;
	}
      }
    }
  }
  //cout<<"count "<<ii<<" "<<jj<<" "<<count<<endl; 
  if(temp[ii][jj] == m){
    if(!f)return count*-1;
  }else {
    if(!f)return count;
  }
  return 0;
}




int huga(){
  int flag[MAX][MAX] = {};
  int count = 0;
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= i; j++){
      count += hoge(flag,i,j);
    }
  }
  return count;
}

int main(){
  
  while(true){
    int ans = INF*-1;
    vector<pair<int,int>> ve;
    cin>>n>>m;
    if(!n&&!m)break;
    for(int i = 1; i <= n; i++){
      for(int j = 1; j <= i; j++){
	cin>>temp[i][j];
	if(temp[i][j] == 0) ve.push_back(make_pair(i,j));
      }
    }
    for(pair<int,int> y : ve){
      temp[y.first][y.second] = m;
      ans = max(huga(),ans);
      temp[y.first][y.second] = 0;
    }

    cout<<ans<<endl;
  }

  return 0;
}



Measured memory_bytes: 3056
#include<stdio.h>

int main(){
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    if(A>B, A>C){
        printf("%d", A*10+B+C);
    }else if(B>A && B>C){
        printf("%d", B*10+A+C);
    }else{
        printf("%d", C*10+A+B);
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
string s;
int main(){
	cin >> s;
	if(s.find("RRR")!= string::npos )cout << "3" << endl;
	else if(s.find("RR") != string::npos) cout << "2" << endl;
	else if(s.find("R") != string::npos) cout << "1" << endl;
	else cout << "0" << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#define NUMBER 100

void print_array(int array[],int num){
	int i;
	
	for(i = 0; i < num - 1; i++)
		printf("%d ", array[i]);
	
	//スペースを出力したくないので最後の要素だけfor文外で出力
	printf("%d\n", array[i]);
}

int bubbleSort(int array[],int num){
	int cnt = 0;
	int j;
	int flag = 1;
	while(flag){
		flag = 0;
		for(j = num - 1; j >= 1; j--){
			if(array[j] < array[j-1]){
				int temp = array[j];
				array[j] = array[j-1];
				array[j-1] = temp;
				flag = 1;
				cnt++;
			}
		}
	}
	return cnt;
}

int main(void){
	int array[NUMBER];
	int num, i, n;
	
	scanf("%d", &num);
	
	for(i = 0; i < num; i++){
		//配列を入力
		scanf("%d", &array[i]);
	}
	//バブルソート
	n = bubbleSort(array, num);
	
	print_array(array, num);
	
	printf("%d\n", n);
	
	return 0;
}


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

using namespace std;

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

    int l , r;
    cin >> l >> r;

    r = min(r , l + 2019);

    int mn = 1e9;
    for (int i = l ;i < r ;i++)
        for (int j = i + 1 ;j <= r ;j++)
            mn = min(1ll * mn , (i * 1ll * j) % 2019);

    cout << mn;
}

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

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

    vector<int> vec(N);

    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;

        vec.at(i) = x;
    }

    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());

    int sum_Alice = 0, sum_Bob = 0;

    if (N % 2 == 0) {
        for (int i = 0; i < N/2; i++) {
            sum_Alice += vec.at(2*i);
            sum_Bob += vec.at(2*i + 1);
        }
    }
    else {
        vec.push_back(0);
        for (int i = 0; i < N/2 + 1; i++) {
            sum_Alice += vec.at(2*i);
            sum_Bob += vec.at(2*i + 1);
        }
    }

    int ans;
    
    ans = sum_Alice - sum_Bob;
    cout << ans << endl;
}


Measured memory_bytes: 3588
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (group, sort, sortOn)

main :: IO ()
main = do
  (n : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  ss <- sequence . replicate n $ T.getLine :: IO [T.Text]
  let
    ss' :: [(Int, T.Text)]
    ss' = sortOn (negate . fst) . map ((,) <$> length <*> head) . group . sort $ ss
    m :: Int
    m = fst . head $ ss'
  mapM_ (T.putStrLn . snd) . takeWhile ((== m) . fst) $ ss'

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 99452
def countingSort
    c = Array.new(10001,0)
    $A.each { |e|
        c[e] += 1
    }

    (1..10000).each { |i|
        c[i] += c[i-1]
    }

    $A.reverse_each { |e|
        c[e] -= 1
        $b[c[e]] = e
    }
end
$N = gets.to_i
$A = gets.split.map &:to_i
$b = Array.new($A.size)
countingSort
puts $b * ' '

Measured memory_bytes: 333564