akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

template<int N> class AdjacentLoop {
private:
  const static array<int, N> dy, dx;

  struct Iterator {
    const int y, x, h, w;
    int val;

    Iterator(int y, int x, int h, int w, int val) : y(y), x(x), h(h), w(w), val(val) {
      for (; this->val < N; ++this->val) {
        int yy = y + dy[this->val];
        int xx = x + dx[this->val];
        if (0 <= yy && yy < h && 0 <= xx && xx < w) break;
      }
    }

    pair<int, int> operator*() {return make_pair(y + dy[val], x + dx[val]);}

    bool operator!=(Iterator& itr) {return val < itr.val;}

    void operator++() {
      while (++val < N) {
        int yy = y + dy[val];
        int xx = x + dx[val];
        if (0 <= yy && yy < h && 0 <= xx && xx < w) break;
      }
    }
  };

  Iterator i, n;

public:
  AdjacentLoop(int y, int x, int h, int w) : i(y, x, h, w, 0), n(y, x, h, w, N) {}

  Iterator& begin() {return i;}

  Iterator& end() {return n;}
};

template<> const array<int, 2> AdjacentLoop<2>::dy = {{0, 1}};
template<> const array<int, 2> AdjacentLoop<2>::dx = {{1, 0}};

template<> const array<int, 4> AdjacentLoop<4>::dy = {{0, -1, 0, 1}};
template<> const array<int, 4> AdjacentLoop<4>::dx = {{1, 0, -1, 0}};

template<> const array<int, 5> AdjacentLoop<5>::dy = {{0, -1, 0, 1, 0}};
template<> const array<int, 5> AdjacentLoop<5>::dx = {{1, 0, -1, 0, 0}};

template<> const array<int, 8> AdjacentLoop<8>::dy = {{-1, -1, -1, 0, 0, 1, 1, 1}};
template<> const array<int, 8> AdjacentLoop<8>::dx = {{-1, 0, 1, -1, 1, -1, 0, 1}};

template<> const array<int, 9> AdjacentLoop<9>::dy = {{-1, -1, -1, 0, 0, 0, 1, 1, 1}};
template<> const array<int, 9> AdjacentLoop<9>::dx = {{-1, 0, 1, -1, 0, 1, -1, 0, 1}};

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  cin >> s;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (s[i][j] == '#') continue;
      s[i][j] = '0';
      for (auto k : AdjacentLoop<8>(i, j, h, w)) {
        if (s[k.first][k.second] == '#') ++s[i][j];
      }
    }
  }
  cout << s;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	char S[20];
	scanf("%s", S);

	int i, m, count = 0, I;
	for (i = 0; S[i] != '\0'; i++);
	I = i;

	if (S[0] == 'A') {
		for (i = 2; i <= I - 2; i++) {
			if (S[i] == 'C') {
				count++;
				m = i;
			}
		}
		if (count == 1) {
			for (i = 1; i <= I - 1; i++) {
				if (i == m)continue;
				if (S[i] >= 'A'&&S[i] <= 'Z') {
					printf("WA\n");
					break;
				}
				if (i == I - 1)printf("AC\n");
			}
		}else {
			printf("WA\n");
		}
	}else {
		printf("WA\n");
	}
	return 0;
}
 

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
const int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

void solve()
{
    long long H;
    cin >> H;
    long long two = 0;
    for(long long i = 0;(long long)pow(2,i) <= H;i++)
    {
        if((long long)pow(2,i+1) > H)
            two = i;
    }
    long long sum = 1;
    for(long long i = 1;i <= two;i++)
        sum += (long long)(pow(2 , i));
    cout << sum << endl;
}

int main()
{
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  string s;
  cin >> s;
  int n = s.length();
  int c =0;
  for(int i = 0; i<n/2;i++)
  {
      if(s[i] != s[n-1-i])c++;
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
li=[0]*n
for i in range(m):
    si,ci=map(int,input().split())
    if li[si-1] != 0 and li[si-1] !=ci:
        print(-1)
        exit(0)
    if si==1 and ci==0:
        if n>1:
            print(-1)
            exit(0)
    li[si-1]=ci
if n>1 and li[0]==0:
    li[0]=1
for i in range(n):
    print(li[i],end="")

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int n,flag = 1;
    cin >> n;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        if(a%2) flag = 0;
    } 
    if(flag) cout << "second" << endl;
    else cout << "first" << endl;
}

Measured memory_bytes: 256
def main():
    A, B, C = list(map(int, input().split()))
    K = int(input())
    for _ in range(K):
        if A >= B:
            B *= 2
        elif B >= C:
            C *= 2
    if A < B < C:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 8972
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ull B = 100000007;
int mod = 1000000007;


