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

typedef long long ll;

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

    int h,w;cin>>h>>w;
    vector<string> a(h);
    for(int i=0;i<h;i++) cin>>a[i];
    vector<vector<char>> tak(h,vector<char>(w,'.')),aoki(h,vector<char>(w,'.'));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i==0) tak[i][j]='#';
            else if(i!=h-1 &&j==0) tak[i][j]='#';
            else if(i%2==0 && j!=w-1 && i!=h-1) tak[i][j]='#';

            //cout<<tak[i][j];
            if(tak[i][j]=='.') aoki[i][j]='#';
        }
        //cout<<endl;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]=='#'){
                tak[i][j]=aoki[i][j]='#';
            }
        }
    }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<tak[i][j];
        }
        cout<<endl;
    }
    cout<<endl;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<aoki[i][j];
        }
        cout<<endl;
    }
    /*
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(tak[i][j]=='#'&&aoki[i][j]=='#') cout<<'#';
            else cout<<'.';
        }
        cout<<endl;
    }*/
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N; cin >> N;
    vector<int> A(3*N);
    for (int i = 0; i < 3*N; i++) cin >> A[i];
    sort(rbegin(A), rend(A));
    long long sum = 0;
    for (int i = 0; i < N; i++) sum += A[1+2*i];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#define NIL -1
 
typedef struct node{
  int left;
  int right;
  int parent;
}node;
 
int Sibling(int);
int Degree(int);
int Depth(int);
int Height(int);
void printTree(void);
 
node *tree;
int n;
 
int main(){
  int id,left,right,i;
   
  scanf("%d",&n);
   
  tree = (node *)malloc(sizeof(node)*n);
  for(i=0;i<n;i++){
    tree[i].parent = NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&left,&right);
    tree[id].left = left;
    tree[id].right = right;
    tree[tree[id].left].parent = id;
    tree[tree[id].right].parent = id;
  }
 
  printTree();
 
  return 0;
}
 
int Sibling(int c){
  int left,right;
  if(tree[c].parent!=-1){
    left = tree[tree[c].parent].left;
    right = tree[tree[c].parent].right;
 
    if(left!=-1&&c!=left) return left;
    else if(right!=-1&&c!=right) return right;
  }
  return -1;
}
 
int Degree(int c){
  int d=0;
  if(tree[c].left!=-1) d++;
  if(tree[c].right!=-1) d++;
  
  return d;
}
 
int Depth(int c){
  int d=0;
  while(tree[c].parent!=-1){
    c=tree[c].parent;
    d++;
  }
  return d;
}
 
int Height(int c){
  int d=0;
  if(tree[c].left==-1&&tree[c].right==-1) return 0;
  if(tree[c].left==-1) return Height(tree[c].right)+1;
  if(tree[c].right==-1) return Height(tree[c].left)+1;
  if(Height(tree[c].left)<Height(tree[c].right))
    return Height(tree[c].right)+1;
  else return Height(tree[c].left)+1;
  return d;
}
 
void printTree(){
  int i,dep,h;
  for(i=0;i<n;i++){
    dep=Depth(i);
    h=Height(i);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,tree[i].parent,Sibling(i),Degree(i),dep,h);
    if(dep==0) printf("root\n");
    else if(h==0) printf("leaf\n");
    else printf("internal node\n");
  }
 
  return;
}

Measured memory_bytes: 612
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// use std::io::{stdout, Write, BufWriter};
// use std::cmp::{max, min};

