akhauriyash/Code-Regression huggingface dataset:
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
//#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    string s,ss,sss;
    cin>>s>>ss>>sss;
    cout<<"A"<<ss[0]<<"C"<<endl;


}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i];
	reverse(b.begin(), b.end());
	int c = -1;
	for (int i = 0; i < n; i++) {
		if (a[i] == b[i]) {
			c = a[i];
			break;
		}
	}
	int l = n, r = -1;
	for (int i = 0; i < n; i++) {
		if (a[i] == c and b[i] == c) {
			l = min(l, i);
			r = max(r, i);
		}
	}
	for (int i = 0; i < n; i++) {
		if (a[i] != c and b[i] != c and l <= r) {
			swap(b[i], b[l]);
			++l;
		}
	}
	if (l <= r) {
		cout << "No" << "\n";
		return 0;
	}
	cout << "Yes" << "\n";
	for (int i = 0; i < n; i++) {
		cout << b[i] << " \n"[i == n - 1];
	}
	return 0;
}

Measured memory_bytes: 4752
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (H, A) = Scanner.Scan<int, int>();
            var answer = H / A;
            if (H % A > 0) answer++;
            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28272
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define ll long long int
#define dbl double
#define pi acos(-1)
#define sc1(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pb push_back
#define mxx 100000
map<string,ll>mp,mp2;
map<ll,ll>vis1;
map<ll,ll>vis;
map<ll,ll>vis_s;
map<pair<ll,ll>,ll>vis2;
priority_queue<ll>pq;
priority_queue<ll>pq2;
vector<ll>vec;
vector<ll>vec_s;
vector<ll>vec1;
map<vector<ll>,ll>mp3;
ll ara[1000006],ara1[1000006];


ll dx[]= {-1,0,+1,-1,+1,-1,0,+1};
ll dy[]= {-1,-1,-1,0,0,+1,+1,+1};
string v="aeiou";
ll n,m,t,cnt=0,a,b,c=0,no,d,sum=0,ans=0,item,mx=0,mn=10000000;

int main()
{
    ll str=0;
    for(ll i=1; i<=5; i++)
    {
        sc1(item);
        if(item==0)
            str=i;
    }
    cout<<str<<endl;
    return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<stdio.h>
#include<cctype>
#include<string>
using namespace std;


int main() {
	int c = 0, j = 0, n = 0, a = 0;
	bool clear = false;
	string W, T;
	char t;
	cin >> W;
	
	
	while (cin >> T) {
		
		a = T.size();
		if (T == "END_OF_TEXT") {
			break;
		}
		for (int p = 0; p < a; p++) {
			if (T[p] < 91&&T[p]>64) {
				T[p] += 32;
}
		}

		if (T == W) {
			c++;
		}
		


	}

		

	
	
	cout << c << endl;

	return 0;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  string S;
  cin>>S;
  int N=S.size();
  bool flag=1;
  rep(i,1,N){
    if(S[i]==S[i-1]){
      flag=0;
      cout<<i<<" "<<i+1<<endl;
      break;
    }
  }
  if(flag){
    rep(i,2,N){
      if(S[i]==S[i-2]){
        flag=0;
        cout<<i-1<<" "<<i+1<<endl;
        break;
      }
    }
  }
  if(flag)
    cout<<-1<<" "<<-1<<endl;
  }



Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>

using namespace std;
int main() {
    int A,B;
    scanf("%d",&A);
    scanf("%d",&B);

    if(A+B==15){
        printf("+");
    }
    else if (A*B == 15){
        printf("*");
    } else{
        printf("x");
    }
}

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

#define ll long long
#define llu unsigned long long
#define ld long double
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pf push_front
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define vvi(v, n, m) vector<vi> v(n, vi(m))
#define vvll(v, n, m) vector<vll> v(n, vll(m))
#define all(x) (x).begin(), (x).end()
#define present(v,x) (v).find(x) != (v).end()
#define cpresent(v,x) (find(all(v),x) != (v).end())
#define mset(x,v) memset(x, v, sizeof(x))
#define sz(x) (int)x.size()

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
void debug_out() { cout << ""; }
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cout << " " << to_string(H); debug_out(T...);}
#define pr(v, n) {for(int j=0; j<n; j++){debug_out(v[j]); if(j<n-1) cout<<",";}}
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__); { cout << endl; }
#define dbg1d(v, n) cout << "[" << #v << "]: {"; pr(v, n); {cout << " }" << endl;}
#define dbg2d(v, n, m) cout<<"["<<#v<<"]:"<<endl;{for(int i=0; i<n; i++){cout<<right<<setw(10)<<"["+to_string(i)+"] {";pr(v[i],m);{cout<<" }"<<endl;}}}
#define shout()  {cout << "I'm Here...!!!" << endl;}

inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int addmod(int a, int val, int p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline int submod(int a, int val, int p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

#define MAXN 22
#define MAXMASK (1<<MAXN)-1
int n;
bool a[MAXN][MAXN];
vector<int> dp(MAXMASK, -1);

int makeMatch(int mask, int j){
	if(dp[mask]>=0)
		return dp[mask];

	int sum = 0;
	for(int i=0; i<n; i++)
		if((mask&(1<<i)) and a[i][j-1])
			sum = addmod(sum, makeMatch(mask&(~(1<<i)), j-1));

	return dp[mask]=sum;
}

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

	cin >> n;
	for(int i=0; i<n; i++)
		for(int j=0; j<n; j++)
			cin >> a[i][j];
	dp[0] = 1;
	
	int mask = (1<<n)-1;
	cout << makeMatch(mask, n) << endl;

	return 0;
}

Measured memory_bytes: 16640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#include<set>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvii = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

const int MAX_INT = 5e5 + 1;
const ll inf = 1LL << 60;

struct Point{
    int queri;
    int x,y;
    int bangou;

    Point(int q, int xx, int yy, int bb){
        queri = q;
        x = xx;
        y = yy;
        bangou = bb;
    }
};

struct BIT{
    int N;
    vector<int> bit;

    BIT(int n_){
        N = n_;
        /*while(n_ > N){
            N *= 2;
        }*/
        bit.resize(N,0);
    }

    int sum(int i){  //1 ~ i までの和を求める
        int ans = 0;
        while(i > 0){
            ans += bit[i];
            i -= (i & -i);
        }
        return ans;
    }

    void add(int i, int x){ //i番目にxを加える
        while(i <= N){
            bit[i] += x;
            i += (i & -i);
        }
    }
    
};

bool for_sort(Point p1, Point p2){
    if(p1.x == p2.x){
        return p1.queri < p2.queri;
    }
    else{
        return p1.x > p2.x;
    }
}

int main(){
    int N,Q; cin >> N >> Q;
    vector<int> last(N,-1);
    vector<Point> point;
    

    REP(i,N){
        int c; cin >> c;
        c--;
        if(last[c] != -1){
            point.push_back(Point(0, last[c], i+1, -1));
        }
        last[c] = i+1;
    }
    REP(i,Q){
        int l,r;
        cin >> l >> r;
        //l--; r--;
        point.push_back(Point(1,l,r, i));
    }

    sort(ALL(point), for_sort);
    /*REP(i,point.size()){
        cout << point[i].queri << " " << point[i].x << " " << point[i].y << endl;
    }*/

    int itr = 0;
    BIT tree(MAX_INT);
    vector<int> ans(Q);

    for(int line = MAX_INT; line != 0; line--){
        while(point[itr].x == line && itr < point.size()){
            if(point[itr].queri == 0){
                tree.add(point[itr].y + 1 ,1);
            }
            else{
                int now = tree.sum(point[itr].y+1);
                int ban = point[itr].bangou;
                ans[ban] = point[itr].y - point[itr].x + 1 - now;
            }
            itr++;
        }
    }

    REP(i,ans.size()){
        cout << ans[i] << endl;
    }
    
}


Measured memory_bytes: 24660
#include <iostream>

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

int main() {
	int A, B; cin >> A >> B;
	if (A + B >= 10) {
		cout << "error";
	}
	else {
		cout << A + B;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (a,b) = get!(usize, usize);
    let mut a_str = String::new();
    let mut b_str = String::new();
    for i in 0..b {
        a_str += &a.to_string();
    }
    for i in 0..a {
        b_str += &b.to_string();
    }
    if a_str > b_str {
        println!("{}", b_str);
    } else {
        println!("{}", a_str);
    }
}


Measured memory_bytes: 8572
h,w=map(int,input().split())
ans=[]
for i in range(h):
    x=input()
    if x!='.'*w:
        ans.append(x)
if len(ans)==0:
    print(*ans)
    exit()
flag=[0 for _ in range(w)]
for i in range(w):
    if ans[0][i]=='.':
        flag[i]=1
if len(ans)==1:
    for i in range(w):
        if flag[i]==0:
            print(ans[0][i],end='')
else:
    for i in range(1,len(ans)):
        for j in range(w):
            if flag[j]==1:
                if ans[i][j]!='.':
                    flag[j]=0
    for i in range(len(ans)):
        for j in range(w):
            if flag[j]==0:
                print(ans[i][j],end='')
        print()

Measured memory_bytes: 4468
#include <stdio.h>
int binarysearch(int *,int,int);

int main (){

  int n[100000],nc,q[50000],qc,i,j,count=0;
  scanf("%d",&nc);
  for(i=0 ; i<nc ; i++){
    scanf("%d",&n[i]);
  }
  scanf("%d",&qc);
  for(i=0;i<qc;i++){
    scanf("%d",&q[i]);
    if(q[i] == n[binarysearch(n,nc,q[i])] ){
      count++;
    }
  }

  printf("%d\n",count);
  return 0;
}

  int binarysearch(int *n,int right,int key){
    int i,left=0,mid;
    while(left<right){
      mid = (left + right) / 2;
      if(n[mid] == key){
        return mid;
        break;
      }
      else if(key < n[mid]){
        right = mid;
      }
      else{
        left = mid + 1;
      }
    }
    return 0;
  }

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

long long gcd(long long a, long long b)
{
	return (b == 0) ? a : gcd(b, a % b);
}

long long lcm(long long a, long long b)
{
	long long h = gcd(a, b);
	return h ? (a * (b / h)) : 0;
}

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

	vector<long long> oddav = av;
	for (auto& o : oddav) {
		if (o % 2 != 0) {
			cout << 0 << endl;
			return 0;
		}
		o /= 2;
	}

	long long t = 1;
	while (oddav[0] % 2 == 0) {
		oddav[0] /= 2;
		t *= 2;
	}

	{
		long long t2 = t * 2;
		for (long long i = 1; i < n; ++i) {
			if (oddav[i] % t == 0 && oddav[i] % t2 != 0) {
				oddav[i] /= t;
			}
			else {
				cout << 0 << endl;
				return 0;
			}
		}
	}

	long long l = oddav[0];
	for (long long i = 1; i < n; ++i) {
		l = lcm(l, oddav[i]);
	}

	double m2 = (double)m / (double)t;
	long long ret = m2 / l;
	if (ret % 2 == 1) {
		ret = ret / 2 + 1;
	}
	else {
		ret = ret / 2;
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,b,answer;
  cin >> N;
  for(int i = 0;i < N;i++){
  cin >> A;
    while(1)
      {
      if(A % 2 == 1)
        break;
      else
        A /= 2;
        b += 1;
      }
    if(i == 0||b <= answer)
    {
      answer = b;
    }
    b = 0;
                          }
  cout << answer << endl;
 
 
  // ここにプログラムを追記
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

const ll MOD = 1e9 + 7;
const ll maxN = 5e5 + 5;


ll powerM(ll x, ll y, ll M = MOD) // default argument
{ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;}

ll power(ll x, ll y)
{ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;}


ll fact[maxN], invfact[maxN];

ll modinv(ll a) { return powerM(a, MOD - 2, MOD); }

ll nCr(ll n, ll r) {
	if (r > n) return 0;
	return ((fact[n] * invfact[r]) % MOD * invfact[n - r]) % MOD;
}

void precomputenCr() {
	fact[0] = fact[1] = 1;
	for (ll i = 2; i < maxN; i++) {
		fact[i] = (fact[i - 1] * i) % MOD;
	}
	/*
	n! = n * (n-1) !
	==> 1/(n-1!) = n/(n!)
	==> (1/(n-1!)) % M = (n/(n!)) % M
	==> (1/(n-1!)) % M = ((n % M) * ((1/(n!)) % M)) % M
	*/
	invfact[maxN - 1] = modinv(fact[maxN - 1]);
	for (ll i = maxN - 2; i >= 0; i--) {
		invfact[i] = invfact[i + 1] * (i + 1);
		invfact[i] %= MOD;
	}

}

int main()
{
	// WHILE(!(SUCCEED == TRY()));
	// BEFORE WRITING MAKE SURE YOU HAVE ANALYSED THE CONSTRAINTS
	// AND THINK THROUGH THE LOGIC ONCE MORE
	FIO
	precomputenCr();
    // USING PRINCIPLE OF INCLUSION AND EXCLUSION
	ll n, m; cin >> n >> m;
	ll ans = nCr(m, n) * fact[n];
	ans %= MOD;
	for (ll i = 1; i <= n; i++) {
		ll cur = nCr(n, i);

		cur *= nCr(m - i, n - i);
		cur %= MOD;

		cur *= fact[n - i];
		cur %= MOD;

		if (i % 2 == 1) cur = MOD - cur;

		ans += cur;
		ans %= MOD;
	}
	ans = ans * ((nCr(m, n) * fact[n]) % MOD);
	ans = ans % MOD;
	cout << ans << "\n";
	return 0;
}
// “Well, probably you won’t understand anything, because you
// didn’t try to understand anything in your life, you expect
// all hard work to be done for you by someone else” - um_nik
/*
We can also see this question as derangement of n disitinct objects from their original positions
https://brilliant.org/wiki/derangements/
Revise the theory from here
...
https://codeforces.com/blog/entry/79438
...

https://codeforces.com/blog/entry/79438?#comment-651722

That's not assumed. Do you understand what we're doing PiE over? I can phrase in a different way:

Take WLOG Ai=i
for 1≤i≤n as in the editorial above. Then, let Si be the set of sequences for B satisfying the
second condition (Bi≠Bj when i≠j) and with Bi=i

. Then clearly we want to work out
(MN)N!−|S1∪S2∪⋯∪SN|

as this is the number of valid B
sequences (assuming Ai=i for all i). We can work this out via PiE (since the sizes intersections
of various Si sets are easy to work out), and then we just multiply by (MN)N! as that's the number
of possibly A sequences.

*/

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

int func(int x)
{
    if(x%100 != 0) return 0;
    return func(x/100) + 1;
}

int main()
{
    int d, n;
    cin >> d >> n;
    int cnt = 0;
    for(int i=1;;i++)
    {
        if(func(i) == d)
        {
          cnt++;
          if(cnt == n)
          {
          	cout << i;
            return 0;
          }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
int main() {
	int N;
	while (cin >> N, N) {
		vector<int> A(N);
		for (int i = 0; i < N; ++i) cin >> A[i];
		vector<pair<int, int> > dp = { make_pair(0, 0) };
		for (int i = 0; i < N; ++i) {
			vector<pair<int, int> > ndp((i + 1) * 1000 + 1, make_pair(-inf, inf));
			for (int j = 0; j <= i * 1000; ++j) {
				ndp[j] = max(ndp[j], dp[j]);
				int reward = (500 - A[i] % 500) % 500;
				ndp[j + reward] = max(ndp[j + reward], make_pair(dp[j].first, dp[j].second - A[i]));
				int loss = 500 - (1000 - A[i] % 1000) % 1000;
				if (j >= loss) ndp[j - loss] = max(ndp[j - loss], make_pair(dp[j].first + 1, dp[j].second - A[i]));
			}
			dp = ndp;
		}
		pair<int, int> ans = *max_element(dp.begin(), dp.end());
		cout << ans.first << ' ' << -ans.second << endl;
	}
	return 0;
}


Measured memory_bytes: 5968
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

long long chmin(long long a, long long b){
    if(a > b) return b;
    return a;
}

int main() {
    int i, j;
    int n, k;
    long long  h[100100] = {0};
    long long dp[100100] = {0};
    
    for(i=0;i<100100;i++) dp[i]=10000000001;
    
    scanf("%d%d", &n, &k);
    for(i = 0; i < n; i++){
        scanf("%lld", &h[i]);
    }
    dp[0] = 0;
    for(i = 0; i < n; i++){
        for(j = 1; j <= k; j++){
            dp[i+j] = chmin(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
        }
    }
    printf("%lld\n", dp[n-1]);

    return 0;
}


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

const int mod = 1e9+7;
void add_self(int& a, int b){
    a = a+b;
    if(a>=mod)
        a-=mod;
}
void sub_self(int& a,int b){
    a-=b;
    if(a<=0){
        a+=mod;
    }
}

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> dp(k+1);
    dp[0] = 1;
    // dp[i] is the number of ways to make i sum 
    for(int child = 0;child<n;child++){
        int upto;
        cin>>upto;
        vector<int> fake(k+1);
        for(int used = k;used>=0;used--){
            int temp = dp[used];
            int L = used+1;
            int R = used+min(upto,k-used);
            if(L<=R){
                add_self(fake[L],temp);
                if(R+1<=k){
                    sub_self(fake[R+1],temp);
                }
            }
            // for(int i=L;i<=R;i++)
            //     add_self(dp[i],temp);
            // for(int i= 1;i<=min(upto,k-used);i++)
            //     add_self(dp[used+i],dp[used]);
        }
        int prefix_sum = 0;
        for(int i=0;i<=k;i++){
            add_self(prefix_sum,fake[i]);
            add_self(dp[i],prefix_sum);
        }
    }
    cout<<dp[k];
    return 0;
}


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


int main()
{
    int N,K;
    cin >> N >> K;
    vector<long long> h(N);
    for(int i = 0;i < N;i++)
        cin >> h[i];
    sort(h.begin(),h.end());
    long long count = 0;
    for(int i = N - 1;0 <= i;i--)
    {
        if(K != 0)
        {
            K--;
            continue;
        }
        count += h[i];
    }
    cout << count << '\n';
}


Measured memory_bytes: 1792
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int price = 0;
		if(a >= 13){
			price = b;
		}else if(a >= 6){
			price = b / 2;
		}
		System.out.println(price);
	}
}


Measured memory_bytes: 35620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace PriRect
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = new string[2];
            //for(int i = 0; i < str.Length; i++){
            while (true)
            {
                str = Console.ReadLine().Split(' ');
                int height = int.Parse(str[0]);
                int weight = int.Parse(str[1]);
                if ((height == 0) && (weight == 0))
                {
                    break;
                }
                for (int i = 0; i < height; i++)
                {
                    for (int k = 0; k < weight; k++)
                    {
                        Console.Write("#");


                    } Console.WriteLine("");
                } Console.WriteLine("");
            }
        }
    }
}

Measured memory_bytes: 5288
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n;
string s, t;

int main(){
	cin >> n >> s >> t;
	
	ll start = n;
	for(ll i = 0; i < n; i++){
		bool ok = true;
		for(ll k = 0; k < n-i; k++){
			if(s[i+k] != t[k]){ok = false;}
		}
		if(ok){
			start = i;
			break;
		}
	}
	
	cout << n+start << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(void){
	int n=in(),i,c;
	long long a[100010],x=0;
	rep(i,n)a[i]=llin();
	sort_r(a,n);
	rep(i,n){
		for(c=0;a[i+c]==a[i+c+1];c++);
		c++;
		if(c>=4&&!x){
			llprint(a[i]*a[i]);
			return 0;
		}
		else if(c>=2&&!x)
			x=a[i];
		else if(c>=2){
			llprint(x*a[i]);
			return 0;
		}
		i+=c-1;
	}
	print(0);
	return 0;
}

Measured memory_bytes: 1788
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
struct UnionFind{
  vector<int> rank;
  UnionFind(int size) : rank(size, -1) {}
  bool unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y){
      return 0;
    }
    if(rank[y] < rank[x]){
      swap(x, y);
    }
    rank[x] += rank[y];
    rank[y] = x;
    return 1;
  }
  bool same(int x, int y){
    return find(x) == find(y);
  }
  int find(int x){
    return rank[x] < 0 ? x : rank[x] = find(rank[x]);
  }
  int size(int x){
    return -rank[find(x)];
  }
};

