akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int main()
{
	int N,X,Y;
	cin >> N >> X >> Y;
	int i,j;
	int number[N];
	for(i=0;i<N;i++)
	{
		number[i] = 0;
	}
	for(i=1;i<N;i++)
	{
		for(j=i+1;j<=N;j++)
		{
			int length;
			if((i<=X)&&(j<=X)) length=j-i;
			else if((i<=X)&&(X<j)&&(j<Y))
			length = min((j-i),(Y-j+1+X-i));
			else if((i<=X)&&(Y<=j))
			length = X-i+1+j-Y;
			else if((X<i)&&(i<Y)&&(X<j)&&(j<Y))
			length = min((j-i),(Y-j+i-X+1));
			else if((X<i)&&(i<Y)&&(Y<=j))
			length = min((j-i),(j-Y+1+i-X));
			else if((Y<=i)&&(Y<=j))
			length = j-i;
			number[length] = number[length] + 1;
		}
	}
	for(i=1;i<N;i++)
	{
		cout << number[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back

int main() {
  int N;
  cin >> N;
  int sum = 0;
  for (int i = 0; i <= N; i+=7){
    for (int j = 0; j <= N; j+=4) {
      sum = i + j;
      if (sum == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  
  cout << "No" << endl;

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0){
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 5e5 + 5;
bool edge[105][105];
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, k; cin >> n >> k;
	if (k > (n - 1) * (n - 2) / 2) {
		cout << -1;
		return 0;
	}
	for (ll i = 2; i <= n; i++) {
		edge[i][1] = 1; edge[1][i] = 1;
	}
	ll kek = (n - 1) * (n - 2) / 2;
	ll cur0 = 2; ll cur1 = 3;

	while (kek > k) {
		kek--;
		if (cur1 <= n) {
			edge[cur0][cur1] = 1;
			edge[cur1][cur0] = 1;
			cur1++;
		}
		else {
			cur0++;
			cur1 = cur0 + 1;
			edge[cur0][cur1] = 1;
			edge[cur1][cur0] = 1;
			cur1++;
		}
	}
	vector<pair<ll, ll>>ans;
	for (ll i = 1; i <= n; i++) {
		for (ll j = i + 1; j <= n; j++) {
			if (edge[i][j]) {
				ans.push_back({ i,j });
			}
		}
	}
	cout << ans.size() << endl;
	for (auto p : ans) {
		cout << p.X << " " << p.Y << '\n';
	}
	return 0;
}
/*

*/

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
const int mod = 1000000007;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
vector<int> f = {1},fi = {1};
int fact(int x){
    while((int)f.size() <=x)f.push_back((f.back()*f.size())%mod);
    return f[x];
}
int ifact(int x){
    return modpow(fact(x),mod-2,mod);
}
int C(int x,int y){
    if(x < y)return 0;
    return fact(x)*ifact(y)%mod*ifact(x-y)%mod;
}

signed main(){
    int n;cin >> n;
    int ret = modpow(10,n,mod);
    ret -= 2*modpow(9,n,mod);
    ret = (ret%mod + mod)%mod;
    ret += modpow(8,n,mod);
    ret %= mod;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3628
/*Bismillahir Rahmanir Rahim
->>Code by Ashraful Islam Paran
->>CUET,CSE
*/
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef unsigned long long ull;
typedef vector<int> vi;
const int MX=2e5+5;
#define f(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define endl "\n"
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

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

    int n,k,x,y;
    cin>>n>>k>>x>>y;
    if(k>=n)
    {
        cout<<x*n<<endl;
    }
    else
    {
        cout<<k*x+(n-k)*y<<endl;
    }

    return 0;
}



Measured memory_bytes: 3480
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	int N,H,W;
	cin>>N>>H>>W;
	cout<<(N-W+1)*(N-H+1);
}

Measured memory_bytes: 256
#!venv/bin/python

import math

points = [0,0,0,0,0]
for i in range(3):
    for a in input().split():
        points[int(a)] += 1

over = False
for p in points:
    if p >= 3:
        over = True
if over:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 3064
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

//-----------------------ここから-----------


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

	int ans = 0;
	for(int i = 1; i < 36; i++){
		int num = i;

		if(i == 1){
			ans = max(ans, 1);
			continue;
		}
		int tmp = num;
		if(tmp * num <= x){
			while(tmp * num <= x){
				tmp *= num;
				ans = max(ans, tmp);
			}
		}
		
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n, k = map(int, input().split())
    dp = [INF] * n
    dp[0] = 0
    H = list(map(int, input().split()))
    for i in range(n):
        for pi in range(i - k, i):
            if pi < 0:
                continue
            dp[i] = min(dp[i], dp[pi] + abs(H[i] - H[pi]))
    print(dp[n - 1])
resolve()

Measured memory_bytes: 53216
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	int A;
	map<int, int> vmap;
	cin >> N;
	rep(i, 0, N)
	{
		cin >> A;
		vmap[A]++;
	}

	int ans = 0;
	int cnt = 0;
	for (auto p : vmap)
	{
		ans += (p.second - 1) / 2;
		if (p.second % 2 == 0)
		{
			cnt++;
		}
	}

	ans += (cnt + 1) / 2;

	ans = N - ans * 2;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <iterator>
#include <bitset>
#include <random>
#include <assert.h>
#include <unordered_map>
#include <array>
#include <ctime>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second
#define MP make_pair
#define umap unordered_map

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> P;
typedef unsigned int uint;

int s_to_dec(int base, string x){
	int res = 0;
	for (auto c : x){
		res *= base;
		if ('0' <= c && c <= '9') res += c - '0';
		if ('A' <= c && c <= 'Z') res += c - 'A' + 10;
		if ('a' <= c && c <= 'z') res += c - 'a' + 36;
	}
	return res;
}

string s_to_bin(int base, string x){
	int dec = s_to_dec(base, x);
	string res;
	while (dec){
		res += dec & 1 ? '1' : '0';
		dec /= 2;
	}
	return string(REV(res));
}

int split_xor(string s){
	int res = 0;
	int run = 0;
	for (auto c : s){
		if (c == '0'){
			res ^= run;
			run = 0;
		}
		else{
			++run;
		}
	}

	return res^run;
}

int main(){
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	int x = 0;
	rep(i, n){
		int base;
		string s;
		cin >> base >> s;
		x ^= split_xor(s_to_bin(base, s));
	}
	cout << (x ? "win" : "lose") << endl;

	return 0;
}

Measured memory_bytes: 1212
#include<stdio.h>

int main(void){
    long int n,a[200000],b[200000],i,j;
    scanf("%ld",&n);
    for(i=0;i<n;i++){
        scanf("%ld",&a[i]);
        b[0]+=a[i];
    }
    b[0]/=2;
    for(i=0;i<(n-1)/2;i++){
        b[0]-=a[(1+2*i)%n];
    }
    for(i=1;i<n;i++){
        b[i]=a[i-1]-b[i-1];
    }
    for(i=0;i<n;i++){
        printf("%ld ",2*b[i]);
    }
    return 0;
}


Measured memory_bytes: 3712
# Problem https://atcoder.jp/contests/abc072/tasks/abc072_b
# Ruby 2nd Try
si = gets.chomp.split('')
answer = si[0]
slengthm = si.size-1
for j in 1..slengthm do
    if j.even?
        answer << si[j]
    end
end
puts(answer)

Measured memory_bytes: 7036
from math import cos, radians
a, b, h, m = map(int, input().split())

h_d = h*30 + m/2
m_d = 6*m

theta = abs(h_d - m_d)
if theta > 180:
    theta = 360 - theta
print((a**2 + b**2 - 2*a*b*cos(radians(theta)))**0.5)

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define size_of(a) (int)a.size()

int n, d, p[110];
stack< int > c[110];

int main() {
	while (scanf("%d %d", &n, &d), n) {
		int sum = 0;
		
		for_(i,0,n) {
			while (!c[i].empty()) c[i].pop();
			p[i] = 0;
			
			int m; scanf("%d", &m);
			sum += m;
			
			for_(j,0,m) {
				int a; scanf("%d", &a);
				c[i].push(a);
				p[i] += a;
			}
		}
		
		while (sum) {
			int mx = 0, sc = 0;
			for_(i,0,n) {
				sc = max(sc, p[i]);
				if (sc >= mx) swap(sc, mx);
			}
			
			bool f = 0;
			for_(i,0,n) {
				if (c[i].empty()) continue;
				if (p[i] == mx && sc <= p[i] - c[i].top() + d) {
					p[i] -= c[i].top(); c[i].pop();
					f = 1;
					break;
				} else if (p[i] == sc && mx <= p[i] - c[i].top() + d) {
					p[i] -= c[i].top(); c[i].pop();
					f = 1;
					break;
				}
			}
			
			if (!f) break;
			--sum;
		}
		
		cout << (sum ? "No" : "Yes") << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1324
using System;
using static System.Console;
using static System.Math;
using System.Numerics;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var s = myRead.readStr();
            var t = myRead.readStr();
            int max = 0;
            int t_l = t.Length;
            int s_l = s.Length;
            for (int i = 0; i < s_l - t_l + 1; i++)
            {
                int num = 0;
                for (int j = 0; j < t_l; j++)
                {
                    num += s[i + j] == t[j] ? 1 : 0;
                }
                max = num > max ? num : max;
            }
            var ans = t_l - max;
            WriteLine(ans);
        }
    }
    public static class myRead
    {
        public static int readInt() { return int.Parse(ReadLine()); }
        public static long readLong() { return long.Parse(ReadLine()); }
        public static string readStr() { return ReadLine(); }
        public static int[] readIntArray() { return ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        public static long[] readLongArray() { return ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        public static string[] readStrArray() { return ReadLine().Split(' '); }
    }


    public static class MyMath
    {
        public static long Factorical(long n)
        { return n <= 1 ? 1L : n * Factorical(n - 1); }
        public static long Permutation(long n, long m)
        { return m == 0 ? 1L : (m == n) ? Permutation(n, m - 1) : n * Permutation(n - 1, m - 1); }
        public static long Combination(long n, long m)
        { return n - m > m ? Permutation(n, m) / Factorical(m) : Permutation(n, n - m) / Factorical(n - m); }
        public static long Gcd(long n, long m)
        { return n % m == 0 ? m : Gcd(m, n % m); }
        public static long Lcm(long n, long m)
        { return n * m / Gcd(n, m); }
        public static long Pow(long n, long m)
        { return m == 0 ? 1L : m == 1 ? n : n * Pow(n, m - 1); }
    }


}

Measured memory_bytes: 25980
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author hakamada
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Nikkei_2 solver = new Nikkei_2();
        solver.solve(1, in, out);
        out.close();
    }

    static class Nikkei_2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            String[] A = in.next().toUpperCase().split("");
            String[] B = in.next().toUpperCase().split("");
            String[] C = in.next().toUpperCase().split("");

            int count = 0;
            for (int i = 0; i < N; i++) {
                char cA = A[i].charAt(0);
                char cB = B[i].charAt(0);
                char cC = C[i].charAt(0);

                if ((cA == cB) && (cB == cC)) {
                } else if ((cA != cB) && (cB != cC) && (cA != cC)) {
                    count += 2;
                } else {
                    count++;
                }

            }
            out.println(count);
        }

    }
}



Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define vvvll vector<vector<vector<ll>>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define  ones(x)  __builtin_popcount(x)
using namespace std;

int main(){

    int n, m;
    cin >>n >> m;
    int h[n + 1];
    rep(i,n)cin >> h[i + 1];
    vector<int> r[n + 1];
    for(int i = 1; i <= m; i++){
        int x,y;
        cin >> x>> y;
        r[x].pb(y);
        r[y].pb(x);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        bool good = true;
        for(int j = 0; j < r[i].size(); j++){
            if(h[r[i][j]] >= h[i]){good = false; break;}
        }
        if(good)ans++;
    }
    cout << ans;
    // for(int i = 1; i <= n; i++){
    //     cout << i<<"-> ";
    //     for(int j = 0; j < r[i].size(); j++)cout << r[i][j]<<" ";
    //     cout << endl;
    // }

    

}

Measured memory_bytes: 9108
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    int fives = 0;
    int sevens = 0;
    for (int i = 0; i < 3; i++) {
        int n;
        cin >> n;
        if (n == 5) fives++;
        if (n == 7) sevens++;
    }
    if (fives == 2 && sevens == 1) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    int n;
    cin>>n;
    ld s=0;
    for(int i = 0; i < n; i++){
        ld x;
        cin>>x;
        s+=1/x;
    }   
    cout<<fixed<<setprecision(10)<<1/s;
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 256
#include<iostream>
#include<complex>
#include<algorithm>
#define EPS 1e-6
using namespace std;

typedef complex<double> P;

int n,m;
P p[100][4];

double cross(P a,P b){return imag(conj(a)*b);}
double dot(P a,P b){return real(conj(a)*b);}
/*
bool is_cp(P a1,P a2,P b1,P b2){
  if(cross(a2-a1,b1-a1) * cross(a2-a1,b2-a1) < EPS)
    if(cross(b2-b1,a1-b1) * cross(b2-b1,a2-b1) < EPS)return true;
  return false;
}

bool interp(int q,P x){
  P tmp = P(10000,x.imag());
  bool res = false;
  for(int i=0;i<4;i++)if(is_cp(p[q][i],p[q][(i+1)%4],x,tmp))res=!res;
  return res;
}
*/

int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;
  if (cross(b,c)<-EPS) return -1;
  if (dot(b, c)<-EPS) return 2;
  if (abs(b)<abs(c)) return -2;
  return 0;
}
bool is_cp(P a1, P a2, P b1, P b2){
    return ( ccw(a1, a2, b1) * ccw(a1, a2, b2) <= 0 &&
     ccw(b1, b2, a1) * ccw(b1, b2, a2) <= 0 );
}
bool interp(int q, P x){
  for(int i=0;i<4;i++){
    if ( ccw(p[q][i], p[q][(i+1)%4], x ) == 1 ) return false;
  }
  return true;
}
bool inter(int q1,int q2){
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      if(is_cp(p[q1][i],p[q1][(i+1)%4],p[q2][j],p[q2][(j+1)%4]))return true;

  for(int i=0;i<4;i++)if(interp(q1,p[q2][i]))return true;
  for(int i=0;i<4;i++)if(interp(q2,p[q1][i]))return true;
  return false;
}

int par[100];
int rank[100];

void init(int n){
  for(int i=0;i<n;i++){
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int x){
  if(par[x] == x)return x;
  return par[x] = find(par[x]);
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x==y)return;

  if(rank[x] < rank[y])par[x] = y;
  else{
    par[y] = x;
    if(rank[x] == rank[y])rank[x]++;
  }
}

int main(){
  while(cin >> n && n){
    for(int i=0;i<n;i++){
      cin >> m;
      for(int j=0;j<m;j++)
	for(int k=0;k<4;k++)cin >> p[j][k].real() >> p[j][k].imag();

      init(m);

      for(int j=0;j<m;j++)
	for(int k=0;k<j;k++)
	  for(int l=0;l<4;l++)
	    if(inter(j,k))unite(j,k);

      int ans = 0;
      for(int j=0;j<m;j++){
	find(j);
	if(par[j]==j)ans++;
      }
      cout << ans << endl;
    }
  }
}

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

#define rep(i, n) for(int i=0; i<n; i++)
#define repA(i, a, n) for(int i=a; i<n; i++)
#define repD(i, a, n) for(int i=a; i>=n; i--)
#define trav(it, ctr) for(auto it=ctr.begin(); it!=ctr.end(); it++)
#define p(x) cout<<x<<"\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pp(x, y) cout<<x<<" "<<y<<"\n"
#define btc __builtin_popcount
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define N 1000001
 
using namespace std;
 
typedef priority_queue<int> pq;
typedef pair<int, int> ii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
using ll=long long int;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // cout<<fixed<<setprecision(10);
    int n, m, x;
    cin>>n>>m>>x;
    int cost[n], a[n][m];
    rep(i, n){
        cin>>cost[i];
        rep(j, m)cin>>a[i][j];
    }
    ll mi=LLONG_MAX;
    rep(i, 1<<n){
        ll pric=0;
        ll lvl[m];
        memset(lvl, 0, sizeof lvl);
        rep(j, n){
            if(i&(1<<j)){
                pric+=cost[j];
                rep(k, m)
                lvl[k]+=a[j][k];
            }
        }
        bool ok=true;
        rep(j, m){
            if(lvl[j]<x){
                ok=false;
                break;
            }
        }
        if(ok){
            mi=min(mi, pric);
        }
    }
    if(mi==LLONG_MAX)p(-1);
    else p(mi);
    return 0;
}

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

int gcd(int a,int b){
    if(a%b==0) return b;
    else return gcd(b,a%b);
}

int main(void){
  int K;
  cin>>K;
  long long sum=0;
  for(int a=1;a<=K;a++){
      for(int b=1;b<=K;b++){
          for(int c=1;c<=K;c++){
              sum+=gcd(gcd(a,b),c);
          }
      }
  }
  cout<<sum<<endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  int l,r;
  int x=0;
  
  for (int i=0; i<N; i++) {
    cin >> l >> r;
    x += (r-l+1);
  }
  
  cout << x << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
a = set(int(input()) for _ in range(M))
dp = [0] * (N + 1)
dp[0] = 1
if 1 not in a:
    dp[1] = 1

for i in range(2, N + 1):
    for k in [-2, -1]:
        if i + k not in a:
            dp[i] += dp[i+k]

print(dp[N] % 1000000007)


Measured memory_bytes: 465400
#include<stdio.h>
int main ()
{  int n,m; scanf("%d %d",&n,&m);
   int N=0,M=0;
   if(n==1||n==0)
     N=0;
    else 
     N=n*(n-1)/2;
    if(m==1||m==0)
      M=0;
      else
       M=m*(m-1)/2;
    printf("%d",N+M);
    return 0;
}

Measured memory_bytes: 128
# AtCoder Beginner Contest 134
# C - Exception Handling

N=int(input())
ls = []
lsmax=0
lsmaxnum=1
lsmax2=0
for i in range (N):
    a=int(input())
    ls.append(a)
    if a==lsmax:
        if lsmaxnum==1:
            pass
        else:
            lsmaxnum+=1
    if a>lsmax:
        lsmax=a
if lsmaxnum==1:
    ls2=sorted(ls)
    lsmax2=ls2[-2]

# print(lsmax,lsmax2,lsmaxnum)

for j in range (N):
    if ls[j]==lsmax:
        if lsmaxnum>1:
            print(lsmax)
        else:
            print(lsmax2)
    else:
        print(lsmax)

Measured memory_bytes: 19068
n = int(input())
D = list(map(int,input().split()))
mod = 998244353
if D[0]!= 0:
  print(0)
else:
  D.sort()
  if D[0]==0 and D[1]==0:
    print(0)
  elif D[0] ==0 and D[1] != 1:
    print(0)
  else:
      D += [max(D)+1]
      ans = 1
      before = 1
      now = 1
      ok =True
      for i in range(1,n):
          if D[i]==D[i+1]:
              now +=1
          else:
            if D[i+1] == D[i]+1:
                ans *= ((before%mod)**now)%mod
                before = now
                now = 1
                ans = ans%mod
            else:
              print(0)
              ok = False
              break
      if ok:
        print(ans)   
      

Measured memory_bytes: 54060
#include<stdio.h>

int main(void){
	const int n_max = 10000;
	int n, q, S[n_max+1], T, i, j, ans = 0;

	scanf("%d", &n);
	for(i=0; i<n; ++i)
		scanf("%d", S+i);
	scanf("%d", &q);
	for(i=0; i<q; ++i){
		scanf("%d", &T);
		S[n] = T;
		j = 0;
		while(S[j] != T)
			++j;
		if(j == n)
			continue;
		++ans;
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 1860
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 10000000000000000
#define mod 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

signed main() {
	int n, d, ans = 0;
	cin >> n >> d;
	int x[15][15];
	rep(i, n) {
		rep(j, d) {
			cin >> x[i][j];
		}
	}
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			int cnt = 0;
			rep(k, d) {
				cnt += abs(x[i][k] - x[j][k]) * abs(x[i][k] - x[j][k]);
			}
			int now = 0;
			while (now* now <= cnt) {
				if (now * now == cnt) {
					ans++;
					break;
				}
				now++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <float.h>
#include <random>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
#define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const int INF = 1e9;
const ll MOD = 998244353;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H,W;cin>>H>>W;
  vector<string> A(H);
  queue<pair<int,Pii> > Q;
  repeat(i,H){
    cin>>A[i];
    repeat(j,W){
      if(A[i][j]=='#')Q.push({0,{i,j}});
    }
  }
  vector<vint> fld(H,vint(W,-1));
  int ans=0;
  while(!Q.empty()){
    int cnt;
    Pii pos;
    tie(cnt,pos)=Q.front();
    Q.pop();
    int i,j;
    tie(i,j)=pos;
    if(fld[i][j]>=0)continue;
    fld[i][j] = cnt;
    ans=max(ans,cnt);
    if(i>0)Q.push({cnt+1,{i-1,j}});
    if(i<H-1)Q.push({cnt+1,{i+1,j}});
    if(j>0)Q.push({cnt+1,{i,j-1}});
    if(j<W-1)Q.push({cnt+1,{i,j+1}});
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 53576
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;


#include <vector>

class union_find
{
private:
	std::vector<int>parent;
	std::vector<int>rank;
	std::vector<int>clump;
public:
	union_find(int siz)
	{
		parent.resize(siz);
		rank.resize(siz);
		clump.resize(siz);
		for (int i = 0; i < siz; ++i)
		{
			parent[i] = i;
			rank[i] = 0;
			clump[i] = 1;
		}
	}
	void unite(int x, int y)
	{
		int xr = find(x);
		int yr = find(y);
		if (xr == yr)return;
		if (rank[xr] > rank[yr])
		{
			parent[yr] = xr;
			clump[xr] += clump[yr];
		}
		else if (rank[yr] > rank[xr])
		{
			parent[xr] = yr;
			clump[yr] += clump[xr];
		}
		else if (xr != yr)
		{
			parent[yr] = xr;
			clump[xr] += clump[yr];
			++rank[xr];
		}
	}
	int find(int x)
	{
		if (parent[x] == x)
		{
			return x;
		}
		else
		{
			return parent[x] = find(parent[x]);
		}
	}
	bool check(int x, int y)
	{
		return find(x) == find(y);
	}
	int size(int x)
	{
		return clump[find(x)];
	}
};



int main(void)
{
	int n;
	cin >> n;
	vector<pair<LL, int>>x, y;
	for (int i = 0; i < n; ++i)
	{
		LL xx, yy;
		cin >> xx >> yy;
		x.push_back({ xx,i });
		y.push_back({ yy,i });
	}
	union_find uf(n);
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	vector<pair<LL, pair<int, int>>>vec;
	for (int i = 1; i < n; ++i)
	{
		vec.push_back({ x[i].first - x[i - 1].first,{x[i].second,x[i - 1].second} });
		vec.push_back({ y[i].first - y[i - 1].first,{ y[i].second,y[i - 1].second } });
	}
	sort(vec.begin(), vec.end());
	LL ans = 0;
	int i = 0;
	while (uf.size(0) < n)
	{
		auto p = vec[i];
		if (!uf.check(p.second.first, p.second.second))
		{
			uf.unite(p.second.first, p.second.second);
			ans += p.first;
		}
		++i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10852
import java.util.*;
class Main{
    Scanner sc=new Scanner(System.in);
    void main(){
	while(true){
	    int x=sc.nextInt();
	    int y=sc.nextInt();
	    if(x==0&&y==0)break;
	    if(x<y)System.out.println(x+" "+y);
	    else System.out.println(y+" "+x);
	}
    }
    public static void main(String[]ag){
	new Main().main();
    }
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    ll answer = 1;
    while (true)
    {
        if (answer * 8 / 100 == A && answer * 10 / 100 == B)
        {
            break;
        }
        if (answer * 8 / 100 > 100)
        {
            answer = -1;
            break;
        }
        answer++;
    }
    cout << answer << endl;
    return 0;
}


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

int main(){
  constexpr int Nalp= 26;
  string S;
  cin >> S;

  vector<int> data;
  bitset<Nalp> appear;
  for(auto c:S){
    int ord= c- 'a';
    data.emplace_back(ord);
    appear.set(ord);
  }

  if(data.size() < Nalp){
    int ord_tail= 0;
    while(appear.test(ord_tail)){
      ord_tail++;
    }
    char tail= 'a'+ ord_tail;

    string ans= S+ tail;

    cout << ans << endl;
  }
  else{
    if(next_permutation(data.begin(), data.end())){
      string ans;
      for(int i=0; i<Nalp; i++){
        int ord= data.at(i);
        ans+= 'a'+ ord;
        if(ans.at(i) != S.at(i)){ break; }
      }

      cout << ans << endl;
    }
    else{
      cout << -1 << endl;
    }
  }
}

Measured memory_bytes: 3584
#include <bits/stdtr1c++.h>
// typedef __int128 int128;
// typedef __float128 float128;

using namespace std;
using namespace rel_ops;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ld> vd;
typedef vector<vd> vvd;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;
#define pb push_back


int main(){


  // freopen("A.in", "r", stdin);

  ll N;
  cin >> N;

  ll W;
  cin >> W;

  ll w[110], v[110];

  for (ll i = 1; i <= N; ++i) {
    cin >> w[i] >> v[i];
  }

  ll p[100010];

  ll nums[100010];
  p[w[1]] = v[1];

  nums[w[1]]++;

  for (ll k = 2; k <= N; k++) {
    ll numt[100010];
    p[w[k]] = max(p[w[k]], v[k]);
    nums[w[k]]++;
    for (ll x = W; x >= 1; x--) {
      numt[x] = nums[x];
    }
    for (ll x = W; x >= 1; x--) {
      if (p[x] && x + w[k] <= W && (x != w[k] || numt[w[k]] > 1)){
        numt[w[k]]--;
        p[x+w[k]] = max(p[x+w[k]],  v[k] + p[x]);
      }
    }

  }

  ll res = 0;
  for (ll i = 1; i <= W; ++i) {
    res = max(res, p[i]);
  }

  cout << res << endl;

}


Measured memory_bytes: 2560
x,n = map(int, input().split())
s = set()
if n > 0:
	s = set(list(map(int, input().split())))

# print(s)

i = 0
while (True):
	if (x - i) not in s:
		print(x - i)
		exit()
	if (x + i) not in s:
		print(x + i)
		exit()
	i += 1

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    int a,b,c,ans;
    cin>>a>>b>>c;
    ans=min(b/a, c);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	string s;
	cin >> s;
	puts(s == "ABC" ? "ARC" : "ABC");


	return 0;
}

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

void out(vector<int> ve, int size) {
	for (int i = 0; i < size-1; ++i)
	{
		cout << ve[i] << " ";
	}
	cout << ve[size-1] << endl;
	return;
}

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

	for (int i = 1; i < n; ++i)
	{
		int v = a[i];
		int j = i-1;
		while (j >= 0 && a[j] > v)
		{
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
		out(a, n);
	}

	return 0;
}


Measured memory_bytes: 3104
/* 
 *Author : Sisir Ramanan
 *Date : 
 */
 
#include <bits/stdc++.h>

using namespace std;

int main(){

    long long N, W;
    cin >> N >> W;
    vector<long long> weight(N), value(N);
    for(long long i=0; i<N; ++i){
        cin >> weight[i] >> value[i];
    }

    // dp table
    long long dp[N][W+1];
    memset(dp,0,sizeof(dp));

    long long val;
    for(long long i=0; i<N; ++i){
        for(long long j =1; j<W+1; ++j){
            if(weight[i] <= j){
                // for first row need to take care of i-1 index since there is no top row
                if(i>0){
                    val = value[i] + dp[i-1][j-weight[i]]; // including item
                    val = max( val, dp[i-1][j] ); // max of including vs excluding
                } else {
                    val = value[i];
                }
                dp[i][j] = val;
           } else if(weight[i] > j && i > 0) {
               dp[i][j] = dp[i-1][j];
           }
       }
    }

    cout << dp[N-1][W] << endl;

	return 0;
}



Measured memory_bytes: 81684
import math
a, b, h, m = map(int, input().split())
if h > 12 :
    h -= 12
mnt = h * 60 + m
degA = mnt*math.pi/360
degB = m*math.pi/30
print(math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(degA - degB)))

Measured memory_bytes: 9504
#include<stdio.h>

#define MAX 100
#define INFTY 5000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int prim(void);

int n,M[MAX][MAX];


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

  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  int e;
	  scanf("%d",&e);
	  if(e==-1)M[i][j]=INFTY;
	  else M[i][j]=e;
	}
    }

  printf("%d\n",prim());

  
  return 0;
}


int prim()
{
  int i,u,minv,v;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++)
    {
      d[i]=INFTY;
      p[i]=-1;
      color[i]=WHITE;
    }

  d[0]=0;

  while(1)
    {
      minv=INFTY;
      u=-1;
      for(i=0;i<n;i++)
	{
	  if(minv>d[i]&&color[i]!=BLACK)
	    {
	      u=i;
	      minv=d[i];
	    }
	}
      if(u==-1)break;
      color[u]=BLACK;
      for(v=0;v<n;v++)
	{
	  if(color[v]!=BLACK && M[u][v]!=INFTY)
	    {
	      if(d[v]>M[u][v])
		{
		  d[v]=M[u][v];
		  p[v]=u;
		  color[v]=GRAY;
		}
	    }
	}
    }
  int sum =0;
  for(i=0;i<n;i++)
    {
      if(p[i]!=-1)sum+=M[i][p[i]];
    }
  return sum;
}



Measured memory_bytes: 2128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n, a;
    cin >> n >> a;
    vector<ll> x(n);
    rep(i, n) {
        cin >> x[i];
        x[i] -= a;
    }

    ll dp[2][5003] = {};
    dp[0][2501] = 1;
    ll *now = dp[0];
    ll *next = dp[1];
    rep(i, n) {
        rep(j, 5003) {
            if(now[j]) {
                next[j] += now[j];
                next[j+x[i]] += now[j];
            }
        }
        swap(now, next);
        rep(j, 5003) {
            next[j] = 0;
        }
    }

    cout << now[2501]-1 << endl;

}

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

using namespace std;

#define rep(i, j, k) for (int i = j; i < (int)k; i++)
#define pb push_back
#define mt make_tuple
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef complex<ld> point;
typedef vector<int> vi;

inline void fileIO(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}

template <class T, class S>
inline bool smin(T &a, S b) {
  return (T)b < a ? a = b, 1 : 0;
}
template <class T, class S>
inline bool smax(T &a, S b) {
  return a < (T)b ? a = b, 1 : 0;
}

constexpr int MOD = 998244353;
constexpr int N = 302;

template <typename T>
inline T mod(T &v) {
  return v = (v % MOD + MOD) % MOD;
}
template <typename S, typename T>
inline S add(S &l, T r) {
  return mod(l += r);
}
ll po(ll v, ll u) {
  return u ? po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD : 1;
}

int n, m, id[N], sz;
bitset<N> tmp, paye[N];

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

#ifndef LOCAL
  // fileIO("superposition");
#endif

  memset(id, -1, sizeof(id));
  cin >> n >> m;
  rep(i, 0, n) {
    rep(j, 0, m) {
      bool local;
      cin >> local;
      tmp[j] = local;
    }
    rep(j, 0, m) if (~id[j] && tmp[j]) tmp ^= paye[id[j]];
    if (tmp.count()) {
      int me = tmp._Find_first();
      id[me] = sz;
      rep(j, 0, sz) if (paye[j][me]) paye[j] ^= tmp;
      paye[sz++] = tmp;
    }
  }

  ll res = po(2, n) - po(2, n - sz) + MOD;
  mod(res *= po(2, m - 1));
  cout << res << 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 REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll h,w;
	cin >> h >> w;
	vvll a(h+1,vll(w+1));
	rep(i,h)rep(j,w) cin >> a[i][j];
	rep(i,h) a[i][w]=sumvec(a[i]);
	rep(i,w){
		ll sum=0;
		rep(j,h){
			sum+=a[j][i];
		}
		a[h][i]=sum;
	}
	a[h][w]=sumvec(a[h]);
	rep(i,h+1)rep(j,w+1) cout << a[i][j] << (j==w?"\n":" ");
	return 0;
}


Measured memory_bytes: 3176
n, m = map(int, input().split())
x = list(map(int, input().split()))

if n >= len(x):
    print(0)
    exit()

ls = []
x.sort()

for i in range(m-1):
    diff = x[i+1] - x[i]
    ls.append(diff)

ls.sort(reverse=True)
ans = sum(ls)

for i in range(n-1):
    ans -= ls[i]

print(ans)

Measured memory_bytes: 13960
#include <stdio.h>

int main(void){
    int h,w;
    while (1){
        scanf("%d %d",&h,&w);
        if(h==0 && w==0){
            break;
        }else{
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                    if(i!=0 && i!=h-1 && j!=0 && j!=w-1){
                        printf(".");
                    }else{
                        printf("#");
                    }
                }
                printf("\n");
            }
            printf("\n");
        }
    }
}


