akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

template <typename A, typename B>
string to_string(pair<A, B> p){
    return "(" + to_string(p.fi) + ", " + to_string(p.se) + ")";
}

template <typename T>
string to_string(T v){
    string s = "{";
    bool first = true;
    for(const auto & x : v){
        if(!first) s += ", ";
        first = false;
        s += to_string(x);
    }
    return s + "}";
}

void debug_out(){ cerr << endl;}
template <typename First, typename... Next>
void debug_out(First F, Next... N){
    cerr << " " << to_string(F);
    debug_out(N...);
}

#ifdef LOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1
#endif

const int N = 2e5 + 5;
int par[N], ans[N], sz[N];
vector<int> e[N];

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

void join(int u, int v){
    u = find(u);
    v = find(v);
    if(u == v) return;
    if(sz[u] > sz[v]) swap(u, v);
    par[u] = v;
    sz[v] += sz[u];
}

int main(){
    fcin;
    int n, m, k;
    cin >> n >> m >> k;

    for(int i = 1; i <= n; i++) par[i] = i;
    for(int i = 1; i <= n; i++) sz[i] = 1;

    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        e[u].pb(v);
        e[v].pb(u);
        join(u, v);
    }

    for(int i = 0; i < k; i++){
        int u, v;
        cin >> u >> v;
        e[u].pb(v);
        e[v].pb(u);
    }
    
    for(int i = 1; i <= n; i++){
        int s = sz[find(i)];
        for(int v : e[i]) if(find(v) == find(i)) s--;
        ans[i] = s - 1;

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



Measured memory_bytes: 11776
#include <stdio.h>

/* 多分全探索で求められる */
int main(int argc, char *argv[])
{
	int i, N, K;
	int ng[10] = {0};
	scanf("%d %d", &N, &K);
	for ( i = 0; i < K; i++ ){
		int n;
		scanf("%d", &n);
		ng[n] = 1;
	}

	for ( ;; ){
		char buf[512];
		sprintf(buf, "%d", N);
		for ( i = 0; buf[i] != '\0'; i++ ){
			if ( ng[ buf[i] - '0' ] ){
				break;
			}
		}
		if ( buf[i] == '\0' ){
			printf("%d\n", N);
			break;
		}
		N++;
	}

	return 0;
}


Measured memory_bytes: 128
import scala.io.StdIn._
import scala.collection._

object Main {

  class Sieve(val n: Int){
    private[this] val top = (n - 3) / 2 + 1
    private[this] val sqrtLimit = (Math.sqrt(n).toInt - 3) / 2

    private[this] val cmpsts = new Array[Int]((top >>> 5) + 1)
    def isPrime(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) == 0
    def notPrime(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)

    def next(i: Int): Int = if((i > top) || isPrime(i)) 2 * i + 3 else next(i + 1)

    def exec: Iterator[Int] = {
      /*
      for{
        i <- 0 to sqrtLimit
        if isPrime(i)
        j <- Range(((2 * i + 3)*(2 * i + 3)-3)/2, top, (2 * i + 3))
      } notPrime(j)
      */
      /*
      (0 to sqrtLimit).map{ i =>
        val p = 2 * i + 3
        if(isPrime(i))Range((p*p-3)/2, top, p).map{notPrime}
      }
      */

      (0 to sqrtLimit).withFilter(isPrime).map{ i =>
        val p = 2 * i + 3
        Range((p*p-3)/2, top, p).map{notPrime}
      }

      if(n==2)Iterator.single(2)
      else Iterator.single(2) ++ Iterator.iterate(3)(p => next((p - 1) / 2)).takeWhile(_ <= n)
    }
  }

  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else println(new Sieve(n).exec.size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit = loop(readLine)
}

Measured memory_bytes: 305788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int M = input.nextInt();
		int D = input.nextInt();
		long cnt = 0;
		for (int day = 22; day <= D; day++) {
			int tens = day/10;
			int ones = day%10;
			if (tens*ones<=M&&tens*ones>0&&ones>1) {
				//System.out.println(tens*ones+" "+day);
				cnt++;
			} 
		}
		System.out.println(cnt);
	}	
}

Measured memory_bytes: 21204
n = int(input())
Str = ""
while (n != 0):
    r = n % 2
    if r < 0:
        r += 2
    # n = (-2)*q + rよりqについて式変形する。q = nとすると
    n = (n-r) // (-2)
    Str += str(r)
tmp = list(reversed(list(Str)))
ans = "".join(tmp)
if Str == "":
    print(0)
    exit()
print(ans)

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

int main() {
    int n; cin >>n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        int a_;
        cin >>a_;
        a.at(i) = a_;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a.at(a.at(i)-1)-1==i) ans++;
    }
    cout << ans/2 << endl;
    return 0;
}

