akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, i, j;
  cin >> N;
  int sum = 0;
  int min = 114514;
  int A[N];
  
  for (i = 0; i < N; i++) {
    cin >> A[i];
    sum = 0;
    for (j = 0; j < 100000; j++) {
      if (A[i] % 2 == 0) {
        A[i] /= 2;
        sum++;
      }
      else {
        if (sum < min) min = sum;
        break;
      }
    }
  }

  if (min == 114514) cout << 0 << endl;
  else cout << min << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;
static const long long INF = 1<<31;

string s;
int n, dp[100005][4];

int main(void) {
  cin >> n >> s;
  
  for (int i=0; i<=1; i++) for (int j=0; j<=3; j++) dp[i][j] = (j>>i) & 1;
  
  for (int i=1; i<n-1; i++) for (int j=0; j<=3; j++) {
    dp[i+1][j] = (dp[i-1][j] + dp[i][j] + (s[i]=='o' ? 1 : 0) ) % 2;
  }
  
  int idx = -1;
  for (int i=0; i<=3; i++) {
    if (((dp[n-2][i]+dp[n-1][i]+(s[n-1]=='o' ? 1 : 0))%2 == dp[0][i]) && (dp[0][i]+dp[1][i]+(s[0]=='o' ? 1 : 0))%2==dp[n-1][i]) idx = i;
  }
  
  if (idx==-1) {
    puts("-1");
    return 0;
  }
  
  for (int i=0; i<n; i++) {
    if (dp[i][idx]) printf("S");
    else printf("W");
  }
  
  printf("\n");
  
    
    //cout << ans << "\n";

    return 0;
}



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

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> weight(N), value(N);
  for (int i = 0; i < N; i++) {
    cin >> weight.at(i) >> value.at(i);
  }
  
  vector<vector<long long int>> DP(N + 1, vector<long long int>(W + 1));
  for (int j = 0; j <= W; j++) DP.at(0).at(j) = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= W; j++) {
      if (j >= weight.at(i)) {
        DP.at(i + 1).at(j) = max(DP.at(i).at(j - weight.at(i)) + value.at(i),
                                 DP.at(i).at(j));
      }
      else DP.at(i + 1).at(j) = DP.at(i).at(j);
    }
  }
  
  cout << DP.at(N).at(W) << endl;
}

Measured memory_bytes: 80256
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        String str;
        while(!(str = scn.next()).equals("-")) {
            int lim = scn.nextInt();
            for(int i = 0; i < lim; i++) {
                int n = scn.nextInt();
                str = str.substring(n) + str.substring(0, n);
            }
            System.out.println(str);
        }
    }
}

Measured memory_bytes: 26392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main() {
  ll n;
  string x;
  cin >> n;
  vector<string> s(n);
  vector<ll> vec(n);
  ll sum = 0;
  rep(i,n){
    cin >> s[i] >> vec[i];
    sum += vec[i];
  }
  cin >> x;
  rep(i,n){
    sum -= vec[i];
    if(s[i] == x){
      break;
    }
  }
  cout << sum << endl;

}

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

int main(void) {
    int N;
    int A[2][101] = {{0}, {0}};

    cin >> N;
    for (int i = 0; i < 2; i++) {
        for (int j = 1; j <= N; j++) {
            cin >> A[i][j];
        }
    }

    for (int i = 1; i <= N; i++) {
        A[0][i] += A[0][i - 1];
    }

    for (int i = 1; i <= N; i++) {
        A[1][i] += max(A[1][i - 1], A[0][i]);
    }

    cout << A[1][N] << endl;

    return 0;
}

Measured memory_bytes: 256
# E - Knapsack 2

N, W = map(int, input().split())
knapsack_list = []
value_max = 0
max_cost = 0
for i in range(N):
    knap =  list(map(int, input().split()))
    knapsack_list.append(knap)
    value_max = value_max + knap[1]

cost_list = [[10**12]*(value_max+1) for _ in range(N+1)]

cost_list[0][0] = 0
for i in range(N):
    cost_list[i+1][0] = 0
    weight = knapsack_list[i][0]
    value = knapsack_list[i][1]
    for j in range(value_max+1):
        if j<value:
            cost_list[i+1][j] = cost_list[i][j] # そのまま遷移させる
            continue
        new_cost = cost_list[i][j-value] + weight
        new_cost = min(cost_list[i][j], new_cost)
        cost_list[i+1][j] = new_cost # 次の遷移状態へコストを渡す

for i in range(value_max+1):
    weight = cost_list[N][i]
    if weight<=W:
        max_cost = i

print(max_cost)


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