Measured memory_bytes: 2032
#include <cmath>
#include <iostream>
#include <vector>

int main() {
  size_t N;
  std::cin >> N;
  std::vector<int> h(N);
  for (size_t i = 0; i < N; ++i) {
    std::cin >> h[i];
  }

  std::vector<int> dp(N);
  dp[0] = 0;
  dp[1] = std::abs(h[0] - h[1]);
  for (size_t i = 2; i < N; ++i) {
    dp[i] = std::min(std::abs(h[i - 1] - h[i]) + dp[i - 1],
                     std::abs(h[i - 2] - h[i]) + dp[i - 2]);
  }
  std::cout << dp[N - 1] << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    char temp = s[0];
    ll ans = 0;
    for (ll i = 1; i < s.size(); i++)
    {
        if (temp != s[i])
        {
            ans++;
            temp = s[i];
        }
    }
    cout << ans << endl;
}


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

int main() {
  string s; cin >> s;
  int K; cin >> K;
  for (int i = 0; i < s.length(); i++) {
    int n { 'z' - s[i] + 1 };
    if (s[i] != 'a' and n <= K) {
      s[i] = 'a';
      K -= n;
    }
    if (i == s.length() - 1) {
      s[i] = (char)('a' + (s[i] - 'a' + K) % 26);
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 512