Measured memory_bytes: 640
def resolve():
    m = 10**9 + 7
    ans = 0
    n, k = map(int, input().split())
    for i in range(k, n+2):
        low = i*(i-1)//2
        high = i*(2*n - i + 1)//2
        ans += (high - low + 1)
    ans %= m
    print(ans)
resolve()

Measured memory_bytes: 9196
//copy from Antiquality
//https://www.cnblogs.com/antiquality/p/9102470.html

#include<bits/stdc++.h>
const int maxn = 100035;

int a[maxn],n,l,t,x,cnt;

int main()
{
    scanf("%d%d%d",&n,&l,&t);
    for (int i=1; i<=n; i++)
    {
        scanf("%d%d",&a[i],&x);
        a[i] += x==1?t:-t;
        cnt += a[i]/l;
        if (a[i]%l<0)	cnt--;
        
				((a[i]%=l)+=l)%=l;
    }
    std::sort(a+1, a+n+1);
    ((cnt%=n)+=n)%=n;
    for (int i=cnt+1; i<=n; i++) printf("%d\n",a[i]);
    for (int i=1; i<=cnt; i++) printf("%d\n",a[i]);
    return 0;
}

Measured memory_bytes: 1536
#include <cstdio>

const int MOD=1e9+7;

int N,K;

int dp[100005];

int main(){
  scanf("%d %d",&N,&K);
  dp[0]=1;
  for(int t=0;t<N;t++){
    int A;
    scanf("%d",&A);
    for(int i=1;i<=K;i++){
      dp[i]=(dp[i]+dp[i-1])%MOD;
    }
    for(int i=K;i>A;i--){
      dp[i]=(dp[i]-dp[i-A-1])%MOD;
    }
  }
  printf("%d\n",(dp[K]+MOD)%MOD);
  return 0;
}


Measured memory_bytes: 512
n = int(input())
A = [list(map(int, input().split())) for i in range(n)]

ans = 0; ok = 1
for i in range(n):
    for j in range(i+1, n):
        cost = A[i][j]
        for k in range(n):
            if i == k or j == k:
                continue
            if A[i][k] + A[k][j] < A[i][j]:
                ok = 0
            elif A[i][k] + A[k][j] == A[i][j]:
                cost = 0
        ans += cost
print(ans if ok else -1)

Measured memory_bytes: 44380
use std::io::*;
use std::str::FromStr;
 
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
 
#[allow(dead_code)]
struct Main {}
 
#[allow(dead_code)]
impl Main {}
 
fn main() {
    let r: f64 = read();
    println!("{}", r * 2.0 * 3.14);
}

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

using ll = long long;

ll f(string &s) {
   string a = "";
   ll sum = 0;
   int n = s.size();
   for (int i = 0; i < n; i++) {
      if (s[i] == '+') {
         sum += stoll(a);
         a = "";
      } else {
         a += s[i];
      }
   }
   sum += stoll(a);
   return sum;
}

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

   int n = s.size();
   ll sum = 0;
   for (int mask = 0; mask < (1<<(n-1)); mask++) {
      string t;
      t += s[0];
      for (int i = 0; i < n-1; i++) {
         if ((mask >> i)&1) {
            t += '+';
         }
         t += s[i+1];
      }
      sum += f(t);
   }
   cout << sum << endl;

   return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
Map = [[s for s in input()] for _ in range(H)]

for i in range(H):
    for j in range(W):
        if Map[i][j] == '#':
            for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
                ny = i + dy
                nx = j + dx
                if ny < 0 or ny >= H or nx < 0 or nx >= W:
                    continue
                if Map[ny][nx] == '#':
                    break
            else:
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 67688
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    ll n, m;
    vector< pll > op;
    ll a[100005];
    ll i;
    cin>>n>>m;
    ll ans = 0;
    FOR0(i, n) 
    {
        cin>>a[i];
        ans += a[i];
    }
    FOR0(i, m)
    {
        ll c, b;
        cin>>b>>c;
        op.push_back(mp(c, b));
    }
    sort(a, a+n);
    sort(op.begin(), op.end(), greater< pll >());
    ll cur = 0;
    i = 0;
    while(cur < m && i < n)
    {
        if(op[cur].ff < a[i]) break;
        ans += op[cur].ff - a[i];
        op[cur].ss--;
        if(op[cur].ss==0)
            cur++;
        i++;
    }
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int N;
  int M;
  cin >>N>>M;
  int x=(N-1)*(M-1);
  cout << x<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define ll long long