int main(){
  int n, q, com, x, y;
  cin >> n >> q;
  UnionFind uf(n);
  for(int i = 0; i < q; ++i){
    cin >> com >> x >> y;
    if(com == 0){
      uf.unite(x, y);
    }
    else{
      cout << (uf.same(x, y) ? 1 : 0) << endl;
    }
  } 
  return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include<deque>
#include<algorithm>
#include<vector>


int main(){
    int N;
    int tt;
    std::cin>>N;
    std::vector<std::deque<int>> a(N,std::deque<int>{});

    for(int i=0;i<N;++i){
        for(int k=0;k<N-1;++k){
            std::cin>>tt;
            a[i].push_back(tt-1);
        }
    }

    int count = 0;
    std::vector<int> list,next_list;
    for(int i=0;i<N;++i){
        next_list.push_back(i);
    }
    for(;;){
        std::vector<int> tmp(N,false);
        list = std::move(next_list);
        next_list = {};
        bool changed = false;
        for(int i:list){
            if(a[i].empty())
                continue;
            int x = a[i][0];
            if (! tmp[i] && ! tmp[x] && ! a[x].empty() && a[x][0] == i){
//                std::cout<<i<<x<<"\n";
                a[i].pop_front();
                a[x].pop_front();
                tmp[x]=1;
                tmp[i]=1;
                next_list.push_back(i);
                next_list.push_back(x);
                changed=true;
            }
        }
        if (!changed)
            break;
        count +=1;
    }

    if (std::all_of(a.begin(),a.end(),[](auto&aa){return aa.size() == 0;})){
        std::cout<<count;
    }else{
        std::cout<<-1;
    }

}




Measured memory_bytes: 4736
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	cout << (abs(x - a) <= abs(x - b) ? 'A' : 'B') << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >>n;
    int cards[4][13]={{}};
    char a;
    int b;
    for (int i=0; i<n; i++){
        cin >>a >>b;
        if(a == 'S'){
            cards[0][b-1] = 1;
        }else if(a == 'H'){
            cards[1][b-1] = 1;
            
        }else if(a == 'C'){
            cards[2][b-1] = 1;
        }else if(a == 'D'){
            cards[3][b-1] = 1;
        }
    }for (int i=0; i<4; i++){
        for (int j=0; j<13; j++){
            if(cards[i][j] != 1){
                if(i==0){
                    cout<<"S "<<j+1<<endl;
                }else if(i==1){
                    cout<<"H "<<j+1<<endl;
                }else if(i ==2){
                    cout<<"C "<<j+1<<endl;
                }else if(i==3){
                    cout<<"D "<<j+1<<endl;
                }
            }
        }
    }return 0;
}


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