int main(void) {
    int H, W;
    cin >> H >> W;
    vector<string> s(H);

    for (int i = 0; i < H; i++)
    {
        cin >> s[i];
    }
    
    deque<pii> deq;
    vector<vector<int>> cost(H, vector<int>(W, INF));

    if(s[0][0] == '.'){
        cost[0][0] = 0;
    } else {
        cost[0][0] = 1;
    }

    vector<int> dh = {0,1};
    vector<int> dw = {1,0};

    deq.push_back(pii(0,0));

    while (!deq.empty())
    {
        pii front = deq.front();
        deq.pop_front();

        for (int i = 0; i < 2; i++)
        {
            int h_next = front.first + dh[i];
            int w_next = front.second + dw[i];

            if(h_next >= H) continue;
            if(w_next >= W) continue;

            if(s[h_next][w_next] == '#' && s[front.first][front.second] == '.'){
                if(cost[h_next][w_next] > cost[front.first][front.second] + 1){
                    cost[h_next][w_next] = cost[front.first][front.second] + 1;
                    deq.push_back(pii(h_next, w_next));
                }
            } else {
                if(cost[h_next][w_next] > cost[front.first][front.second]){
                    cost[h_next][w_next] = cost[front.first][front.second];
                    deq.push_front(pii(h_next, w_next));
                }
            }
            
        }
    }

    cout << cost[H-1][W-1] << endl;
    
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; ++i)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define P pair<int, int>

map<string, char> m;

void set_m(){
  m["11"] = 'a';
  m["12"] = 'b';
  m["13"] = 'c';
  m["14"] = 'd';
  m["15"] = 'e';
  m["21"] = 'f';
  m["22"] = 'g';
  m["23"] = 'h';
  m["24"] = 'i';
  m["25"] = 'j';
  m["31"] = 'k';
  m["32"] = 'l';
  m["33"] = 'm';
  m["34"] = 'n';
  m["35"] = 'o';
  m["41"] = 'p';
  m["42"] = 'q';
  m["43"] = 'r';
  m["44"] = 's';
  m["45"] = 't';
  m["51"] = 'u';
  m["52"] = 'v';
  m["53"] = 'w';
  m["54"] = 'x';
  m["55"] = 'y';
  m["61"] = 'z';
  m["62"] = '.';
  m["63"] = '?';
  m["64"] = '!';
  m["65"] = ' ';
}

bool has_key(string s){
  return ((m.find(s) == m.end()) ? false : true);
}

int main() {
  set_m();
  string str;
  while(cin >>str){
    string ans = "";
    if(str.length() % 2 != 0) ans = "NA";
    for(int i = 0; ans != "NA" && i < str.size(); i += 2){
      string now = str.substr(i, 2);
      if(!has_key(now)) ans = "NA";
      else ans += m[now];
    }
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 1216
import sys
import re
import random
# import numpy as np
from math import sqrt,log
from fractions import gcd  # python<=3.4
from collections import Counter, defaultdict

def lcm(a,b):
  return a // gcd(a,b) * b

## INPUT

def read_int():
  return int(input())

def read_ints():
  # return map(int,raw_input().split())
  return [int(x) for x in input().split()]

def read_field():
  return input().rstrip()

def read_fields():
  return input().rstrip().split()

def solve(a,b,n):
    x=min(b-1, n)
    # print("x=%d" % x)
    u=a*x//b
    # print("u=%d" % u)
    return u

a,b,n = read_ints()
print(solve(a,b,n))


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

int main(void) {
    uint64_t N,M;
    uint64_t s,c;
    cin >> N >> M;

    if((N*2) < M){
        cout << N + ((M-(N*2)) / 4) << "\n";
    } else {
        cout << M/2 << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,a;
  cin >> n >> a;
  if(n%500<=a) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

int main(){
    int n, c;
    cin >> n >> c;
    vector<int> cakes(c);
    for(auto&& i : cakes){
        cin >> i;
    }
    int sum = accumulate(begin(cakes), end(cakes), 0);
    cout << sum / (n + 1) + !!(sum % (n + 1)) << "\n";
}


Measured memory_bytes: 3120
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int C = windowCover(sc.nextInt(), sc.nextInt());
		System.out.println(C);
		
		sc.close();

	}
	
	static int windowCover(int A, int B) {
		int C = A-2*B;
		if(C < 0) {
			C = 0;
		}
		return C;
	}

}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define __ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int maxn = 2e5 + 10;
const int maxm = 1e4 + 10;
const ll mod = 998244353;

int n, a[maxn], b[maxn];

int main() {
    __;
    cin >> n;
    ll ct = 0;
    for (int i = 1; i <= n + 1; ++i)cin >> a[i];
    for (int i = 1; i <= n; ++i)cin >> b[i];
    for (int i = 1; i <= n + 1; ++i) {
        if (a[i] <= b[i]) {
            b[i] -= a[i];
            ct += a[i];
            a[i] = 0;
        } else {
            ct += b[i];
            a[i] -= b[i];
            b[i] = 0;
        }
        if (a[i + 1] <= b[i]) {
            b[i] -= a[i + 1];
            ct += a[i + 1];
            a[i + 1] = 0;
        } else {
            ct += b[i];
            a[i + 1] -= b[i];
            b[i] = 0;
        }
    }
    cout << ct << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
 int n;
 cin >> n;
 VI t(n);
 rep(i,n){
   cin >> t.at(i);
 }
 int m;
 cin >> m;
 VI p(m),x(m);
 rep(i,m){
   cin >> p.at(i) >> x.at(i);
 }
 rep(i,m){
   ll sum=0;
   rep(j,n){
     if(j==p.at(i)-1){
       sum+=x.at(i);
     }
     else sum+=t.at(j);
   }
   cout << sum << endl;
 }
}

Measured memory_bytes: 3560
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  int n,k;
  cin>>n;
  int cnt=0;
  for(int i=1;i<=n;i++){
    cin>>k;
    if(k!=i)cnt++;
  }
  if(cnt<=2)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define fbo find_by_order
#define ook order_of_key
#define INF (ll)1e18
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

const ld PI=3.14159265358979323846;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ld a,b,c,d;cin>>a>>b>>c>>d;
    ld ma=d*6;
    ld ha=c*30+d/2;
    ld angle=abs(ha-ma)*PI/180.0;
    ld e=a*a+b*b-2.0*a*b*cos(angle);
    cout<<fixed<<setprecision(24)<<pow(e,0.5)<<"\n";
}


Measured memory_bytes: 4184
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  while(true){
    vector<int> v;
    string str;
    getline(cin, str);
    stringstream ss(str);
    int tmp;
    while(ss>>tmp){
      if(tmp == 0) goto end;
      if(tmp > 10) tmp = 10;
      v.push_back(tmp);
    }
    sort(v.begin(), v.end());
    int sum = accumulate(ALL(v), 0);
    if(sum < 12 && v[0] == 1)
      sum += 10;
    if(sum > 21) sum = 0;
    cout << sum << endl;
  }
 end:
  return 0;
}

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