class Solution {
public:
    ll d(ll n) {
        ll res = 0;
        res += n * (n + 1) / 2;
        for(ll i = 2; i <= n; ++i) {
            ll t = n / i;
            //cout << t * (i + i + (t - 1) * i) / 2 << endl;
            res += t * (i + i + (t - 1) * i) / 2;
        }
        return res;
    }
};

int main() {
    int n;
    cin >> n;
    Solution zhy;
    cout << zhy.d(n) << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>

using namespace std;

int main()
{
    int a, b, c, k, count = 0;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> k;

    if (a <= k)
    {
        count += a;
        k -= a;
    }
    else
    {
        count += k;
    }

    k -= b;

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

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3636
n = int(input())
list = []
for xi in range(n):
    add1, add2 = input().split()
    add = [int(add2), add1, xi+1]
    list.append(add)
list.sort(key=lambda list2: list2[1])


name = list[0][1]
list2 = [list[0]]
count = 1
for xi in range(1,n):
    if name == list[xi][1]:
        list2.append(list[xi])
        count += 1
    else:
        list2.sort()
        for yi in range(count-1,-1,-1):
            print(list2[yi][2])
        name = list[xi][1]
        list2 = [list[xi]]
        count = 1

if len(list2)<n:
    list2.sort()
for yi in range(count-1,-1,-1):
    print(list2[yi][2])
name = list[xi][1]
list2 = [list[xi]]
count = 1


Measured memory_bytes: 9248
<?php
fscanf(STDIN, "%d %d %d", $h, $w, $d);

$a = [];
for ($i = 0; $i < $h; $i++) {
	$line = explode(" ", fgets(STDIN));
	for ($j = 0; $j < $w; $j++) {
		$key = (int)$line[$j];
		$a[$key] = [$j, $i];
	}
}

$max = $h * $w;
$memo = [];
foreach($a as $key => $point) {
	$temp = $key;
	if (isset($memo[$temp]['link'])) {
		continue;
	}
	$consumed = 0;
	while ($temp <= $h * $w) {
		$memo[$key][$temp] = $consumed;
		$memo[$temp]['link'] = $key;
		$before = $a[$temp];
		$temp += $d;
		$after = $a[$temp];
		$consumed += abs($before[0] - $after[0]) + abs($before[1] - $after[1]);
	}
}

fscanf(STDIN, "%d", $q);

for ($k = 0; $k < $q; $k++) {
	fscanf(STDIN, "%d %d", $l, $r);
	if (isset($memo[$l]['link'])) {
		echo ($memo[$memo[$l]['link']][$r] - $memo[$memo[$l]['link']][$l]), "\n";
		continue;
	}
	echo $memo[$l][$r], "\n";
}


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

int main(){
        int n;
        int i;
        cin >> n;

        int num[n],value;
        for(i = 0; i<n; i++)
        {
                cin >> num[i];
        }
        for(i = 0; i<n-1; i++)
        {
                cout << num[n-1-i] << " ";
        }
        cout << num[0] << endl;

        return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

ll dp[100010];
signed main(void)
{
	ll n, k;
	cin >> n >> k;
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		dp[a] += b;
	}

	ll sum = 0;
	REP(i, 100001) {
		sum += dp[i];
		if(sum >= k) {
			cout << i << endl;
			return 0;
		}
	}
	assert(false);

	return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 998244353;

const int64 infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int H, N;
  cin >> H >> N;
  auto dp = make_v< int64 >(H + 1);
  fill_v(dp, infll);
  dp[H] = 0;
  for(int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    for(int j = H - 1; j >= 0; j--) {
      chmin(dp[j], dp[min(j + a, H)] + b);
    }
  }
  cout << dp[0] << endl;
}

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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MOD 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
typedef vector<pl> vpl;

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(a == 0 || b == 0) {
        return max(abs(a), abs(b));
    }

    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return abs(b);
}

ll lcm(ll a, ll b){
    return (a/gcd(a,b)*b);
}

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}