using namespace std;
const int N = 400;
const int mod = 1e9 + 7;
int n, ans, g[N][N], f[N][N], s[N][N];
int a[N], b[N], pa[N], pb[N], cnt[N][N], ss[N], cnt_;
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		pa[a[i]] = i;	
	}
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
		pb[b[i]] = i;	
	}
	for (int i = 1; i <= n; i++) {
		ss[a[i]]++;
		if (ss[a[i]] == 1) cnt_++;
		for (int j = 1; j <= n; j++) {
			ss[b[j]]++;
			if (ss[b[j]] == 1) cnt_++;
			cnt[i][j] = cnt_;
		}
		for (int j = 1; j <= n; j++) {
			ss[b[j]]--;
			if (ss[b[j]] == 0) cnt_--;
		}
	}
	for (int i = 1; i <= n + 1; i++)
		for (int j = 1; j <= n + 1; j++)
			s[i][j] = 1;
	for (int i = 1; i <= n / 3; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				f[j][k] = 0;
				if (pa[b[k]] <= j) continue;
				if (pb[a[j]] <= k) continue;
				f[j][k] = (ll)(n - cnt[j][k] - (i - 1) * 3) * s[j + 1][k + 1] % mod;
			}
		}
		for (int j = 0; j <= n + 1; j++)
			s[j][n + 1] = s[n + 1][j] = 0;
		for (int j = n; j >= 1; j--) {
			for (int k = n; k >= 1; k--) {
				s[j][k] = f[j][k];
				(s[j][k] += (s[j + 1][k] + s[j][k + 1] - (ll)s[j + 1][k + 1] + mod) % mod) %= mod;
			}
		}
	}
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++) 
			(ans += f[i][j]) %= mod;
	g[0][0] = 1;
	for (int i = 0; i <= n / 3; i++) {
		for (int j = 0; j <= n; j++) {
			if (g[i][j] == 0) continue;
			if (i * 3 > j) (g[i][j + 1] += (ll)g[i][j] * (3 * i - j) % mod) %= mod;
			(g[i + 1][j + 1] += g[i][j]) %= mod;
		}
	} 
	cout << (ll)ans * g[n / 3][n] % mod << endl;
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}




void oneCase () {
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> x(n);
    for (auto& v : x) {
        cin >> v;
    }
    ll res = 0;
    for (int pos = 0; pos + 1 < n; ++pos) {
        auto dist = x[pos + 1] - x[pos];
        res += min(dist * a, b);
    }
    cout << res << "\n";

}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 1024
n, m = gets.split.map(&:to_i)

shops = n.times.map do
  gets.split.map(&:to_i)
end.sort

ans = shops.inject([0, 0]) do |memo, shop|
  if memo[1] < m
    count = [m-memo[1], shop[1]].min
    memo[0] += count * shop[0]
    memo[1] += count
  end
  memo
end

puts ans[0]


Measured memory_bytes: 13176
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	ll N,M,X;
	cin >> N >> M >> X;
	vector<ll> DP(N + 1, 0);
	for (ll m = 0; m < M; m++) {
		ll a;
		cin >> a;
		DP[a]++;
	}
	for (ll n = 1; n <= N; n++) {
		DP[n] += DP[n - 1];
	}
	cout << min(DP[N] - DP[X], DP[X] - DP[0]) << endl;
	return 0;
}

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

struct Problem {

	void Solve() {
		UL N, A, B; cin >> N >> A >> B;
		UL M = min(A, B);
		UL m = max(A + B, N) - N;
		cout << M << " " << m << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

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


int main(void) {
    using namespace std;

    long n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--, b--, c--, d--;

    string s;
    cin >> s;

    if(a > b)
        swap(a, b), swap(c, d);
    assert(a < b);

    long go = b;
    while(go < d)
        if(s[go+1] == '.') go++;
        else if(s[go+2] == '.') go+=2;
        else break;
    if(go != d)
        goto bad;

    go = a;
    while(go < c)
        if(s[go+1] == '.') go++;
        else if(s[go+2] == '.') go+=2;
        else break;
    if(go != c)
        goto bad;

    if(d < c) {
        for(int i=b; i <= d; i++)
            if(i-1 >= 0 && i+1 < n && s[i-1] == '.' && s[i] == '.' && s[i+1] == '.')
                goto ok;
        goto bad;
    }

ok:
    cout << "Yes" << endl;
    return 0;
bad:
    cout << "No" << endl;
}


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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  ll n;
  cin >> n;

  string s = to_string(n);
  int sum = 0;
  for (int i = 0; i < s.size(); ++i) {
    int d = s[i] - '0';
    sum += d;
  }

  if (n % sum == 0) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }

