akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double W = Integer.parseInt(sc.next());
    double H = Integer.parseInt(sc.next());
    double x = Integer.parseInt(sc.next());
    double y = Integer.parseInt(sc.next());

    double ans = (W*H)/2.0;
    if(x==W/2.0 && y==H/2.0){
      System.out.println(ans + " " + 1);
    }else{
      System.out.println(ans + " " + 0);
    }
  }
}

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


int main() {

	unsigned long long N;
	vector<unsigned long long> a(5);
	cin >> N;
	for(auto &x: a) cin >> x;
	sort(a.begin(), a.end());
	unsigned long long b = a[0];
	unsigned long long out = (N - 1) / b + 5;
	cout << out << endl;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,X;
int A[10000];

signed main(){
    cin>>N>>X;
    rep(i,N){
        cin>>A[i];
        A[i+N]=A[i+N+N]=A[i];
    }

    int mi=1001001001001001001ll;
    for(int i=0;i<N;i++){
        int cost=X*i;
        deque<pint>deq;
        rep(j,N){
            while(deq.size()&&deq.back().fi>=A[j])deq.pop_back();
            deq.pb(pint(A[j],j));
        }
        for(int j=N;j<2*N;j++){
            while(deq.size()&&deq.back().fi>=A[j])deq.pop_back();
            deq.pb(pint(A[j],j));
            while(deq.front().se+i<j)deq.pop_front();
            cost+=deq.front().fi;
        }
        chmin(mi,cost);
    }

    cout<<mi<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;


int main(){

	int p[8],min,min_pattern,tmp,pattern[8],tmp_sum,S;
	pattern[0] = 12121414,
	pattern[1] = 12141412,
	pattern[2] = 14121214,
	pattern[3] = 14141212,
	pattern[4] = 21214141,
	pattern[5] = 21414121,
	pattern[6] = 41212141,
	pattern[7] = 41412121;

	while(scanf("%d %d %d %d %d %d %d %d ",&p[0],&p[1],&p[2],&p[3],&p[4],&p[5],&p[6],&p[7]) != EOF){
		min = 2147483647;

		for(int i=0; i <= 7; i++){
			tmp = pattern[i];
			tmp_sum = 0;
			S = 10000000;
			for(int k=0; k <= 7; k++){
				if(p[k] < (tmp/S))tmp_sum += 0;
				else{
					tmp_sum += p[k] - (tmp/S);
				}
				tmp %= S;
				S /= 10;
			}
			if(min > tmp_sum){
				min = tmp_sum;
				min_pattern = i;
			}
		}

		S = 10000000;
		tmp = pattern[min_pattern];
		printf("%d",tmp/S);
		tmp %= S;
		S /= 10;
		for(int i=1; i<=7; i++){
			printf(" %d",tmp/S);
			tmp %= S;
			S /= 10;
		}
		printf("\n");
	}
    return 0;
}

Measured memory_bytes: 2740
#!/usr/bin/env python3
#ABC78 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,z,w = LI()
a = LI()
if n == 1:
    print(abs(a[-1] - w))
else:
    print(max(abs(a[-1]-w),abs(a[-2]-a[-1])))


Measured memory_bytes: 38768
def main():
    num_a, num_b = map(int, input().split())
    data_a = list(map(int, input().split()))
    data_b = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    visit_b = [0 for i in range(num_b)]

    for i in range(num_a):
        visit_b_kari = [0 for i in range(num_b)]
        now_kari = 0
        for j in range(num_b):
            if data_a[i] == data_b[j]:
                visit_b_kari[j] += now_kari + 1
                visit_b_kari[j] %= mod
            now_kari += visit_b[j]
        for j in range(num_b):
            visit_b[j] += visit_b_kari[j]
            visit_b[j] %= mod

        # print(visit_b)
        # print(visit_b_kari)

    ans = 1
    for j in range(num_b):
        ans += visit_b[j]
        ans %= mod

    print(ans)






if __name__ == '__main__':
    main()




Measured memory_bytes: 43228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int a[4] = {6000, 4000, 3000, 2000};
  for (int i = 0; i < 4; i++) {
    int t, n;
    cin >> t >> n;
    cout << a[t - 1] * n << endl;
  }

  return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<math.h>
using namespace std;

int sum, k, buf;
int m = 0;

int main(){
    for(int i = 0; i < 3; i++){
        cin >> buf;
        sum = sum + buf;
        if(m < buf) m = buf;
    }
    cin >> k;
    cout << sum + m * pow(2, k) - m << endl;
    return 0;
}

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

#define all(x) x.begin(),x.end()
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define pr(x) printf("%d",x)
#define prl(x) printf("%lld",x)
#define LL long long
#define pb push_back
#define PB pop_back
#define PF pop_front
#define F first
#define S second
#define inrow(vec)    for(int i=0;i<vec.size();i++)cout<<vec[i]<<" ";
#define incoloum(vec) for(int i=0;i<vec.size();i++)cout<<vec[i]<<endl;

const double PI=3.1415926;
const int KL=1e6;

using namespace std;

LL q,x,y,z,n,m,p[KL],mn=1e9,mx=-1e9,ans;
string t;
vector <LL> vec;
set <int> s;
map <int,int> M;


int main()
{
    scl(n);scl(x);
    if(n>=10)cout<<x<<endl;
    else cout<<100*(10-n)+x<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define err(A) cout << #A << " = " << (A) << endl
using namespace std;

const int N=3e3+100,mod=1e9+7,M=1e5+100;
/*F*/

ll dp[N][N];
pii par[N][N];
int32_t main(){
    string s,t;
    cin >> s >> t;
    for (int i=1;i<=s.size();i++){
        for (int j=1;j<=t.size();j++){
            if (dp[i-1][j]>dp[i][j-1]){
                dp[i][j]=dp[i-1][j];
                par[i][j]={i-1,j};
            }
            else{
                dp[i][j]=dp[i][j-1];
                par[i][j]={i,j-1};
            }
            if (s[i-1]==t[j-1]){
                if (dp[i][j]<dp[i-1][j-1]+1){
                    dp[i][j]=dp[i-1][j-1]+1;
                    par[i][j]={i-1,j-1};
                }
            }
        }
    }
    ll u=s.size(),v=t.size();
    string y="";
    while(u!=0 && v!=0){
        ll p=par[u][v].F;
        ll q=par[u][v].S;
        if (v+u-p-q==2){
            y.pb(s[p]);
        }
        u=p;
        v=q;
    }
    reverse(y.begin(),y.end());
    cout << y;
}


Measured memory_bytes: 219392
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vii;
typedef vector<ll> vll;
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 dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int h, w, c[10][10], a[210][210];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> h >> w;
    rep(i, 0, 10) rep(j, 0, 10) cin >> c[i][j];
    rep(k, 0, 10) rep(i, 0, 10) rep(j, 0, 10) {
      c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    }
    rep(i, 0, h) rep(j, 0, w) cin >> a[i][j];
    ll ans = 0;
    rep(i, 0, h) rep(j, 0, w) {
      if (a[i][j] == -1) continue;
      ans += c[a[i][j]][1];
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 384
N = gets.to_i
dists = $<.map{|s|s.split.map &:to_i}

ans = 0
N.times{|i|
  (i+1...N).each{|j|
    a = dists[i][j]
    flg = false
    N.times{|k|
      b = dists[i][k] + dists[k][j]
      if a > b
        p~0
        exit
      elsif a == b && i != k && j != k
        flg = true
        break
      end
    }
    ans += a if !flg
  }
}
p ans

Measured memory_bytes: 3196
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
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;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif


int main() {
  int H, W; cin >> H >> W;
  int K; cin >> K;

  vector<string> S(H, "");
  vi sum(H, 0);
  vi max_row(W, 0);
  rep(i, H) {
    cin >> S[i];
    rep(j, W)
      if (S[i][j] == '1') {
        ++sum[i];
      }
  }

  int res = 1e9;
  rep(bit, 1LL << (H-1)) {
    // bitが立っている行の下で割る
    vector<vector<string>> S2; // 割った後にK以上含んでいるエリア
    rep(i, H) {
      int j = i, choco = 0;
      vector<string> temp;
      rep(j, i, H) {
        temp.push_back(S[j]);
        choco += sum[j];
        if (bit & (1 << j))
          break;
        ++i;
      }
      if (choco <= K)
        continue;
      S2.push_back(temp);
    }

    int ans = 0;
    vi count(S2.size(), 0);
    rep(j, W) {
      rep(i, S2.size()) {
        for (const auto& s : S2[i]) {
          if (s[j] == '1')
            ++count[i];
        }
      }
      rep(i, S2.size()) {
        if (count[i] > K) {
          ++ans;
          all(fill, count, 0);
          rep(k, S2.size()) {
            for (const auto& s : S2[k]) {
              if (s[j] == '1')
                ++count[k];
            }
          }
          break;
        }
      }
    }
    rep(i, S2.size()) {
      if (count[i] > K) {
        ans = 1e9;
        break;
      }
    }
    if (chmin(res, ans + __builtin_popcount(bit))) {
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>

using namespace std;

int main(){
  int N;
  cin>>N;
  int temp=N;
  int sn=0;
  while (temp>0){
    sn+=temp%10;
    temp/=10;
  }
  cout<<((N%sn==0)?"Yes":"No");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long hp,num;
  cin >> hp >> num;
  vector<long long> v;
  for(int i = 0; i < num; i++){
    int a;
    cin >> a;
    v.push_back(a);
  }
  
  long long atk = 0;
  bool is_win = false;
  for (int i = 0; i < v.size(); i++){
    atk = atk + v[i];
    if(atk >= hp){
      is_win = true;
      break;
    }
  } 
  is_win ? cout << "Yes" << endl : cout << "No" << endl;
}

Measured memory_bytes: 1400
H,W,K = map(int,input().split())

G = []
for _ in range(H):
    G.append(input())

ans = 0

black=0

for mask_h in range(1 << H):
    for mask_w in range(1 << W):
        black=0
        for i in range(H):
            for j in range(W):
                if((mask_h >> i) & 1 == 0 ) and ((mask_w >> j) & 1 == 0 ) and G[i][j] == '#':
                    black+=1
        if black == K:
            ans += 1

print(ans)


Measured memory_bytes: 9124
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

S = IS()
if S[0] == "A" and S.count("C") == 1 and S[-1] != "C":
    if S[1].islower() == True:
        if S[S.index("C")+1:].islower() == True:
            print("AC")
        else:
            print("WA")
    else:
        print("WA")
else:
    print("WA")

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7
const double c_PI = 3.14159265358979323846264338327950288;



char S[200][200];


int main() {
	int N,P[200];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%s%d", S[i], &P[i]);
	}

	int taiou[200];
	for (int i = 0; i < N; i++) {
		taiou[P[i]] = i + 1;
	}



	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			if (strcmp(S[i], S[j] )> 0) {
				char memo[200];
				memcpy(memo, S[i], sizeof(S[i]));
				memcpy(S[i], S[j], sizeof(S[j]));
				memcpy(S[j], memo, sizeof(memo));

				int temp = P[i];
				P[i] = P[j];
				P[j] = temp;
			}
			else if (strcmp(S[i], S[j]) == 0) {
				if (P[i] < P[j]) {
					int temp = P[i];
					P[i] = P[j];
					P[j] = temp;
				}
			}
		}
	}

	for (int i = 0; i < N; i++) {
		printf("%d\n", taiou[P[i]]);
	}






}








Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}


void solve() {
  int n;
  cin >> n;
  cout << n * n * n << endl;
}


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

using namespace std;

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

int main(void){

	int dis[11][11];
	int h, w, a;

	cin >> h >> w;

	for (int i = 0; i < 10; i++){
		for (int j = 0; j < 10; j++){
			cin >> dis[i][j];
		}
	}



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

	long long int num = 0;

	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			cin >> a;
			if (a != -1)
				num += dis[a][1];
		}
	}

	cout << num << endl;

	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
const MOD: u64 = 1000000007;


fn main() {
    input!{
        S: String,
    }
    let mut S = S;
    for _ in 0..10 {
        S = S.replace("0B", "");
        S = S.replace("1B", "");
    }
    S = S.replace("B", "");
    println!("{}", S);
}

Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
"""
String
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0506

"""
import sys
import re


def solve(n, s):
    for _ in range(n):
        s = re.sub(r'(\d)\1*', lambda m: f'{len(m.group(0))}{m.group(1)}', s)
    return s


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break
        s = input()
        ans = solve(n, s)
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 7804
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long,long>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<int, int> mp;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
class Union_Find {
private:
	vector<int> par;
	vector<int> rank;
public:
	Union_Find(int n) {
		rep(i, n) {
			par.push_back(i);
			rank.push_back(0);
		}
	}
	int find(int x) {
		if (par.at(x) == x) return x;
		else return par.at(x) = find(par.at(x));
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank.at(x) < rank.at(y)) {
			par.at(x) = y;
		}
		else {
			par.at(y) = x;
			if (rank.at(x) == rank.at(y)) rank.at(x)++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	bool tmp = false;
	int p = 0;
	for (int i = 0; i + t.size() <= s.size(); i++) {
		string u = s.substr(i, t.size());
		bool f = true;
		rep(i, u.size()) {
			if (u.at(i) == '?') continue;
			if (u.at(i) != t.at(i)) {
				f = false;
				break;
			}
		}
		if (f) {
			tmp = true;
			p = max(i, p);
		}
	}
	if (!tmp) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	rep(i, s.size()) {
		if (i == p) s.replace(i, t.size(), t);
		else if (s.at(i) == '?') s.replace(i, 1, "a");
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

pub struct UnionFind {
    n: usize,
    root: Vec<usize>,
    rank: Vec<usize>,
    size: Vec<usize>,
}
impl UnionFind {
    pub fn new(n: usize) -> Self {
        let root = (0..n).collect();
        let rank = vec![0; n];
        let size = vec![1; n];
        Self {
            n,
            root,
            rank,
            size,
        }
    }
    pub fn find(&mut self, x: usize) -> usize {
        if x >= self.n {
            panic!();
        }
        if self.root[x] == x {
            x
        } else {
            let root = self.find(self.root[x]);
            self.root[x] = root;
            root
        }
    }
    pub fn unite(&mut self, x: usize, y: usize) {
        if x >= self.n || y >= self.n {
            panic!();
        }
        let x_root = self.find(x);
        let y_root = self.find(y);
        if x_root == y_root {
            return;
        }
        if self.rank[x_root] < self.rank[y_root] {
            self.root[x_root] = y_root;
            self.size[y_root] += self.size[x_root];
        } else {
            self.root[y_root] = x_root;
            self.size[x_root] += self.size[y_root];
            if self.rank[x_root] == self.rank[y_root] {
                self.rank[x_root] += 1;
            }
        }
    }
    pub fn size(&mut self, x: usize) -> usize {
        if x >= self.n {
            panic!();
        }
        let x_root = self.find(x);
        self.size[x_root]
    }
    pub fn is_same(&mut self, x: usize, y: usize) -> bool {
        if x >= self.n || y >= self.n {
            panic!();
        }
        self.find(x) == self.find(y)
    }
}

pub fn bsearch<F>(ok: i64, ng: i64, pred: F) -> Option<i64>
where
    F: Fn(i64) -> bool,
{
    let orig_ok = ok;
    let mut ok = ok;
    let mut ng = ng;
    while (ok - ng).abs() > 1 {
        let mid = (ok + ng) / 2;
        if pred(mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    if ok == orig_ok {
        None
    } else {
        Some(ok)
    }
}

fn solve() {
    input! {
        n: usize, m: usize,
        abv: [(Usize1, Usize1); m]
    };

    if m == 0 {
        println!("1");
        return;
    }

    let mut uf = UnionFind::new(n);
    for (a, b) in abv {
        uf.unite(a, b);
    }
    let mut table = HashMap::new();
    for i in 0..n {
        *table.entry(uf.find(i)).or_insert(0) += 1 as i64;
    }
    let mut v = Vec::new();
    for &val in table.values() {
        if val != 1 {
            v.push(val as i64);
        }
    }
    v.sort();
    println!("{}", v[v.len() - 1]);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


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

int main()
{
	
	//freopen ("t.txt","r",stdin);
	int a,b,c;
	cin>>a>>b>>c;
	if (c>=a && c <=b ) cout<<"Yes"<<endl;
	else if (c>=b && c <=a )cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	 return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		long ary[] = new long[N];
		
		for(int i = 0; i < N; i++) {
			ary[i] = sc.nextLong();
		}
		
		Arrays.sort(ary);
		
		int cnt = 0;
		long sideLength1 = 0;
		long sideLength2 = 0;
		
		for(int i = N - 1; i > 0; i--) {
			if(ary[i] == ary[i - 1] && cnt == 0) {
				sideLength1 = ary[i];
				cnt++;
				i--;
				continue;
			}
			
			if(ary[i] == ary[i - 1] && cnt == 1) {
				sideLength2 = ary[i];
				cnt++;
				i--;
			}
			
			if(cnt >= 2) {
				System.out.println(sideLength1 * sideLength2);
				return;
			}
		}
		System.out.println(0);
	}
}


Measured memory_bytes: 49780
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

__attribute__ ((constructor))
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

signed main(){
  int n,m;
  cin >> n >> m;
  if(n==m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3552
def solve():
    H, W = map(int, input().split())
    _ = int(input())
    a = list(map(int, input().split()))
    
    ans = [[0] * W for _ in range(H)]
    ans[0][0] = 1
    a[0] -= 1
    direction = 1
    i, j, k = 0, 0, 1
    cnt = 1
    while cnt != H * W:
        if j == W - 1 and direction == 1:
            i += 1
            direction = -1
        elif j == 0 and direction == -1:
            i += 1
            direction = 1
        else:
            j += direction
        
        if a[k - 1] == 0:
            k += 1
        a[k - 1] -= 1
        ans[i][j] = k
        cnt += 1
    
    for line in ans:
        print(' '.join(map(str, line)))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3568
import java.util.Scanner;

public class Main {
    public static void main(String...args){
        Scanner sc= new Scanner(System.in);
        int K = sc.nextInt();
        int X = sc.nextInt();
        if(K*500 >= X){
            System.out.println("Yes");
        }
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 23632
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97 '0'=0x30=48
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  ll n,d;
  cin>>n>>d;
  d*=d;
  int cnt=0;
  rep(i,n){
    ll a,b;
    cin>>a>>b;
    a*=a;b*=b;
    if(a+b<=d)cnt++;
  }
  cout<<cnt<<endl;}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >>N;
  vector<vector<long long>> A(N,vector<long long>(2,0));
  for(int i=0; i<N; i++){
    long long a,b;
    cin >>a>>b;
    A[i][0]=a;
    A[i][1]=b;
  }
  long long ans=0;
  for(int i=N-1; i>=0; i--){
    A[i][0]+=ans;    
    if(A[i][0]%A[i][1]==0) continue;
    ans+=(A[i][1]-A[i][0]%A[i][1]);
//    cout<<"i:"<<i<<" ans:"<<ans<<endl;
  }
  cout <<ans <<endl;
}


Measured memory_bytes: 7808
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())
j, k = x2-x1, y2-y1
l, m = x3-x1, y3-y1
a = ( j**2 + k**2 )**0.5
b = ( l**2 + m**2 )**0.5
c = ( (j-l)**2 + (k-m)**2 )**0.5
S = abs(j*m-k*l)/2
T = (a+b+c)/2
M = max(a, b, c)
r = S / (2*S/M + T)
print(r)

Measured memory_bytes: 3064
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXX 1e12

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N; cin>>N;
    ll H[N];
    ll dp[N];
    
    for(ll i=0;i<N;++i)
    {
        dp[i] = MAXX;
        
        cin>>H[i];
        
        if(i == 0)
            dp[i] = 0;
        
        if(i > 0)
            dp[i] = dp[i - 1] + abs(H[i] - H[i - 1]);
        
        if(i > 1)
            dp[i] = min(dp[i],dp[i - 2] + abs(H[i - 2] - H[i]));
    }
    
    cout<<dp[N - 1]<<endl;
}

Measured memory_bytes: 5216
import java.util.Scanner;
 
class Main{
  public static void main(String[] arg){
    int m, f, r;

    Scanner in = new Scanner(System.in);

    while(true){
        m = in.nextInt();
        f = in.nextInt();
        r = in.nextInt();
        
        if(m == -1 && f == -1 && r == -1) break;

        char check;
        if(m == -1 || f == -1) check = 'F';
        else if((m+f)>=80) check = 'A';
        else if((m+f)>=65) check = 'B';
        else if((m+f)>=50) check = 'C';
        else if((m+f)>=30){
            if(r>=50) check = 'C';
            else check = 'D';

        }
        else check = 'F';

        System.out.println(check);
    }

  }
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long S){
    int ans = INF;
    while(S != 0) {
        ans = min(ans, (int)abs(753 - S % 1000));
        S /= 10;
    }
    cout << ans << endl;
}

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


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

using namespace std;

bool visited[100000];
vector<int> tos;
vector<int> v[100000];

void dfs(int s){
	for(auto x : v[s]){
		if(visited[x]) continue;
		dfs(x);
	}
	visited[s] = true;
	tos.emplace_back(s);
}

int main(){
	int n, m;
	cin >> n >> m;
	int a, b;
	for (int i = 0; i < m; ++i)
	{
		cin >> a >> b; --a; --b;
		v[a].emplace_back(b);
	}
	tos.reserve(n);
	for (int i = 0; i < n; ++i)
	{
		if(!visited[i]) dfs(i);
	}
	int dis[n] = {0};
	reverse(tos.begin(), tos.end());
	for(auto i : tos){
		for(auto x : v[i]){
			dis[x] = max(dis[x], dis[i] + 1);
		}
	}
	cout << *max_element(dis, dis+n);
}

Measured memory_bytes: 11268
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 50;
typedef long long ll;
int vis[maxn];
int main()
{
    std::ios::sync_with_stdio(false);
    for(int i = 1;i <= 100;i++){
        for(int j = 1;j <= 100;j++){
            for(int k = 1;k <= 100;k++){
                int x = i * i + j * j + k * k + i * j + j * k + i * k;
                if(x <= 1e4)
                    vis[x]++;
            }
        }
    }
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++){
        cout << vis[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

int main(){
    ll a,b;
    cin>>a>>b;
    ll a1=a+b;
    ll a2=a-b;
    ll a4=a*b;
    ll ans1=max(a1,a2);
    ll ans2=max(ans1,a4);
    cout<<ans2;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <cmath>
#include <string>
#include <sstream>

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define debug(x) cout << #x << " : " << x << endl

using namespace std;

typedef vector<int> VI;
typedef long long LL;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main()
{
    int p[3];
    cin >> p[0] >> p[1] >> p[2];

    sort(p, p+3);
    int cnt = 0;

    FOR(i,0,2) {
        if (p[i] != p[i+1]) cnt++;
    }
    cout << ++cnt << endl;
    return 0;
}


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

void printVec(std::vector<int> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}

int main() {
  ll n;

  cin >> n;
  ll ans = 0;
  for(int i = 1; i <= n; i++) {
    if (i % 5 == 0 && i % 3 == 0) {
      ;
    } else if (i % 3 == 0) {
      ;
    } else if (i % 5 == 0) {
      ;
    } else {
      ans = ans + i;
    }
  }
  cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	string s,t;
	cin>>s>>t;
	
	cout<<t<<s<<endl;
}


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

int main() {
  char x, y;
  cin >> x >> y;
  if (x == y) {
    cout << '=' << endl;
  }
  else if (x > y) {
    cout << '>' << endl;
  }
  else {
    cout << '<' << endl;
  }
}


Measured memory_bytes: 256
until (n = gets.chomp.to_i) == 0
  arr = gets.split.map(&:to_i)

  sum = 0
  n.times do |i|
    sum = sum + arr[i]
  end
  ave = sum.to_f / n

  alpha = 0
  n.times do |i|
    alpha = alpha + ((arr[i] - ave)**2)
  end

  puts (alpha / n) ** 0.5
end

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int imp = int.Parse(Console.ReadLine());
            if (imp > 999)
            {
                Console.Write("ABD");
            }
            else
            {
                Console.Write("ABC");
            }



          
        }
    }
}

Measured memory_bytes: 11092
def solve(n, a, b):
    t = max(b)
    for a_, b_ in sorted(zip(a, b), key=lambda _:-_[1]):
        if t > b_:
            t = b_
        t -= a_
    return "No" if t < 0 else "Yes"

n = int(input())
a, b = [0]*n, [0]*n
for i in range(n):
    a[i], b[i] = map(int, input().split())
print(solve(n, a, b))

Measured memory_bytes: 41304
#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main()
{
	int n;
	cin>>n;
	cin>>a[1];
	int t=a[1];
	for(int i=2;i<=n;++i) 
	    cin>>a[i],t^=a[i];
	for(int i=1;i<=n;++i)
	    cout<<(t^a[i])<<" ";
	cout<<endl;
	return 0;
}

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

long long rng(long long l, long long r) {
  static mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
  return uniform_int_distribution<long long>(l, r - 1)(mt);
}

struct RollingHash {
  static constexpr uint64_t m31 = (1LL << 31) - 1;
  static int mod_m31(uint64_t a) {
    a = (a >> 31) + (a & m31);
    return a >= m31 ? a - m31 : a;
  }
  static long long base[2];
  static vector<int> powb[2];
  vector<int> h[2];
  RollingHash(const string& s) : h{{0}, {0}} {
    for (int k : {0, 1}) {
      for (char c : s) h[k].push_back(mod_m31(h[k].back() * base[k] + c));
      while (powb[k].size() <= s.size())
        powb[k].push_back(mod_m31(powb[k].back() * base[k]));
    }
  }
  int get(int l, int r, int k) const {
    return mod_m31(h[k][r] + (m31 - h[k][l]) * powb[k][r - l]);
  }
  auto get(int l, int r) const { return make_pair(get(l, r, 0), get(l, r, 1)); }
  int size() const { return h[0].size() - 1; }
};
long long RollingHash::base[2] = {rng(1e9, 2e9), rng(1e9, 2e9)};
vector<int> RollingHash::powb[2] = {{1}, {1}};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  vector<int> b(n);
  for (auto&& e : b) {
    cin >> e;
  }
  vector<bool> ok(n, true);
  vector<int> res(n);
  for (int k = 0; k < 30; ++k) {
    string s, t;
    for (int i = 0; i < n; ++i) {
      s += a[i] >> k & 1 ? '1' : '0';
      t += b[i] >> k & 1 ? '1' : '0';
    }
    s += s;
    RollingHash rh(s);
    auto zero = RollingHash(t).get(0, n);
    for (auto&& e : t) {
      e ^= 1;
    }
    auto one = RollingHash(t).get(0, n);
    for (int i = 0; i < n; ++i) {
      if (rh.get(i, i + n) == zero) {
      } else if (rh.get(i, i + n) == one) {
        res[i] |= 1 << k;
      } else {
        ok[i] = false;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (ok[i]) {
      cout << i << ' ' << res[i] << '\n';
    }
  }
}


Measured memory_bytes: 12536
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;


ll ruijo(int i) {
	ll ans = 1;
	for(int j = 0; j < i; j++) {
		ans = ans*2%MOD;
	}
	return ans;
}

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

	ll temp = a[n-1];
	int count = 0;
	while(temp > 0) {
		temp /= 2;
		count++;
	}

	ll ans = 0;
	for(int i=0; i<count; i++) {
		ll sum1 = 0;
		ll sum2 = 0;
		for(int j=0; j<n; j++) {
			if(a[j] % 2 == 0) sum1++;
			else sum2++;
			a[j] /= 2;
		}
		ans += ((sum1 * sum2)%MOD * (ruijo(i) % MOD)) % MOD;
	}
	cout << ans%MOD << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
 using namespace std;
 
 #define mkp make_pair
 #define F first
 #define S second
 #define rep(i,n) for(int i=0;i<n;i++)
 
 typedef vector<int> vint;
 typedef pair<int,int> pii;
 
int main(){
	int w,h;
	while(cin>>h>>w,w||h){
		vint tt(h,0);
		vector<vint> vv(w,tt);
		vector<vint> table=vv;
		int v[4][2]={0,1,1,0,0,-1,-1,0};
		rep(i,w){
			rep(j,h){
				char t;
				cin>>t;
				if(t=='.') vv[i][j]=0;
				else if(t=='W'){
					vv[i][j]=1;
					table[i][j]=-1;
				}
				else{
					vv[i][j]=2;
					table[i][j]=-1;
				}
			}
		}
		rep(i,w){
			rep(j,h){
				if(vv[i][j]==0) continue;
				else{
					queue<pii> q;
					q.push(mkp(i,j));
					while(!q.empty()){
						pii t=q.front();
						q.pop();
						rep(k,4){
							int x=t.F+v[k][0],y=t.S+v[k][1];
							if(x>=0&&y>=0&&x<w&&y<h){
								if(table[x][y]==0||table[x][y]==3-vv[i][j]){
									table[x][y]+=vv[i][j];
									q.push(mkp(x,y));
								}
							}
						}
					}
				}
			}
		}
		int answ=0,ansb=0;
		//cout<<"w h "<<w<<" "<<h<<endl;
		rep(i,w){
			rep(j,h){
				//cout<<table[i][j]<<" ";
				if(table[i][j]==1){
					answ++;
				}
				else if(table[i][j]==2){
					ansb++;
				}
			}
			//cout<<endl;
		}
		//cout<<endl;
		cout<<ansb<<" "<<answ<<endl;
		
	}
	return 0;
}
		

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int planA = n * a;
  if (planA < b) {
    cout << planA << endl;
  }else if (planA > b) {
    cout << b << endl;
  }else
    cout << b;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll d[1010];

int main() {
  ll n,m;
  cin>>n>>m;
  vector<vector<ll> > vv(n,vector<ll>());
  rep(i,0,m){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    vv[a].pb(b);
  }
  vector<ll> vp;
  ll p = -1;
  rep(i,0,n){
    ll flag = 0;
    queue<ll> q1;
    clr(d,0);
    q1.push(i);
    d[i] = 1;
    while(!q1.empty()){
      ll a = q1.front();q1.pop();
      rep(j,0,vv[a].sz){
        ll b = vv[a][j];
        if(b==i)flag = 1;
        if(d[b]==1)continue;
        d[b] = 1;
        q1.push(b);
      }
    }
    if(flag==1){
      vp.pb(i);
      p = i;
    }
  }
  if(p==-1){
    cout << p << endl;
    return 0;
  }
  ll mn = 1010;
  vector<ll> ans;
  rep(i,0,vp.sz){
    ll p = vp[i];
    queue<ll> q1;
    queue<vector<ll> > q2;
    clr(d,0);
    vector<ll> v1;
    v1.pb(p);
    q1.push(p);
    q2.push(v1);
    d[p] = 1;
    while(!q1.empty()){
      ll a = q1.front();q1.pop();
      vector<ll> vb = q2.front();q2.pop();
      if(vb.sz==mn)continue;
      rep(j,0,vv[a].sz){
        ll b = vv[a][j];
        if(b==p){
          if(vb.sz<mn){
            mn = vb.sz;
            ans = vb;
          }
        }
        if(d[b]==1)continue;
        d[b] = 1;
        q1.push(b);
        vector<ll> vb1 = vb;
        vb1.pb(b);
        q2.push(vb1);
      }
    }
  }
  cout << ans.sz << endl;
  rep(i,0,ans.sz){
    cout << ans[i]+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define vl vector
#define pb push_back
#define ld long double
#define ff first
#define ss second
using namespace std;

ll fact(ll a)
{
    if(a==0) return 1;
    else return a*fact(a-1);
}

int main()
{
    ll i,j,n,k,t,m,a,b;
    cin>>n;
    for(i=1;i<10;i++)
    {
        a=i;
        if(n%i) continue;
        else b=n/i;
        if(a<=9 && b<=9) 
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<stack>

using namespace std;

int main() {

	int n;
	stack<int> line;

	while (cin >> n) {
		if (n == 0) {
			cout << line.top() << endl;
			line.pop();
		}
		else {
			line.push(n);
		}
	}

	return 0;
}

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

using namespace std;

int main(void){
    int N;cin>>N;
    vector<int> A(N,0);
    for(int i = 0; i < N; i++){
        cin>>A[i];
    }

    double gayaku = 0;
    for(int i: A){
        gayaku += (1/(double)i);
    }

    cout << 1/ gayaku << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string.h>
#include <vector>
using namespace std;
int N,K;
const long long INF=100000000000LL;
long long a[20];
long long reg(int n,int k,long long t){
	if(k==K)return 0;
	if(n==N)return INF;
	if(a[n]>t)return reg(n+1,k+1,a[n]);
	long long was=INF;
	was=min(was,t+1-a[n]+reg(n+1,k+1,t+1));
	was=min(was,reg(n+1,k,t));
	//cout<<n<<" "<<k<<" "<<t<<" "<<was<<endl;
	return was;
}
int main(){
//	memset(dp,-1,sizeof(dp));
	cin>>N>>K;
	for(int i=0;i<N;++i){
		cin>>a[i];
	}
	cout<<reg(1,1,a[0])<<endl;
	return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  int N;
  cin >> N;
  vec<int> A(N);
  REP(i, N) cin >> A[i];

  vec<int> sorted(A);
  sort(ALL(sorted), greater<int>());
  REP(i, N) cout << (A[i] == sorted[0] ? sorted[1] : sorted[0]) << endl;
  return 0;
}


Measured memory_bytes: 4756
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200100


int main() {
	char a[N + 1];
	f(i, N + 1)a[i] = 0;
	long long b2[N];
	long long b3[N];
	b2[0] = 1;
	b3[0] = 1;
	f(i, N - 1) {
		b2[i + 1] = (b2[i] * 2) % MOD;
		b3[i + 1] = (b3[i] * 3) % MOD;
	}
	int n, k;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%s", a);
	k = 0;
	n = strlen(a);
	f(i, n-1) {
		if (a[i] == '1') {
			s = (b2[k] * b3[n - i - 1]) % MOD;
			ans = (ans + s) % MOD;
          k++;
		}
	}
	ans = (ans + b2[k]) % MOD;
	if (a[n - 1] == '1') {
		ans = (ans + b2[k + 1]) % MOD;
	}

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


	return 0;
}

Measured memory_bytes: 3456
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) throws Exception {
        int[][][] rooms = new int[4][3][10];
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        br.readLine();
        String line;
        while ((line = br.readLine()) != null) {
            String[] arr = line.split(" ");
            int b = Integer.parseInt(arr[0]) - 1;
            int f = Integer.parseInt(arr[1]) - 1;
            int r = Integer.parseInt(arr[2]) - 1;
            int v = Integer.parseInt(arr[3]);
 
            rooms[b][f][r] += v;
        }
 
        for (int b = 0; b < 4; b++) {
            for (int f = 0; f < 3; f++) {
                for (int r = 0; r < 10; r++) {
                    System.out.print(" " + rooms[b][f][r]);
                }
                System.out.println();
            }
            if (b != 3)
                System.out.println("####################");
        }
    }
}

Measured memory_bytes: 19464
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define lint long long
#define FOR(i,a,b) for(lint i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009

typedef pair<int, int> P;

lint ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	int a, b, c; cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}

Measured memory_bytes: 896