int main() {
    
    int N;
    cin >> N;
    vpl AB(N);
    ll ans = 1;

    //入力の受け取り
    rep(i,N) {
        ll A, B;
        cin >> A >> B;

        //有理数(比)として値を保存（右半平面-{(0,-1)}）
        if(A == 0 && B == 0) {
            AB[i].first = 0;
            AB[i].second = 0;
        } else if(A == 0){
            AB[i].first = 0;
            AB[i].second = 1;
        } else if(B == 0){
            AB[i].first = 1;
            AB[i].second = 0;
        } else {
            AB[i].first = A/gcd(A, B);
            AB[i].second = B/gcd(A, B);
            if(AB[i].first < 0) {
                AB[i].first *= -1;
                AB[i].second *= -1;
            }
        }
        
    }

    //同じ有理数になる個数を数える
    map<pl,int> mp;
    rep(i,N) {
        mp[AB[i]]++;
    }

    //各有理数に対して数えあげ
    auto itr = mp.begin();
    int zeronum = 0;
    while(itr != mp.end()) {
        if(itr->first == make_pair(0LL, 0LL)) { //(0,0)はどのイワシとも仲が悪い
            zeronum += itr->second;
        } else {
            if(itr->second != 0){ //チェック済みでないイワシの処理
                ll chA = itr->first.second;
                ll chB = itr->first.first * -1;
                if(chA < 0 || (chA == 0 && chB < 0)) {
                    chA *= -1; chB *= -1;
                }
                auto itrch = mp.find(make_pair(chA, chB));
                if(itrch != mp.end()){ //仲が悪いイワシのグループがある時
                    ll tmp = mpow(2, itr->second);
                    ll tmpch = mpow(2, itrch->second);
                    tmp = (tmp + tmpch - 1 + MOD) % MOD;
                    ans = ans * tmp % MOD;

                    itrch->second = 0;
                } else { //仲が悪いイワシのグループがない時
                    ans = ans * mpow(2,itr->second) % MOD;
                }
                itr->second = 0;
            }
        }
        itr++;
    }

    ans = (ans + zeronum - 1 + MOD)%MOD;

    //string ans = ( flag ? "Yes" : "No" );
    //printf("%.8lf", ans);
    cout << ans;
    cout << "\n";
    return 0;
}


Measured memory_bytes: 18700
// AOJ 2021: Princess in Danger
// 2017.12.11 bal4u@uu

#include <stdio.h>
#include <string.h>

#define MAX 50000
typedef struct { int t, n, s, p; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int n, int t, int s, int p)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].n = n, que[i].t = t, que[i].s = s, que[i].p = p;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 0x07070707

typedef struct { int to[101], t[101]; } TBL;
TBL tbl[101];
int len[101];
char f[101];
char mk[101][101];

int dijkstra(int start, int goal, int m)
{
	int i, s, t, k, p, s2, t2, k2;

	memset(mk, 0, sizeof(mk));
	qsize = 0;
	enq(start, 0, m, start);
	while (qsize) {
		s = que[0].n, t = que[0].t, k = que[0].s; p = que[0].p, deq();
		if (s == goal) {
			if (t > m) t = (t << 1) - m;
			return t;
		}

		if (mk[p][s]) continue;
		mk[p][s] = 1;

		if (f[s]) k = m, p = s;
		for (i = 0; i < len[s]; i++) {
			s2 = tbl[s].to[i], t2 = t + tbl[s].t[i];
			k2 = k - tbl[s].t[i];
			if (k2 < 0 || mk[s][s2]) continue;
			enq(s2, t2, k2, p);
		}
	}
	return INF;
}

char buf[400], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = 10*n + (*p++ & 0xf);
	p++;
	return n;
}

int main()
{
	int n, m, l, k, a, h, i, x, y, t, ans;

	while (fgets(p=buf, 60, stdin) && *p != '0') {
		n = getint(), m = getint(), l = getint();
		k = getint(), a = getint(), h = getint();

		memset(f, 0, sizeof(f));
		if (l > 0) {
			fgets(p=buf, sizeof(buf), stdin);
			while (l--) f[getint()] = 1;
		}

		memset(len, 0, sizeof(len));
		while (k--) {
			fgets(p=buf, 20, stdin);
			x = getint(), y = getint(), t = getint();
			if (t > m) continue;
			i = len[x]++, tbl[x].to[i] = y, tbl[x].t[i] = t;
			i = len[y]++, tbl[y].to[i] = x, tbl[y].t[i] = t;
		}

		ans = dijkstra(a, h, m);
		if (ans == INF) puts("Help!");
		else printf("%d\n", ans);
	}
	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  VI xs(N);
  cin >> xs;
  SORT(xs);
  UNIQ(xs);
  cout << SZ(xs) << endl;

  return 0;
}


Measured memory_bytes: 256
S =input()
l =len(S)
letters=[]
for i in range(l):
  letters.append(S[i:i+1])
