akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const double PI=3.14159265358979323846;
int main(){
    int a,b;cin>>a>>b;
    vector<int> v(b);
    int sum=0;
    int c;
    for(int i=0;i<b;i++){
        cin>>c;
        sum+=c;
    }
    if(sum<=a){
        cout<<a-sum<<endl;
    }else{
        cout<<-1<<endl;
    }
    return 0;
}


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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  string s;
  int g = 0, p = 0, ans = 0;
  cin >> s;
  rep(i, 0, s.length()) {
    if(p + 1 <= g) {
      p++;
      if(s[i] == 'g') ans++;
    }else {
      g++;
      if(s[i] == 'p') ans--;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

const i64 INF = 1e15;

int main() {
    int N, C;
    cin >> N >> C;
    i64 ans = INF;
    vector<vector<i64>> D(C, vector<i64>(C));
    vector<vector<int>> c(3, vector<int>(C, 0));
    for(int i = 0; i < C; i++) {
        for(int j = 0; j < C; j++) {
            cin >> D[i][j];
        }
    }
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            int tmp;
            cin >> tmp;
            c[(i + j + 2) % 3][tmp - 1]++;
        }
    }
    int y[3];
    for (y[0] = 0; y[0] < C; y[0]++) {
        for (y[1] = 0; y[1] < C; y[1]++) {
            for (y[2] = 0; y[2] < C; y[2]++) {
                if(y[0] == y[1] || y[1] == y[2] || y[2] == y[0]) continue;
                i64 cand = 0;
                for(int b = 0; b < 3; b++) {
                    for(int i = 0; i < C; i++) {
                        cand += c[b][i] * D[i][y[b]];
                    }
                }
                ans = min(ans, cand);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int ans = c - (a-b);
        if (ans <= 0) {
            System.out.println(0);
        } else {
            System.out.println(ans);
        }
    }

}


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

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

long long MOD = 1000000000 + 7;

bool operator>(vll x, vll y){
  return x[0] > y[0];
}

int main(){
  cout << setprecision(10);
  priority_queue<vll, vector<vll>, less<vll>> que;

  int x,y,z,k;
  cin >> x >> y >> z >> k;
  vector<ll> A(x);
  vector<ll> B(y);
  vector<ll> C(z);
  for(int i= 0; i < x; i++){
    cin >> A.at(i);
  }
  for(int i= 0; i < y; i++){
    cin >> B.at(i);
  }
  for(int i= 0; i < z; i++){
    cin >> C.at(i);
  }
  sort(A.rbegin(), A.rend());
  sort(B.rbegin(), B.rend());
  sort(C.rbegin(), C.rend());

  int a_index = 0;
  int b_index = 0;
  int c_index = 0;
  int num = 0;
  map<string,bool> m;
  vll v_tmp = {A[a_index] + B[b_index] + C[c_index], a_index, b_index, c_index};
  que.push(v_tmp);
  while(num < k){
    vll now = que.top();
    cout << now[0] << endl;
    num++;
    que.pop();
    int now_a = now[1];
    int now_b = now[2];
    int now_c = now[3];
    // cerr << "now_ " << now_a << " " << now_b << " " << now_c << endl;

    string s1 = to_string(now_a+1) + "_" + to_string(now_b) + "_" + to_string(now_c);
    string s2 = to_string(now_a) + "_" + to_string(now_b+1) + "_" + to_string(now_c);
    string s3 = to_string(now_a) + "_" + to_string(now_b) + "_" + to_string(now_c+1);
/* 
    cerr << "now: " << now[0] << " s1: " << s1 << endl;
    cerr << "now: " << now[0] << " s2: " << s2 << endl;
    cerr << "now: " << now[0] << " s3: " << s3 << endl;
 */
    if(m.count(s1) == 0 && now_a+1 < x){
      m[s1]= true;
      v_tmp = {A[now_a + 1] + B[now_b] + C[now_c], now_a+1, now_b, now_c};
      que.push(v_tmp);
    }
    if(m.count(s2) == 0 && now_b+1 < y){
      m[s2]= true;
      v_tmp = {A[now_a] + B[now_b + 1] + C[now_c], now_a, now_b+1, now_c};
      que.push(v_tmp);
    }
    if(m.count(s3) == 0 && now_c+1 < z){
      m[s3]= true;
      v_tmp = {A[now_a] + B[now_b] + C[now_c + 1], now_a, now_b, now_c+1};
      que.push(v_tmp);
    }
  }

}


Measured memory_bytes: 1408
import sys
import heapq
import bisect

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(list(sys.stdin.readline())[:-1])

def main():
    N = I()
    s = S()
    dp = [[0 for _ in range(N)] for _ in range(N)]

    for i in range(N-1,-1,-1):
        for j in range(N-1,-1,-1):
            if s[i] == s[j]:
                if i+1<=N-1 and j+1<=N-1:
                    dp[i][j] = dp[i+1][j+1]+1
                else:
                    dp[i][j] = 1

    ans = 0
    for i in range(N):
        for j in range(N):
            if dp[i][j] > ans and i + dp[i][j] <= j:
                ans = dp[i][j]
    return(ans)

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 247432
class Graph<T : List<Int>> constructor(val graph: Array<T>) {
    private val dp = IntArray(100000) { -1 }

    fun rec(v: Int): Int {
        if (dp[v] != -1) return dp[v]

        var res = 0
        graph[v].forEach {
            res = Math.max(res, rec(it) + 1)
        }
        dp[v] = res
        return res
    }

}

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }

    val graph = Array(n) { mutableListOf<Int>() }
    repeat(m) {
        val (x, y) = readLine()!!.split(' ').map { it.toInt() }
        graph[x - 1].add(y - 1)
    }

    val g = Graph(graph)
    var res = 0
    (0 until n).forEach {
        res = Math.max(res, g.rec(it))
    }
    println(res)
}


