akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<string> S(2);
  for (int i = 0; i < 2; i++)
    cin >> S[i];

  ll ans = 1;

  for (int j = 0; j < N; j++)
  {
    if (S[0][j] == S[1][j])
    {
      if (j == 0)
      {
        ans *= 3;
        ans %= MOD;
      }
      else
      {
        // 左2文字が等しいときと異なるとき (XとY)
        if (S[0][j - 1] == S[1][j - 1])
        { // Xの場合
          ans *= 2;
          ans %= MOD;
        }
        else
        { // Yの場合
          continue;
        }
      }
    }
    else if (j + 1 < N && S[0][j] == S[0][j + 1])
    {
      if (j == 0)
      {
        ans *= 3;
        ans %= MOD;
        ans *= 2;
        ans %= MOD;
        j++;
      }
      else
      {
        // 左2文字が等しいときと異なるとき(XとY)
        if (S[0][j - 1] == S[1][j - 1])
        { // Xの場合
          ans *= 2;
          ans %= MOD;
          j++;
        }
        else
        { // Yの場合
          ans *= 3;
          ans %= MOD;
          j++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

// 横2つが縦に2つ連なる場合が横に2つ連なる場合の不足
// ↑の場合に色の組み合わせがどうなるのかをしっかり実験する
// 縦2×横1をX，縦1×横2をYとする．一番左の箇所についてはX: 3, Y: 6通り．
// それ以外の場所についてはそれより左の箇所が全て塗られているとき，X(すぐ隣がX): 2通り，X(すぐ隣がY): 1通り，Y(すぐ隣がX): 2通り，Y(すぐ隣がY): 3通り　(解説参照)


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

int n;
int k;
string s;
vector<string> v;

int main(){
    cin >> s >> k;
    n = s.size();
    for(int i = 0; i < n; i++){
        for(int l = 1; l <= k && l + i <= n; l++) v.push_back(s.substr(i, l));
    }
    sort(v.begin(), v.end());
    unique(v.begin(), v.end());
    cout << v[k-1] << '\n';
    return 0;
}


Measured memory_bytes: 1660
import java.util.Scanner;

public class Main {
	static boolean[][] nodes;
	static int cnt = 0;

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

		int n = sc.nextInt(); // 頂点の数
		int m = sc.nextInt(); // 辺の数

		nodes = new boolean[n][n];
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			nodes[a][b] = true;
			nodes[b][a] = true;
		}

		// printArray(nodes);

		boolean[] arrived = new boolean[n];

		move(arrived, 0);
		// move(arrived, 0, "");

		System.out.println(cnt);
		sc.close();
	}

	static boolean arrivedAllNodes(boolean[] arr) {
		for (int i = 0; i < arr.length; i++) {
			if (!arr[i]) {
				return false;
			}
		}
		return true;
	}

	static boolean isAlreadyArrived(boolean[] arr, int n) {
		return arr[n];
	}

	static boolean[] copyArray(boolean[] arr) {
		boolean[] newArr = new boolean[arr.length];
		for (int i = 0; i < arr.length; i++) {
			newArr[i] = arr[i];
		}
		return newArr;
	}

	static void move(boolean[] arrived, int n) {
		boolean[] newArr = copyArray(arrived);
		if (newArr[n]) {
			return;
		} else {
			newArr[n] = true;
		}

		if (arrivedAllNodes(newArr)) {
			cnt++;
			return;
		}


		for (int i = 0; i < nodes[n].length; i++) {
			if (nodes[n][i]) {
				move(newArr, i);
			}
		}
		return;
	}

	static void move(boolean[] arrived, int n, String str) {
		str += n + 1;
		boolean[] newArr = copyArray(arrived);

		if (newArr[n]) {
			System.out.println(str + "x");
			return;
		} else {
			newArr[n] = true;
		}

		if (arrivedAllNodes(newArr)) {
			System.out.println(str);
			cnt++;
			return;
		}


		for (int i = 0; i < nodes[n].length; i++) {
			if (nodes[n][i]) {
				move(newArr, i, str);
			}
		}
		return;
	}

	static void printArray(boolean[][] arrs) {
		int i = 0;
		for (boolean[] arr : arrs) {
			System.out.print(i + " : {");
			for (int j = 0; j < arr.length; j++) {
				System.out.print((arr[j] ? 1 : 0) + ", ");
			}
			System.out.println("}");
		}
	}

}


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

using namespace std;

int main() {
    string str,str1;
    while(cin >> str >> str1) {
        reverse(str1.begin(),str1.end());

        if(str == str1)
            cout << "YES" << endl;
        else cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    string S, T;
    cin >> S >> T;
    T += S;
    cout << T << endl;
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int n,k;
int main(){
	cin >> n >> k;
	int l[n];
	rep(i,0,n){
		cin >> l[i];
	}
	sort(l,l+n);
	reverse(l,l+n);
	
	int ans = 0;
	rep(i,0,k){
		ans += l[i];
	}
	pout(ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool f , c[200001] , d[200001];
signed main(){
  int n , m , a , b;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>a>>b;
    if(a == 1){
      c[b] = true;
    } else if(b == n){
      d[a] = true;
    } 
  }
  
  for(int i=1;i<=n;i++){
    if(c[i] && d[i]){
      f=1;
    }
  }

  if(f){
    cout<<"POSSIBLE\n";
  } else {
    cout<<"IMPOSSIBLE\n";
  }
  return(0);
}

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

int main(){
    FAST
    int n; cin >> n;
    int cnt[n + 1];
    mm(cnt);
    for(int i = 1; i < n; i++){
        int a; cin >> a;
        cnt[a]++;
    }
    for(int i = 1; i <= n; i++){
        cout << cnt[i] << endl;
    }
    return 0;
}


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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    long long a, b, k;
    cin >> a >> b >> k;
    long long y = min(a, k);
    a -= y;
    k -= y;
    y = min(b, k);
    b -= y;
    cout << a << " " << b;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final long INF = 1L<<60;
    private static long[] dp = new long[100010];
    public static void main(String[] args) throws Exception {
        Arrays.fill(dp,INF);
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        List<Integer> steps = new ArrayList<>();
        for(int i=0;i<N;i++){
            steps.add(Integer.parseInt(sc.next()));
        }
        dp[0] = 0;
        for(int i=1;i<N;i++){
            for(int j=1;j<=K && j<=i;j++){
                dp[i] = Math.min(dp[i],dp[i-j] + Math.abs(steps.get(i) - steps.get(i-j)));
            }
        }
        System.out.println(dp[N-1]);
    }
}


// dp[i] = Math.min(dp[i-1] + Math.abs(steps.get(i) - steps.get(i-1)) ,dp[i-2] + Math.abs(steps.get(i) - steps.get(i-2)));
//2マスまでジャンプできる場合
// dp[i] = Math.min(dp[i-1] + Math.abs(steps.get(i) - steps.get(i-1)) , dp[i-2] + Math.abs(steps.get(i) - steps.get(i-2)));
//の時点でdp[i]には"１マスジャンプまたは2マスジャンプの最小値"が格納されている
//ので、"3マスジャンプとの比較"を考えたい場合は、次のようになる
// dp[i] = Math.min(dp[i],dp[i-3] + Math.abs(steps.get(i) - steps.get(i-3)));(ただしi>=3)
//従って、dp[i]の更新式は以下となる
// dp[i] = Math.min(dp[i],dp[i-j] + Math.abs(steps.get(i) - steps.get(i-j)));
// 1 <= i < N, 1 <= j < K , j <= i;

Measured memory_bytes: 50056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<char> t(Q), d(Q);
  REP(i, Q) { cin >> t[i] >> d[i]; }

  // マスxにいたゴーレムは最終的にどこにいる？
  auto dst = [&](ll x) {
    REP(j, Q) {
      if (x == -1 || x == N) return x;
      if (t[j] != s[x]) continue;
      if (d[j] == 'L')
        x--;
      else
        x++;
    }
    return x;
  };

  //左へ落ちるiの最大値は？
  ll ok = -1, ng = N;
  while (ok + 1 < ng) {
    ll m = (ok + ng) / 2;
    if (dst(m) == -1)
      ok = m;
    else
      ng = m;
  }
  ll l = ok + 1;

  //右へ落ちるiの最小値は？
  ng = -1, ok = N;
  while (ng + 1 < ok) {
    ll m = (ok + ng) / 2;
    if (dst(m) == N)
      ok = m;
    else
      ng = m;
  }
  ll r = N - ok;
  cout << N - (l + r) << endl;
}

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

using namespace std;

typedef long long ll;
const ll mod = 924844033,maxn = 900010;
ll n,head[maxn],to[maxn],nextt[maxn],tot = 1,sizee[maxn],f[maxn],jie[maxn],nijie[maxn],b[maxn],ni[maxn],g[maxn],A[maxn],B[maxn];
ll bin[600010],rev[maxn];

ll qpow(ll a,ll b)
{
    ll res = 1;
    while (b)
    {
        if (b & 1)
            res = 1LL * res * a % mod;
        a = 1LL * a * a % mod;
        b >>= 1;
    }
    return res;
}

void add(ll x,ll y)
{
    to[tot] = y;
    nextt[tot] = head[x];
    head[x] = tot++;
}

void dfs(ll u,ll faa)
{
    sizee[u] = 1;
    f[n]++;
    for (ll i = head[u];i;i = nextt[i])
    {
        ll v = to[i];
        if (v == faa)
            continue;
        dfs(v,u);
        f[sizee[v]]--;
        sizee[u] += sizee[v];
    }
    f[n - sizee[u]]--;
}

void NTT(ll *t,ll n,ll id)
{
    ll len = bin[n];
    for (ll i = 0; i < n; i++)
        rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (len - 1));
    for (ll i = 0; i < n; i++)
        if (i < rev[i])
            swap(t[i],t[rev[i]]);
    for (ll i = 1; i < n; i <<= 1)
    {
        ll Wn = qpow(5,(mod - 1) / (i << 1));
        if (id == -1)
            Wn = qpow(Wn,mod - 2);
        for (ll j = 0; j < n; j += (i << 1))
        {
            ll W = 1;
            for (ll k = j; k < j + i; k++)
            {
                ll t1 = t[k],t2 = 1LL * t[k + i] * W % mod;
                t[k] = (t1 + t2) % mod;
                t[k + i] = (t1 - t2 + mod) % mod;
                W = 1LL * W * Wn % mod;
            }
        }
    }
    if (id == -1)
    {
        ll temp = qpow(n,mod - 2);
        for (ll i = 0; i < n; i++)
            t[i] = 1LL * t[i] * temp % mod;
    }
}

int main()
{
    for (ll i = 0; i <= 19; i++)
        bin[1 << i] = i;
    scanf("%lld",&n);
    for (ll i = 1; i < n; i++)
    {
        ll x,y;
        scanf("%lld%lld",&x,&y);
        add(x,y);
        add(y,x);
    }
    dfs(1,0);
    ni[0] = ni[1] = jie[0] = jie[1] = nijie[0] = nijie[1] = 1;
    for (ll i = 2; i <= n; i++)
    {
        jie[i] = 1LL * jie[i - 1] * i % mod;
        ni[i] = 1LL * (mod - mod / i) * ni[mod % i] % mod;
        nijie[i] = 1LL * nijie[i - 1] * ni[i] % mod;
    }
    for (ll i = 0; i <= n; i++)
        f[i] = 1LL * (f[i] + mod) % mod * jie[i] % mod;
    for (ll i = 0; i <= n; i++)
        g[i] = nijie[i];
    reverse(g,g + 1 + n);
    ll len = 1;
    while (len <= 2 * (n + 1))
        len <<= 1;
    NTT(f,len,1),NTT(g,len,1);
    for (ll i = 0; i < len; i++)
        f[i] = 1LL * f[i] * g[i] % mod;
    NTT(f,len,-1);
    for (ll i = 1; i <= n; i++)
        printf("%lld\n",1LL * nijie[i] * f[i + n] % mod);

    return 0;
}


Measured memory_bytes: 61312
import numpy as np
from bisect import bisect_left


def primes():
    p = []
    c = np.ones(10**5 + 10)
    c[0] = c[1] = 0
    for i, f in enumerate(c):
        if f:
            p.append(i)
            c[2 * i:10**5 + 10:i] = 0
    return p


def solve(string):
    x = int(string)
    ps = primes()
    return str(ps[bisect_left(ps, x)])


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 15308
#include<iostream>
using namespace std;
int main(){
long n,i,a,b,aa,bb=0;
cin>>n;
for(i=0;i<n;i++){
cin>>a>>b;
if(bb<b){aa=a;bb=b;}
else if(bb==b&&a<aa){aa=a;bb=b;}
}
cout<<aa<<" "<<bb<<endl;
return 0;
}

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

using namespace std ;

long long int a[500009]={} ;

int main () {

    long long int n ,cnt=1 ;

    for(long long int i=0;i<3;i++)
        cin >>a[i] ;
    sort(a,a+3) ;

    cout<<(a[0]*a[1])/2<<endl ;

}


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

int fac(int k) {
    int sum = 1;
    for (int i = 1; i <= k; i++) {
        sum *= i;
    }
    return sum;
}

int main()
{
    int n;
    cin >> n;
    vector<int> P(n), Q(n);
    rep(i, n) cin >> P.at(i);
    rep(i, n) cin >> Q.at(i);

    int a = 0, b = 0;

    for (int i = 0; i < n; i++) {
        if (P.at(i) != 1) {
            a += (P.at(i) - 1) * fac(n - i - 1);
        }
        if (Q.at(i) != 1) {
            b += (Q.at(i) - 1) * fac(n - i - 1);
        }
        for (int j = i + 1; j < n; j++) {
            if (P[i] < P[j]) {
                P[j]--;
            }
            if (Q[i] < Q[j]) {
                Q[j]--;
            }
        }
        
    }

    cout << abs(a - b) << endl;

    return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  int x[n];
  for(int i=0;i<n;i++){
    cin >> x[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    ans+=min(x[i],k-x[i])*2;
  }
  cout << ans << endl;
}

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

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

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

    vector<long long int> b = a, c = a;
    long long int count1 = 0, // +-+-...
                  count2 = 0; // -+-+...

    if(b[0] <= 0){
        count1 += 1 - b[0];
        b[0] = 1;
    }
    if(c[0] >= 0){
        count2 += c[0] - (-1);
        c[0] = -1;
    }
    for(int i=1; i<n; i++){
        b[i] += b[i-1];
        c[i] += c[i-1];

        if(i % 2 == 0){
            if(b[i] <= 0){
                count1 += 1 - b[i];
                b[i] = 1;
            }
            if(c[i] >= 0){
                count2 += c[i] - (-1);
                c[i] = -1;
            }
        }
        if(i % 2 != 0){
            if(b[i] >= 0){
                count1 += b[i] - (-1);
                b[i] = -1;
            }
            if(c[i] <= 0){
                count2 += 1 - c[i];
                c[i] = 1;
            }
        }
    }
    cout << min(count1, count2) << endl;
    return 0;
}

Measured memory_bytes: 2560
from sys import stdin
from math import sqrt
input = stdin.readline
N = int(input())

s = [0] * (int(sqrt(N)) + 1)

ans = 0

for i in range(2, int(sqrt(N)) + 1):
    tmp = i

    while N % tmp == 0:
        N //= tmp
        s[tmp] += 1

for i in s:
    for j in range(10 ** 5):
        if (j * (j + 1)) // 2 > i:
            k = j
            break

    ans += k - 1

for i in range(2, int(sqrt(N)) + 1):
    if N % i == 0:
        print(ans)
        exit()

if N != 1:
    ans += 1


print(ans)


Measured memory_bytes: 74148
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0];
    
    const array = ["SUN","MON","TUE","WED","THU","FRI","SAT"];
    
    if(S === "SUN") {
        console.log(7)   
    }
    
    if(S === "MON") {
        console.log(6)   
    }
    
    if(S === "TUE") {
        console.log(5)   
    }
    
    if(S === "WED") {
        console.log(4)   
    }
    
    if(S === "THU") {
        console.log(3)   
    }
    
    if(S === "FRI") {
        console.log(2)   
    }
    
    if(S === "SAT") {
        console.log(1)   
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 22084
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "C"
string s, a[]={"dreamer", "eraser", "dream", "erase"};
int f[100001];
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    cin>>s;
    s='0'+s;
    f[0]=1;
    FFOR(i, 1, s.size()){
        FFOR(j, 0, 4) if(i>=a[j].size()){
            if(!f[i-a[j].size()]) continue;
            int k=i-a[j].size();
            FFOR(k, 0, a[j].size()){
                if(s[i-a[j].size()+k+1]!=a[j][k]) goto line1;
            }
            f[i]=1;
            break;
            line1:;
        }
    }
    puts(f[s.size()-1]?"YES":"NO");
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

void solve(){   
    ll n; cin>>n;
    ll ans = n*180 - 360;
    cout<<ans<<endl;
}   

signed main(){

   FastRead;    

    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}




Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
int n;
int main(){
	scanf("%d",&n);
	for(int i=0;i*7<=n;i++) if ((n-i*7)%4==0){
		printf("Yes\n");
		return 0;
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define clear(v) memset(v,0,sizeof(v))
#define ALL(v) (v).begin(),(v).end()

int main(){
	int p[2][4];
	int sum[2] = {};
	rep(i, 2){
		rep(j, 4) cin >> p[i][j];
	}
	rep(i, 2){
		rep(j, 4) sum[i]+=p[i][j];
	}
	cout << ((sum[0] > sum[1]) ? sum[0] : sum[1]) << endl;
	return 0;
}

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


main(){
   string s;
   cin >> s;
   if(s=="SUN") cout << 7 << endl;
   if(s=="MON") cout << 6 << endl;
   if(s=="TUE") cout << 5 << endl;
   if(s=="WED") cout << 4 << endl;
   if(s=="THU") cout << 3 << endl;
   if(s=="FRI") cout << 2 << endl;
   if(s=="SAT") cout << 1 << endl;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 1; i <= 100000; ++i) {
        if ((a * i) % b == c) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    for(int i = 0; i < n; i++) cin >> x[i];
    int l, q;
    cin >> l >> q;
    vector<int> a(q);
    vector<int> b(q);
    for(int i = 0; i < q; i++)
    {
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
    }
    vector<vector<int>> next(21, vector<int>(n));
    for(int i = 0; i < n; i++)
    {
        int ar = upper_bound(x.begin(), x.end(), x[i] + l) - x.begin();
        next[0][i] = ar-1;
    }
    for(int k = 0; k < 20; k++)
    {
        for(int i = 0; i < n; i++)
        {
            if(next[k][i] == n-1) next[k+1][i] = n-1;
            else next[k+1][i] = next[k][next[k][i]];
        }
    }
    for(int i = 0; i < q; i++)
    {
        int u = a[i];
        int v = b[i];
        if(u > v) swap(u, v);
        int ans = 0;
        for(int k = 20; k >= 0; k--)
        {
            if(next[k][u] < v)
            {
                u = next[k][u];
                ans += 1 << k;
            }
        }
        cout << ans + 1 << endl;
    }
}


Measured memory_bytes: 10232
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

dp = [0] * (N + 1)
dp[0] = 1
x = 0
for i in range(1, N + 1):
    if i - 3 >= 0:
        x += dp[i-3]
        x %= mod
    dp[i] = x
print(dp[N])

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int d;
  cin >> d;
  arrll(c,26);
  vecll2(s, d, 26);
  rep(i,d){
    rep(j,26){
      cin >> s[i][j];
    }
  }

  srand(time(NULL));

  vecll human(26);
  vecll last(26);

  vecll ans;

  rep(i,d){
    ans.pb(rand()%26+1);
  }

  rep(i,d){
    prt(ans[i]);
  }


}


Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <cctype>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;



int main() {
    
    string a,b,c; cin >>a>>b>>c;
    string s = "";

    vector<char> al(26);
    int count = 0;
    for (char i = 'A'; i <= 'Z'; i++) {
        al[count] = i;
        count++;
    }

    count = 0;
    for (char i = 'a'; i <= 'z'; i++) {
        if (a[0] == i) {
            s += al[count];
            break;
        } 
        count++;
    }
    count = 0;
    for (char i = 'a'; i <= 'z'; i++) {
        if (b[0] == i) {
            s += al[count];
            break;
        } 
        count++;
    }
    count = 0;
    for (char i = 'a'; i <= 'z'; i++) {
        if (c[0] == i) {
            s += al[count];
            break;
        } 
        count++;
    }

    cout << s << endl;
    return 0;
}




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

int main() {
  int a,p,ans = 0;
  cin >> a >> p;
  ans = a*3+p;
  cout << ans/2 << endl;
  return 0;
}

Measured memory_bytes: 256
import sys; readline = sys.stdin.readline
from collections import deque

N = int(readline())

P = list(map(int, readline().split()))
Q = list(map(int, readline().split()))

def pr(n):
    ans = 1
    for i in range(1, n + 1):
        ans *= i
    return ans


def a(b):
    s = sorted(b)
    c = 0
    for i in b:
        rank = s.index(i)
        c += pr(len(s) - 1) * rank
        s.remove(i)
    return c

print(abs(a(P) - a(Q)))

Measured memory_bytes: 38640
#include "bits/stdc++.h"
using namespace std;
typedef vector<string> vect;
#define r(i,a,n) for(int i=a;i<(int)(n);i++)
bool solve(const vect& W){
        const int n = W.size();
        //condition 1
        r(i,0,n-1){
                if(W[i].back()!=W[i+1].front())return false;
        }
        //condition 2
        r(i,0,n){
                r(j,i+1,n){
                        if(W[i]==W[j])return false;
                }
        }
        return true;
}
vect input(){
        int n; cin>>n;
        vect W(n);
        r(i,0,n)cin>>W[i];
        return W;
}
int main(){
        const vect W = input();
        if(solve(W))cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        return 0;
}


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

int main(int argc, char const *argv[]) {
  cin >> N;
  int monster[N];
  for (int i = 0; i < N; i++){
    cin >> monster[i];
  }


  while(1){
  sort(monster,monster+N);

  if(monster[N-2] == 0) break;

  int hoge = 0;
  while(1){
    if(monster[hoge] != 0) break;
    hoge++;
  }

  for (int j = hoge + 1; j < N; j++){
    monster[j] = monster[j] % monster[hoge];

  }
  }


  cout << monster[N-1] << endl;
  return 0;
}


Measured memory_bytes: 640
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int a,b;
    cin>>a>>b;
    
    if(a*b%2==0) cout<<"Even"<<endl;
    else cout<<"Odd"<<endl;
}



Measured memory_bytes: 3080
#pragma GCC optimize("Ofast")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    string s;
    cin >> s;
    cout << s.substr(0, 4) + ' ' + s.substr(4) << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>

using namespace std; 

int main(){
    int N, x;
    cin >> N;

    vector<int>  Xs(N);
    for(int i=0;i<N;++i){
        cin >> x;
        Xs[i] = x;
    }

    long long minimum=1000000000000;
    long long tmp;
    for(int p=1;p<=100;++p){
        tmp = 0;
        for(int j=0;j<N;++j){
            tmp += (Xs[j] - p)*(Xs[j] - p);
        }
        minimum = min(minimum, tmp);
    }

    cout << minimum << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
li = list(map(int,input().split()))
c = 0
for i in li:
  for j in li:
    for k in li:
      li2 = [i,j,k]
      long = max(li2)
      if long*2 < i + j + k:
        if i!=k:
          if k!=j:
            if i !=j:
              c = c + 1
print(int(c/6))

Measured memory_bytes: 9192
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

vector<vector<int>> getSplitPos(int H)
{
    vector<vector<int>> ret;
    if (H == 1) {
        ret.push_back(vector<int>());
        return ret;
    }
    ret = getSplitPos(H-1);
    int size = ret.size();
    rep(i, size) {
        vector<int> add = ret[i];
        add.push_back(H-1);
        ret.push_back(add);
    }
    return ret;
}

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

    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    rep(i, H) cin >> S[i];
    
    vector<vector<int>> spos = getSplitPos(H);
    rep(i, spos.size()) {
        spos[i].push_back(H);
    }
    int ans = 1000000;
    vector<int> curr(10);
    vector<int> next(10);
    for (auto sp: spos) {
        // cout << "--------------------------" << endl;
        // dump(sp);
        fill(curr.begin(), curr.end(), 0);
        int tmp = sp.size()-1; //! the number of breaks
        int prevX = 0;
        // cout << "    tmp = " << tmp << endl;
        rep(x, W) {
            bool overflow = false;
            int y = 0;
            int level = 0;
            for (int sy: sp) {
                next[level] = curr[level];
                // cout << "    level = " << level << ", next[level] = " << next[level] << endl;
                for (; !overflow && y < sy; ++y) {
                    // cout << "        y = " << y << ", x = " << x << endl;
                    if (S[y][x] == '1') {
                        next[level]++;
                        if (K < next[level]) {
                            overflow = true;
                        }
                    }
                }
                if (overflow) {
                    break;
                } else {
                    ++level;
                }
            }
            if (overflow) {
                if (x == prevX) {
                    //! this sp is impossible 
                    tmp = 1000000;
                    break;
                } else {
                    //! break!
                    ++tmp;
                    --x;
                    prevX = x;
                    fill(curr.begin(), curr.end(), 0);
                }
            } else {
                curr.swap(next);
            }
        }
        // cout << "    tmp = " << tmp << endl;
        ans = min(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}


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

#define f(i, a, b, c) for(int i = a ; i < b ; i += c)
#define fr(i, a, b, c) for(int i = a ; i >= b ; i -= c)
#define fit(it, v) for(auto it = v.begin() ; it != v.end() ; ++it)
#define frit(it, v) for(auto it = v.rbegin() ; it != v.rend() ; ++it)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define eb emplace_back
#define pb push_back
#define lli long long int
#define PI 3.14159265358979
#define modn 1000000007
#define NL '\n'

using namespace std;

typedef vector< int > vi;
typedef vector< char > vc;
typedef vector< bool > vb;
typedef vector< string > vs;
typedef vector< lli > vli;
typedef vector< vector< char > > vvc;
typedef vector< vector< int > > vvi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef pair< lli, int> pli;
typedef pair< lli, lli> pll;
typedef set< int > si;
typedef set< ii > sii;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	#ifdef LOCAL_TEST
		clock_t z = clock();
    	ifstream h("in");
	    ofstream g("out");
	#else
	    #define h cin
	    #define g cout
	#endif // LOCAL_TEST
	
	unordered_map< string ,int > m;
	int n;
	h >> n;
	f(i, 0, n, 1){
		string s;
		h >> s;
		if (m.find(s) == m.end())
			m[s] = 1;
		else
			m[s]++;
	}
	vs ans;
	int mx = 0;
	fit(it, m)
		mx = max(mx, it -> second);
	fit(it, m){
		if (it -> second == mx)
			ans.eb(it -> first);
	}
	sort(all(ans));
	fit(it, ans)
		g << *it << NL;
	
	#ifdef LOCAL_TEST
		cerr << "Time taken is: " << double(clock() - z) / CLOCKS_PER_SEC << NL;
		h.close();
		g.close();
	#endif // LOCAL_TEST
}

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

int main(){
    int H, W;
    cin >> H >> W;
    int x[H + 2][W + 2];
    
    rep(i,H + 2){
        rep(j,W + 2){
            x[i][j] = 0;
        }
    }

    rep(i,H){
        rep(j,W){
            char tmp;
            cin >> tmp;
            if (tmp == '.'){
                x[i + 1][j + 1] = 0;
            } else {
                x[i + 1][j + 1] = 1;
            }
        }
    }

    rep(i,H){
        rep(j,W){
            if (x[i + 1][j + 1] == 1){
                cout << '#';
            } else {
                int counter = 0;
                counter += x[i][j] + x[i][j + 1] + x[i][j + 2]
                        + x[i + 1][j] + x[i + 1][j + 1] + x[i + 1][j + 2]
                        + x[i + 2][j] + x[i + 2][j + 1] + x[i + 2][j + 2];
                cout << counter;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;

/* ---------------------------------------------------------------------- */
// 順列
class Permutation {
	// 公開関数
public:
	// コンストラクタ
	Permutation();
	// デストラクタ
	~Permutation();
	// 順列を計算するメイン関数
	const vector<vector<int>>& calc_main(int N);
	// 内部関数
private:
	// 順列を計算するための再帰関数
	void calc_perm(vector<bool> jdg, vector<int> num);
	// 内部変数
private:
	// 計算した順列を格納するvector配列
	vector<vector<int>> ans;
	// 計算する階乗を示す整数
	int N = 1;
};
/* ---------------------------------------------------------------------- */

// コンストラクタ
Permutation::Permutation() {
	// 答えを格納するメンバ変数のvector配列を初期化
	ans.clear();
}

// デストラクタ
Permutation::~Permutation() {
}

// 順列を計算するメイン関数
const vector<vector<int>>& Permutation::calc_main(int N) {
	// 計算する階乗を示す整数を内部変数に格納
	this->N = N;

	// 順列に含まれているかを確認するbool型のvector配列を宣言
	vector<bool> jdg(this->N, false);

	// 再帰関数を用いて順列を計算
	vector<int> num;
	// 初期化
	num.clear();
	calc_perm(jdg, num);

	// 順列が格納されたvector配列を戻り値として返す
	return ans;
}

// 順列を計算するための再帰関数
void Permutation::calc_perm(vector<bool> jdg, vector<int> num) {
	// すべての整数を使って順列を作成した場合
	if (jdg.end() == find(jdg.begin(), jdg.end(), false)) {
		// 答えを格納
		ans.push_back(num);
	}

	// 整数のループ
	for (size_t i = 1; i <= N; i++) {
		if (jdg[i - 1] == false) {
			vector<int> dnum = num;
			dnum.push_back(i);
			jdg[i - 1] = true;
			calc_perm(jdg, dnum);
			jdg[i - 1] = false;
		}
	}
}

int main() {

	int N, M;
	cin >> N >> M;

	vector<vector<int>> edge(N, vector<int>());

	int a, b;
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		a--;
		b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}

	Permutation P;
	const vector<vector<int>>& perm = P.calc_main(N - 1);

	int ini = 0;
	bool jdg = true;
	int ans = 0;

	for (int i = 0; i < perm.size(); i++) {
		ini = 0;
		jdg = true;
		for (int j = 0; j < perm[i].size(); j++) {
			if (edge[ini].end() != find(edge[ini].begin(), edge[ini].end(), perm[i][j])) {
				ini = perm[i][j];
			}
			else {
				jdg = false;
				break;
			}
		}
		if (jdg == true) {
			ans += 1;
		}
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define ll long long

const int MOD = 1e9 + 7;

int main() {
    int map[500][500];
    vector<int> a,b,c,d;
    int H, W;
    cin >> H >>W;
    REP(y, H) REP(x, W) {
        cin >> map[y][x];
    }
    
    int dx = 1, x = 0, y = 0, x2, y2;
    int cnt = 0;
    while(1) {
        if(x + dx == W || x + dx == -1) {
            dx *= -1;
            x2 = x;
            y2 = y + 1;
        } else {
            x2 = x + dx;
            y2 = y;
        }

        if(y2 >= H) {
            break;
        }

        if(map[y][x] % 2 == 1) {
            a.push_back(y+1);
            b.push_back(x+1);
            c.push_back(y2+1);
            d.push_back(x2+1);
            map[y][x]--;
            map[y2][x2]++;
            cnt++;
        }

        x = x2;
        y = y2;
    }
    printf("%d\n", cnt);
    REP(i, cnt) {
        printf("%d %d %d %d\n", a[i],b[i],c[i],d[i]);
    }
}



Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;

int main() {
  int N,A,B;
  cin>>N>>A>>B;
  if((A-B+1)%2!=0){cout<<"Alice"<<endl;}
  else{cout<<"Borys"<<endl;}
  return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define inf LLONG_MAX>>2
#define MAX 1000000
#define mod 998244353
#define pb push_back
#define f(i,a,n,x) for ((i)=(a);(i)<(n);(i)+=(x))
#define fd(i,a,n,x) for ((i)=(a);(i)>=(n);(i)-=(x))
#define fi first
#define se second
#define mk make_pair
#define pi pair
#define vt vector
#define ms multiset
using namespace std;
void read(vt<ll> &a,ll n){ll i,temp;f(i,0,n,1){cin>>temp;a.pb(temp);}}
ll fa[MAX];
ll power(ll p,ll q){
    ll res=1;
    p%=mod;
    while(q){
        if (q&1)
            res=(res*p)%mod;
        q>>=1;
        p=(p*p)%mod;
    }
    return res;
}
ll fact(ll n){
    if (n<=1)
        return fa[n]=1;
    if (fa[n])
        return fa[n];
    return fa[n]=(n*fact(n-1))%mod;
}
ll ncr(ll n,ll r){
    if (!r)
        return 1;
    return (((fact(n)*power(fact(n-r),mod-2))%mod)*power(fact(r),mod-2))%mod;
}
ll func(ll n,ll m,ll i){
    return (((m*ncr(n-1,i))%mod)*power(m-1,n-1-i))%mod;
}
void solve(){
    ll n,m,k,i,ans=0;
    cin>>n>>m>>k;
    f(i,0,k+1,1)
        ans=(ans+func(n,m,i))%mod;
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 8212
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
using namespace std;
// #define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////

const int N = 30, K = 1 << 21, M = 1e9+7;
int n, m[N][N];
vector<int> a[N];
int dp[N][K];
int add(int a, int b) {return (a+b)%M;}

int rec(int id, int mask) {
	if(id == 0) return 1;
	int& memo = dp[id][mask];
	if(memo != -1) return memo;
	int res = 0;
	for(int w : a[id]) if(mask & (1 << w)) res = add(res, rec(id-1, mask & ~(1 << w)));
	return memo = res;
}

signed main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    memset(dp, -1, sizeof(dp));
    cin >> n;
    FOR(i, 1, n) {
    	FOR(j, 1, n) {
    		cin >> m[i][j];
    		if(m[i][j] == 1) a[i].push_back(j-1);
    	}
    }
    cout << rec(n, (1 << n)-1) << endl;

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE)
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - integer division (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting min to 0 instead of -INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)


Measured memory_bytes: 246016
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n;
string s;
int main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> s;
	int ans = 1;
	for(int i=1; i<n; i++){
		ans += (s[i] != s[i-1]);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
def main():
    import sys
    N=int(sys.stdin.readline())
    X=sys.stdin.readline()

    no=X.count('1')
    np=no+1
    nm=no-1
    nm_flag=bool(nm)

    np_mods=[-1]*N
    nm_mods=[-1]*N
    
    np_mods[0]=1
    nm_mods[0]=1
    
    for i in range(1,N):
        np_mods[i]=(np_mods[i-1]*2)%np
        if nm_flag:
            nm_mods[i]=(nm_mods[i-1]*2)%nm

    np_mods.reverse()
    nm_mods.reverse()
    
    np_mods_sum=0
    nm_mods_sum=0
    for i in range(N):
        if X[i]=='1':
            np_mods_sum+=np_mods[i]
            nm_mods_sum+=nm_mods[i]

    for i in range(N):
        if X[i]=='0':
            n=(np_mods_sum+np_mods[i])%np

        else:
            if nm_flag:
                n=(nm_mods_sum-nm_mods[i])%nm
            else:
                print(0)
                continue
        if n==0:
            print(1)
            continue
        count=1
        while True:
            bs=str(bin(n))[2:]
            k=bs.count('1')
            n=n%k
            count+=1
            if n==0:
                break
        print(count)

main()

Measured memory_bytes: 25168