#print(letters)
indicater =0
#odd...R U D even...L U D
if l%2==0:
  for i in range(l//2):
    if (letters[2*i]=="R" or letters[2*i]=="U" or letters[2*i]=="D") and (letters[2*i+1]=="L" or letters[2*i+1]=="U" or letters[2*i+1]=="D"):
      indicater=indicater+0
    else:
      indicater=indicater+1
if l%2==1:
  for i in range((l+1)//2):
    if (letters[2*i]=="R" or letters[2*i]=="U" or letters[2*i]=="D"):
      indicater=indicater+0
    else:
      indicater=indicater+1
  for i in range((l-1)//2):
    if (letters[2*i+1]=="L" or letters[2*i+1]=="U" or letters[2*i+1]=="D"):
      indicater =indicater+0
    else:
      indicater =indicater+1
#print(indicater)
if indicater==0:
  print("Yes")
else:
  print("No")
  

Measured memory_bytes: 3064
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    if (a==b){
        cout << c;
        return 0;
    }
    else if (a==c){
        cout <<b;
        return 0;
    }
    else if (b==c){
        cout << a;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;

int H,W;
string s[51];
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
bool inside(int y,int x){
  return y>=0 && x>=0 && y<H && x<W;
}

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

  rep(i,H){
    cin>>s[i];
  }

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){

      if(s[i][j]=='#'){
        bool flag = false;
        rep(k,4){
          int ny = i+dy[k];
          int nx = j+dx[k];
          if(inside(ny,nx)){
            if(s[ny][nx]=='#'){
              flag=true;
            }
          }

        }
        if(!flag){
          cout<<"No"<<endl;
          return 0;
        }
      }

    }
  }
  cout<<"Yes"<<endl;

}


Measured memory_bytes: 256
#include<iostream>
#define int long long
using namespace std;
const int N=1e6+2;
const int mod=1e9+7;
int fact[N],inv[N];
int binpow(int x,int y){
	int tich=1;
	while(y){
		if((y&1)){
			tich*=x;
			tich%=mod;
		}
		x*=x;
		x%=mod;
		y>>=1;
	}
	return tich;
}
int C(int x,int y){
	return ((fact[y]*inv[y-x])%mod*inv[x])%mod;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l,now=0,ans=0;
	cin>>n;
	fact[0]=1;
	for(i=1;i<=n;i++){
		fact[i]=(fact[i-1]*i)%mod;
		//cout<<fact[i]<<endl;
	}
	inv[n]=binpow(fact[n],mod-2);
	for(i=n;i>=1;i--){
		inv[i-1]=(inv[i]*i)%mod;
		//cout<<inv[i-1]<<endl;
	}
	for(i=(n+1)/2;i<n;i++){
		j=((C(n-i-1,i-1)*fact[i])%mod*fact[n-1-i])%mod;
		//cout<<i<<" "<<j<<endl;
		ans+=((j-now)*i)%mod;
		ans%=mod;
		now=j%mod;
		//cout<<ans<<endl;
	}
	if(ans<0){
		ans+=mod;
	}
	cout<<ans;
}

Measured memory_bytes: 15872
#include <iostream>
#include <cctype>
#include <string>
using namespace std;

int main()
{
	string s;
	int a, b;
	
	cin >> a >> b;
	cin >> s;
	
	for (int i=0; i<s.size(); i++) 
	{
		
	     if (i==a)
	     {
	     	if (s[i]!='-')
	     	{
	     		cout << "No";
	     		return 0;
	     	}
	     }
	     else if (!isdigit(s[i]))
	     {
	     	cout << "No";
	     	return 0;
	     }
	}
	
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)

int count(string &s, bool rev = false){
	int n = s.length();
	int ret = 0;
	REP(i, n){
		if(rev?  s[n-i-1] == ')' : s[i] == '(') ret++;
		else ret = max(ret-1, 0);
	}
	return ret;
}

int main(){
	int n;
	string s;
	cin >> n >> s;
	int ca = count(s, true);
	int cb = count(s);
	cout << string(ca, '(') << s << string(cb, ')') << endl;
	return 0;
}


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

struct UnionFind{
    vector<int> par;
    vector<int> sz;
    public:
    UnionFind(int n):par(n),sz(n,1){
        iota(par.begin(),par.end(),0);
    }
    int find(int x){
        if(par[x]==x) return x;
        else return par[x]=find(par[x]);
    }
    int unite(int x,int y){
        x=find(x),y=find(y);
        if(sz[x]<sz[y]){
            par[x]=y;
            sz[y]+=sz[x];
        }
        else{
            par[y]=x;
            sz[x]+=sz[y];
        }
    }
    int getSize(int x){return sz[find(x)];}
};
using ll=long long;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(m),b(m);
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--,b[i]--;
    }
    vector<ll> res(m);
    ll nres=ll(n)*ll(n-1)/2;
    UnionFind u(n);
    for(int i=m-1;i>=0;i--){
        res[i]=nres;
        if(u.find(a[i])!=u.find(b[i])){
            ll sza=u.getSize(a[i]),szb=u.getSize(b[i]);
            nres-=sza*szb;
            u.unite(a[i],b[i]);
        }
    }
    for(int i=0;i<m;i++){
        cout<<res[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 3712
n = int(input())
ans = pow(10, 10)

for i in range(n+1):
    cnt = 0
    j = n - i
    while i > 0:
        cnt += i % 6
        i //= 6

    while j > 0:
        cnt += j % 9
        j //= 9

    ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 8876
n = int(input())
count = 1
while True:
    if n==4 or n==2 or n==1:
        count += 3
        break
    else:
        if n%2 == 0:
            n = n//2
            count += 1
        else:
            n = 3*n + 1
            count += 1
print(count)

Measured memory_bytes: 2940
<?php

$N = trim(fgets(STDIN));

$count = 0;
for ($a = 1; $a < $N; $a++) {
    for ($b = $a; $b < $N; $b++) {

        if ($a * $b >= $N) {
            break;
        }

        if ($a == $b) {
            $count += 1;
        } else {
            $count += 2;
        }
    }
}
echo $count;



Measured memory_bytes: 16200
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define rpe(i,r,l) for(int i=(r);i>=(l);--i)
#define rpp(i,x,e,head) for(int i=head[x];~i;i=e[i].next)
#define dyes cerr<<"yes"<<endl
#define dbg(x) cerr<<#x<<"="<<x<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define pts puts("")
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
inline int read(){
    int f=1,x=0;char ch;
    do{ch=getchar();if(ch=='-')f=-1LL;}while(ch<'0'||ch>'9');
    do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
    return f*x;
}
inline ll readll(){
    ll f=1,x=0;char ch;
    do{ch=getchar();if(ch=='-')f=-1LL;}while(ch<'0'||ch>'9');
    do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
    return f*x;
}
template <class T> inline void chmax(T &a,T b){if(a<b) a=b;}
template <class T> inline void chmin(T &a,T b){if(a>b) a=b;}
inline void swap(int &a,int &b){int c=a;a=b;b=c;}
using namespace std;
#define mst(a,val) memset(a,val,sizeof(a))
#define pii pair<int,int>
#define piii pair<int,pair<int,int> >
#define mp(i,j) make_pair(i,j)
#define fi first
#define sc second
#define inf (0x3f3f3f3f)
#define infl (0x3f3f3f3f3f3f3f3fLL)
#define forvec(i,j) for(vector<int>::iterator i=j.begin();i!=j.end();++i)
#define forvecv(i,j) for(vector<int>::iterator i=--j.end();i>=j.begin();--i)
int n,k;
int main(){
    n=read();k=read();
    if(n<=k){puts("1");return 0;}
    printf("%d\n",(n-k-1)/(k-1)+2);
    return 0;
}


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

int main(){
	int n;	cin>>n;
	vector<double> item(n);

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

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

	double ans=item[0];
	for(int i=1;i<n;i++){
		ans+=item[i];
		ans/=2;
	}

	printf("%.6lf\n", ans);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <cstdio>
#include <set>
#include <map>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> P;


int main(){
	map<char, int> m;
	m['I'] = 1;
	m['V'] = 5;
	m['X'] = 10;
	m['L'] = 50;
	m['C'] = 100;
	m['D'] = 500;
	m['M'] = 1000;

	string s;
	while(cin >> s){
		int ans = 0;
		rep(i, s.size()-1) ans += (m[s[i+1]]>m[s[i]]?-1:1)*m[s[i]]; 
		ans += m[s[s.size()-1]];
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1188
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)



def main():
    N, T = map(int, input().split())
    TS = list(map(int, input().split()))

    X = 0
    prev = TS[0]
    for i in range(1, N):
        now = TS[i]
        X += min(now-prev, T)
        prev = now
    X += T

    print(X)

if __name__ == "__main__": main()


Measured memory_bytes: 25848
#include <cmath>
#include <iostream>
#include <string>
#include <time.h>
#include <stdio.h>
#include <iomanip>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    for (int i = n - 1; i >= 0; i--){
        if(i == 0){
          cout << vec.at(i) << endl;
          return 0;   
        }
        cout << vec.at(i) << " ";
    }
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    char s[100];
    scanf("%s",s);
    bool n;
    int cou=0;
    n=true;
    int a;
    a=strlen(s);
    if(s[0]!='A')
    n=false;
    if(s[a-1]=='C')
        n=false;
    if(s[1]=='C')
        n=false;
    for(int i=1;i<a;i++)
    {
        if(s[i]=='C')
            cou++;
        else if(s[i]!='A'&&(s[i]<'a'||s[i]>'z'))
            n=false;
    }
    if(cou==1&&n)
        printf("AC\n");
    else
        printf("WA\n");
    return 0;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

int main()
{
    int N,K,S;
    cin >> N >> K >> S;


    if(S != 1e9){
        _for(i,0,N){
            if(i) printf(" ");
            if(K > 0) {
                    printf("%d",S);
                    K--;
            }else printf("%d",S+1);
        }
        printf("\n");
    }else{
        _for(i,0,N){
            if(i) printf(" ");
            if(K > 0){
                printf("%d",S);
                K--;
            }
            else printf("%d",1);
        }
        printf("\n");
    }



    return 0;
}


Measured memory_bytes: 1280
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define N 0
#define INF 0x3f3f3f3f
#define LL long long
#define mz(x) ms(x,0)
#define ms(x,y) memset(x,y,sizeof(x))
#define mc(x,y) memcopy(x,y,sizeof(y))
#define MOD 1000000007

using namespace std ;

int main()
{
	LL x, k, d ;
	scanf("%lld%lld%lld", &x, &k, &d) ;
	
	LL t = abs (x / d) ;
	if (t >= k)
		t = k ;
	else if ((k - t) & 1)
		t++ ;
	
	LL f ;
	if (x < 0)
		f = x + t * d ;
	else
		f = x - t * d ;
	
	cout << abs (f) << endl ;

	return 0 ;
}

Measured memory_bytes: 3296
h,w = map(int, input().split())
a = [list(input()) for _ in range(h)]

skip = []
for i in range(h):
  if a[i] == ["."] * w: skip.append(i)

a = list(zip(*a))
d = []
for i in range(w):
  if set(a[i]) == {"."}: d.append(i)
d.sort(reverse=True)
for i in d:
  a.pop(i)

a = list(zip(*a))
for i in range(h):
  if i in skip: continue
  else:
    print("".join(a[i]))


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

#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n,0);
    rep(i,n){
        cin >> a[i];
    }
    ll count=0;
    if(n>1){
        FOR(i,n,1){
            if(a[i]<a[i-1]){
                count+=(a[i-1]-a[i]);
                a[i]=a[i-1];
            }
        }
    }
    cout << count << endl;

}

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

int main(){
  string s;
  cin>>s;
  char t=s[s.size()-1];
  if(t=='3')
    cout<<"bon"<<endl;
  else if(t=='0'||t=='1'||t=='6'||t=='8')
    cout<<"pon"<<endl;
  else
    cout<<"hon"<<endl;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "

int main(void){
    int a,b,c;cin>>a>>b>>c;
    a+b+c>=22?co("bust"):co("win");
}

Measured memory_bytes: 256
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

bool iswinning[100005];
int a[105];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int N, K; cin >> N >> K;
    rep(i, N) cin >> a[i];
    rep(i, K+1)
        rep(j, N) {
            if(i < a[j]) break;
            if(!iswinning[i-a[j]]) {
                iswinning[i] = 1;
                break;
            }
        }
    if(iswinning[K]) cout << "First" << endl;
    else cout << "Second" << endl;
}



Measured memory_bytes: 384
#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;
  string s;
  cin >> n >> s;
  mat dp(n+1,vec(n+1));
  for(ll i=0;i<=n;i++) {
    dp[0][i]=1;
  }
  for(ll i=0;i<n;i++) {
    vec a(n+2);
    for(ll j=0;j<n-i;j++) {
      a[j+1]=(a[j]+dp[i][j])%mod;
    }
    for(ll j=0;j<n-i;j++) {
      if(s[i]=='<') {
        dp[i+1][j]=(a[n-i]-a[j+1]+mod)%mod;
      }
      else {
        dp[i+1][j]=a[j+1];
      }
    }
  }
  cout << dp[n][0] << endl;
}

Measured memory_bytes: 73744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5, mod = 1e9 + 7, inf = 0x3f3f3f3f;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    double s = 0.5 * h * w;
    cout << fixed << setprecision(10) << s << " ";
    if (w % 2 == 0 && h % 2 == 0 && x == w / 2 && y == h / 2) cout << "1" << endl;
    else cout << "0" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;
typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef map<int, int> M;
typedef pair<int, int> P;

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

    string s;
    cin >> s;
    itn i = 0;
    if (s[0] == '+') ++i;
    else --i;
    if (s[1] == '+') ++i;
    else --i;
    if (s[2] == '+') ++i;
    else --i;
    if (s[3] == '+') ++i;
    else --i;
    cout << i << endl;

    return 0;
}

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