Measured memory_bytes: 66156
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll X, K, D;
    cin >> X >> K >> D;
    // Xの正負は考慮しなくて良い
    if (X < 0)
    {
        X *= -1;
    }

    // 貪欲に原点に近づけば良い場合
    if (X / D > K)
    {
        cout << X - K * D << endl;
    }
    // 原点に近い点の候補が２つになる場合
    else
    {
        K -= X / D;
        if (K % 2 == 0)
        {
            cout << X % D << endl;
        }
        else
        {
            cout << D - X % D << endl;
        }
    }
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int X;
signed main() {
    cin >> X;
    reps(i, 1000) {
        int a = X - i * 100;
        if (0 <= a && a <= 5 * i) { fin(1); }
    }
    cout << 0 << endl;
}


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

int main() {
  int N,M,T;
  T=0;
  cin >> N >>M;
  int A[M];
  for(int i=0;i<M;i++){
      cin >> A[i];
  }
  for(int i=0; i<M;i++){
      T+=A[i];
  }
  if(T>N){
      cout << "-1" << endl;
  }
  else{
      cout << N-T <<endl;
  }

}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string x;
    cin >> x;
    int scnt = 0, delcnt = 0;
    
    rep(i, x.length()) {
        if (x[i] == 'S') {
            scnt++;
        }
        else if (x[i] == 'T') {
            if (scnt > 0) {
                scnt--;
                delcnt += 2;
            }
        }
    }
    
    cout << (x.length() - delcnt) << endl;
    return 0;
}

Measured memory_bytes: 720
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;


int main(void)
{
	char c[10+2];
	while(scanf("%1[a-y]\n", c)==1)
	{
		printf("%c\n", c[0]+1);
	}
	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m,x,s[25],sum,ans,a[25][25],c[25];
int main()
{int i,j,k;
	scanf("%d%d%d",&n,&m,&x);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&c[i]);
		for (j=1;j<=m;j++)
		scanf("%d",&a[i][j]);
	 } 
	 ans=2e9;
	for (i=0;i<(1<<n);i++)
	{
		memset(s,0,sizeof(s));
		sum=0;
		for (j=0;j<n;j++)
		if ((i&(1<<j))!=0){
			for (k=1;k<=m;k++)
				s[k]+=a[j+1][k];
			sum+=c[j+1];
		}
		for (j=1;j<=m;j++)
		if (s[j]<x) break;
		if (j>m) ans=min(ans,sum);
	} 
	if (ans==2e9) printf("-1\n");
	else printf("%d",ans);
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
 