ll ReturnDigit(ll n){
  int keta=1;
  while(n/10!=0){
    n /= 10;
    keta++;
  }
  return keta;
}

int main(){
  ll n; cin>>n;
  ll ans = 100000000000;
  for (ll i=1; i*i<=n; i++){
    if (n%i==0){
      ll A = i;
      ll B = n/i;
      //cout << "A" << A << endl;
      //cout << "B" << B << endl;
      ans = min(ans, max(ReturnDigit(A),ReturnDigit(B)));
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n;
    ll ans = 0;
    cin >> n;
    ll a[100050];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    ans = a[1] - 1;
    a[1] = 1;
    ll now = 2;
    for(int i = 2; i <= n; i++){
        if(a[i] == now){
            now++;
            continue;
        }
        if(a[i] < now){
            continue;
        }
        ans += (a[i] - 1) / now;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
N,Y = [int(i) for i in input().split()]
a=-1
b=-1
c=-1
for i in range(N+1):
    for j in range(N+1-i):
        if(Y-1000*(N-(i+j)) == 10000*i + 5000*j):
            a=i
            b=j
            c=N-i-j
print(str(a) +' '+str(b)+' '+str(c)) 


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:0;}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:0;}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=155;
const int L=128,W=62;
//const int L=10,W=4;

inline char gc(int t){return t<26?t+'a':(t<52?t-26+'A':t-52+'0');}
int n;
string s[MAXN][MAXN];
int ask(string str)
{
	int ans;
	cout<<"? "<<str<<endl;
	cin>>ans;
	return ans;
}
void solve(int l,int r)
{
	if(l==r)return;
	int mid=(l+r)>>1;
	solve(l,mid);
	solve(mid+1,r);
	string sl=s[l][mid],sr=s[mid+1][r],cur="";
	int x=0;
	for(int y=0;y<sr.length();++y)
	{
		while(x<sl.length())
		{
			string str=cur+sr[y];
			for(int i=x;i<sl.length();++i)str=str+sl[i];
			if(ask(str)==n-str.length())break;
			cur=cur+sl[x++];
		}
		cur=cur+sr[y];
	}
	while(x<sl.length())cur=cur+sl[x++];
	s[l][r]=cur;
}

int main()
{
	#ifndef ONLINE_JUDGE
//	freopen("code.in","r",stdin);
//	freopen("code.out","w",stdout);
	#endif
	for(int k=0;k<W;++k)
	{
		string str="";
		for(int i=1;i<=L;++i)str=str+gc(k);
		int t=L-ask(str);
		for(int i=1;i<=t;++i)s[k][k]=s[k][k]+gc(k);
		n+=t;
	}
	solve(0,W-1);
	cout<<"! "<<s[0][W-1]<<endl;
	return 0;
}

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

int main(){
    int N,M,X; cin>>N>>M>>X;
    vector<int> A(N,0);
    for(int i=0;i<N;i++){
        int a; cin>>a;
        A[a]++;
    }

    int right=0,left=0;
    for(int i=X+1;i<N;i++){
        if(A[i]) right++;
    }
    for(int i=X-1;i>0;i--){
        if(A[i]) left++;
    }
    cout<<min(right,left)<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
     
    static int count = 0;
     
    static int gcd(int a,int b){
        count++;
        int r = a%b;
        if(r == 0) {
            return b;
        }else {
            return gcd(b,r);
        }
    }
 
 
    void main() {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a + b == 0) break;
            if(a<b) {
                int temp = a;
                a = b;
                b = temp;
            }
            int ans = gcd(a,b);
            System.out.println(ans +" " + count);
            count = 0;
        }
         
    }
 
    public static void main(String[] args) {
        new Main().main();
    }
 
}