int main()
{
    /// Watch
    int getSec,sec,minute,hour;
    cin>>getSec;

    hour=getSec/3600;
    minute=(getSec%3600)/60;
    sec=((getSec%3600)%60);

    cout<<hour<<":";
    cout<<minute<<":";
    cout<<sec<<endl;

    return 0;
}



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

int main(){
    string s;
    cin >> s;
    for(auto c : s){
        if(c == ','){
            cout << " ";
        } else {
            cout << c;
        }
    }
    cout << endl;
    return 0;
}

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

int main(){
    for(int i = 0; ; i++){
        int x,y;
        cin >> x >> y;
        if(x == 0 && y == 0){
            break;
        }
        int a,b;
        if(x >= y){
            a = x;
            b = y;
        }else{
            a = y;
            b = x;
        }
        cout << b << " " << a << endl;
    }
    return 0;
}



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

int main(){
    string s;
    cin >> s;

    map<char, int> m;
    for(int i = 0; i < s.size(); i++){
        m[s[i]]++;
    }
    for(int i = 97; i <= 122; i++){
        if(m[i] == 0){
            cout << (char)i << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;
typedef pair< int, int > pii;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

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

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

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

  string s;
  cin >> s;

  int n = s.length();

  if(s[0] != 'A'){
    cout << "WA" << endl;
    return 0;
  }

  int count = 0;
  for(int i = 2; i <= n - 2; i++){
    if(s[i] == 'C') ++count;
  }

  if(count != 1){
    cout << "WA" << endl;
    return 0;
  }
  
  for(int i = 0; i < n; i++){
    if(s[i] == 'A' || s[i] == 'C') continue;
    if(!('a' <= s[i] && s[i] <= 'z')){
      cout << "WA" << endl;
      return 0;
    }
  }

  cout << "AC" << endl;

  return 0;
}


Measured memory_bytes: 888
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            int dupCnt = 0;
            for (int i = 0; i < n; i++)
            {
                if (t.Substring(0, i + 1) == s.Substring(n - (i + 1)))
                {
                    dupCnt = Math.Max(dupCnt, i + 1);
                }
            }
            Console.WriteLine(s.Length+t.Length - dupCnt);
        
        
        }
    }
}


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