int main(){ 
long long a,b,k;
cin>>a>>b>>k;
if(k>=a+b)
cout<<0<<" "<<0<<endl;
else if(k>=a)
cout<<0<<" "<<b-(k-a)<<endl;
else
cout<<a-k<<" "<<b<<endl;  
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll N;
  scanf("%lld", &N);

  vector<ll> a_list;
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    a_list.emplace_back(v);
  }

  vector<ll> csum(a_list.size() + 1);
  for (ll i = 1; i < a_list.size() + 1; i++) {
    csum[i] = csum[i - 1] + a_list[i - 1];
  }
  // // [2] + [3] + [4]
  // cout << (csum[4 + 1] - csum[2]) << endl;
  // // [1] + [2] + [3]
  // cout << (csum[3 + 1] - csum[1]) << endl;

  ll ans = 0;

  for (ll i = 0; i < N - 1; i++) {
    ll s = (csum[N - 1 + 1] - csum[i + 1]);
    s %= MOD;
    ll plus = a_list[i] * (s);
    plus %= MOD;
    ans += plus;
    ans %= MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 6392
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N, C, K;
const int MAX_N = 100000;
ll T[MAX_N];

int main(){
  cin >> N >> C >> K;
  REP(i, N) cin >> T[i];
  sort(T, T + N);

  int i = 0;
  int ans = 0;
  while(i < N) {
    ans++;
    int j = 0;
    int prv = i++;
    while(j < C - 1 && T[i] <= T[prv] + K && i < N) {
      i++;
      j++;
    }
  }

  cout << ans << endl;


  return 0;
}



Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main() {
	int	n, k;

	cin >> n >> k;

	int count = n / 2;
	if (n % 2 != 0) {
		count++;
	}

	if (k <= count) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

}


Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
    char s1[50],s2[50],s3[50];
    scanf ("%s %s %s",&s1,&s2,&s3);
    printf ("%c%c%c\n",s1[0]-32,s2[0]-32,s3[0]-32);
    return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>

#define ll long long
#define ull unsigned long long

using namespace std;

const long long mod = 1e9 + 7;

struct city{
    int number;
    int p;
    int y;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    city *cities;
    cin >> n >> m;
    cities = new city[m];
    for(int i = 0; i < m; ++i){
        cities[i].number = i;
        cin >> cities[i].p;
        cin >> cities[i].y;
    }

    sort(cities, cities+m, [](city &a, city &b){
        if(a.p == b.p) return a.y < b.y;
        else return a.p < b.p;
    });

    cities[0].y = 1;
    int count = 2;
    int currentP = cities[0].p;
    for(int i = 1; i < m; ++i){
        if(cities[i].p == currentP){
            cities[i].y = count;
            ++count;
        }else{
            cities[i].y = 1;
            count = 2;
            currentP = cities[i].p;
        }
    }

    sort(cities, cities+m, [](city &a, city &b){
        return a.number < b.number;
    });

    for(int i = 0; i < m; ++i){
        cout << setw(6) << setfill('0') << cities[i].p;
        cout << setw(6) << setfill('0') << cities[i].y << "\n";
    }
}

Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int S = 100000;
int ls[S],n,ans=0;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> ls[i];
	for (int i = 0; i < n; i++) {
		if (ls[i] == i+1&&i + 1 < n&&ls[i + 1] == i + 2) { ans++; i++; }
		else if (ls[i] == i+1)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
using namespace std;

bool ochiru(int y0, int H, int N, string S, string T, char c0, char c1){
    int l = 0;
    int r = H+1;
    for(int i=N-1; i>=0; i--){
        if(T[i] == c0) r = min(H+1, r+1);
        if(T[i] == c1) l = max(0, l-1);
        if(r <= l || l == H || r == 1) return true;
        if(S[i] == c1) r--;
        if(S[i] == c0) l++;
        if(r <= l || l == H || r == 1) return true;
    }
    if(y0 <= l || r <= y0) return true;
    else return false;
}

int main(){
    int H, W, N;
    cin >> H >> W >> N;
    int y0, x0;
    cin >> y0 >> x0;
    string S, T;
    cin >> S >> T;
    if(ochiru(y0, H, N, S, T, 'U', 'D') || ochiru(x0, W, N, S, T, 'L', 'R')) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}

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

using namespace std;

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

#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int main () {
    int n;
    scanf("%d", &n);

    vector<int> a(n);
    fto(i, 0, n-1)
        scanf("%d", &a[i]);
    sort(a.begin(), a.end());

    int ans = 0;
    for(int sum = (1<<30); sum > 1; sum >>= 1) {
        int r = n-1;

        vector<bool> avail(n, true);
        fto(l, 0, n-1) {
            while (r > l && a[l] + a[r] > sum)
                --r;
            if (r <= l)
                break;

            if (l < r && a[l] + a[r] == sum) {
                ++ans;
                avail[l] = avail[r--] = false;
            }
        }

        vector<int> nxt;
        fto(i, 0, n-1)
            if (avail[i])
                nxt.pb(a[i]);
        a = nxt;
        n = sz(a);
    }

    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 2920
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
    int N,A,B;
    cin >> N;
    if(N == 1)
    {
        cout << "Hello World";
    }
    else
    {
        cin >> A;
        cin >> B;
        cout << A + B;
    }
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.container;
import std.string;
import std.array;
import std.algorithm;

int[][] duplicate(int[][] F) {
    int[][] copy = new int[][F.length];
    foreach (i, L; F) {
        copy[i] = L.dup;
    }
    return copy;
}

int[][] set(int[][] F, int v) {
    int y = cast(int)F.length;
    int x = cast(int)F[0].length;
    int[][] copy = F.duplicate;
    auto mark = new bool[][](y, x);
    void setMark(int i, int j) {
        static const dy = [1, 0, -1, 0];
        static const dx = [0, 1, 0, -1];
        if (mark[i][j]) return;
        mark[i][j] = true;
        foreach (k; 0 .. 4) {
            int ny = i + dy[k], nx = j + dx[k];
            if (0 <= ny && ny < y && 0 <= nx && nx < x) {
                if (F[i][j] == F[ny][nx] && !mark[ny][nx]) {
                    setMark(ny, nx);
                }
            }
        }
    }
    setMark(0, 0);
    foreach (i; 0 .. y) 
        foreach (j; 0 .. x) 
            if (mark[i][j]) copy[i][j] = v;
    return copy;
}

class State {
    int t;
    int[][] F;
    this(int t, int[][] F) {
        this.t = t;
        this.F = F;
    }
    bool finished() {
        int v = F[0][0];
        foreach (L; F) 
            foreach (C; L) 
                if (C != v) return false;
        return true;
    }
}

void dump(int[][] F) {
    foreach (L; F) {
        L.map!(to!string).join(" ").writeln;
    }
}

string encode(int[][] F) {
    char[] hash;
    foreach (L; F) {
        foreach (C; L) {
            hash ~= cast(char)(C + '0');
        }
    }
    return cast(string)hash;
    /*
    return F.map!(function(int[] L) {
        return L.map!(to!string).join("");
    }).join("");
    */
}

void main() {
    int x, y; 
    int[][] F;
    while (readf("%d %d\n", &x, &y), x || y) {
        F = new int[][y];
        foreach (ref L; F) {
            L = readln.chomp.split(" ").map!(function(string s) {
                switch (s) {
                    case "R": return 0;
                    case "G": return 1;
                    case "B": return 2;
                    default: // XXX;
                }
                throw new Error("?");
            }).array;
        }
        auto Q = new DList!State(new State(0, F.duplicate));
        bool[string] used;
        while (!Q.empty) {
            State s = Q.front;
            Q.removeFront;
            //s.t.writeln;
            //s.F.dump;
            if (s.finished) {
                s.t.writeln;
                break;
            }
            foreach (v; 0 .. 3) {
                if (s.F[0][0] == v) continue;
                auto next = s.F.set(v);
                auto hash = next.encode;
                if (used.get(hash, false)) {
                    delete(next);
                    continue;
                } 
                used[hash] = true;
                Q.insert(new State(s.t + 1, next));
            }
        }
    }
}

Measured memory_bytes: 11728
import sys
input = sys.stdin.readline

N=int(input())
S=input().strip()

# Rolling Hash
LEN=len(S)

p=26# 文字の種類
mod=(1<<50)+1# Hashがぶつからない, pと互いに素な数を適当に指定

TABLE=[0]# Rolling Hashのテーブル. 最初は0

for i in range(LEN):
    TABLE.append((p*TABLE[-1]%mod+ord(S[i])-97)%mod)# テーブルを埋める

def hash_ij(i,j): # [i,j)のハッシュ値を求める
    return (TABLE[j]-TABLE[i]*pow(p,j-i,mod))%mod


MIN=0
MAX=LEN//2

from collections import defaultdict

while MIN!=MAX:
    x=(MIN+MAX+1)//2
    DICT=defaultdict(list)

    for i in range(LEN-x+1):
        DICT[hash_ij(i,i+x)].append(i)

    #print(DICT,MIN,MAX,x)

    for l in DICT:
        if max(DICT[l])-min(DICT[l])>=x:
            MIN=x
            break
    else:
        MAX=x-1

print(MIN)
        
        


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N, M;
	cin >> N >> M;
	vector<int>AC(N), WA(N);
	int ACcnt = 0, WAcnt = 0;
	for (int i = 0; i < M; i++){
		int p;
		string s;
		cin >> p >> s;
		--p;
		if (AC[p]) {
			continue;
		}
		if (s == "AC") {
			AC[p] = 1;
		}
		else {
			WA[p]++;
		}
	}
	for (int i = 0; i < N; i++){
		ACcnt += AC[i];
		if (AC[i]) {
			WAcnt += WA[i];
		}
	}
	cout << ACcnt << " " << WAcnt << endl;

	return 0;
}

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

int main() {
  int L,M,N;
  int sum,ans;
  while(cin >> L) {
    if(L==0) break;
    sum=0;
    bool r = true;
    for(int i=0;i<12;i++) {
      cin >> M >> N;
      sum += M-N;
      if(sum >= L && r) {
        ans = i+1;
        r = false;
      }
    }
    if(!r)
      cout << ans << endl;
    else
      cout << "NA" << endl;
  }
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n;
  cin >> n;

  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    string x = to_string(i);
    if (x.length() % 2 != 0) ++cnt;
  }

  cout << cnt << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

    int c = 0;
    for (int a = 1; a <= 9; a++) {
        for (int b = 1; b <= 9; b++) {
            if (a * b == n) c = 1;
        }
    }

    if (c) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}

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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int a,b;
    cin >> a >> b;
    cout << a*b -(a+b-1) << endl;
	return 0;
}