Measured memory_bytes: 32940
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n;
    string s;
    int left[300010],right[300010];
    int w,e;
    int result=10000000;
    cin>>n;
    cin>>s;
    left[0]=0;
    right[0]=0;
    for(int i=1;i<n;i++){
        w=0;
        e=0;
        if(s[i-1]=='W'){
            w++;
        }
        if(s[n-i]=='E'){
            e++;
        }
        left[i]=left[i-1]+w;
        right[i]=right[i-1]+e;
    }
    for(int i=1;i<=n;i++){
        result=min(result,(right[i-1]+left[n-i]));
    }
    cout<<result<<"\n";
    return 0;
}


Measured memory_bytes: 2964
/*
Author: Deep Chaklasiya
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/

#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update> data_set;
#define fbo find_by_order
#define ook order_of_key




#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define piiii       pair<pii,pii>
#define viiii       vector<pair<pii,pii>>
#define mi          map<int,int>
#define mii         map<pii,int>
#define piii           pair<int,pair<int,int> >
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define ef else if





int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }
bool mod(double a,double b) {return a/b - floor(a/b);}

int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}

int logb(int base, int x) {
    return (log(x) / log(base));
}


template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}

void set_min(int &m,int a){
    if(m==-1||m>a)m=a;
}


signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int i,j,x,n,m,k,t;
    cin>>n;
    vi v(n);
    for(auto &x:v) cin>>x;
    int e=v[0],count=0;
    for(int i=0;i<n;i++)
    {
    	if(v[i]<=e)
    	{
    		count++;
    		e=v[i];
		}
	}
	cout<<count;
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<long long> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    long long answer = 0;
    for (int i = 0; i < n - k; ++i) {
        answer += h[i];
    }
    cout << answer << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define mp1(a,b,c) P1(a,P(b,c))
#define pque(a) priority_queue<a>
#define rpque(a) priority_queue<a,vector<a>,greater<a>>

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880};

const int nex[2][6][2] = {
	{{1,0},{0,1},{-1,0},{0,-1},{-1,-1},{1,-1}},
	{{1,0},{0,1},{-1,0},{0,-1},{-1,1},{1,1}}
};

int a[110][110];
void dfs(int x,int y){
	if(a[x][y] == 0){
		a[x][y] = -1;
		rep(i,6){
			dfs(x + nex[x%2][i][0],y + nex[x%2][i][1]);
		}
	}
}

int main(){
	rep(i,110){
		rep(j,110){
			if(i == 0 || i == 109 || j == 0 || j == 109)a[i][j] = -2;
			else a[i][j] = 0;
		}
	}
	
	int w,h;
	
	scanf("%d%d",&w,&h);
	rep(i,h){
		rep(j,w){
			scanf("%d",&a[i+3][j+3]);
		}
	}
	
	/*rep(i,8){
		rep(j,12){
			if(i%2 == 0){
				printf("%2d  ",a[i][j]);
			}
			else {
				printf("  %2d",a[i][j]);
			}
		}
		puts("");
	}*/
	
	dfs(1,1);
	
	int ret = 0;
	
	rep1(i,108){
		rep1(j,108){
			rep(k,6){
				if(a[i][j]*a[i+nex[i%2][k][0]][j+nex[i%2][k][1]] < 0)ret ++;
			}
		}
	}
	
	/*rep(i,8){
		rep(j,12){
			if(i%2 == 0){
				printf("%2d  ",a[i][j]);
			}
			else {
				printf("  %2d",a[i][j]);
			}
		}
		puts("");
	}*/
	
	printf("%d\n",ret/2);
}