  return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 5050, mod = 1e9 + 7;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	string s;
	cin >> s;
	int ans = 0, cur = 0;
	s += 'S';
	for(auto i : s) {
		if(i == 'R') cur++;
		else ans =max(ans, cur), cur = 0;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3600
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
  priority_queue<ll> preque,postque;
  ll a[310000],presum[310000],postsum[310000],ans;
  int N;
  cin>>N;
  presum[N]=0; postsum[N]=0;
  
  for(int i=1;i<=3*N;i++) cin>>a[i];

  for(int i=1;i<=N;i++){
    presum[N]+=a[i];
    preque.push(a[i]*(-1));
    postsum[N]+=a[3*N+1-i];
    postque.push(a[3*N+1-i]);
  }

  for(int i=N+1;i<=3*N;i++){
    preque.push(a[i]*(-1));
    presum[i]=presum[i-1]+a[i]+preque.top();
    preque.pop();

    postque.push(a[3*N+1-i]);
    postsum[i]=postsum[i-1]+a[3*N+1-i]-postque.top();
    postque.pop();
  }

  ans=presum[N]-postsum[2*N];

  for(int i=N+1;i<=2*N;i++){
    ans=max(ans,presum[i]-postsum[3*N-i]);
  }

  cout<<ans<<endl;

  
  
}


Measured memory_bytes: 9204
#include <iostream>
#include <cmath>

using namespace std;

typedef long long ll;


ll N, X;
ll ans = 0;
ll A[51];
ll P[51];


ll a(int level) {
	if (A[level] != -1) return A[level];
	else return A[level] = 2 * a(level - 1) + 3;
}

ll p(int level) {
	if (P[level] != -1) return P[level];
	else return P[level] = 2 * p(level - 1) + 1;
}

ll dfs(ll remain, ll level) {
	if (level == 0) return (remain <= 0) ? 0 : 1;
	else if (remain <= 1 + a(level - 1)) return dfs(remain - 1, level - 1);
	else if (remain == 2 + a(level - 1)) return p(level - 1) + 1;
	else if (remain <= 2 + 2 * a(level - 1)) return p(level - 1) + 1 + dfs(remain - 2 - a(level - 1), level - 1);
	else return p(level);
}

int main() {
	cin >> N >> X;

	for (int i = 0; i < 51; i++) A[i] = P[i] = -1;
	A[0] = 1;
	P[0] = 1;

	cout << dfs(X, N) << endl;

	return 0;
}

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

int main() {
  int A,B,C;
  cin>>A>>B>>C;
  if(B>=C){
    cout<<B+C<<endl;
  }
  else{
    cout<<B*2+min(C-B,A+1)<<endl;
  }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin>>N;
  string S;
  cin>>S;
  int count=0,ans=1;
  REP2(i,1,N){
    if(S[i-1]==S[i])count++;
    else{
      count=0;
      ans++;
    }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 512
s = set(input())
s = list(s)
list =["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p"
       ,"q","r","s","t","u","v","w","x","y","z"]
l = len(s)
for i in range(l):
  list.remove(s[i])
if list ==[]:
  print('None')
else:
  print(list[0])

Measured memory_bytes: 3188
#include <stdio.h>

int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);
    if (a < b) {
        printf("a < b\n");
    } else if (a > b) {
        printf("a > b\n");
    } else if (a == b) {
        printf("a == b\n");
    }
    return 0;
}



Measured memory_bytes: 2148
n, m, l = gets.split.map(&:to_i)
a = []
b = []
n.times do |i|
  tmp = gets.split.map(&:to_i)
  a[i] =tmp
end
m.times do |j|
  tmp = gets.split.map(&:to_i)
  b[j] = tmp
end

n.times do |i|
  cr = []
  l.times do |k|
    sum = 0
    m.times do |j|
      sum += a[i][j] * b[j][k]
    end
    cr[k] = sum
  end
  puts cr.join(" ")
end



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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> l(N);
    int a,b,c;
    for (int i = 0; i < N; i++) {
        cin >> a >> b >> c;
        l.at(i) = { a, b, c };
    }
    int CX, CY, H;
    for (int cx = 0; cx < 101; cx++) {
        bool frag = false;
        for (int cy = 0; cy < 101; cy++ ) {
            int i = 0;
            while (l.at(i).at(2) == 0) {
                i++;
            }
            H = l.at(i).at(2) + abs(l.at(i).at(0) - cx) + abs(l.at(i).at(1) - cy);
            for (int k = 0; k < N; k++) {
                if (l.at(k).at(2) != max(H - abs(l.at(k).at(0) - cx) - abs(l.at(k).at(1) - cy), 0)) {
                    break;
                }
                else if (k == N - 1) { 
                    frag = true;
                }
            }
            if (frag) {
                CY = cy;
                break;
            }
        }
        if (frag) {
            CX = cx;
            break;
        }
    }
    cout << CX << " " << CY << " " << H << endl;
}

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

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