Measured memory_bytes: 256
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll>
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;
int main(){
    ll a,b;
    cin>>a>>b;
    cout<<(a+b+1)/2<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> c(N);
  int count = 0;
  for (int i = 1; i < N; i++) {
    if (S.at(i-1) == 'A' && S.at(i) == 'C') count++;
    c.at(i) = count;
  }
  
  for (int i = 0; i < Q; i++) {
    int l,r;
    cin >> l >> r;
    cout << c.at(r-1) - c.at(l-1) << endl;
  }
}

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

int main() {
	int n;
    cin >> n;
    int w[n];
    int dif;
    int sum=0;
    int tmp=0;
    int ans = 1000000;
    for(int i=0;i<n;i++){
       cin >> w[i];
       sum = sum + w[i];
    }


    for(int i=0;i<n;i++){
       tmp = tmp + w[i];
       dif = sum - tmp*2;
       if(dif<0) dif = -dif;
       if(dif<ans) ans = dif;
    }

    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
 
ll exp(ll a, ll b){
	if(b==0)
	return 1;
	if(b==1)
	return a;
	ll R = exp(a,b/2);
	if(b&1) {
		ll p = ((R%mod)*(R%mod))%mod;
		p = ((a%mod) * p)%mod;
		return p;
		
		}
	
	else
	return ((R%mod)*(R%mod))%mod;
	}

int main(){
    ll n; cin>>n;
    ll ans = 0;
    ans = (ans + exp(10, n) - 2*exp(9, n) + exp(8, n))%mod;
    ans = ans+mod;
    ans%=mod;
    cout<<ans;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <iostream>
#include <string>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <vector>
#include <iomanip>
using namespace std;


int main(){
    // input
    string S; cin >> S;

    // compute
    list<char> s = {S[0], S[1], S[2], S[3]};
    s.sort();

    char s0 = s.front();
    s.pop_front();
    char s1 = s.front();
    s.pop_front();
    char s2 = s.front();
    s.pop_front();
    char s3 = s.front();
    
    
    if(s0 == s1 && s2 == s3 && s0 != s2) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    // output
}



Measured memory_bytes: 256
N,M = map(int, input().split())
L = [[int(l) for l in input().split()] for _ in range(N)]

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
        
    def find_root(self, x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]
        
    def unite(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1
                
    def isSameGroup(self, x, y):
        return self.find_root(x) == self.find_root(y)
    
    def count(self, x):
        return -self.root[self.find_root(x)]

uf = UnionFind(N+M)
for i in range(N):
    for j in range(1, L[i][0]+1):
        uf.unite(i+M+1, L[i][j])

ans = "YES"
for i in range(M+1, M+N+1):
    if uf.isSameGroup(M+1, i):
        continue
    ans = "NO"
    break

print(ans)

Measured memory_bytes: 21136
s = input()[::-1]
t = input()[::-1]
ans = "UNRESTORABLE"

def search():
    si = ti = 0
    for k in range(len(s)-len(t)+1):
        si = k
        ans = s[:k]
        while(True):
            if s[si]==t[ti] or s[si]=='?':
                si+=1
                ti+=1
                ans += t[ti-1]
                if ti == len(t):
                    ans+=s[k+ti:]
                    ans =ans.replace('?','a')
                    return ans[::-1]
                continue
            ti = 0
            break

    return "UNRESTORABLE"

print(search())


Measured memory_bytes: 3064
X, Y, Z, K = [int(x) for x in input().split()]
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
A = sorted(A, reverse=True)
B = sorted(B, reverse=True)
C = sorted(C, reverse=True)
ABC = []
for a in range(len(A)):
    if a+1 > K:
        break
    for b in range(len(B)):
        if (a+1)*(b+1) > K:
            break
        for c in range(len(C)):
            if (a+1)*(c+1) > K:
                break
            elif (b+1)*(c+1) > K:
                break
            elif (a+1)*(b+1)*(c+1) > K:
                break
            ABC.append(A[a] + B[b] + C[c])
ABC = sorted(ABC, reverse=True)
for i in range(K):
    print(ABC[i])

Measured memory_bytes: 9564
n=int(input())
s=[int(x) for x in input().split()]
s.sort()
a=s[0]
b=s[-1]
m=9999999999999
for i in range(a,b+1):
    sum=0    
    for j in s:
        sum+=(j-i)**2
    if sum < m:
        m=sum
        
print(m)

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

int main() {
  
  int a,b,c;
  char d,e;
  cin >> a >> d >> b >> e >> c;
  
  if(b>4){cout << "TBD" << endl;}
  else {cout << "Heisei" << endl;}
  
}

Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]
parade = [list(map(int, input().split())) for i in range(n)]
vec = [int(input()) for i in range(m)]

for i in range(n):
    temp = []
    for x, y in zip(parade[i], vec):
        temp.append(x * y)
    print(sum(temp))



Measured memory_bytes: 6020
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)
using namespace std;
using Graph = vector<vector<int>>;
using P = pair<long, long>;

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

struct compare1 { 
    bool operator()(const pair<long, long>& value,  
                                const long& key) 
    { 
        return (value.first < key); 
    } 
    bool operator()(const long& key,  
                    const pair<long, long>& value) 
    { 
        return (key < value.first); 
    } 
};

int main()
{
    int N, X, Y; cin >> N >> X >> Y;
    X--;
    Y--;
    int ans[3000];
    REP(i, 3000) ans[i] = 0;
    REP(i, N){
        for(int j=i+1; j < N; j++){
            if(j <= X){
                ans[j-i]++;
                continue;
            }
            if(i >= Y){
                ans[j-i]++;
                continue;
            }
            if(i >= X && j <= Y){
                ans[min(j-i, i-X+Y-j+1)]++;
                continue;
            }
            if(i<=X && j >= Y){
                ans[X-i+j-Y+1]++;
                continue;
            }
            if(i<=X && X < j && j < Y){
                ans[X-i+min(j-X, Y-j+1)]++;
                continue;
            }
            if(j>=Y && i >= X && i <= Y){
                ans[j-Y+min(Y-i, i-X+1)]++;
            }
            
        }
    }

    for(int i=1;i<N;i++) cout << ans[i] << endl;
    
    return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>

int ifso(int num);

int main()
{
    int n,i=11,j=0;
    scanf("%d",&n);
    while(j<n)
    {
        if(ifso(i))
        {
            printf("%d ",i);
            j++;
        }
        i+=10;
    }
}

int ifso(int num)
{
    int a,flag=1;
    for(a=2;a<=sqrt(num);a++)
    {
        if(num%a==0)flag=0;
    }
    return flag;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll N;
    cin >> N;
    ll A[N];
    ll sum[N+1]={};
    ll xorsum[N+1]={};
    rep(i,N){
        cin >> A[i];
        sum[i+1]=sum[i]+A[i];
        xorsum[i+1]=xorsum[i]^A[i];
    }
    DEBUG{
        rep(i,N+1){
            cout << "sum : " << sum[i] << endl;
            cout << "xorsum : " << xorsum[i] << endl;
        }
    }
    ll from=1,to=1;
    ll res=0;
    while(from<=N){
        while(sum[to]-sum[from-1]==(xorsum[to]^xorsum[from-1])&&to<=N)to++;
        to--;
        DEBUG{
            printf("from : %lld, to: %lld\n", from, to);
        }
        res += to-from+1;
        from++;
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll n;
  cin >> n;
  vll a(n);
  rep(i, n) {
    cin >> a[i];
  }

  map<ll, ll> m;
  rep(i, n) {
    m[a[i]]++;
  }

  ll ans = 0;
  for (auto& it : m) {
    ans += it.first * it.second;
  }

  ll q;
  cin >> q;
  rep(i, q) {
    ll b, c;
    cin >> b >> c;
    m[c] += m[b];

    ans += (c - b) * m[b];

    m[b] = 0;

    cout << ans << endl;
  }

  return 0;
}


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


int main(){
  int N,M,a,b,memo[200100]={};
  cin>>N>>M;
  for(int k=0;k<M;k++){
    cin>>a>>b;
    if(a==1){
      memo[b]+=1;
      if(memo[b]==2){
        cout<<"POSSIBLE"<<endl;
        return 0;
      }
    }
    if(b==N){
      memo[a]+=1;
      if(memo[a]==2){
        cout<<"POSSIBLE"<<endl;
        return 0;
      }
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


Measured memory_bytes: 1024
def main():
    N = int(input())
    x = list(map(int, input().split()))
    xx = sum(x)
    p = xx//N
    if (2*N*p+N-2*xx) < 0:
        ans = p+1
    else :
        ans = p
    kyori = 0
    for i in range(N):
        kyori += (x[i]-ans)**2
    print(kyori)
main()

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

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

    if ((H == 1) || (W == 1)) cout << 1 << endl;
    else cout << (H * W + 1) / 2 << endl;

    return 0;
}

 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'

using namespace std;
typedef long long ll;

const ll INF = 3e9, MAX = 3e5;
ll a[MAX], sol[MAX];
	
int main(){

	int n; scanf("%d", &n);
 
	for(int i = 0; i < (1 << n); i++) cin >> a[i];
	
 
	for(int i = 0; i < (1 << n); i++)
	{
		ll  mx1 = -INF, mx2 = -INF;
	
		for(int j = i; j >= 0; j = (j - 1)&i)
		{
			
			if(a[j] > mx1)
					mx2 = mx1, mx1 = a[j];
			else{
				if(a[j] > mx2) mx2 = a[j];
			}
			
			if(j == 0) break;
		}
		
		sol[i] = mx1 + mx2;
	}
	
	sol[0] = -INF;
	for(int i = 1; i < (1 << n); i++){
		//~ cout << sol[i] << endl;
	    sol[i] = max(sol[i - 1], sol[i]);	    
	    printf("%lld\n", sol[i]);
	}
	
	return 0;
}


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

#define _ << " _ " <<
#define TRACE(x) cout << #x << " = " << x << endl

const int MaxN = 2e5 + 10;
long long n, a[MaxN];

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

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] > i) {
            cout << -1;
            return 0;
        }
    }

    long long sol = 0;
    int b = n - 1;

    for (int i = n - 1; i >= 0; i--) {
        if (b < i - a[i]) {
            cout << -1;
            return 0;
        }                                                                                               
        b = i - a[i];

        sol += a[i];
        for (; i > 0 && a[i - 1] + 1 == a[i]; i--) {}
    }

    cout << sol;

    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int l[200010], r[200010];
int p[100010], q[100010];

int mp[505][505];

int main(){
    int n, m, Q;
    cin >> n >> m >> Q;
    rep(i, m) cin >> l[i] >> r[i];
    rep(i, Q) cin >> p[i] >> q[i];

    rep(i, m){
        mp[r[i]][l[i]]++;
    }

    rep(i, n + 1){
        rep(j, n + 1){
            mp[i][j+1] += mp[i][j];
        }
    }

    // rep(i, n+2){
    //     rep(j, n+2) cout << mp[i][j] << " ";
    //     cout << endl;
    // }
    vector<int> ans;

    rep(i, Q){
        int tmp = 0;
        for (int t = p[i]; t <= q[i]; t++){
            tmp += mp[t][q[i] + 1] - mp[t][p[i] - 1];
        }
        ans.push_back(tmp);
    }
    rep(i, Q) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 4728
#include<iostream>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;
int main() {
	int n;
	cin >> n;
	int j = 0, k = 0;
	vector<char> s(n), t(n),ans(n * 2);
	for (int i = 0; i < n; i++)
		cin >> s[i];
	for (int i = 0; i < n; i++)
		cin >> t[i];

	for (int i = 0; i < n*2; i++) {
		if (i % 2 == 0) {
				ans[i] = s[j];
				j++;
		}
		else {
			ans[i] = t[k];
			k++;
		}
	}
	for (int i = 0; i < n * 2; i++)
		cout << ans[i];
  
	cout << endl;

	return 0;

}

Measured memory_bytes: 256
using System;

class Atcoder40
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        string a = input[0];
        string b = input[1];
        string c = input[2];

        char aa = a[0];
        char bb = b[0];
        char cc = c[0];

        string aaa = aa.ToString();
        string bbb = bb.ToString();
        string ccc = cc.ToString();

        Console.WriteLine(aaa + bbb + ccc);
    }
}

Measured memory_bytes: 13140
from collections import deque
S = input()
ans = deque(S)
Q = int(input())
rev = False
for i in range(Q):
    a_list = input().split()
    if a_list[0] == "1":
        if rev == True:
            rev = False
        else:
            rev = True
    elif (a_list[1] == "1" and rev == False) or (a_list[1] == "2" and rev == True):
        ans.appendleft(a_list[2])
    else:
        ans.append(a_list[2])
if rev:
    ans.reverse()
ans = "".join(ans)
print(ans)

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

void Main()
{
    long h;
    cin >> h;
    long ans = 0;
    long a = 1;
    for (int i = 0; h > 0; i++)
    {
        ans += a;
        a = a << 1;
        h /= 2;
    }
    
    cout << ans << endl;

    // ans = 2^n + 2^(n-1) + ... + 1
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3552
#include<cstdio>
#include<algorithm>
#include<bitset>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
using namespace std;

const int mod=998244353,N=305;
int mi[N],n,m,k,ans,a[N][N];
bitset<N>b[N],x;

int main(){
	mi[0]=1; rep(i,1,300) mi[i]=2ll*mi[i-1]%mod;
	scanf("%d%d",&n,&m);
	rep(i,1,n){
		x.reset(); int l=-1;
		rep(j,0,m-1) scanf("%d",a[i]+j),x.set(j,a[i][j]);
		rep(j,0,m-1) if (x[j]){
			if (b[j].any()) x^=b[j]; else{ b[j]=x; l=j; break; }
		}
		if (l==-1) k++;
	}
	ans=(1ll*mi[m]*mi[k]+1ll*mi[m-1]*(mi[n]+mod-mi[k]))%mod;
	printf("%lld\n",(1ll*mi[n]*mi[m]+mod-ans)%mod);
	return 0;
}

Measured memory_bytes: 640
//#define anjn
//      Anjan Agarwala - anjn98

//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, 
                  tree_order_statistics_node_update> ordered_set;

//ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int csrand(int l=0, int r=1e9){
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

#define PR(x) cout<<#x<<": "<<x<<"\n";
#define PR1(x,y) cout<<#x<<": "<<x<<"  |  "<<#y<<": "<<y<<"\n";
#define PR2(x,y,z) cout<<#x<<": "<<x<<"  |  "<<#y<<": "<<y<<"  |  "<<#z<<": "<<z<<"\n";
#define ED cout<<'\n';

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define endl            '\n'
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define PB              push_back
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first
#define S               second 
#define binf            2000000000000000001
#define mod             1000000007


const int N=2e5+99;


int32_t main() 
{
    IO


    string s;
    cin>>s;

    int tk=0;
    for(int i=1;i<s.length();i++) if(s[i]==s[i-1]) tk=1;

    if(tk)
        cout<<"Bad"<<endl;
    else 
        cout<<"Good"<<endl; 



}




 


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




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

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

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;


map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


int main() {
	int x;
	cin >> x;
	if (x == 7 || x == 5 || x == 3)cout << "YES";
	else cout << "NO";
	return 0;
}













Measured memory_bytes: 256
n = gets.to_i
e = gets.split.map(&:to_i)
n.times{ |i|
  puts e.join(" ")
  break if (i == (n-1))
  i.downto(0){ |j|
    e.insert(j,e.slice!(j+1)) if (e[j] > e[j+1])
    break if (e[j] > e[j-1])
  }
}

Measured memory_bytes: 8744