using namespace std;

int main()
{
    typedef pair<string,int> p;
    typedef pair<p,int> q;
    q p1[150];
    int N,i,m;
    cin>>N;
    for(i=0; i<N; i++)
    {
        cin>>p1[i].first.first>>m;
        p1[i].first.second=101-m;
        p1[i].second=i+1;
    }
    sort(p1,p1+N);
    for(i=0; i<N; i++)
        cout<<p1[i].second<<endl;
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
const double eps = 0.000000000001;
typedef long long ll;
struct edge { int to; int cost;};
int ans[114514];
signed main() {
	string s; cin >> s;
	char now = s[0];
	vector<int>V;
	rep(i, s.size() - 1) {
		if (s[i] == 'R'&&s[i + 1] == 'L') {
			V.push_back(i);
		}
	}
	V.push_back(inf);
	rep(i, s.size()) {
		if (s[i] == 'R') {
			int st = *lower_bound(V.begin(), V.end(), i);
			if ((st - i) & 1)ans[st + 1]++;
			else ans[st]++;
		}
		else {
			auto st = upper_bound(V.begin(), V.end(), i);
			st--;
			int u = *st;
			if ((u - i) & 1)ans[u + 1]++;
			else ans[u]++;
		}
	}
	rep(i, s.size()) {
		if (i)cout << ' '; cout << ans[i];
	}cout << endl;
}

Measured memory_bytes: 1912
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int k=scanner.nextInt();
        String s=scanner.next();
        if(s.length()<=k){
            System.out.println(s);
        }
        else{
            System.out.println(s.substring(0,k)+"...");
        }

    }

}


Measured memory_bytes: 27036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 2e9;
typedef pair<int, int> pi;
int a[200001];
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int xs = 0;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        xs ^= a[i];
    }
    for (int i = 0; i < n; i++) {
        cout << (xs ^ a[i]) << " ";
    }
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){

  string s;
  cin >> s;
  string t = "";
  rep(i,s.size())if(s[i] != 'x')t += s[i];
  for(int i = 0,j = (int)t.size()-1;i < j;i++,j--){
    if(t[i] != t[j]){
      cout << -1 << endl;
      return 0;
    }
  }
  ll l = 0,r = 0;
  ll res = 0;
  for(ll i = 0,j = s.size()-1;i < j;i++,j--){
    ll sl = 0,sr = 0;
    for(int k = i;s[k] == 'x';k++){
      sl++;
      i = k;
    }
    for(int k = j;s[k] == 'x';k--){
      sr++;
      j = k;
    }
    if(i < j)res += abs(sl-sr);
    if(sl)i++;
    if(sr)j--;
  }
  cout << res << endl;





  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s.size()==2){
        if(s[0]==s[1]) cout << 1 << " " << 2 << endl;
        else cout << -1 << " " << -1 << endl;
        return 0;
    }
    for(int i = 0;i<s.size()-2;i++){
        if(s[i]==s[i+1] || s[i]==s[i+2] || s[i+1]==s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys
from itertools import chain


def solve(N: int, D: int, X: "List[int]", Y: "List[int]"):
    D2 = D * D
    answer = 0
    for x, y in zip(X, Y):
        if x * x + y * y <= D2:
            answer += 1
    return answer


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # N, D, X, Y = map(int, line.split())
    N = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    X = [int()] * (N)  # type: "List[int]"
    Y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        X[i] = int(next(tokens))
        Y[i] = int(next(tokens))
    answer = solve(N, D, X, Y)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 83468
#include<stdio.h>
#include<algorithm>

using namespace std;

int main() {
	int n, ele, maxim = -1000001, minim = 1000001;
	long long int sum = 0;

	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%d", &ele);
		maxim = max(maxim, ele);
		minim = min(minim, ele);
		sum += ele;
	}
	printf("%d %d %lld\n", minim, maxim, sum);
}


Measured memory_bytes: 2760
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

ll a[10000010];

int main(){
	ll n; cin >> n;
	for( ll d = 1; d <= n; ++d ){
		ll k = d;
		while( k <= n ){
			++a[k];
			k += d;
		}
 	}
	ll sum = 0;
	for( ll k = 1; k <= n; ++k ){
		sum += a[k] * k;
	}
	cout << sum << endl;
}

Measured memory_bytes: 81764
#include<stdio.h>
#include<math.h>
int main(void){
  int N,i,x1;
  scanf("%d",&N);
  int A[N];
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<N;i++){
    if(i%2==0){
      x1=x1+A[i];
    }
    else{
      x1=x1-A[i];
    }
  }
  int ans[N];
  ans[0]=x1;
  for(i=1;i<N;i++){
    ans[i]=A[i-1]-ans[i-1]/2;
    ans[i]=ans[i]*2;
  }
  for(i=0;i<N;i++){
    printf("%d ",ans[i]);
  }
  return 0;
}

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

