akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define llong long long
int T;
int n;
llong a[220];
llong B[110];
int op[220];
void ins(llong x)
{
	for(int i=61;i>=0;--i)
		if((x>>i)&1)
		{
			if(!B[i])
			{
				B[i]=x;
				break;
			}
			x^=B[i];
		}
}
bool find(llong x)
{
	for(int i=61;i>=0;--i)
		if((x>>i)&1)x^=B[i];
	return x==0;
}
int main()
{
	scanf("%d",&T);
while(T--)
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%lld",&a[i]);
	for(int i=1;i<=n;++i)scanf("%1d",&op[i]);
	memset(B,0,sizeof(B));
	int ans=0;
	for(int i=n;i;--i)
		if(op[i]==0)ins(a[i]);
		else if(!find(a[i]))
		{
			ans=1;break;
		}
	printf("%d\n",ans);
}
	return 0;
}


Measured memory_bytes: 3828
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <iomanip>
#include <cassert>
#include <numeric>
using namespace std;
 
#define ff first
#define ss second
#define pb push_back 
 
using LL = long long int;
using VL = vector<LL>;
using VI = vector<int>;
using VVL = vector<VL>;
using PLL = pair<LL,LL>;
using PII = pair<int ,int>;
 
#ifdef DEBUG
void _print()
{
  cout << endl;
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
  cout << first_elem << " ";
  _print(args...);
}
#else
void _print()
{
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
}
#endif
 
 
// NOTE: Please dont implement _print() as function in your program. It is reserved
// for debug purpose.