float cal(float a, float b)
{
    return (a + b) / 2;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    float ans = a[0];
    rep(i, n-1)
    {
        ans = cal(ans, a[i + 1]);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    String S = sc.next();
	    String[] Dates = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	    
	    for (int i = 0; i < Dates.length; i++) {
	    	if (S.equals(Dates[i])) {
	    		System.out.println(7 - i);
	    	}
	    }
	}	
}	

Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
int a;
while(cin>>a,a){
	int sum=0;
	vector<vector<int>>c(a+1);
	c[0].push_back(0);
	for(int b=0;b<a;b++){
		int e;
		scanf("%lld",&e);
		sum+=e;
		for(int d=0;d<c[b].size();d++){
			c[b+1].push_back(c[b][d]);
			c[b+1].push_back(c[b][d]+e);
		}
	}
	int MIN=LLONG_MAX/3;
	for(int x=0;x<c[a].size();x++){
		MIN=min(MIN,abs(c[a][x]-(sum-c[a][x])));
	}
	printf("%lld\n",MIN);
}
}

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

const int N = 1005;
const int W = 20005;

struct block_t {
	int weight, able, value;
	bool operator < (const block_t &b) const {
		return weight + able < b.weight + b.able;
	}
};

int n;
block_t a[N];
long long f[N][W];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d %d %d", &a[i].weight, &a[i].able, &a[i].value);
	}
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++i) {
		for (int w = 0; w < W; ++w) {
			f[i][w] = max(f[i][w], f[i - 1][w]);
			if (w <= a[i].able && w + a[i].weight < W) {
				f[i][w + a[i].weight] = max(f[i][w + a[i].weight], f[i - 1][w] + a[i].value);
			}
		}
	}
	long long ans = 0;
	for (int i = 0; i < W; ++i) {
		ans = max(ans, f[n][i]);
	}
	printf("%lld\n", ans);
}

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

using namespace std;