int main(){
  int N;
  cin >> N;
  for(int i=0; i<N; i++){
    string S;
    cin >> S;
    if(S =="Y"){
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>
#include <queue>
#include <fstream>
#include <ostream>
#include <random>
#include <chrono>
using namespace std;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int a, b, c;
	cin >> a >> b >> c;

	if (a < c && c < b)
	{
		cout << "Yes\n";
	}
	else if (b < c && c < a)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}
}

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

len = len(str(n))
sn = 0
ni = n

for i in reversed(range(0, len)):
    ans =  ni // (10**i)
    sn = ans + sn
    ni = ni - ans * (10**i)

if (n % sn == 0):
    print("Yes")
else:
    print("No")



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

template <typename _Tp> inline _Tp read(_Tp&x){
	char c11=getchar();x=0;while(!isdigit(c11))c11=getchar();
	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();return x;
}

int n,m,tot,a[105];

int main(){
	read(n),read(m);
	for(rg int i=1;i<=m;i++)read(a[i]),tot+=(a[i]&1);
	if(tot>2){puts("Impossible");return 0;}
	if(tot){
		bool flag=0;
		for(rg int i=1;i<m;i++)
			if(a[i]&1)
				if(flag)swap(a[i],a[m]);
				else flag=1,swap(a[i],a[1]);
	}
	if(m==1){
		if(a[1]==1){puts("1\n1\n1");return 0;}
		printf("%d\n",a[1]);puts("2");
		printf("1 %d\n",a[1]-1);
		return 0;
	}
	for(rg int i=1;i<=m;i++)printf("%d ",a[i]);
	if(a[m]==1){
		printf("\n%d\n",m-1);
		printf("%d\n",a[1]+1);
		for(rg int i=2;i<m;i++)printf("%d ",a[i]);
	}
	else {
		printf("\n%d\n",m);
		printf("%d\n",a[1]+1);
		for(rg int i=2;i<m;i++)printf("%d ",a[i]);
		printf("%d\n",a[m]-1);
	}return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> vc(n);
	for (int i=0;i<n;i++){
		cin >> vc.at(i);
	}
	
	int min, tmp, ans=0;
	for (int i=0;i<n;i++){
		min = i;
		for (int j=i;j<n;j++){
			if (vc.at(j) < vc.at(min)){
				min = j;
			}
        }
        if (min != i){
		tmp = vc.at(i);
		vc.at(i) = vc.at(min);
		vc.at(min) = tmp;
		ans++; 
        }

	}
	
	for (int i=0;i<n;i++){
		if (i!=n-1){
			cout << vc.at(i) << " ";
		}
		else{
			cout << vc.at(i) << endl;
		}
	}
	cout << ans << endl;
}


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

int main(){
  int n,k;
  cin>>n>>k;
  double ans=0;
  for(int i=1;i<=n;i++){
     double t=1.0/n;
     int a=i;
    while(a<k){
      t=t/2;
      a=a*2;
    }
    ans+=t;
  }
  printf("%.12f\n",ans);
  
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;

int main(){
  string s;
  cin>>s;

ll tmp=0;
vector<ll> num;
char pre='R';
  for(ll i=0;i<s.size();i++){
    if(s[i]==pre){
      tmp++;
    }
    else{
      num.push_back(tmp);
      tmp=1;
      pre=s[i];
    }
  }

  num.push_back(tmp);


  for(ll i=0;i<num.size();i+=2){
     ll R = num[i]-1;
     ll L = num[i+1]-1;

      if(R==L){
        for(ll j=0;j<R;j++){
          cout<<"0 ";
        }
        cout<<R+1<<" ";
        cout<<L+1<<" ";
        for(ll j=0;j<L;j++){
           cout<<"0 ";
        }
      }

      else if(R>L){
        ll d = R-L;
        if(d%2==0){
          for(ll j=0;j<R;j++){
          cout<<"0 ";
        }
        cout<<(num[i]+num[i+1])/2<<" ";
        cout<<(num[i]+num[i+1])/2<<" ";
        for(ll j=0;j<L;j++){
           cout<<"0 ";
        }
        }
        else{
          if(R%2==0){
            //左第
            for(ll j=0;j<R;j++){
          cout<<"0 ";
        }
        cout<<(num[i]+num[i+1])/2+1<<" ";
        cout<<(num[i]+num[i+1])/2<<" ";
        for(ll j=0;j<L;j++){
           cout<<"0 ";
        }
          }
          else{
            //右大
             for(ll j=0;j<R;j++){
          cout<<"0 ";
        }
        cout<<(num[i]+num[i+1])/2<<" ";
        cout<<(num[i]+num[i+1])/2+1<<" ";
        for(ll j=0;j<L;j++){
           cout<<"0 ";
        }
          }


        }



      }
      else{
        ll d = L-R;
        if(d%2==0){
          for(ll j=0;j<R;j++){
          cout<<"0 ";
        }
        cout<<(num[i]+num[i+1])/2<<" ";
        cout<<(num[i]+num[i+1])/2<<" ";
        for(ll j=0;j<L;j++){
           cout<<"0 ";
        }
        }
        else{
          if(L%2!=0){
            //左第
            for(ll j=0;j<R;j++){
          cout<<"0 ";
        }
        cout<<(num[i]+num[i+1])/2+1<<" ";
        cout<<(num[i]+num[i+1])/2<<" ";
        for(ll j=0;j<L;j++){
           cout<<"0 ";
        }
          }
          else{
            //右大
             for(ll j=0;j<R;j++){
          cout<<"0 ";
        }
        cout<<(num[i]+num[i+1])/2<<" ";
        cout<<(num[i]+num[i+1])/2+1<<" ";
        for(ll j=0;j<L;j++){
           cout<<"0 ";
        }
          }


        }





      }


  }

}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define int long long
const int maxn = 10 + 10;

using namespace std; 

signed main() {
	string a, b;
	cin >> a >> b;
	int c, d;
	cin >> c >> d;
	string e;
	cin >> e;
	if (e == a) c--;
	else d--;
	cout << c << ' ' << d << endl;
}

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

public class Main {

  int n, pPre,pPost;
  int[] pre,in,post;

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

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

      n = Integer.parseInt(br.readLine());
      String[] linesPre =  br.readLine().split(" ");
      String[] linesIn  =  br.readLine().split(" ");

      pre  = new int[n];
      in   = new int[n];
      post = new int[n];
  
      for(int i=0; i<n; i++){
        pre[i] = Integer.parseInt(linesPre[i]);
        in[i]  = Integer.parseInt(linesIn[i] );
      }

      solve();

    } catch ( IOException e ) {
      System.out.println("IOException!");
    }
  }
  
  void solve() {
    pPre = pPost = 0;
    StringBuilder buf = new StringBuilder();

    rec(0,pre.length);

    for (int var : post) {
      buf.append(var).append(" ");
    }
    buf.setLength(buf.length()-1);
    System.out.println(buf);
  }

  void rec(int l, int r) {
    if( l < r ) {
      int root = pre[pPre++];
      int m = arrayDistance(0, in.length, root);

      rec(l,m);
      rec(m+1,r);
  
      post[pPost++] = root;
    }
  }

  int arrayDistance(int start, int end, int find) {
    int d=start;

    for( ; d<end; d++)
      if( in[d] == find ) break;

    return d;
  }
}


Measured memory_bytes: 24496
#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<int, int> pi;
typedef pair<long long, long long> pl;
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll mod(ll a, ll b) { return (a%b+b)%b; }
ll gcd(ll x, ll y) { return __gcd(x, y); }
ll lcm(ll x, ll y) { return x * 1ll * y / gcd(x, y); }
 
 
const ll MAXN = 1e9 + 9;
const ll SIZE = 1e5 + 5;
const ll MOD  = 1e9 + 7;

ll a, b;

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

	cout << a * b << endl;

	return 0;
}


Measured memory_bytes: 3588
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n,m = LI()
    e = collections.defaultdict(set)
    t = [0] * n
    for _ in range(m):
        a,b = LI_()
        e[a].add(b)
        e[b].add(a)

    q = [0]
    t[0] = 1
    for i in range(n):
        c = q[i]
        tc = t[c]
        for d in e[c]:
            if t[d] == 0:
                t[d] = 3-tc
                q.append(d)
            elif t[d] == tc:
                return n*(n-1) // 2 - m

    a = sum(t) - n

    return a*(n-a) - m


print(main())




Measured memory_bytes: 43340