Measured memory_bytes: 1756
#include<bits/stdc++.h>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int n,m;
	cin >> n >> m;
	int now = 0;
	vector<ll> b(n,1);
	vector<bool> f(n);
	f[0]=1;
	rep(i,0,m){
		int x,y;
		cin>>x>>y;
		x--; y--;
		b[x]--;
		b[y]++;
		
		if(f[x]){
			f[y]=1;
		}
		if(f[x]&&!b[x]){
			f[x]=0;
		}
	}

	int cnt = 0;
	rep(i,0,n) if(f[i]) cnt++;
	cout << cnt << endl;

	ret 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

int main() {
  int N;
  std::cin >> N;
  std::vector<std::tuple<std::string, int, int>> book;

  std::string S;
  int P;
  for(int i = 0; i < N; i++){
    std::cin >> S >> P;
    book.emplace_back(S, P*(-1), i+1);
  }
  std::sort(book.begin(), book.end());

  for(const auto& elem : book){
    std::cout << std::get<2>(elem) << std::endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=200005;
const ll mod=1e9+7;
inline int read()
{
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0',ch=getchar();}
    return x*f;
}
int n,m;
char s[N];
int main()
{
	scanf("%s",s+1); n=strlen(s+1);
	int ok=1;
	for(int i=1; i<=n/2; i++) if(s[i]!=s[n-i+1]) ok=0;
	for(int i=1; i<=n/2; i++) if(s[i]!=s[n/2-i+1]) ok=0;
	for(int i=1; i<=n/2; i++) if(s[i+(n+1)/2]!=s[n/2-i+1+(n+1)/2]) ok=0;
	if(ok) puts("Yes"); else puts("No");
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input!{
        k: usize,
        s: String,
    }
    let l = s.chars().count();
    if l > k {
        let t: String = s.clone().drain(..k).collect();
        println!("{}...", t);
    } else {
        println!("{}", s);
    }
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

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


///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    ll K; cin >> K;
    ll q = K / 50;
    ll r = K % 50;
    if (K == 0){
        cout << 4 << "\n" << "3 3 3 3" << endl;
        return 0;
    }else if (K == 1){
        cout << 3 << "\n" << "1 0 3" << endl;
        return 0;
    }
    
    if (K <= 50){
        cout << K << "\n";
        REP(i,K){
            cout << K << " ";
        }
        cout << endl;
        return 0;
    }

    cout << 50 << "\n";

    REP(i,r){
        cout << 50 + q << " ";
    }
    REP(i,50-r){
        cout << 49 + q - r << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main(void){
    int a[1000],b[1000],j,k,l;
    int i=0;
    while(1){
        scanf("%d %d",&a[i],&b[i]);
        if(a[i]==0 && b[i]==0){
            break;
            }
        i++;
        }
    for(j=0;j<i;j++){
        for(k=0;k<a[j];k++){
            for(l=0;l<b[j];l++){
                if(1<=k&&k<a[j]-1&&1<=l&&l<b[j]-1){
                printf(".");
            }else{
                printf("#");
            }
            }
        printf("\n");
            
    }
    printf("\n");
    
}    
    return 0;
}
     


Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector< set<int> >q(30);

int main(){
    int n,i,j,t,l,r,k,u,ans;
    string s;
    char c;
    cin>>n>>s;
    for(int i=0;i<26;i++) q[i].insert(n);//ÏÈ´æÈën£¬·ÀÖ¹ºóÐø²éÕÒÔ½½ç
    for(int i=0;i<n;i++) q[s[i]-'a'].insert(i);
    cin>>t;
    while(t--){
        cin>>u;
        if(u==1){
            cin>>k>>c;k--;
            if(s[k]!=c) q[s[k]-'a'].erase(k);
            s[k]=c;q[c-'a'].insert(k);
        }
        else{
            ans=0;
            cin>>l>>r;l--;r--;
            for(int j=0;j<26;j++) if(*q[j].lower_bound(l)<=r) ans++;
            cout<<ans<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 24324
n=int(input())
s=[input()for i in range(n)]
ans=""
for i in range(97,97+26):
    small=float("inf")
    for j in range(n):
        cnt=0
        for k in range(len(s[j])):
            if s[j][k]==chr(i):
                cnt+=1
        small=min(small,cnt)
    for l in range(small):
        ans+=chr(i)
print(ans)



Measured memory_bytes: 3060
#include <iostream>

int main()
{
  int a, b;

  std::cin >> a >> b;

  if (a%3 == 0 || b%3 == 0 || (a+b)%3 == 0) {
    std::cout << "Possible" << std::endl;
  } else {
    std::cout << "Impossible" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256