#define print(s) cout << (s) << endl;
#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n) 
#define all(a) (a).begin(), (a).end()
#define inf 10000000
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x; cin>>x;
    if(x<1200){
        cout<<"ABC"<<endl;
    } else {
        cout<<"ARC"<<endl;
    }
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{

    int n,k;
    cin >> n >> k;
    cout << (k==1 ? 0:n-k) << endl;
    
    
    
    

    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  
  int ans = 1001001001;
  for (int i= 0; i < n-2; i++) {
    int a = stoi(s.substr(i,3));
    int b = abs(a-753);
    ans = min(ans,b);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
typedef long long LL;
LL dp[65][2][2], n;
LL dfs(int b, int rem, int x){
    if(b == -1){
        if(rem == 0) return 1;
        return 0;
    }
    if(dp[b][rem][x] != -1) return dp[b][rem][x];

    LL ans = 0;
    if(rem == 1){
        for(int i=0;i<2;i++){
            for(int j=0;j<=i;j++){
                if(i+j == 0) continue;
                if(x == 0){
                    if(i+j == 2){
                        ans = (ans + dfs(b-1, 0, 0))%mod;
                        ans = (ans + dfs(b-1, 1, 0))%mod;
                    }
                    if(i+j == 1) ans = (ans + dfs(b-1, 1, 0))%mod;
                }
                else{
                    if((n>>b)&1){
                        if(i+j == 1) ans = (ans + dfs(b-1, 1, 0))%mod;
                        if(i+j == 2){
                            ans = (ans + dfs(b-1, 0, 0))%mod;
                            ans = (ans + dfs(b-1, 1, 1))%mod;
                        }
                    }
                    else{
                        if(i+j == 1) ans = (ans + dfs(b-1, 1, 1))%mod;
                        if(i+j == 2) ans = (ans + dfs(b-1, 0, 1))%mod;
                    }
                }
            }
        }
    }
    else{
        for(int i=0;i<2;i++){
            for(int j=0;j<=i;j++){
                if(i+j == 2) continue;
                if(x == 0){
                    if(i+j == 0){
                        ans = (ans + dfs(b-1, 0, 0))%mod;
                        ans = (ans + dfs(b-1, 1, 0))%mod;
                    }
                    if(i+j == 1) ans = (ans + dfs(b-1, 0, 0))%mod;
                }
                else{
                    if((n>>b)&1){
                        if(i+j == 0){
                            ans = (ans + dfs(b-1, 1, 1))%mod;
                            ans = (ans + dfs(b-1, 0, 0))%mod;
                        }
                        if(i+j == 1) ans = (ans + dfs(b-1, 0, 1))%mod;
                    }
                    else{
                        if(i+j == 0) ans = (ans + dfs(b-1, 0, 1))%mod;
                    }
                }
            }
        }
    }
    return dp[b][rem][x] = ans;
}
int main(){
    memset(dp, -1, sizeof(dp));
    scanf("%lld", &n);
    printf("%lld\n", dfs(60, 0, 1));
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func sum(a []int) int {
	ret := 0
	for _, v := range a {
		ret += v
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	l := nextInts(n)
	sort.Sort(sort.IntSlice(l))
	if l[n-1] < sum(l[:n-1]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int compare(const void*a,const void *b) {
	return *(int*)a - *(int*)b;
}

int main() {
	char T[10000];

	
	
	scanf("%s", T);
	if (T[strlen(T) - 1] != 's')printf("%ss", T);
	else printf("%ses", T);
	return 0;
}

Measured memory_bytes: 1740
#include "stdio.h"
#include "stdarg.h"
#include "math.h"
#include "limits.h"

#define SWAP(type,a,b) do{type c=a;a=b;b=c;}while(0)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define DEBUG(format,a) do{printf(#a" : "#format,a);}while(0)


int main() {
	char a;
	scanf("%c", &a);
	printf("%c", a+1);
	return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
	int r[3][2];
	bool used[3];
	fill(used, used+3, false);
	for(int i = 0; i < 3; i++)cin >> r[i][0] >> r[i][1];
	int now = 1;
	while(1){
		bool ren = true;
		for(int i = 0; i < 3; i++){
			if(used[i]==false && r[i][0] == now){
				used[i] = true;
				ren = false;
				now = r[i][1];
				break;
			}
			else if(used[i]==false && r[i][1] == now){
				used[i] = true;
				ren = false;
				now = r[i][0];
				break;
			}
		}
		if(ren){
			if(used[0] && used[1] && used[2])break;
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

vector<vector<int>>ans;
int n;

void func(int cnt,int i){
  rep(k,n-1){
    rep(l,ans[k].size()){
      if(ans[k][l]==0){
        ans[k][l]=i+2;
        --cnt;
        if(cnt==0)return;
      }
    }
  }
}

void solve(){
  cin>>n;
  ans.resize(n,vector<int>(n));
  rep(i,n-1){
    for(int j=i+1;j<n;++j){
      int x=i^j;
      rep(k,30){
        if(x&(1<<k)){
          ans[i][j]=k+1;
          break;
        }
      }
    }
  }
  rep(i,n-1){
    rep(j,ans[i].size()){
      if(ans[i][j]==0)continue;
      cout<<ans[i][j]<<" ";
    }
    cout<<"\n";
  }
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


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

#define check(val) std::cout << "\033[31m" << #val << ": " << val << "\033[m" << std::endl
#define check_v(vec) \
  std::cout << "\033[31m" << #vec << ": [ ";\
  for(auto it=vec.begin(); it!=vec.end(); it++){cout << *it << " ";}\
  cout << "]"<< "\033[m" << endl;

int main() {
  int n;
  cin >> n;
  string s_tmp;
  map<string, int> mp;
  map<int, vector<string> > pm;
  rep(i,n){
    cin >> s_tmp;
    mp[s_tmp] +=1;
  }
  int kazu = 0;
  string moji;
  int last_n = 0;

  for(auto x : mp) {
    pm[x.second].push_back(x.first);
  }
  map<int,vector<string> >::reverse_iterator i = pm.rbegin();
  
  vector<string> ans(0);
  for( ; i != pm.rend() ; ++i ){
    // std::cout << i->first << " " << i->second << std::endl;
    // std::cout << i->first << endl;
    ans = i->second;
    
    sort(ans.begin(), ans.end());
    rep(i, ans.size()){
      cout << ans[i] << endl;
    }
    return 0;
  }
  //   kazu = i->first;
  //   moji = i->second;
  //   cout << last_n << " " << kazu << endl;
  //   if(last_n != 0 &&  last_n != kazu) {
  //     // break;
  //   }
  //   ans.push_back(moji);
  //   last_n = kazu;
  // }
  return 0;
}


Measured memory_bytes: 28404
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <cassert>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=1e5+10;
const int N=2e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,m,k,t,a[maxn];
int main()
{
    int i,j;
    scanf("%d",&n);
    rep(i,1,n)scanf("%d",&a[i]);
    int ret=0;
    for(i=1;i<=n;)
    {
        ret++;
        int posx=i,posy=i;
        while(posx+1<=n&&a[posx]>=a[posx+1])posx++;
        while(posy+1<=n&&a[posy]<=a[posy+1])posy++;
        i=max(posx,posy)+1;
    }
    printf("%d\n",ret);
    return 0;
}


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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader scan = 
        		new BufferedReader(new InputStreamReader(System.in));
        String line = "";
        String[] numArr;
        
        while((line = scan.readLine()) != null) {
        	
        	numArr = line.split(" ");
            
        	System.out.println
        	(gcdHelper(Integer.parseInt(numArr[0]), 
        			   Integer.parseInt(numArr[1])));
        }
        scan.close();
    }

    private static int gcdHelper(int x, int y) {
        if(y == 0) {
        	return x;
        } else {}
        return gcdHelper(y, x % y);
    }
}


Measured memory_bytes: 23988
# include<iostream>
# include<cstdio>
# include<cstring>
# include<algorithm>
using namespace std;
char sh[100005];
int main()
{
    
	scanf("%s",sh);
    for(int i=0;i<strlen(sh);i++)
    {
    	if((i+1)%2)printf("%c",sh[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 384
import java.io.*;
import java.util.*;

public class Main {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

        public int nextInt() {return Integer.parseInt(next());}

        public long nextLong() {return Long.parseLong(next());}

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    static class DSU {
        int[] root;
        int[] rank;

        public DSU(int n) {
            root = new int[n];
            rank = new int[n];
            for(int i=0;i<n;i++) {
                root[i] = i;
            }
        }

        public int find(int x) {
            if(root[x] == x) {
                return x;
            }
            else {
                return find(root[x]);
            }
        }

        public void unite(int x, int y) {
            x = find(x);
            y = find(y);
            if(x == y) {
                return;
            }
            if(rank[x] < rank[y]) {
                root[x] = y;
            }
            else {
                root[y] = x;
                if(rank[x] == rank[y]) {
                    rank[x]++;
                }
            }
        }

        public boolean same(int x, int y) {
            return find(x) == find(y);
        }
    }

	public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int n = sc.nextInt();
        long x = sc.nextLong();

        Long[] a = new Long[n];
        for(int i=0;i<n;i++) a[i] = sc.nextLong();

        Arrays.sort(a);

        for(int i=1;i<n;i++) {
            a[i] += a[i-1];
        }

        if(a[n-1] == x) {
            pw.println(n);
        }
        else {
            int ans = -1;
            for(int i=0;i<n;i++) {
                if(a[i] <= x) {
                    ans = i;
                }
                else {
                    break;
                }
            }
            pw.println(a[n-1] < x ? ans : ans + 1);
        }
        
        pw.close();
    }
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 2e5 + 10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1000000007;


int a[maxN];
int main()
{
	
	int n;
	ll K;
	scanf("%d",&n);
	scanf("%lld",&K);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	int st = 1;
	vector<int> v;
	v.push_back(1);
	vector<int> vis(n+1);
	vis[1] = 1;
	int flag = 0;
	while(1)
	{
		st = a[st];
		if(vis[st] == 1)
		{
			flag = st;
			break;
		}
		vis[st] = 1;
		v.push_back(st);
	}
	int m = v.size();
	int cnt = 0;
	for(int i=0;i<m;i++)
	{
		if(v[i] != flag)
		{
			cnt++;
		}
		else
			break;
	}
	if(K < cnt)
	{
		cout<<v[K]<<endl;
	}
	else
	{
		K -= cnt;
		int p = K % (m-cnt);
		cout<<v[cnt+p]<<endl;
	}
	
	return 0;
}

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


int main()
{
	int n,m;
	int i,j,k,l;
	int ans;

	scanf("%d",&n);

	for(i=0;i<n;i++)
	{
		char a[73];
		char c[1000][73];
		ans=1;
		scanf("%s",a);
		strcpy(c[1],a);

		//文字列を作成する
		for(j=1;j<strlen(a);j++)
		{
			int count=0;
			char f[73]={0};
			char b[73]={0};
			char mf[73]={0};
			char mb[73]={0};
			for(k=0;k<j;k++){f[k]=a[k];}
			for(k=j;k<strlen(a);k++){b[k-j]=a[k];}
			for(k=0;k<strlen(f);k++){mf[strlen(f)-k-1]=f[k];}
			for(k=0;k<strlen(b);k++){mb[strlen(b)-k-1]=b[k];}

			//文字列を比較する
			for(k=1;k<=ans;k++){	
				char x[73]={0};
				strcat(x,f);strcat(x,mb);
				if(strcmp(c[k],x)!=0){count++;}
				if(count==ans){strcpy(c[ans+1],x);ans++;break;}}

			count=0;
			for(k=1;k<=ans;k++){	
				char x[73]={0};
				strcat(x,mf);strcat(x,mb);
				if(strcmp(c[k],x)!=0){count++;}
				if(count==ans){strcpy(c[ans+1],x);ans++;break;}}

			count=0;
			for(k=1;k<=ans;k++){	
				char x[73]={0};
				strcat(x,mf);strcat(x,b);
				if(strcmp(c[k],x)!=0){count++;}
				if(count==ans){strcpy(c[ans+1],x);ans++;break;}}

			count=0;
			for(k=1;k<=ans;k++){	
				char x[73]={0};
				strcat(x,f);strcat(x,mb);
				if(strcmp(c[k],x)!=0){count++;}
				if(count==ans){strcpy(c[ans+1],x);ans++;break;}}

			count=0;
			for(k=1;k<=ans;k++){	
				char x[73]={0};
				strcat(x,b);strcat(x,f);
				if(strcmp(c[k],x)!=0){count++;}
				if(count==ans){strcpy(c[ans+1],x);ans++;break;}}

			count=0;
			for(k=1;k<=ans;k++){	
				char x[73]={0};
				strcat(x,mb);strcat(x,f);
				if(strcmp(c[k],x)!=0){count++;}
				if(count==ans){strcpy(c[ans+1],x);ans++;break;}}

			count=0;
			for(k=1;k<=ans;k++){	
				char x[73]={0};
				strcat(x,mb);strcat(x,mf);
				if(strcmp(c[k],x)!=0){count++;}
				if(count==ans){strcpy(c[ans+1],x);ans++;break;}}

			count=0;
			for(k=1;k<=ans;k++){	
				char x[73]={0};
				strcat(x,b);strcat(x,mf);
				if(strcmp(c[k],x)!=0){count++;}
				if(count==ans){strcpy(c[ans+1],x);ans++;break;}}
		}
		printf("%d\n",ans);

		}
	return 0;
}

Measured memory_bytes: 664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<int> A(N),B(N);
    for(int i=0;i<N;i++){
        cin >> A[i] >> B[i];
    }
    int inf = 1e9+1;
    if(N%2==1){
        int la = 0,ra = inf;
        while(la+1<ra){
            int m = (la+ra)/2;
            int c = 0;
            for(int i=0;i<N;i++){
                if(A[i]<=m) c++;
            }
            if(c>=(N+1)/2) ra = m;
            else la = m;
        }
        int lb = 0,rb = inf;
        while(lb+1<rb){
            int m = (lb+rb)/2;
            int c = 0;
            for(int i=0;i<N;i++){
                if(m<=B[i]) c++;
            }
            if(c>=(N+1)/2) lb = m;
            else rb = m;
        }
        cout << lb-ra+1 << "\n";
    }else{
        sort(A.begin(),A.end());
        sort(B.begin(),B.end());
        int a = A[N/2-1]+A[N/2],b = B[N/2-1]+B[N/2];
        cout << b-a+1 << "\n";
    }
}


Measured memory_bytes: 4768
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [u32;n],
        b: [u32;n],
    }
    let aa: Vec<u32> = a.iter().scan(0,|acc, x| {
        *acc += *x;
        Some(*acc)
    }).collect::<Vec<_>>();
    let mut bb: Vec<u32> = b.iter().rev().scan(0,|acc, x| {
        *acc += *x;
        Some(*acc)
    }).collect::<Vec<_>>();
    bb.reverse();
    println!("{}",
        aa.iter().zip(bb.iter()).map(|(a,b)| a+b).max().unwrap()
    );
}


Measured memory_bytes: 4352
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int x,y,z,k;
vi a,b,c,bc,r;

signed main(){
    I(x); I(y); I(z); I(k);
    a.resize(x);
    b.resize(y);
    c.resize(z);
    bc.resize(y*z);
    REP(i,x) I(a[i]);
    REP(i,y) I(b[i]);
    REP(i,z) I(c[i]);
    REP(i,y) REP(j,z) bc[i*z+j] = b[i] + c[j];
    sort(all(a));
    sort(all(bc));
    int lo = 0;
    int hi = a[x-1] + bc[y*z-1] + 1;
    int szbc = sz(bc);
    while( abs(lo-hi) > 1){
        int mid = (lo+hi)/2;
        int r = 0;
        for (auto v:a) r += (bc.end() - lower_bound(all(bc), mid-v));
        if (r >= k){
            lo = mid;
        } else {
            hi = mid;
        }
    }

    for (auto v: a){
        auto it = lower_bound(all(bc), lo-v);
        for(; it<bc.end(); it++) r.pb(*it + v);
    }
    sort(all(r), greater<int>());

    REP(i,k) printf("%lld\n", r[i]);
}

Measured memory_bytes: 141024
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int n, m;
  cin >> n >> m;
  cout << (n - 1) * (m - 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5+5 , M = 998244353, OO = 0x3f3f3f3f;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
const double Pii = 3.14159265359;
ll n;
ll a[N];
int main()
{
    FIO
    cin >> n;
    ll tot = 0;
    for(int i=0; i<n; ++i)
    {
        cin >> a[i];
        tot ^= a[i];
    }
    for(int i=0; i<n; ++i) a[i]^= tot;
    for(int i=0; i<n; ++i) cout << a[i] << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 5064