int main() {
  char S;

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

Measured memory_bytes: 256
s = str(input())
f = int(s[:2])
r = int(s[2:])
if 1<=f<=12:
    if 1<=r<=12:
        ans = 'AMBIGUOUS'
    else:
        ans = 'MMYY'
else:
    if 1<=r<=12:
        ans = 'YYMM'
    else:
        ans = 'NA'
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();

		char k[][] = new char[h][w];
		for (int i = 0; i < h; i++) {
			String s = sc.next();
			k[i] = s.toCharArray();
		}
boolean ans=true;
		for (int i = 0; i < h; i++) {
			for (int o = 0; o < w; o++) {
				if (k[i][o] == '#') {
					if (k[Math.min(i + 1, h-1)][o] == '.' && k[i][Math.min(o + 1,w-1)] == '.'
							&& k[Math.max(i - 1,0)][o] == '.' && k[i][Math.max(o - 1, 0)] == '.') {
ans=false;
break;
					}

				}
			}

		}
		if(ans){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23892
#include <stdio.h>
#include <math.h>
int main(void){
    int s[1000]={0};
    int i,n;
    int sum;
    double a;
    double ave;
    
    while(1){
        scanf("%d\n", &n);
        if(n==0) break;
        sum=0;
        for(i=0; i<n; i++){
            scanf("%d", &s[i]);
            sum+=s[i];
        }
        
        ave=(double)sum/n;
        a=0;
        for(i=0;i<n;i++){
            a+=(s[i]-ave)*(s[i]-ave);
        }
        
        printf("%f\n", sqrt(a/n));
        
    }
    
    return 0;
}



Measured memory_bytes: 2068
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(int i=p;i<n;++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

ll N;

const ll MAXM = 3;
ll A[MAXM];
ll B[MAXM];

const ll MAXN = 5001 * 5001;
ll AB[MAXN];
ll BA[MAXN];

int main()
{
    cin >> N;
    rep (i, MAXM) { cin >> A[i]; }
    rep (i, MAXM) { cin >> B[i]; }

    AB[0] = N;

    for (ll w=0;w<=N;++w) if (AB[w] != 0)
    for (ll i=0;i<MAXM;++i) if (B[i] > A[i])
    {
        const ll ww = w + A[i];
        const ll vv = B[i] - A[i];

        if (ww <= N) { AB[ww] = max(AB[ww], AB[w] + vv); }
    }

    ll m1 = N;
    rep (i, N + 1) { m1 = max(m1, AB[i]); }

    BA[0] = m1;

    for (ll w=0;w<=m1;++w) if (BA[w] != 0)
    for (ll i=0;i<MAXM;++i) if (A[i] > B[i])
    {
        const ll ww = w + B[i];
        const ll vv = A[i] - B[i];

        if (ww <= m1) { BA[ww] = max(BA[ww], BA[w] + vv); }
    }

    ll m2 = m1;
    rep (i, m1 + 1) { m2 = max(m2, BA[i]); }

    cout << m2 << endl;

    return 0;
}


Measured memory_bytes: 196864
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <set>

using namespace std;

using ll = long long;

int main() {
    ll a, b;
    cin >> a >> b;
    set<ll> s;
    s.insert(a+b);
    s.insert(a-b);
    s.insert(a*b);
    cout << *s.rbegin() << "\n";
    return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

template <typename T>
std::tuple<T, T, T> extgcd(T a, T b){
    T s1 = 1, t1 = 0, s2 = 0, t2 = 1;
    while(b != 0){
        std::tie(s1, t1, s2, t2) = std::make_tuple(s2, t2, s1 - (a / b) * s2, t1 - (a / b) * t2);
        std::tie(a, b) = std::make_tuple(b, a % b);
    }
    return std::make_tuple(s1, t1, a);
}

template <typename T>
T mod_expt(T a, std::int64_t n, T mod){
    T power {1};
    while(n > 0){
        if(n & 1){power = power * a % mod;}
        a = a * a % mod;
        n >>= 1;
    }
    return power;
}

template <typename T>
T mod_inverse(T a, T mod){
    T b;
    std::tie(b, std::ignore, std::ignore) = extgcd(a, mod);
    if(b < 0){b += mod;}
    return b;
}

template<typename T>
std::tuple<T, T> garner(T a1, T n1, T a2, T n2){
    T s, t;
    std::tie(s, t, std::ignore) = extgcd(n1, n2);
    T n = n1 * n2, sol = (a2 * n1 % n * s % n + a1 * n2 % n * t % n) % n;
    if(sol < 0){sol += n;}
    return std::make_tuple(sol, n);
}

constexpr ll MOD = 1'000'000'007;
int N, A, B;

ll nCk(int n, int k){
    ll x = 1;

    for(int i=0;i<k;++i){
        x = x * (n - i) % MOD;
    }

    for(int i=1;i<=k;++i){
        x = x * mod_inverse<ll>(i, MOD) % MOD;
    }

    return x;
}

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

  std::cin >> N >> A >> B;

  ll res = (mod_expt<ll>(2, N, MOD) + MOD - 1) % MOD;
  res = (res + MOD - nCk(N, A)) % MOD;
  res = (res + MOD - nCk(N, B)) % MOD;

  std::cout << res << std::endl;
}


Measured memory_bytes: 256
s = int(input())
a = []
b = []
o = 0
count = 0
for j in range(s):
        if j%2 == 0:
                a.append(int(input()))
        else:
                b.append(int(input()))
a = sorted(a)
c = sorted(a+b)
for i in range(s):
        if o == len(a):
                break
        if a[o] == c[i]:
                if i%2 == 1:
                        count += 1
                o += 1
print(count)

Measured memory_bytes: 8920
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int inf = 6e18;
const int mod = 1e9 + 7;

signed main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    cin >> A >> B;
    auto dp = vector<vector<int>>(1 << N, vector<int>(N, inf));
    for (int i = 0; i < N; i++) {
        dp[1 << i][i] = i;
    }
    for (int i = 1; i < (1 << N); i++) {
        int now = __builtin_popcount(i);
        for (int j = 0; j < N; j++) {
            if (~i & (1 << j)) continue; // 0 continue
            int add = 0;
            for (int k = 0; k < N; k++) {
                if (i & (1 << k)) continue; // 1 continue
                int before = abs(j - (now - 1)) % 2 == 0 ? A[j] : B[j];
                int select = abs(k - now) % 2 == 0 ? A[k] : B[k];
                if (before <= select) dp[i | (1 << k)][k] = min(dp[i | (1 << k)][k], dp[i][j] + add);
                ++add;
            }
        }
    }
    int ans = inf;
    for (int i = 0; i < N; i++) ans = min(ans, dp[(1 << N) - 1][i]);
    cout << (ans == inf ? -1 : ans) << endl;
}


Measured memory_bytes: 47488
#include <bits/stdc++.h>
using namespace std;
// nichijou
#define REP(i,a,b) for (int i(a), _B(b); i < _B; ++i)
#define RP(i,n) REP(i,0,n)
#define PER(i,a,b) for(int i((a)-1), _B(b); i >= _B; --i)
#define PR(i,n) PER(i,n,0)
#define REP1(i,a,b) REP(i,a,(b)+1)
#define RP1(i,n) REP1(i,1,n)
#define PER1(i,a,b) PER(i,(a)+1,b)
#define PR1(i,n) PER1(i,n,1)
#define DO(n) REP(__i,0,n)
template<typename T>
void cmax(T & a, T b) {a = max(a, b);}
template<typename T>
void cmin(T & a, T b) {a = min(a, b);}

// data type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second

// STL container
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define CLR(a) a.clear()
#define BK(a) (a.back())
#define FT(a) (a.front())
#define DB(a) a.pop_back()
#define DF(a) a.pop_front()
#define PB push_back
#define EB emplace_back

/* I gave you my heart and then you turned around. */
void _BG(const char * s) {}
template<typename T, typename ... TT>
void _BG(const char * s,T a, TT...b)
{
	for (int c = 0; *s && (c || *s != ','); ++s) {
		cerr<<*s;
		switch (*s) {
		case '(':
		case '[':
		case '{':
			++c;
			break;
		case ')':
		case ']':
		case '}':
			--c;
			break;
		}
	}
	cerr<<" = "<<a;
	if (*s) {
		cerr<<", ";
		_BG(++s,b...);
	} else
		cerr<<endl;
}
#define BG(...) do { \
	cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
	_BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)

/* Reading input is now 20% cooler! */
bool RD(void) {return true;}
bool RD(char & a) {return scanf(" %c", &a) == 1;}
bool RD(char * a) {return scanf("%s", a) == 1;}
bool RD(double & a) {return scanf("%lf", &a) == 1;}
bool RD(int & a) {return scanf("%d", &a) == 1;}
bool RD(ll & a) {return scanf("%lld", &a) == 1;}

template<typename T, typename ... TT>
bool RD(T & a, TT & ...  b) {return RD(a) && RD(b...);}

/* Do princesses dream of magic sheep? */
#define RI(a) int a; RD(a)
#define RII(a,b) RI(a); RI(b)
#define RIII(a,b,c) RI(a); RII(b,c)
#define RIIII(a,b,c,d) RI(a); RIII(b,c,d)

/* For it's time for you to fulfill your output. */
void PT(const char a) {putchar(a);}
void PT(const char * a) {fputs(a, stdout);}
void PT(char * a) {fputs(a, stdout);}
void PT(const double a) {printf("%.16f", a);}
void PT(const int a) {printf("%d", a);}
void PT(const ll a) {printf("%lld", a);}

/* The line will last forever! */
template<char sep = ' ',char end = '\n'>
void PL(void) {if (end) PT(end);}
template<char sep = ' ',char end = '\n',typename T, typename ... TT>
void PL(const T a, const TT ...  b) {PT(a); if (sizeof...(b) && sep) PT(sep); PL<sep,end>(b...);}

/* Good Luck && Have Fun ! */
const int N = 1e5 + 87;
int c[N];
int main()
{
	RI(n);
	DO(n) {
		RI(a);
		++c[a];
	}
	int k = -1;
	RP1(i,n-1)
		if (c[i]) {
			if (c[i] + c[i+1] < n) {
				PL("No");
				return 0;
			}
			k = i;
			break;
		}
	if (c[k+1]) {
		n = c[k+1];
		k = k + 1 - c[k];
		if (1 <= k && k <= n/2)
			PL("Yes");
		else
			PL("No");
		return 0;
	}
	if (k == n - 1)
		PL("Yes");
	else if (k <= n/2)
		PL("Yes");
	else
		PL("No");
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long
template<class T> void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;

const long long LLINF = 1LL << 60;

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

	int hanako_point = 0, taro_point = 0;
	rep(i, N) {
		string taro, hanako;
		cin >> taro >> hanako;
		if (hanako > taro) {
			hanako_point += 3;
		}
		else if (hanako < taro) {
			taro_point += 3;
		}
		else {
			hanako_point++;
			taro_point++;
		}
	}

	printf("%d %d\n",taro_point,hanako_point);
}


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

#define rep(i,l,r) for(int i=l;i<=r;++i)
char s[10];
void out()
{
	puts("Impossible");
	exit(0);
}

int main()
{
	//freopen("1.in","r",stdin);
	int last=1;
	int n,m;
	cin>>n>>m;
	rep(i,1,n)
	{
		scanf("%s",s+1);
		rep(j,1,last-1)
		if(s[j]=='#')out();
		if(s[last]!='#')out();
		while(s[last+1]=='#')++last;
		rep(j,last+1,m)
		if(s[j]=='#')out();
	}
	if(last!=m)out();
	puts("Possible");
}

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

int main() {
	
	long long S,W;
	cin>>S>>W;
	
	if(W>=S)
	{
		cout<<"unsafe"<<endl;
	}
	else
	{
		cout<<"safe"<<endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 3624
from collections import deque

H,W = map(int, input().split())
fields = []
for i in range(H):
    fields.append(list(input()))
# print(fields)

mvs = [(1,0),(-1,0),(0,1),(0,-1)]

ans = 0
for i1 in range(H):
    for j1 in range(W):
        if fields[i1][j1] == "#":continue
        s = (i1,j1)
        # 探索
        q = deque([])
        q.append(s)
        used = [[-1]*W for i in range(H)]
        used[i1][j1] = 0
        while len(q) > 0:
            h,w = q.popleft()
            for dh,dw in mvs:
                if 0 <= h+dh < H and 0 <= w+dw < W:
                    if used[h+dh][w+dw]==-1 and fields[h+dh][w+dw]==".":
                        q.append((h+dh,w+dw))
                        used[h+dh][w+dw] = used[h][w] + 1
        for i in range(H):
            for j in range(W):
                ans = max(ans, used[i][j])
print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

int main() {

    string figure;

    while(cin >> figure) {
        int result = 0;
        char prev = '?';

        for(int i = 0; i < figure.length(); i++) {
            switch(figure[i]) {
                case 'M':
                    result += 1000;
                    if (prev == 'C')    result -= 200;
                    break;
                case 'D':
                    result += 500;
                    if (prev == 'C')    result -= 200;
                    break;
                case 'C':
                    result += 100;
                    if (prev == 'X')    result -= 20;
                    break;
                case 'L':
                    result += 50;
                    if (prev == 'X')    result -= 20;
                    break;
                case 'X':
                    result += 10;
                    if (prev == 'I')    result -= 2;
                    break;
                case 'V':
                    result += 5;
                    if (prev == 'I')    result -= 2;
                    break;
                case 'I':
                    result += 1;
                    break;
            }
            prev = figure[i];
        }

        cout << result << endl;
    }
     
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
 
int main() {
int n, m;
 
cin >> n >> m;
 
if ( n == m ) {
cout <<  "a == b" << endl;
} else if ( n > m) {
cout << "a > b" << endl;
} else {
cout <<  "a < b" << endl;
}
 
return 0;
}

Measured memory_bytes: 3080
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
//#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

ll n,m;
ll a[100],b[100];
bool suc=false;
vector<vl> mp;
set<ll> visited;

ll getNext(ll curPoint, ll disabledEdge){
  rp(i,mp[curPoint].size()){
    if(visited.find(mp[curPoint][i]) == visited.end()){
      if(!(curPoint== a[disabledEdge] && mp[curPoint][i] == b[disabledEdge]) &&
        !(curPoint== b[disabledEdge] && mp[curPoint][i] == a[disabledEdge])){
          // cout << "Returning bond is "<<curPoint+1<<" - "<<mp[curPoint][i]+1<<endl;
          // cout << "disabledEdge is " << a[disabledEdge]+1 <<" - "<< b[disabledEdge]+1 << " index is - "<<disabledEdge<<endl;
          return mp[curPoint][i];

        }
    }
  }
  return -1;
}
void doDFS(ll curPoint, ll desiredPoint, ll disabledEdge){
  visited.insert(curPoint);
  ll nextPoint = getNext(curPoint,disabledEdge);
  while(nextPoint != -1){
    // cout << "My current path is " << curPoint+1 << " - " << nextPoint+1<< endl;
    if(nextPoint == desiredPoint) {
      // cout <<"I made suc true"<<endl;
      suc = true;
      return;
    } else
      doDFS(nextPoint,desiredPoint,disabledEdge);
    nextPoint = getNext(curPoint,disabledEdge);
  }
}


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    cin >> n >>m;
    rp(i,n) {
      vl temp;
      mp.pb(temp);
    }
    rp(i,m) {
      cin >> a[i] >> b[i];
      a[i]--;
      b[i]--;
      mp[a[i]].pb(b[i]);
      mp[b[i]].pb(a[i]);
    }
    ll ans = 0;
    rp(i,m){
      visited.clear();
      suc = false;
      // cout <<"doing for i - "<<i<<endl;
      doDFS(a[i],b[i],i);
      // cout <<"At this point suc is "<<to_string(suc)<<endl;
      if (!suc) ans++;
    }
    cout << ans << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h> 
#include <iostream>
#include <map>
#include <cmath>
#include<set>
#include <vector>
#include<bitset>
#include <string>
#include<queue>
#include <algorithm>
#include<set>
using namespace std;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define vl vector<long long >;
//#define rep(i,a,b) for(int i=a;i<b;++i)
//typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,int>ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef long long ll;
const int N=1e5+5;
int A[N];int B[N];int C[N];
#define INF 10000
ll dp[N][4];
//int dp[N][N][N]={0};
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

/*void show(vi v,int valeur){
    int count=0;
    
    rep(i,0,(int)v.size()){
        ++count;
        cout<<v[i]<<" " ;
        if(count==valeur){cout<<"\n";count=0;}
    }
}*/
 int main() {
        ios_base::sync_with_stdio(false); cin.tie(NULL);int n,k;
  
  cin>>n;
  rep(i,0,n){
      cin>>A[i]>>B[i]>>C[i];
  }
  if(n==1){
      cout<<max(A[0],max(B[0],C[0]));return 0;
  }
  dp[n-1][1]=A[n-1];dp[n-1][2]=B[n-1];dp[n-1][3]=C[n-1];
  for(int j=(n-2);j>=0;--j){
      dp[j][1]=max(dp[j+1][2],dp[j+1][3])+A[j];
       dp[j][2]=max(dp[j+1][1],dp[j+1][3])+B[j];
        dp[j][3]=max(dp[j+1][2],dp[j+1][1])+C[j];
  }
  cout<<max(dp[0][1],max(dp[0][2],dp[0][3]));
   return 0;
 }



Measured memory_bytes: 7884
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    int N, tzero = 0;
    cin >> N;
    vector<int> A(N), cnt(100000);
    bool fl = false;
    ll ans = 1;
    for(int i = 0; i < N; ++i) {
        cin >> A[i];
        if(A[i] == 0) {
            ans = ans * (3 - tzero) % MOD;
            tzero++;
        } else {
            ans = ans * cnt[A[i] - 1] % MOD;
            cnt[A[i] - 1] = max(cnt[A[i] - 1] - 1, 0);
        }
        cnt[A[i]]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
  	ll x,y,z;cin>>x>>y>>z;
  	if(x+y+z>=22)cout<<"bust";
  	else cout<<"win";
}


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

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
//#define int long long
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define all(x) x.begin(), x.end()
using pii = pair<int, int>;
using ll = long long;

bool candiv[202][202];
string ss[202];
int M, N;
map<string, int> mp;
int rec(string &state) {
    int cnt = 0;
    if (mp.count(state)) {
        return mp[state];
    }
    REP(i, N) {
        bool same = true;
        REP(j, M) {
            if (state[j] != '?') {
                if (ss[i][j] != state[j]) {
                    same = false;
                    break;
                }
            }
        }
        if (same) cnt++;
    }
    if (cnt == 1) return mp[state] = 0;
    int ans = 100;
    REP(j, M) {
        if (state[j] == '?') {
            state[j] = '0';
            int res1 = 1 + rec(state);
            state[j] = '1';
            int res2 = 1 + rec(state);
            ans = min(ans, max(res1, res2));
            state[j] = '?';
        }
    }
    return mp[state] = ans;
}
bool solve() {
    cin >> M >> N;
    mp.clear();
    if (M == 0) return false;
    REP(i, N) {
        string s;
        cin >> s;
        ss[i] = s;
    }
    string state;
    REP(i, M) state += '?';
    int ans = rec(state);
    cout << ans << endl;
    return true;
}

signed main() {
    while (solve())
        ;
}


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

#ifdef LOCAL
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else 
#define dump(x) true
#endif

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int B = 50000;
bitset<B> bt[B];

int main() {
	int N, M, T; cin >> N >> M >> T;
	V<pii> sw(M);

	rep(i, M) {
		int x, y;
		cin >> x >> y;
		--x; --y;
		sw[i] = mp(x, y);
	}

	if (T == 2) {
		if (N == 2) {
			puts("-1");
			return 0;
		}
		string ans(M, '?');
		V<int> to(N), cnt(N);
		rep(i, N) {
			to[i] = i;
			cnt[i] = 1;
		}

		for (int i = M-1; i >= 0; --i) {
			int a, b;
			tie(a, b) = sw[i];
			if (to[a] == to[b]) {
				ans[i] = '^';
			} else {
				if (cnt[to[a]] > cnt[to[b]]) {
					ans[i] = 'v';
					--cnt[to[a]];
					++cnt[to[b]];
					to[a] = to[b];
				} else {
					ans[i] = '^';
					--cnt[to[b]];
					++cnt[to[a]];
					to[b] = to[a];					
				}
			}
		}
		cout << ans << endl;
	} else {
		rep(i, N) bt[i].set(i);
		for (int i = M-1; i >= 0; --i) {
			int a, b;
			tie(a, b) = sw[i];
			bt[a] = bt[b] = (bt[a] | bt[b]);
		}
		auto res = bt[0];
		for (int i = 1; i < N; ++i) {
			res = res & bt[i];
		}

		if (res.any()) {
			int to = res._Find_first();
			string ans(M, '?');
			V<int> can(N);
			can[to] = 1;
			for (int i = M-1; i >= 0; --i) {
				int a, b;
				tie(a, b) = sw[i];
				if (!can[a]) {
					ans[i] = 'v';
					can[a] = can[b];
				} else {
					ans[i] = '^';
					can[b] = can[a];
				}
			}
			cout << ans << endl;
		} else {
			puts("-1");
		}
	}

	return 0;
}

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

int main(){
    int N; cin >> N;
    ll nofd = 0, sum = 0;
    rep(i,N){
        ll d,c; cin >> d >> c;
        nofd += c;
        sum += d*c;
    }
    cout << (nofd - 1) + (sum-1)/9 << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  rep(i,n) {
    string s;
    cin >> s;
    rep(j,n) {
      if (s[j] == '1') g[i].emplace_back(j);
    }
  }

  vector<int> color(n, -1);
  auto dfs = [&](auto& f, int u, int p, int c)->int{
    if (color[u] != -1) return color[u] == c;
    color[u] = c;
    int ret = 1;
    for (auto v : g[u]) {
      if (v == p) continue;
      ret &= f(f, v, u, c ^ 1);
    }
    return ret;
  };

  if (!dfs(dfs, 0, -1, 0)) {
    cout << -1 << endl;
    return 0;
  }

  auto calc = [&](int s){
    queue<int> que;
    vector<int> d(n, -1);
    que.push(s);
    d[s] = 0;
    while (!que.empty()) {
      int u = que.front(); que.pop();
      for (auto v : g[u]) {
        if (d[v] == -1) {
          d[v] = d[u] + 1;
          que.push(v);
        }
      }
    }
    return *max_element(d.begin(), d.end());
  };
  int res = 0;
  for (int i = 0; i < n; i++) {
    res = max(res, calc(i) + 1);
  }
  cout << res << endl;
  return 0;
}


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

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, x = 0;
    cin >> n;
    while(n - 4*x >= 0 && (n-4*x)%7 != 0) {
        x++;
    }
    if((n-4*x)%7 == 0) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0; 
}

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

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

  if(a > b){
    cout << "a > b" << endl;
  }else if(a < b){
    cout << "a < b" << endl;
  }else if(a == b){
    cout << "a == b" << endl;
  }
  return 0;
}


Measured memory_bytes: 3092
def main():
    from collections import Counter
    import sys
    input = sys.stdin.buffer.readline

    _ = int(input())
    A = [int(i) for i in input().split()]

    ans = 0
    c = Counter(A)
    B = sorted(c.keys(), reverse=True)

    for b in B:
        if c[b] == 0:
            continue
        a = (2 ** b.bit_length()) - b
        if a == b:
            cur = c[b]//2
        else:
            if a in c:
                cur = min(c[a], c[b])
            else:
                cur = 0
        ans += cur
        # c[b] -= cur
        c[a] -= cur

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 56628
#include <bits/stdc++.h>
using namespace std;
using ld=long double;
ld PI=acos(-1);

signed main(){
  ld a,b,x,ans;cin>>a>>b>>x;x/=a;
  if(x<a*b/2){
    //b*b*tan(m)/2=x
    ans=atan2(b*b,2*x);
  }
  else{
    //(u+b)*a/2=x
    ld u=2*x/a-b;
    //b-a/tan(m)=u
    //tan(m)=(b-u)/a
    ans=atan2(b-u,a);
  }
  cout<<fixed<<setprecision(12)<<ans*180/PI<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
  int n;
  cin >> n;
  cout << (n % 2 == 0 ? n / 2 - 1 : n / 2) << endl;
  return 0;
}

Measured memory_bytes: 256