int main()
{
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    LL ans = INT_MAX;
    for (int i = 0; i <= s.length() - t.length(); i++) {
        LL cnt = 0;
        for (int j = 0; j < t.length(); j++) {
            if (s[i + j] != t[j]) {
                cnt++;
            }
        } 
        ans = min(ans, cnt);       
    }

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

Measured memory_bytes: 3196
<?php
list ($N, $K) = fscanf(STDIN, "%d %d");
$x = explode(" ", trim(fgets(STDIN)));

$a1 = array_map(
    function($item) {
        return min($item, 0);
    },
    array_slice($x, 0, $N-$K+1));

$a2 = array_map(
    function($item) {
        return max($item, 0);
    },
    array_slice($x, $K-1));

$ans = min(array_map(
    function($item1, $item2) {
        return $item2 - $item1 + min(abs($item1), abs($item2));
    },
    $a1, $a2));

print "$ans\n";
?>

Measured memory_bytes: 18932
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

int main(void){
    string S,T;
    cin >> S >> T;
    for (int i = 0; i < S.length() - T.length() + 1; i++)
    {
        for (int t = 0; t < T.length(); t++)
        {
            if(S[S.length() - T.length() - i + t] != '?' && S[S.length() - T.length() - i + t] != T[t]) break;
            if(t == T.length()-1){
                for (int k = 0; k < T.length(); k++)
                {
                    S[S.length() - T.length() - i + k] = T[k];
                }
                for (int k = 0; k < S.length(); k++)
                {
                    if(S[k] == '?') S[k] = 'a';
                }
                cout << S << endl;
                return 0;
            }
        }
        
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
template<typename T>
T get_value(std::istream& is);
 
 
int getMinNum_div(int _nOriginal, const std::vector<int>& _avoid)
{
	for (int i = _nOriginal; i < 100000; i++)
	{
		bool bFound = false;
		int c, d;
 
		c = i;
		while (c > 0 && !bFound)
		{
			div_t dv = div(c, 10);
			if (std::binary_search(_avoid.cbegin(), _avoid.cend(), dv.rem))
			{
				bFound = true;
				break;
			}
 
			c = dv.quot;
		}
		
		if (!bFound) return i;
	}
 
	return -1;
}
 
 
 
 
int main()
{
	std::cin.sync_with_stdio(false);
	std::cin.tie(nullptr);
 
	int N, K;
 
	std::cin >> N >> K;
	std::vector<int> v(K);
 
	for (auto& e : v) {
		std::cin >> e;
	}
 
	int answer = getMinNum_div(N, v);
	std::cout << answer << std::endl;
 
	return 0;
};
 
 
template<typename T>
inline T get_value(std::istream& is)
{
	T v;
	is >> v;
	return v;
}

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

int kaizyou(int a)
{
    int ans = 1;
    for (int i = 0; i < a; i++)
    {
        ans *= a-i;
    }

    return ans;
    
}

int main()
{
   int N;
   cin >> N;
   vector<int> kazu(N);
   vector<int> kkazu(N);
   vector<int> P(N);
   vector<int> Q(N);
   for (int i = 0; i < N; i++)
   {
       cin >> P.at(i);
   }

   for (int i = 0; i < N; i++)
   {
       cin >> Q.at(i);
   }
   
   for (int i = 0; i < N; i++)
   {
       for (int j = i; j >= 0 ; j--)
       {
           if (P.at(i) > P.at(j))
           {
               kazu.at(i) ++;
           }

           if (Q.at(i) > Q.at(j))
           {
               kkazu.at(i) ++;
           }
           
           
       }
       
   }
   

   int a = 0;
   for (int i = 0; i < N; i++)
   {
       a += (P.at(i)-1-kazu.at(i))*kaizyou(N-1-i);
   }
   

   int b = 0;
   for (int i = 0; i < N; i++)
   {
       b += (Q.at(i)-1-kkazu.at(i))*kaizyou(N-1-i);
   }

   int ans;
   if (a >= b)
   {
       ans = a-b;
       cout << ans;
   }

   else
   {
       ans = b-a;
       cout << ans;
   }
   
   
   
   
}

Measured memory_bytes: 256
stringToInt :: String -> Int
stringToInt = read

yesOrNo :: Int -> Int -> Int -> Int -> Int -> String
yesOrNo w h x y r = if x-r < 0 || y-r < 0 || x+r > w || y+r > h
                        then "No"
                        else "Yes"
main = do
    line <- getLine
    let [w, h, x, y, r] = map stringToInt $ words line
    putStrLn $ yesOrNo w h x y r



Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        cin>>n;
        ll res=0;
        vl A(n);
        vl B(n);
        vl C(n-1);
        rep(i,n)cin>>A[i];
        rep(i,n){
            cin>>B[i];
            res+=B[i];
        }
        rep(i,n-1)cin>>C[i];
        rep(i,n-1){
            if(A[i+1]==A[i]+1){
                res+=C[A[i]-1];
            }
        }
        cout<<res<<endl;
    }

Measured memory_bytes: 256
# Author: cr4zjh0bp
# Created: Sun Mar 22 11:54:41 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

s = ns()
n = len(s)
flag = True
if s != ''.join(list(reversed(s))):
    flag = False
for i in range((n - 1) // 2):
    p = (n - 1) // 2
    if s[i] != s[p - i - 1]:
        flag = False

for i in range((n + 3) // 2 - 1, n):
    p = n
    if s[i] != s[p - i - 1]:
        flag = False

print("Yes" if flag else "No")

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;

void next(const bool *t, int N, bool *tn)
{
    for (int i = 0; i < N - 1; i++) {
        tn[i] = t[i] || t[i + 1];
    }
}
bool all(const bool *t, int N)
{
    for (int i = 0; i < N; i++) {
        if (!t[i])
            return false;
    }
    return true;
}

int main()
{
    char s[200];

    scanf("%s", s);

    int N = strlen(s);

    int ks[1000];

    for (char c = 'a'; c <= 'z'; c++) {
        //cerr << "s: " << s << endl;
        bool t[100][200];
        for (int i = 0; i < N; i++) {
            t[0][i] = (s[i] == c);
            //cerr << "t[0][" << i << "]: " << t[0][i] << endl;
        }

        int k;
        for (k = 0; !all(t[k], N - k); k++) {
            next(t[k], N - k, t[k + 1]);
        }
        ks[c] = k;

        /*
        for (int kk = 0; kk <= k; kk++) {
            for (int i = 0; i < N - kk; i++) {
                cerr << "t[" << k << "][" << i << "]" << t[k][i] << endl;
            }
            cerr << endl;
        }
        */
    }

    int min = 1000;
    for (char c = 'a'; c <= 'z'; c++) {
        min = ks[c] < min ? ks[c] : min;
    }

    printf("%d\n", min);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <stack>

typedef long long ll;
typedef std::vector< int > VI;

const double EPS = 1e-10;
const double PI  = acos(-1);
const ll     INF = LLONG_MAX /10;

ll gcd(ll a, ll b)
{
  while (b > 0) {
    a = a % b;
    std::swap(a, b);
  }
  return a;
}

ll lcm(ll a, ll b) {
  ll gcd_val = gcd(a, b);
  return a / gcd_val * b;   // over flow 防止のため、割り算を先にする
}

ll extgcd(ll a, ll b, ll& x, ll& y)
{
  ll d = a;
  if (b != 0) {
    ll x_dash;
    ll y_dash;
    d = extgcd(b, a % b, x_dash, y_dash);
    x = y_dash;
    y = x_dash - (a / b) * y_dash;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}

int main(int argc, char* argv[])
{
  std::string s;
  std::cin >> s;

  ll ans = 0;
  for (ll i = 0; i < (ll)s.size(); i++) {
    for (ll j = i; j < (ll)s.size(); j++) {
      std::string sub = s.substr(i, j-i+1);
      ll x;
      sscanf(sub.c_str(), "%lld", &x);
      //std::cout << i << " " << j << " " << sub << " " << std::pow(2, i-1) << " " << std::pow(2, s.size()-j-1) << std::endl;
      ans += x * std::pow(2, std::max(0LL, i-1)) * std::pow(2, std::max(0LL, (ll)s.size() - j -2));
    }
  }

  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<ctime>
typedef long long ll ;
#define rep(i, a, b) for (ll i = a; i <= b; ++i)
using namespace std;

const int MAXN = 50;
const ll INF = 1e9 + 7;
ll n, x, y, z;
ll ans;
ll f[MAXN];
ll dp[MAXN][1 << 17 + 1];

int main() {
//	freopen("ou.txt","w",stdout);
	cin >> n >> x >> y >> z;
	y += x;
	z += y;
	ans = 1;
	rep(i, 1, n) ans = ans * 10 % INF;
	ll kx = (1 << (z)) - 1;
	ll p = (1 << (x - 1)) | (1 << (y - 1)) | (1 << (z - 1));
//	cerr<<" "<<kx<<" "<<p<<"\n";
//	rep(i, 1, 10) dp[1][1 << (i - 1)] = 1;
	dp[0][0] = 1;
	rep(i, 1, n) {
		rep(s, 0, kx) {
			if (dp[i - 1][s] == 0) continue;
			rep(k, 1, 10) {
				ll j = ((s << k) | (1 << (k - 1))) & kx;
//				cout<<i<<" "<<s<<" "<<k<<" "<<j<<"\n";
				if ((j & p) == p) continue;
				dp[i][j] += dp[i - 1][s];
				if (dp[i][j] >= INF) dp[i][j] -= INF;
			}
			
		}
	}
	rep(i, 0, kx) {
		ans = (ans - dp[n][i]) % INF;
	}
	if (ans < 0) ans += INF;
	cout << ans << "\n";
	return 0;
} 


Measured memory_bytes: 82176
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=10000000007;

int main(){
  ll n;cin>>n;
  ll ans=0;
  vector<ll> v;
  vector<ll> va;
  for(ll i=1;i*i<n;i++){
    if((n-1)%i==0){
      v.push_back(i);
      if(i*i!=n-1){
      v.push_back((n-1)/i);
      }
    }
  }
  
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      va.push_back(i);
      if(i*i!=n){
      va.push_back(n/i);
      }
    }
  }
  
  for(ll x:va){
    ll now=n;
    if(x==1) continue;
    while(now%x==0) now=now/x;
    now=now%x;
    if(now==1) ans++;
  }
  
  ans+=v.size()-1;
  
  cout<<ans<<endl;
}
  


Measured memory_bytes: 384
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        x: usize,
        y: usize,
        z: usize
    }
    let d = 1000000007;
    let t = x + y + z;
    let mut dp = vec![vec![0; 1 << t]; n + 1];
    dp[0][0] = 1;
    for i in 0..n {
        for j in 0..1 << t {
            for k in 1..11 {
                let j2 = (j << k | 1 << k - 1) & (1 << t) - 1;
                dp[i + 1][j2] = (dp[i + 1][j2] + dp[i][j]) % d;
            }
        }
        for j in 0..1 << t {
            if j & 1 << t - 1 != 0 && j & 1 << y + z - 1 != 0 && j & 1 << z - 1 != 0 {
                dp[i + 1][j] = 0;
            }
        }
    }
    println!("{}", (pow_m(10, n, d) + d - dp[n].iter().fold(0, |ac, x| (ac + x) % d)) % d);
}

fn pow_m(n: usize, mut p: usize, d: usize) -> usize {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % d;
            p /= 2;
        } else {
            ret = ret * r % d;
            p -= 1;
        }
    }
    ret
}


Measured memory_bytes: 86268
#include<stdio.h>                                                 
                                                                  
int main(void){                                                   
   int N,M;                                                       
   scanf("%d %d",&N,&M);                                          
   int data[N],i,sum,count;                                       
                                                                  
   sum = 0;                                                       
   for(i = 0; i < N; i++){                                        
      scanf("%d",&data[i]);                                       
      sum += data[i];                                             
   }                                                              
                                                                  
   count = 0;                                                     
   for(i = 0; i < N; i++){                                        
      if( data[i] * 4 * M >= sum){                                  
         count++;                                                 
      }                                                           
   }                                                              
   if( count < M){                                                
      printf("No");                                               
   } else {                                                       
      printf("Yes");                                              
   }                                                              
} 

Measured memory_bytes: 1688
A,B,C,X,Y = map(int, input().split())

ans = 10**9
for i in range(10**6):
    pizza_AB = 2*i*C
    pizza_A = max(X-i,0)*A
    pizza_B = max(Y-i,0)*B
    if ans > pizza_AB+pizza_A+pizza_B:
        ans = pizza_AB+pizza_A+pizza_B

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1 ; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1 ; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const bool debug = 0;
/***************************************/

int M, T, P, R; // M:コンテスト時間, T:チーム数, P:問題数, R:提出数

int main() {
	while (cin >> M >> T >> P >> R, M || T || P || R) {
		
		int wacnt[50][2000] = {};
		int score[50] = {};
		REP(i, R) {
			// m:経過時間, t:チーム番号, p:問題番号, j:ジャッジ結果(0:AC,otherwise:WA)
			int m, t, p, jud;
			scanf("%d %d %d %d", &m, &t, &p, &jud);
			t--; p--;
			
			if (jud == 0) {
				score[t] -= m + wacnt[t][p] * 20;
				score[t] += 100000000;
			}
			else wacnt[t][p]++;
		}
		
		vector<pii> ans;
		REP(i, T) ans.push_back(pii(score[i], i));
		sort(ALL(ans), greater<pii>());
		
		if (debug) putchar('@');
		
		REP(i, ans.size()) {
			if (i > 0 && ans[i - 1].fi == ans[i].fi) putchar('=');
			else if (i > 0) putchar(',');
			printf("%d", ans[i].se + 1);
		}
			
		puts("");
	}
	
	return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
using ll = long long;
int n;
ll a[N];
int main() {
	cin>>n;
	for(int i = 0; i < n; ++i) cin>>a[i];
	set<int> st;
	for(int i = 0; i < n; ++i) st.emplace(a[i]);
	if((int) st.size() == n) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 11136
from collections import deque
n=int(input())
D=deque(list(map(int,input().split())))
pop=D.popleft
A=pop()
memo=0
ans=0
for _ in range(n-1):
    a=pop()
    if memo==0:
        if A>a:
            memo=-1
        elif A<a:
            memo=1
        else:
            pass
    elif memo==1:
        if A>a:
            ans+=1
            memo=0
        else:
            pass
    else:
        if A<a:
            ans+=1
            memo=0
        else:
            pass
    A=a
print(ans+1)

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

using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;

struct BipartiteMatching {
  vector< vector< int > > graph;
  vector< int > match, used;
  int timestamp;

  BipartiteMatching(int n) : graph(n), used(n, 0), match(n, -1), timestamp(0) {}

  void add_edge(int u, int v) {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  bool dfs(int idx) {
    used[idx] = timestamp;
    for(auto &to : graph[idx]) {
      int to_match = match[to];
      // とりあえずつなげる
      // つながりたいやつがもう繋がってたら，そいつが他のやつに繋がれないか探す
      // つまり増加パスを探すとも言える
      if(to_match == -1 || (used[to_match] != timestamp && dfs(to_match))) {
        match[idx] = to;
        match[to] = idx;
        return true;
      }
    }
    return false;
  }

  int bipartite_matching() {
    int ret = 0;
    for(int i = 0; i < int(graph.size()); i++) {
      if(match[i] == -1) {
        ++timestamp;
        ret += dfs(i);
      }
    }
    return ret;
  }

  void output() {
    for(int i = 0; i < int(graph.size()); i++) {
      if(i < match[i]) {
        cout << i << "-" << match[i] << endl;
      }
    }
  }
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // int n, m;
  // cin >> n >> m;
  // rep(i, n) rep(j, m){
  //   string tmp;
  //   cin >> tmp;
  //   bool is_edge = tmp == "o";
  //   if(is_edge) bm.add_edge(i, n+j);
  // }
  int x, y, m;
  cin >> x >> y >> m;
  BipartiteMatching bm(x+y);
  rep(i, m){
    int from, to;
    cin >> from >> to;
    to += x;
    bm.add_edge(from, to);
  }
  int res = bm.bipartite_matching();
  cout << res << endl;
  // bm.output();
}



Measured memory_bytes: 3356
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		long  h =scn.nextLong();
		long w = scn.nextLong();
		
		long val=0;
		if(h==1 || w==1){
			System.out.println("1");
			return;
		}
		val=w*h;
		if(val%2!=0){
			val=val/2;
			val+=1;
			System.out.println(val);
		}else{
			val=val/2;
			System.out.println(val);
		}

	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int k;
	cin >> k;
	vector<vector<int>> is(26);
	int n = s.size();
	rep(i, n) is[s[i] - 'a'].push_back(i);
	set<string> st;
	rep(i, 26) {
		if (is[i].size() == 0) continue;
		for (int c : is[i]) {
			for (int j = 1; j <= min(5, n - c); ++j) {
				st.insert(s.substr(c, j));
			}
		}
		if (st.size() >= k) break;
	}
	rep(i, k - 1) st.erase(*st.begin());
	cout << *st.begin() << endl;
	return 0;
}


Measured memory_bytes: 3688
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)


def main():
    x, y = map(int, input().split())
    if x == y:
        print(0)
        return
    if x == 0:
        if y < 0:
            print(abs(y) + 1)
            return
        else:
            print(y)
            return
    if x < 0:
        if y > 0:
            if abs(x) < y:
                print(y - abs(x) + 1)
                return
            else:
                print(abs(x) - y + 1)
                return
        elif y == 0:
            print(abs(x))
            return
        else:
            if x > y:
                print(x - y + 2)
                return
            else:
                print(y - x)
                return
    else:
        if y > 0:
            if x < y:
                print(y - x)
                return
            else:
                print(x - y + 2)
                return
        elif y == 0:
            print(x + 1)
            return
        else:
            if x < abs(y):
                print(abs(y) - x + 1)
                return
            else:
                print(x - abs(y) + 1)



if __name__ == "__main__":
    main()


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n; cin >> n;
    vl a(n);
    rep(i,n)cin>>a[i];
    ll ttl = accumulate(all(a),0LL);
    ll even_ttl = 0;
    for(int i=1;i<n-1;i+=2)even_ttl += 2*a[i];
    ll dif = ttl - even_ttl;
    vl x(n);
    x[0] = dif;
    rep(i,n-1)x[i+1] = 2*a[i] - x[i];
    rep(i,n){
        if(i)cout << " ";
        cout << x[i];
    }
    cout << endl;
}


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

int main() {
  int N,sum=0;
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  for(int i=0;i<N;i++){
      sum += vec.at(i);
  }
  cout << (sum-N) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
    int a[4];
    vint n(10);
    rep(i, 4)
    {
        cin >> a[i];
        n[a[i]]++;
    }

    if(n[1]==1 and n[4]==1 and n[7]==1 and n[9]==1)
    cout << "YES";
    else
    {
        cout << "NO";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
// dp[足場iをみた時] <- INF埋めしてから最小値
int dp[100100];
int main(){
  int n,k;
  cin >> n >> k;
  vector<int>h(n);
  rep(i,n)cin >> h[i];
  rep(i,100100)dp[i] = INF;
  dp[0] = 0;
  rep(i,n - 1){
    REP(j,1,k + 1){
      if(i + j >= n)continue;
      dp[i + j] = min(dp[i + j],dp[i] + abs(h[i] - h[i + j]));
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 3980
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
const int INF = 1e9;
const double pi = acos(-1.0);
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
int main(){
    string s, t;
    cin >> s >> t;
    ll cnt = 0;
    rep(i,s.size())if(s[i] != t[i])cnt++;
    cout << cnt << endl;
    return 0;
}  

Measured memory_bytes: 3836
/*
This is code of SuperJ6 for Atcoder.
Don't copy my code during f*kin' contests.

2.71828182845904523536
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
#define endl '\n'

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	cin >> s;

	int k = 0;
	string last, cur;
	for(int i = 0; i < s.size(); i++){
		cur += s[i];
		if(i < s.size() && cur == last) continue;
		k++;
		last = cur;
		cur = "";
	}
	
	cout << k << endl;

	return 0;
}

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

namespace ConsoleApp12
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] W = Enumerable.Range(0, N).Select(_ => Console.ReadLine()).ToArray();
            Dictionary<string, bool> dict = new Dictionary<string, bool>();
            string res = "Yes";
            string prev = W[0];
            bool t = true;
            dict.Add(prev, true);
            for(int i = 1; i < N; i++)
            {
                string now = W[i];
                if (prev.Last() != now.First() || dict.TryGetValue(now, out t)) {
                    res = "No";
                    break;
                }
                dict.Add(now, true);
                prev = now;
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13408
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 3 2019
 * 
 */

#include <bits/stdc++.h>

//#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

        bint n;

        cin>>n;

        bint min_number = INT_MAX;

        bint sum =0;
        bint negative_counter = 0;
        rep(n){
            bint temp;

            cin>>temp;
            negative_counter += (temp < 0);
            min_number = min(abs(temp),min_number);
            sum+=abs(temp);
        }

        if(negative_counter & 1)
            cout<<sum-(2*min_number)<<endl;
        else
            cout<<sum<<endl;


        return ;
    }




    int main(void){
#ifdef FAST_INPUT_OUTPUT
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        cout.tie(nullptr);
        cout<<setprecision(10);
        cout<<fixed;
        cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
        freopen("din","r",stdin);
        freopen("dout","w",stdout);
#endif
        int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>
using namespace std;
#define MAX 100005

int main(){
	int a, b, t[3];
	cin >> a >> b >> t[0] >> t[1] >> t[2];
	if(a < 0){
		cout << -a*t[0] + t[1] + b*t[2] << endl;
	}else{
		cout << t[2]*(b-a) << endl;
	}
	return 0;
}

Measured memory_bytes: 3100
x1, y1, x2, y2 = map(int, input().split())

x3 = x2-(y2-y1)
y3 = y2+(x2-x1)
x4 = x3-(y3-y2)
y4 = y3+(x3-x2)

print(x3,y3,x4,y4)

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

int main()
{
	long long int n;
	cin>>n;
	string s="";
	while(n>0)
	{
		int j=(n-1)%26;
		s.push_back((char)(j+'a'));
		n=(n-1)/26;
	}
	reverse(s.begin(),s.end());
	cout<<s;
}



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

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int ans = 800 * input[0] - 200 * (input[0] / 15);
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e18;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+3;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      
      int n;
      cin>>n;
      int a[n];
      for(int i=0;i<n;i++) cin>>a[i];
      a[0]-=1;
      for(int i=1;i<n;i++)
      {
            if(a[i]==a[i-1])
            {

            }
            else if(a[i]>a[i-1])
            {
                  a[i]--;
            }
            else{
                  cout<<"No\n";
                  return 0;
            }
      }
      cout<<"Yes";
}
// I never lose. I either win or I learn


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define ar array
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
lld n,m;
lld arr[300000];
string st;
int main()
{
     ios;
     lld TESTS,q,a,s,b,r,k,c,p,h,w,d,x,y,z,xs,ys,t;
     TESTS=1;
//     ans=0;
     //cin>>TESTS;
   //  memset(dpt,0,sizeof(dpt));memset(dput,0,sizeof(dput));
    // memset(dsu1,0,sizeof(dsu1));
     while(TESTS--)
     {
         cin>>k>>n;
         rep(i,0,n-1)cin>>arr[i];
         lld maxi=0;
         rep(i,0,n-2)maxi=max(maxi,arr[i+1]-arr[i]);
         maxi=max(maxi,k-arr[n-1]+arr[0]);
         cout<<k-maxi;
     }
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
using namespace std;

int main(int argc, char const *argv[])
{
    int s;
    int h, m;

    cin >> s;
    h = s/3600;
    s = s%3600;
    m = s/60;
    s = s%60;

    printf("%d:%d:%d\n", h, m, s);
    return 0;
}



Measured memory_bytes: 3200
#include <cstdio>
#include <cassert>
#include <cstring>
#include <algorithm>
#define meow(args...) fprintf(stderr, args)
const int N=2e5, M=1e6+1, P=998244353;
int n, a[N], dup[M], s[M], inv[M];
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar(), c-'0'>9&c!='-');
	for(a=(b=c=='-')?0:c-'0'; (c=getchar()-'0')<=9; a=a*10+c);
	return b?-a:a;
}
int main() {
	int (*rd)()=read<int>, m, ans=0;
	n=rd();
	std::generate(a, a+n, rd);
	m=*std::max_element(a, a+n);
	for(int i=0; i<n; ++i) ++dup[a[i]];
	for(int i=1; i<=m; ++i) {
		int s1=0, s2=0;
		for(int j=i; j<=m; j+=i) {
			s1=(s1+(long long)j*dup[j])%P;
			s2=(s2+(long long)j*j%P*dup[j])%P;
		}
		s[i]=((long long)s1*s1+P-s2)%P*((P+1)/2)%P;
	}
	for(int i=m; i>=1; --i)
		for(int j=i*2; j<=m; j+=i)
			if((s[i]-=s[j])<0) s[i]+=P;
	inv[1]=1;
	for(int i=2; i<=m; ++i) inv[i]=(long long)(P-P/i)*inv[P%i]%P;
	for(int i=1; i<=m; ++i) ans=(ans+(long long)s[i]*inv[i])%P;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> l(k), r(k);
  rep(i,k) cin >> l[i] >> r[i];
  vector<mint> dp(n+1);
  vector<mint> dpsum(n+1);
  dp[1] = 1;
  dpsum[1] = 1;
  for (int i = 2; i <= n; ++i) {
    rep(j,k) {
      // [l[i], r[i]]
      int li = i-r[j];
      int ri = i-l[j];
      if (ri < 0) continue;
      li = max(li,1);
      dp[i] += dpsum[ri]-dpsum[li-1]; //dp[li]~dp[ri];
    }
    dpsum[i] = dpsum[i-1]+dp[i];
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 6428
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  string s;
  cin>>N>>s;
  int Max=0;
  int sum=0;
  for(int i=0;i<N;i++){
   if(s.at(i)=='I')
     sum++;
    else
      sum--;
    if(Max<=sum)
      Max=sum;
   }cout<<Max<<endl;
   
  return 0;
  }

Measured memory_bytes: 256
INF = 10000
$dx = [1,0,-1,0]
$dy = [0,1,0,-1]
$dp = []
$n = 100

def bfs(pos,queue,bb) 
	while(not queue.empty?) do
		pos = queue.shift
		cnt = bb[pos[0]][pos[1]]
		npos = []
		4.times{|i|
			npos[0] = pos[0] + $dy[i]
			npos[1] = pos[1] + $dx[i]
			if ((0..$h-1).include?(npos[0]) and (0..$w-1).include?(npos[1])) then
				if ($b[npos[0]][npos[1]] == 0 and bb[npos[0]][npos[1]] == -1) then
					bb[npos[0]][npos[1]] = cnt + 1
					queue.push([npos[0],npos[1]])
				end
			end
		}
	end
end

def rec(s,v)
	if $dp[s][v] >= 0 then
		return $dp[s][v]
	end
	
	if ( s == ((1 << $n) -1)) then
		return $dp[s][v] = $dist[0][v+1]
	end
	
	res = INF
	$n.times{|u|
		if ((s >> u & 1) == 0) then
			
			tmp = (rec(s | 1 << u,u) + $dist[v+1][u+1] )
			if tmp < res then
				res = tmp
			end
		end
	}
	
	return $dp[s][v] = res
end

loop{

	$w,$h =gets.split.map(&:to_i)
	if ($w==0 and $h == 0) then
		break
	end
	$b = Array.new($h).map{Array.new($w)}
	d = Array.new()
	dcost = Array.new()
	s = Array.new(2)
	
	$h.times{|hh|
		$b[hh] = gets.chomp.chars.each_with_index.map{|c,i|
			case c 
			when '.'
				0
			when '*'
				d.push([hh,i])
				0
			when 'o'
				s = [hh,i]
				0
			else
				-100
			end
		}
	}
	bb = Array.new($h).map{Array.new($w,-1)}
	queue = []
	queue.push(s)
	bb[s[0]][s[1]] = 0
	bfs(s,queue,bb)

	flag = true
	
	dsize = d.size()
	$n = dsize
	$dist = Array.new(dsize+1).map{Array.new(dsize+1,-1)}
	$dist[0][0] = 0
	d.each_with_index{|pos,i|
		$dist[0][i+1] = bb[pos[0]][pos[1]]
		$dist[i+1][0] = bb[pos[0]][pos[1]]
		
		if bb[pos[0]][pos[1]] == -1 then
			flag = false
		end
	}
	
	if (!flag) then
		print "-1\n"
		next
	end
	
	

	d.each_with_index{|pos,i|
		bb = Array.new($h).map{Array.new($w,-1)}
		queue = []
		queue.push(pos)
		bb[pos[0]][pos[1]] = 0
		bfs(pos,queue,bb)
		dsize.times{|j|
			pos2 = d[j]
			$dist[i+1][j+1] = bb[pos2[0]][pos2[1]]
		}
		
	}
	$dp = Array.new(1 << $n).map{Array.new($n,-1)}
	ans = INF
	$n.times{|i|
		tmp = rec(0,i)
		if ans > tmp then
			ans = tmp
		end
	}
	p ans
}

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

int n;
const int m = 10;
int *data;
int *lp;
int *rp;

//return...fail:0, success:1
bool dfs(int i, int l, int r)
{
	if (i == m)
		return true;

	if (i<m && l<m && lp[l-1]<data[i]) {
		lp[l] = data[i];
		if (dfs(i+1, l+1, r))
			return true;
	}

	if (i<m && r<m && rp[r-1]<data[i]) {
		rp[r] = data[i];
		if (dfs(i+1, l, r+1))
			return true;
	}

	return false;
}

int main()
{
	int i, j;
	data = (int *)calloc(m, sizeof(int));
	lp = (int *)calloc(m, sizeof(int));
	rp = (int *)calloc(m, sizeof(int));
	
	scanf("%d ", &n);
	for (i=0; i<n; i++) {
		for (j=0; j<m; j++)
			scanf("%d ", &(data[j]));

		memset(lp, 0, sizeof(int));
		memset(rp, 0, sizeof(int));

	lp[0] = data[0];
	if (dfs(1, 1, 0))
		puts("YES");
	else
		puts("NO");

/*
		//check input
		for (j=0; j<m; j++)
			printf("%d ", data[j]);
		puts("");
*/
	}

	free(data);
	free(lp);
	free(rp);
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int N,M,C;
    int answer = 0;
    scanf("%d %d %d",&N,&M,&C);
    int *B = (int *)calloc(M,sizeof(int));
    for(int i=0;i<M;i++) {
        scanf("%d",&B[i]);
    }
    int **num = (int **)calloc(N,sizeof(int *));
    for(int i=0;i<N;i++) {
        num[i] = calloc(M,sizeof(int));
        for(int j=0;j<M;j++) {
            scanf("%d",&num[i][j]);
        }
    }

    for(int i=0;i<N;i++) {
        int isAnswer = 0;
        for(int j=0;j<M;j++) {
            isAnswer += num[i][j]*B[j];
        }
        if((isAnswer + C) > 0) {
            answer++;
        }
    }

    printf("%d",answer);

    return 0;
    
}

Measured memory_bytes: 128
def func(A,H,W):
    H_del=[]
    W_del=[]
    for h in range(H):
        if A[h][0]=='.':
            g=1
            for w in range(1,W):
                if A[h][w]!='.':
                    g=0
                    break
            if g==1:
                H_del.append(h)
    for w in range(W):
        if A[0][w]=='.':
            g=1
            for h in range(1,H):
                if A[h][w]!='.':
                    g=0
                    break
            if g==1:
                W_del.append(w)
    return H_del,W_del

def show(A,H_del,W_del,H,W):
    for h in range(H):
        if h in H_del:
            continue
        for w in range(W):
            if w in W_del:
                continue
            print(A[h][w],end='')
        print('')
H,W=map(int,input().split())
A=[]
H_del=[]
W_del=[]
for i in range(H):
    A.append(list(input()))
H_del,W_del=func(A,H,W)
show(A,H_del,W_del,H,W)


Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
//#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    ll x;cin>>x;
    ll g=x/500;
    x-=g*500;
    ll l=x/5;
    cout<<g*1000+l*5<<endl;
    
    return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,c;
  cin>>n>>c;
  vvll d(c,vll(c));
  vvll t(n,vll(n));
  rep(i,c){
    rep(j,c){
      cin>>d[i][j];
    }
  }
  rep(i,n){
    rep(j,n){
      cin>>t[i][j];
    }
  }
  vvll y(3,vll(c));
  rep(i,n){
    rep(j,n){
      ll u=(i+j+2)%3;
      y[u][t[i][j]-1]++;
    }
  }
  ll ans=INF;
  for(int i=0;i<c;i++){
    for(int j=0;j<c;j++){
      for(int u=0;u<c;u++){
        if(i==j||i==u||j==u){
          continue;
        }
        ll cu=0;
        
        rep(q,c){
          if(q==i)continue;
          if(y[0][q]){
            cu+=d[q][i]*y[0][q];
          }
        }
        rep(q,c){
          if(q==j)continue;
          if(y[1][q]){
            cu+=d[q][j]*y[1][q];
          }
        }
        rep(q,c){
          if(q==u)continue;
          if(y[2][q]){
            cu+=d[q][u]*y[2][q];
          }
        }
        ans=min(ans,cu);
      }
    }
  }
  COUT(ans);
}


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

int main(){
    int h,w;
    while(1){
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(j > 0 && j < w - 1 && i > 0 && i < h - 1){
                    cout << ".";
                } else{
                    cout <<  "#";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3112