fn main() {
    input! {
        n: u64,
        a: u64,
        b: u64
    }
    if a == 0u64 { println!("0") }
    else { println!("{}", (n/(a+b))*a + if n%(a+b) >= a { a } else {n%(a+b)}) }
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main ()
{
	int code, test, key, ans, count=0, tries;
	scanf ("%d %d %d", &test, &code, &key);
	int key1[code];
	for (int k=0; k<code; k++) scanf ("%d", &key1[k]);
	for (int i=0; i<test; i++)
	{
		for (int j=0; j<code; j++)
		{
			scanf ("%d", &tries);
			ans+=(tries*key1[j]);
		}
		if ((ans+key)>0) count++;
		ans=0;
	}
	printf ("%d\n", count);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

int a[5050], b[5050];

signed main()
{ // #define int long long ?????????????????§scanf???????????¨???????????????????????\?????????????????????
    int A, B; cin >> A >> B;

    rep(i, A) {
        cin >> a[i];
    }
    rep(i, B) {
        cin >> b[i];
    }

    // O(AB) ??§???????????§??????

    int ma = 0;

    for (int start = 0; start < B; ++start) {
        int b_pos = start;

        int cnt = 0;

        rep(i, A) {
            if (a[i] == b[b_pos]) {
                cnt++;
                b_pos++;
            }

            if (b_pos >= B) break;
        }

        ma = max(ma, cnt);
    }

    cout << ma << endl;
}

Measured memory_bytes: 3160
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <stdio.h>
#include <random>
#include <ctime>
#include <fstream>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;


const int D = 365;
const int si = 26;
vector<int> c(si);
vector<vector<int>> s(D, vector<int>(si));

struct cand {
    int score;
    int hist[D];
    int cc;
    vector<int> last;
    cand(int _cc) {
        score = 1000000;
        cc = _cc;
        last = vector<int>(si);
    }
};

bool operator<(const cand &left, const cand &right) {
	return left.score < right.score;
}

random_device r;
MaxHeap<cand> ans_heap;
int cc = 0;
const int width = 10, branch = 30, reading = 1;
int times = 1;
cand example(0);

void input() {
    int n; cin >> n;
    rip(i,si,0) {
        cin >> c[i];
        cc += c[i];
    }
    rip(i,D,0) rip(j,si,0) cin >> s[i][j];
}

cand gen_next(cand now, int day) {
	rip(i, reading, 0) {
		int a = r() % si;
        now.hist[day + i] = a;
        now.score += s[day+i][a];
        now.cc += cc-c[a]*(day+i-now.last[a]);
        now.last[a] = day+i;
        now.score -= now.cc;
	}
	return now;
}

void beem(int day) {
	MaxHeap<cand> cand_heap;
	rip(i, width, 0) {
		cand now = ans_heap.top();
		ans_heap.pop();
		rip(j, branch, 0) {
			cand next = gen_next(now, day);
			cand_heap.push(next);
		}
    }
    swap(ans_heap, cand_heap);
}

void output(cand ans) {
    rip(i, D, 0) printf("%d\n", ans.hist[i]+1);
}

int main() {
    input();
	rip(i, width, 0) {
		ans_heap.push(example);
	}
	rip(i, D/reading, 0) {
		beem(i*reading);
		times++;
	}
	output(ans_heap.top());
	// cout << ans_heap.top().score << endl;
}

Measured memory_bytes: 6548
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    if(N < 1000) cout << "ABC" << endl;
    else cout << "ABD" << endl;
    return 0;
}


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

int main(){
    int  a,b,c,d;
    cin >> a >> b >> c >> d;
    int takahashi,aoki;
    if(c > b * (c/b)) takahashi = c / b + 1;
    else takahashi = c / b;
    if(a > d * (a/d)) aoki = a / d + 1;
    else aoki = a / d;
    if (takahashi <= aoki) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 3568
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main(){
	string s, str1, str2;
	int maxn = 0;
	map<string, int> mp;
	while(cin >> s){
		mp[s]++;
		if(mp[s] > maxn){maxn = mp[s];str1 = s;}
		int si1 = s.size();int si2 = str2.size();
		if(si1 > si2){str2 = s;}
	}
	cout << str1 << " " << str2 << endl;
	return 0; 
}

Measured memory_bytes: 3068
module SS = Set.Make(String);;
let () =
  let n = read_int () in
  let s = Array.to_list (Array.init n @@ fun _ -> Scanf.scanf "%s\n" @@ fun s -> s) in
  let ans = List.fold_right SS.add s (SS.empty) in
  print_int (SS.cardinal ans)

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

using namespace std;
using ll = long long;

#define gc getchar
int getint() { unsigned int c; int x = 0; while (((c = gc()) - '0') >= 10) { if (c == '-') return -getint(); if (!~c) exit(0); } do { x = (x << 3) + (x << 1) + (c - '0'); } while (((c = gc()) - '0') < 10); return x; }
int getstr(char *s) { int c, n = 0; while ((c = gc()) <= ' ') { if (!~c) exit(0); } do { s[n++] = c; } while ((c = gc()) > ' ' ); s[n] = 0; return n; }
template<class T> inline bool chmin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<class T> inline bool chmax(T &a, T b) { return a < b ? a = b, 1 : 0; }



int main () {
    const int n = getint();
    const int k = getint();

    map<int, int> cnt;
    for (auto i = 0; i < n; ++i) cnt[getint()]++;

    vector<int> values;
    for (auto& p: cnt) values.emplace_back(p.second);

    sort(values.begin(), values.end(), greater<int>());

    int res = 0;
    for (auto i = k; i < values.size(); ++i) res += values[i];

    cout << res << endl;

    return 0;
}




Measured memory_bytes: 10748
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=10000;
const ll INF=1000000010;
const int MAX=100001;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
   	ll i,o,t,j,l,s,z;
	cin>>i>>o>>t>>j>>l>>s>>z;
	if(i&&j&&l){
		cout<<o+max(3LL+(i-1)/2*2+(j-1)/2*2+(l-1)/2*2,i/2*2+j/2*2+l/2*2)<<endl;
	}else{
		cout<<o+i/2*2+j/2*2+l/2*2<<endl;
	}    
	return 0;
}


Measured memory_bytes: 256
r, g, b, n = list(map(int, input().split()))
ans = 0
for i in range(n//r+1):
  for j in range(n//b+1):
    ij = i*r + j*b
    k = (n-ij)//g
    if not (i==k==j==0) and (k>=0 and (n-ij)%g==0):
      ans += 1
print(ans)

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


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

    if( a == b+c || b == a+c || c == a+b ) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<climits>
#include<cfloat>
#include<cmath>
#include<algorithm>


using namespace std;

double EPS = 1e-10;


double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  bool operator == ( const point &p ) const {
    return abs(x-p.x) < EPS && abs(y-p.y) < EPS;
  }
};

bool cmp_x(const point& p, const point& q){
  if(p.x != q.x)return p.x<q.x;
  return p.y < q.y;
}

bool Binary_search(vector<point>N, point x){
  int l=0,r=N.size(),mid=(l+r)/2;

  while(r-l>1){
    if(N[mid]==x)return true;

    if(x.x < N[mid].x ||(N[mid].x==x.x && x.y < N[mid].y))r=mid;
    else l=mid;

    mid=(l+r)/2;
  } 

  if(N[mid]==x)return true;
  return false;
}

point solve(vector<point> M, vector<point> N){

  for(int i=0; i< N.size(); i++){
    int fg=1;
    for(int j=1; j< M.size(); j++){
      point t=N[i]+M[j]-M[0];
      if(!Binary_search(N,t))break;
      else fg++;
      if(fg==M.size())return N[i]-M[0];
    }
  }
  return M[0];
}

int main(void){
  int n,m;
  point in;
  vector<point>M,N;

  while(cin >> m,m){
    M.clear();
    N.clear();    

    for(int i=0; i< m; i++){
      cin >> in.x >> in.y;
      M.push_back(in);
    }
    
    cin >> n;

    for(int i=0; i< n; i++){
      cin >> in.x >> in.y;
      N.push_back(in);
    }

    sort(N.begin(),N.end(),cmp_x);

    point res=solve(M,N);

    cout << res.x <<" "<< res.y << endl;

  } 

  return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

int main(void)
{
  ll w, a, b;
  cin >> w >> a >> b;
  ll c = max(0LL, (max(a,b) - (min(a, b) + w)));
  cout << c << endl;
}


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

#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

int main() {
    rep(i, 5) {
        int a;
        cin >> a;
        if (a == 0) {
            cout << i + 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3548
n = int(input())
a = list(map(int, input().split()))
k = 0
g = 0
for i in a:
  if(i%4 == 0):g+=1
  if(i%2 == 1):k+=1
#print(g,k)
if(g>=k or (g+1>=k and g+k==n)):print("Yes")
else:print("No")

Measured memory_bytes: 85348
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQUE(c)   sort(ALL((c)));(c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
std::vector<int> prime;
void MakePrime(int n) {
	prime.emplace_back(2);
	for (int i = 3; i <= n; i += 2) {
		bool a = false;
		for (int j = 3; j <= std::sqrt(i); j += 2) {
			if (i%j == 0) {
				a = true;
			}
		}
		if (a == false) {
			prime.emplace_back(i);
		}
	}
}
int main() {
	cin >> n;
	MakePrime(55555);
	int num = 0;
	int cnt = 0;
	int pos = 0;
	while (cnt < n) {
		if (prime[pos] % 5 == 1) {
			if (cnt)cout << " ";
			cout << prime[pos];
			cnt++;
		}
		pos++;
	}
	cout << endl;

}

Measured memory_bytes: 256
s = input()
ans = [0] * len(s)

cnt = 0
for i in range(len(s)):
    if s[i] == "R":
        cnt += 1
    elif cnt > 0 and s[i] == "L":
        ans[i - 1] += (cnt + 1) // 2
        ans[i] += cnt // 2
        cnt = 0

cnt = 0
for i in range(len(s) - 1, -1, -1):
    if s[i] == "L":
        cnt += 1
    elif cnt > 0 and s[i] == "R":
        ans[i + 1] += (cnt + 1) // 2
        ans[i] += cnt // 2
        cnt = 0

print(*ans)

Measured memory_bytes: 6400
import std.stdio, std.string, std.conv;
import std.algorithm, std.array, std.range;
import core.bitop;
auto solve(string s_){
    immutable N = s_.chomp.to!int();
    auto A = readln.split.map!(to!int).array(); A.sort;
    int[int] m;
    foreach(a;A){
        if(a !in m) m[a]=0;
        ++m[a];
    }
    int c=0;
    foreach_reverse(a;A) if(m[a]>0){
        auto t=a+1;
        if((t&t-1)!=0) t=1<<bsr(t)+1;
        t-=a;
        assert(t<=a);
        --m[a];
        if(t in m && m[t]>0){
            --m[t];
            ++c;
        }
    }
    return c;
}
void main(){ for(string s; (s=readln.chomp()).length;) writeln(solve(s)); }

Measured memory_bytes: 25880
#[test]
fn test_solve() {
    assert_eq!(solve("3 3\n.#.\n..#\n#..\n"), "10\n");
    assert_eq!(solve("2 4\n....\n....\n"), "0\n");
    assert_eq!(solve("4 3\n###\n###\n...\n###\n"), "6\n");
    assert_eq!(solve("3 3 ### ### ###"), "0\n");
    assert_eq!(solve("3 3 #.# .#. #.#"), "20\n");
    assert_eq!(solve("3 3 ### #.# ###"), "4\n");
}
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let h: usize = sc.read();
    let w: usize = sc.read();
    let mas: Vec<Vec<char>> = (0..h).map(|_| sc.get().chars().collect()).collect();

    let mut vsd = vec![vec![false; w]; h];
    let mut cnt: u64 = 0;
    for i in 0..h {
        for j in 0..w {
            if !vsd[i][j] {
                vsd[i][j] = true;
                let mut bct = 0;
                let mut wct = 0;
                let mut stk = vec![(i, j)];
                while let Some((i, j)) = stk.pop() {
                    let c = mas[i][j];
                    if c == '#' {
                        bct += 1;
                    } else {
                        wct += 1;
                    }
                    let mut chk = |i: usize, j: usize| {
                        if !vsd[i][j] && mas[i][j] != c {
                            vsd[i][j] = true;
                            stk.push((i, j))
                        }
                    };
                    if i > 0 {
                        chk(i - 1, j)
                    }
                    if i < h - 1 {
                        chk(i + 1, j)
                    }
                    if j > 0 {
                        chk(i, j - 1)
                    }
                    if j < w - 1 {
                        chk(i, j + 1)
                    }
                }
                cnt += bct * wct;
            }
        }
    }

    format!("{}\n", cnt)
}
fn main() {
    let mut buf = String::new();
    use std::io::{Read, Write};
    std::io::stdin().read_to_string(&mut buf).unwrap();
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


Measured memory_bytes: 8444
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <cstdlib>
using namespace std;

// 一行取って、一番初めのTを習得
template <class T> int streamvar(std::istream& in, T& var)
{
    string s;
    if (!in) {
        return 1;
    }
    getline(in, s);
    istringstream is(s);
    is >> var;
    if (is.fail()) 
        return 1;
    return 0;
}
// 一行取って、T vectorに格納する
template <class T> int streamvec(std::istream& in, std::vector<T> &v)
{
    v.clear();
    string s;

    if (!in) 
        return 1;
    getline(in, s);
    if (in.fail()) 
        return 1;
    istringstream is(s);
    while (1) {
        T tmp;
        is >> tmp;
        if (is.fail())
            break;
        v.push_back(tmp);
    }
    return 0;
}

long long gcd(long long a, long long b)
{
    if (!b) return a;
    return gcd(b, a % b);
}

int main(void)
{
    vector<int> v;
    while (!streamvec(cin, v)) {
        cout << gcd(v[0], v[1]) << " " << (long long)v[0] / gcd(v[0], v[1]) * v[1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1232
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define F first
#define S second
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll vis[N],res[N];

int solve() 
{
	//happy coding


	int n;
	cin>>n;
	vi a(n);
	int s = 0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		s ^= a[i];
	}

	for(int i=0;i<n;i++){
		//printf("%d%c",a[i]^=s," \n"[i+1==n]);
		cout<<(a[i]^=s)<<" ";
	}cout<<endl;

	
	return 0;
}
int main(){
	int test = 1;
  	//scanf("%d", &test);
  	while (test--)solve();return 0;
}

Measured memory_bytes: 4028
#include <iostream>

int main() {
int a, b;
std::cin >> a >> b;

if (a == b) {
std::cout << "Draw" << std::endl;
} else if (a == 1 && b > 1) {
std::cout << "Alice" << std::endl;
} else if (a > 1 && b==1) {
std::cout << "Bob" << std::endl;
} else if (a > b) {
std::cout << "Alice" << std::endl;
} else {
std::cout << "Bob" << std::endl;
}
return 0;
}

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

int main(){
    while(1){
        int m,n;
        cin >> m >> n;
        if(m+n==0) break;
        else{
            int MAX=7368791+1;
            bool flag[MAX];
            
            for(int i=0;i<MAX;i++){
                flag[i]=false;
            }
            
            for(int year=m;year<MAX;year++){
                if(!flag[year]){
                    if(n==0){
                        cout << year << endl;
                        break;
                    }else{
                        for(int i=year;i<MAX;i+=year){
                            flag[i]=true;
                        }
                        n--;
                    }
                }
            }
        }
    }
}



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

int main()
{
    int N,ii;
    scanf("%d",&N);
    char *s[51];
    for(ii=0;ii<51;ii++)
    {
        s[ii]=(char*)malloc(sizeof(char)*105);
    }
    char X[105];
    char **p=s;
    int t[51];
    int i;
    for(i=0; i<N; i++,p++)
    {
        scanf("%s",*p);
        scanf("%d",&t[i]);
    }
    scanf("%s",X);
    p=s;
    int sum=0,start=0;
    for(i=0; i<N; i++,p++)
    {
        if(!(strcmp(*p,X)))
        {
            start=i;break;
        }

    }
    for(i=start+1;i<N;i++)
    {
        sum+=t[i];
    }
    printf("%d",sum);



    return 0;
}


Measured memory_bytes: 128
N, x = map(int,input().split())
A = list(map(int,input().split()))

A.sort()
S = 0
c = 0
if sum(A) < x:
    print(N-1)
else:
    for i in A:
        if S + i <= x:
            S += i
            c += 1
        else:
            break
    print(c)


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

long long solve(long long X, long long K, long long D) {
    X = abs(X);
    long long q = X/D, r = X%D; // 地点 r に到達するまで
    if (q >= K) return X - D*K;
    long long rem = K - q; // 残り回数
    if (rem % 2 == 0) return r;
    else return D-r;
}
int main() {
    long long X, K, D;
    cin >> X >> K >> D;
    cout << solve(X, K, D) << endl;
}


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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cout << "vowel" << endl;
  else cout << "consonant" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {

int n;
cin >> n;

vector<int> w(n);       //空のベクトル n個の要素を収容可能
for (int i = 0; i < n; i++) {
    cin >> w[i];     // n-1回要素(＝n個）を入力していく  
}

int min = 1e9;  //最小を定義（1e9は１０億、答えはきっと１０億より小さくなるからminが更新される）
int ans;

for (int i = 0; i < n; i++){
    int l = 0;      //境い目Tとその左にある要素の総和
    int r = 0;      //境い目Tより右にある要素の総和
    for (int j = 0; j < i; j++) l += w[j]; // wをj回足し合わせたものをlと定義
    for (int j = i; j < n; j++) r += w[j]; // wをj回足し合わせたものをrと定義

    // 仮にN=8だとして、境い目がT=4(=i)だとする。　1+2+3+4+5+6+7+8 だったら,
    // 右側は0,1,2,3番目の要素(1+2+3+4)が足される。
    // 左側はiからスタートだから4,5,6,7番目の要素(5+6+7+8)が足される。

    if (abs(l-r) < abs(min)) min = abs(l-r) ; //l-rで最小を更新していく。
}

cout << min << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include <limits.h>
   
#define White 0
#define Gray  1
#define Black 2
#define MAX 101
   
   
int n=0, G[MAX][MAX], d[MAX], clr[MAX], que[MAX], head=0, tail=0;
   
void Enqueue(int);
int Dequeue();
void BFS(int);
  
int main()
{
  int i,j,s,u,r;
  int p=1;
  
  scanf("%d",&n);
  
  for(i=1;i<=n;i++)
    {
    for(j=1; j<=n;j++)
      {
    G[i][j] = 0;
      }
    }
   
  for(i=1;i<=n;i++){
    scanf("%d%d", &u,&r);
    for(j=1;j<=r;j++){
      scanf("%d",&s);
      G[i][s] = 1;
    }
  }
  
  BFS(p);
  for(i=1;i<=n;i++){
    printf("%d %d\n",i, d[i]);
  }
  return 0;
}
 
void Enqueue(int s)
{
  que[tail]=s;
  tail+=1;
}
  
int Dequeue()
{
  int y;
  y = que[head];
  head+=1;
  return y;
} 
  
void BFS(int s)
{
  int x,y;
  for(x=1;x<=n;x++){
    clr[x] = White;
    d[x] = -1;
  }
  clr[s] = Gray;
  d[s] = 0;
  Enqueue(s);
  while(head != tail){
    x = Dequeue();
    for(y=1;y<=n;y++){
      if(clr[y] == White && G[x][y] == 1){
        clr[y] = Gray;
        d[y] = d[x] + 1;
        Enqueue(y);
      }
    }
    clr[x] = Black;
  }
}



Measured memory_bytes: 2128
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# library
# -------------------------------------------------------------
def init_fact(n,mod):
    fact,finv,inv = [1]*n,[1]*n,[1]*n
    for i in range(2,n):
        fact[i] = (fact[i-1]*i) % mod
        inv[i]  = mod - inv[mod%i] * (mod//i)%mod
        finv[i] = finv[i-1] * inv[i] % mod
    return (fact,finv,inv)
 
def nCr(n,r,mod,fact,finv):
    if n<r:
        return 0
    else:
        return fact[n] * (finv[r] * finv[n-r] % mod) % mod

mod = 10**9+7
fact,finv,inv = init_fact(200010,mod)


# -------------------------------------------------------------
# main
# -------------------------------------------------------------

N,M,K = map(int,input().split())

ans = 0
for d in range(1,N):
    t = d * nCr(N*M-2, K-2, mod, fact, finv)
    t %= mod
    t *= (N-d)*M*M
    t %= mod
    ans += t
    ans %= mod
for d in range(1,M):
    t = d * nCr(N*M-2, K-2, mod, fact, finv)
    t %= mod
    t *= (M-d)*N*N
    t %= mod
    ans += t
    ans %= mod

print(ans)

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

bool triangle(long long int a, long long int b, long long int c){
    if ((a!=b && b!=c && a!=c) && (a+b>c && b+c>a && a+c>b)) return true;
    return false;
}
int main() {
	int n;
	cin>>n;
	vector<long long int> arr(n);
	for (int i=0; i<n; i++) cin>>arr[i];
	int count=0;
	for (int i=0; i<n; i++){
	    for (int j=i+1; j<n; j++){
	        for (int k=j+1; k<n; k++){
	            if (triangle(arr[i], arr[j], arr[k])) count++;
	        }
	    }
	}
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 3636
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())
    P = [ int(sys.stdin.readline().rstrip()) for i in range(N)]

    print(sum(P) - max(P)//2)



if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.io.*;
class Main{
	public static void main(String[]args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int i,j,k;
		String[] nm=br.readLine().split(" ");
		int n=Integer.parseInt(nm[0]);
		int m=Integer.parseInt(nm[1]);
		int l=Integer.parseInt(nm[2]);
		
		int[][] A=new int[n][m];
		int[][] B=new int[m][l];
		long[][] C=new long[n][l];
		
		for(i=0;i<n;i++){
			String[] numA=br.readLine().split(" ");
			for(j=0;j<m;j++){
				A[i][j]=Integer.parseInt(numA[j]);
			}
		}
		for(j=0;j<m;j++){
			String[] numB=br.readLine().split(" ");
			for(k=0;k<l;k++){
				B[j][k]=Integer.parseInt(numB[k]);
				for(i=0;i<n;i++){
					C[i][k]+=(A[i][j])*(B[j][k]);
				}
			}
		}
		for(i=0;i<n;i++){
			for(k=0;k<l;k++){
				System.out.print(C[i][k]);
				if(k==l-1){
					System.out.println();
				}
				else{
					System.out.print(" ");
				}
			}
		}
	}
}

Measured memory_bytes: 36028
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>

typedef long long int llint;

int main(void){

  double r;
  std::cin >> r;

  std::cout << r*2*3.1415 << std::endl;

  return 0;
}


Measured memory_bytes: 3788
#include<stdio.h>
#include<math.h>
 
 
 
int main(){
long n,i,N;
double x;
long ans;

scanf("%ld",&n);
ans=n;
x=sqrt(n);
 

 
i=2;
while(i<=x){
  if(n%i==0){
   while(n%i==0){
    n=n/i;
   }
   ans=ans*(i-1)/i;
  }
 i++;
}
 
if(n!=1)ans=ans*(n-1)/n;
printf("%ld",ans);
printf("\n");
 
return 0;
}


Measured memory_bytes: 2100
def main():
    n, t = map(int,input().split())

    lst = [0 for i in range(n)]
    for i in range(n):
        lst[i] = list(map(int,input().split()))

    ans = 10000
    for i in lst:
        if i[1] <= t:
            ans = min(ans,i[0])

    if ans > 9999:
        print("TLE")
    else:
        print(ans)


if __name__ == "__main__":
        main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>0)
	{
		cout<<"Positive";	
	}
	else if(b>0)
	{
		cout<<"Zero";
		
	}
	else if((a&1)^(b&1))
	{
		cout<<"Positive";
	}
	else
	{
		cout<<"Negative"; 
	}
} 

Measured memory_bytes: 256
while True:
    n,m=[int(s)for s in input().split(" ")]
    if n==m==0:break
    map_=[int(input())for i in range(n)]
    dice=[int(input())for i in range(m)]
    pos=0
    for i in range(m):
        pos+=dice[i]
        try:pos+=map_[pos]
        except:pass
        if pos>=n-1:
            print(i+1)
            break

Measured memory_bytes: 7716
def main():
    n, m = map(int, input().split())
    adj = [0] * n
    for _ in range(m):
        a, b = map(int, input().split())
        adj[a-1] += 1
        adj[b-1] += 1
    for i in range(n):
        print(adj[i])

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/* basic header */
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <climits>
#include <float.h>
/* STL */
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <array>
#include <iterator>
/* define */
#define ll long long
#define dou double
#define pb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define init(a,b) fill(begin(a),end(a),b)
#define sot(a,b) sort(a+1,a+1+b)
#define rep1(i,a,b) for(int i=a;i<=b;++i)
#define rep0(i,a,b) for(int i=a;i<b;++i)
#define repa(i,a) for(auto &i:a)
#define eps 1e-8
#define int_inf 0x3f3f3f3f
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lson curPos<<1
#define rson curPos<<1|1
/* namespace */
using namespace std;
/* header end */

int n, k;
double ans = 0;

int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        if (i >= k) ans += 1.0 / n;
        else
        {
            int tmp = i, cnt = 0;
            while (tmp < k) tmp *= 2, cnt++;
            ans += 1.0 / n * pow(0.5, (double)cnt);
        }
    }
    printf("%.9f\n", ans);
    return 0;
}

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

public class Main {

	static int[] S ;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");
		long[] A = new long[Ws.length];
		for (int i = 0; i < Ws.length; i++) {
			A[i] = Long.parseLong(Ws[i]);
		}

		long ans = (long)Math.pow(100, A[0])*A[1];
		if(A[1] ==100){
			ans+=(long)Math.pow(100, A[0]);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21076
#include <iostream>

using namespace std;

int main(void)
{
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int val = A * X + B * Y;
    int minNum = min(X, Y);
    int valtemp = C * minNum * 2;
    valtemp += (X - minNum) * A + (Y - minNum) * B;
    int val2 = max(X, Y) * 2 * C;
    int ans = min(valtemp, min(val, val2));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.io.PrintWriter
import kotlin.math.min

fun StringBuilder.appendln(s: String): StringBuilder = this.append(s + "\n")

fun main() {
    val pw = PrintWriter(System.out)

    var (n, a, b, c) = readInputLine().split(" ").map { it.toInt() }

    val query = Array(n) { readInputLine() }

    val builder = StringBuilder()

    builder.appendln("Yes")
//    pw.println("Yes")

    for (i in 0 until n) {
        when(query[i]) {
            "AB" -> {
                if (a == 0 && b == 0) {
                    println("No")
                    return
                }
                if (a < b || (a == 1 && b == 1 && query[min(i + 1, n - 1)] == "AC")) {
//                    pw.println("A")
                    builder.appendln("A")
                    a++
                    b--
                } else {
//                    pw.println("B")
                    builder.appendln("B")
                    a--
                    b++
                }
            }
            "AC" -> {
                if (a == 0 && c == 0) {
                    println("No")
                    return
                }
                if (a < c || (a == 1 && c == 1 && query[min(i + 1, n - 1)] == "AB")) {
//                    pw.println("A")
                    builder.appendln("A")
                    a++
                    c--
                } else {
//                    pw.println("C")
                    builder.appendln("C")
                    a--
                    c++
                }
            }
            "BC" -> {
                if (b == 0 && c == 0) {
                    println("No")
                    return
                }
                if (b < c || (b == 1 && c == 1 && query[min(i + 1, n - 1)] == "AB")) {
//                    pw.println("B")
                    builder.appendln("B")
                    b++
                    c--
                } else {
//                    pw.println("C")
                    builder.appendln("C")
                    b--
                    c++
                }
            }
        }
    }

    println(builder.toString())

//    pw.flush()
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 65156
#include<bits/stdc++.h>
using namespace std;
int n,m,tot,ans,q;
int a[100],b[100],cz[100],d[100];
vector <int> v;
void rec(int c, int l) {
	if(c==n) {
		int tot = 0;
		int i = 0;
		while(i<q) {
			tot+=(v[b[i]-1]-v[a[i]-1])==cz[i] ? d[i] : 0;
			i++;
		}
		ans = max(tot,ans);
		return;	
	}
	for(int i=l;i<=m;i++) {
		v.push_back(i);
		rec(c+1,i);
		v.pop_back();
	}
}

int main() {
	scanf("%d %d %d",&n,&m,&q);
	int i = 0;
	while(i<q) {
		scanf("%d %d %d %d",&a[i],&b[i],&cz[i],&d[i]);
		i++;
	}
	rec(0,1);
	printf("%d\n",ans);
}

Measured memory_bytes: 3800
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

int gcd(int n, int m) {
    if (n < m) swap(n, m);
    while (m != 0) {
        int r = n % m;
        n = m;
        m = r;
    }
    return n;
}

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

    int n, m;
    cin >> n >> m;

    ll r = 1;
    int k = -1;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        a /= 2;

        int t = a, l = 0;
        for (;; l++) {
            if (t % 2 != 0) break;
            t /= 2;
        }
        if (i == 0) {
            k = l;
        } else {
            if (l != k) {
                cout << 0 << endl;
                exit(0);
            }
        }

        r = r / gcd((int)r, a) * a;
        if (r > m) {
            cout << 0 << endl;
            exit(0);
        }
    }

    cout << (m + r) / (r * 2) << endl;

    //偶奇混じったらアウトっぽいな
    //いや、奇数しか掛けれないから持ってる2の個数が違ったらダメか
    //

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] map = new int[150][150];
		for(int j=0;j<150;++j){
			for(int i=0;i<150;++i){
				if(j<i) map[j][i]=(i+1)*(i+1)+(j+1)*(j+1);
				else map[j][i]=-1;
			}
		}
		while(true){
			int h=sc.nextInt();
			int w=sc.nextInt();
			int max=50000,x=0,y=0;
			if(h==0&&w==0) break;
			for(int j=149;j>=0;--j){
				for(int i=149;i>=0;--i){
					if(!(j==h-1&&i==w-1)){
						if(map[h-1][w-1]<=map[j][i]&&map[j][i]<=max){
							if(map[h-1][w-1]==map[j][i]&&map[j][i]<=max){
								if(h-1<j){
									max=map[j][i];
									x=i+1;
									y=j+1;
								}
							} else {
								if(!(map[j][i]==max&&y<j)){
									max=map[j][i];
									x=i+1;
									y=j+1;
								}
							}
						}
					}
				}
			}
			System.out.println(y+" "+x);
		}
	}
}



Measured memory_bytes: 27936
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))
k = []
s = []
for i in range(M):
    k.append(ks[i][0])
    s.append(ks[i][1:])

A = [i for i in range(1, 11)]

count = 0
for i in range(1 << N):
    B = []
    flag = True
    for j in range(10):
        if (i >> j) & 1:
            B.append(A[j] * ((i >> j) & 1))
        
    for x in range(M):
        c = 0
        for y in range(k[x]):
            if s[x][y] in B:
                c += 1
        if c % 2 != p[x]:
            flag = False
            break
    if flag:
        count += 1
print(count)
            

Measured memory_bytes: 41584
#include <bits/stdc++.h>
using namespace std;
string s, t;
int main()
{
  cin >> s >> t;
  int n = s.size(), ans = 0;
  for (int i = 0; i < n; i+=1) if (s[i] != t[i]) ++ans;
  cout << ans << endl;
}

Measured memory_bytes: 3836
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum int = 0, 0, 0

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	if N == 1 {
		fmt.Println(1.0000000000)
	} else {
		if N%2 == 0 {
			fmt.Println(0.5000000000)
		} else {
			//fmt.Println((float64(N)/2 + 1) / float64(N))
			fmt.Println(math.Ceil(float64(N)/2) / float64(N))
		}
	}
}

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

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; 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
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] > h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(void){
 const int inf = 100000000;


 int n,m;
 cin >> n >> m;

 int a[1000],b[1000],c[1000],dist[100][100];

 for(int i = 0; i < m; ++i){
 cin >> a[i] >> b[i] >> c[i];
 a[i]--,b[i]--;
 }

 for(int i = 0; i < n; ++i){
 for(int j = 0; j < n; ++j){
 if(i==j)
 dist[i][j]=0;
 else
 dist[i][j]=inf;
 }
 }

 for(int i = 0; i < m; ++i){
 dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
 dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]);
 }

 for(int k = 0; k < n; ++k){
 for(int i = 0; i < n; ++i){
 for(int j = 0; j < n; ++j){
 dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
 }
}
 }

 int ans=m;for(int i = 0; i < m; ++i){bool shortest=false;for(int j = 0; j < n; ++j) if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true;if(shortest==true){ ans=ans-1;}} cout << ans << endl;
 }

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

int W, H;

string field[100];

bool visit[100][100];

void dfs(int y, int x) {
	visit[y][x] = true;
	static int dy[4] = {0, 1, 0, -1};
	static int dx[4] = {1, 0, -1, 0};
	char c = field[y][x];

	for(int i = 0; i < 4; i++) {
		int ny = y + dy[i];
		int nx = x + dx[i];
		if(0 <= ny && ny < H && 0 <= nx && nx < W && visit[ny][nx] == false && c == field[ny][nx]) {
			dfs(ny, nx);
		}
	}
}

void pv() {
	cerr << endl;
	cerr << "-----"<< endl;
	for(int y = 0; y < H; y++) {
		for(int x = 0; x < W; x++) {
			cerr << visit[y][x];
		}
		cerr << endl;
	}

	cerr << "-----"<< endl;
}

int main() {
	for(;cin >> H >> W, W || H;) {
		for(int y = 0; y < H; y++)
			cin >> field[y];

		memset(visit, 0, sizeof visit);

		int ans = 0;
		for(int y = 0; y < H; y++) {
			for(int x = 0; x < W; x++) {
				if(visit[y][x] == false) {
					ans++;
					dfs(y, x);
				}
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scan = new Scanner(System.in);
		int n =scan.nextInt();
		
		
		//System.out.println(n);
		
	
		switch(n % 10) {
		
		case 2:
			System.out.println("hon");
			break;
		case 4:
			System.out.println("hon");
			break;
		case 5:
			System.out.println("hon");
			break;
		case 7:
			System.out.println("hon");
			break;
		case 9:
			System.out.println("hon");
			break;
		 
		case 0:
			System.out.println("pon");
			break;
		case 1:
			System.out.println("pon");
			break;
		case 6:
			System.out.println("pon");
			break;
		case 8: 
			System.out.println("pon");
			break;
		
		case 3:
			System.out.println("bon");
			break;
		
		default: break;
		
		}
			
	}
}

Measured memory_bytes: 26944
#include <iostream>

using namespace std;

int main (){
	int N,i;
	cin>>N;
	
	for(i=1;i<=9;i++){
		if((N%i==0)&&((N/i)<=9)){
		cout<<"Yes"<<endl;
		return 0;
		}
	}
	cout<<"No"<<endl;
	return 0; 
}


Measured memory_bytes: 256