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

int main(){
  int a,b; cin >> a >> b;
  string as = to_string(a);
  string bs = to_string(b);
  string tmp = as;
  for(int i=0; i<b-1; i++){
    as = as + tmp;
  }
  tmp = bs;
  for(int i=0; i<a-1; i++){
    bs = bs + tmp;
  }
  if(as<bs){
    cout << as << endl;
  }else{
    cout << bs << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void){
  int N,i,X,m,min;
  min=1000;
  scanf("%d%d" ,&N,&X);
  
  for(i=0;i<N;++i){
    scanf("%d" ,&m);
    X-=m;
  if(m<min){
    min=m;
  }
  }
  printf("%d" ,N+X/min);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define nl '\n'

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int , int> pi;

//void solve()
//{
	
//}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	int count = c/b + !(c%b == 0);
	int count2 = a/d + !(a%d == 0);
	if(count <= count2)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}


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


#define MAXN 100005
vector <ll> V[MAXN]; 
ll depth[MAXN];


void boost()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
}


void dfs(ll cur, ll prev) 
{ 
    ll i,j;
    
    depth[cur]=depth[prev]+1;

    for (i=0; i<V[cur].size(); i++) 
    { 
        if (V[cur][i] != prev) 
        {
            dfs(V[cur][i], cur);
            
        }
    }
} 

int main()
{
    boost();
 
    ll i,j,k,n,z,t,l,r,x,y,d=0,u,v,c=0;
    
  cin>>x;
  
  if(x>=30)
  {
cout<<"Yes"<<endl;
  }
  
  else 
  {
    cout<<"No"<<endl;
  }


return 0;
}


Measured memory_bytes: 5984
import numpy as np
N = int(input())
nums = [int(i) for i in input().split()]

new_nums = np.array(sorted([nums[i-1] - i for i in range(1, N+1)]))
b = int(np.median(new_nums))

s = 0
for i in range(1, N+1):
    s += abs(nums[i-1] - (b + i))
print(s)


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

int a[20];
int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d", &a[i]);
	set<int>se;
	rep(i, 1 << n) {
		int sum = 0;
		rep(j, n) {
			if (i >> j & 1)sum += a[j];
		}
		se.insert(sum);
	}
	int q; scanf("%d", &q);
	rep(i, q) {
		int m; scanf("%d", &m);
		puts(se.find(m) != se.end() ? "yes" : "no");
	}
}

Measured memory_bytes: 3168
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}";
  return o;
}



ll N,A,B,C,D;
map<ll,ll> memo;
ll ret(ll n) {
  if (memo.find(n)!=memo.end()) return memo[n];
  if (n==0) return 0;
  if (n==1) return D;

  ll ans = min({
  ret(n/2)+A+n%2*D,
  ret(n/3)+B+n%3*D,
  ret(n/5)+C+n%5*D,
  });
  if (n%2>0) chmin(ans,ret((n+1)/2)+A+D);
  if (n%3>0) chmin(ans,ret((n+2)/3)+B+(3-n%3)*D);
  if (n%5>0) chmin(ans,ret((n+4)/5)+C+(5-n%5)*D);
  if (ans/n>=D) chmin(ans,n*D);
  
  memo[n]=ans;
  return ans;
}


int main() {
  int T;
  cin >> T;
  rep(i,T) {
    cin >> N >> A >> B >> C >> D;
    cout << ret(N) << endl;
    memo.clear();
  }
}

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

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

#define fst first
#define snd second

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

const int B = 27397, MOD = 1e9 + 7;
const int B1 = 33941, MOD1 = 1e9 + 9;

const int MAXN = 1e5 + 5;

int n, m;
int x[MAXN], y[MAXN];

inline int add(const int &a, const int &b) {
  int ret = a + b;
  if (ret < MOD) ret += MOD;
  return ret % MOD;
}

inline int mul(const int &a, const int &b) {
  return (llint) a * b % MOD;
}

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

  for (int i = 0; i < n; ++i)
    scanf("%d", &x[i]);
  for (int i = 0; i < m; ++i)
    scanf("%d", &y[i]);

  int all_x = 0, all_y = 0;

  for (int i = 0; i < n; ++i) {
    all_x = add(all_x, mul(i, x[i]));
    all_x = add(all_x, -mul((n - i - 1), x[i]));
  }

  for (int i = 0; i < m; ++i) {
    all_y = add(all_y, mul(i, y[i]));
    all_y = add(all_y, -mul((m - i - 1), y[i]));
  }

  printf("%d\n", mul(all_x, all_y));

  return 0;
}

Measured memory_bytes: 1024
#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++)
typedef long long ll;

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i += 2){
        cout << s[i];
    }
    cout << endl;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  set<string> s;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    s.insert(S);
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 19272
#include <stdio.h>
int sum1,n,x;
void search(int sum,int count,int num){
    if(sum == x && count == 3)
        sum1++;
    if(sum >= x || count >= 3 || num >=n+1)
        return;
    search(sum+num,count+1,num+1);
    search(sum,count,num+1);
}
int main(void){
    for(;sum1=0,scanf("%d %d",&n,&x),n+x!=0;printf("%d\n",sum1))
        search(0,0,1);
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    
    int keta1 = n % 10;
    int keta2 = (n / 10) % 10;
    int keta3 = (n / 100) % 10;
    int keta4 = n / 1000;
    
    string result = "No";
    
    if(
        (keta1 == keta2 && keta2 == keta3) || 
        (keta2 == keta3 && keta3 == keta4))
    {
        result = "Yes";
    }
    cout << result << endl;
    
}


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

//using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main() {
    int n;
    std::cin >> n;

    int all = 0;
    std::vector<int> w(n);
    for(auto& wi : w){
        std::cin >> wi;
        all += wi;
    }

    int sum = 0;
    int res = INF;

    rep(i,n){
        sum += w[i];
        if(std::abs(sum - (all - sum)) <= res){
            res = std::abs(sum - (all - sum));
        }
    }
    std::cout << res << "\n";

    
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



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

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i,n) for (ll i = 0; i < (n); i++)
#define ru(a,b) (((a)+((b)-1)) / (b))   //切り上げ(a/b)
#define dump(x)  cout << #x << " = " << (x) << endl;

int main()
{
	ll n,k;
	cin >> n >> k;

	// nをkに近づける

	ll x = n;

	if (n == k) {
		cout << "0" << endl;
		return 0;
	}

	if (n < k) {
		x = n % k;
	}
	else
	{
		x = x % k;
	}

	if (x == 0) {
		cout << "0" << endl;
		return 0;
	}

	while (1) {
		ll xx = abs(k - x);
		if (xx >= x) break;
		x = xx;
	}

	cout << x << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

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

	int t = 1;
	while(t < N) t *= 2;
	if(t == N) {
		printf("No");
		return 0;
	}
	printf("Yes\n");
	for(int i = 1; i <= (N - 1) / 2; i++) {
		printf("%d %d\n%d 1\n1 %d\n%d %d\n", 2*i, 2*i+1, 2*i+1, 2*i+N, 2*i+N, 2*i+1+N);
	}
	printf("%d 2\n", N+1);
	if(N % 2 == 0) {
		int a = N & (-N);
		int b = N + 1 - a;
		printf("%d %d\n%d %d\n", N, a % 2 ? a : a + N, 2 * N, b % 2 ? b : b + N);
	}
	return 0;
}


Measured memory_bytes: 2304
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

h,w = [int(i) for i in readline().split()]
b = [readline().strip() for _ in range(h)]

INF = 10**9

dp0 = [[INF]*w for _ in range(h)]
#dp1 = [[INF]*w for _ in range(h)]

if b[-1][-1] == "#":
    dp0[-1][-1] = 1
#    dp0[-1][-1] = INF
else:
    dp0[-1][-1] = 0
#    dp1[-1][-1] = 0

for i in range(h-1,-1,-1):
    for j in range(w-1,-1,-1):
        if b[i][j] == "#":
            r = INF
            if i != h-1: r = min(r,dp0[i+1][j] + (1 if b[i+1][j]=="." else 0))
            if j != w-1: r = min(r,dp0[i][j+1] + (1 if b[i][j+1]=="." else 0))
            #dp1[i][j] = min(dp1[i][j],r)
            dp0[i][j] = min(dp0[i][j],r)
            
        else:
            r = INF
            if i != h-1: r = min(r,dp0[i+1][j])
            if j != w-1: r = min(r,dp0[i][j+1])
            dp0[i][j] = min(dp0[i][j],r)
            #dp1[i][j] = min(dp0[i][j],r)


#print(dp0)
#print(dp1)

print(dp0[0][0])
#print(dp0)



Measured memory_bytes: 3188
#include<stdio.h>

int main(void) {
char s[3];
scanf("%c%c%c", &s[0], &s[1], &s[2]);
int cnt = 0;
for (int i = 0; i < 3; i++) {
if (s[i] == '1') cnt++;
}

printf("%d", cnt);

 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main(){
  int n,k;cin>>n>>k;
  if(k==1)cout<<0<<endl;
  else{
    cout<<n-k<<endl;
  }
}

Measured memory_bytes: 256
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#endif

const double PI=3.1415926535897932384626433;
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
    cini(n);
    cins(s);

    int ans=0;
    set<char> p1;
    for(int i=0; i<n-2; i++) {
        if(p1.count(s[i]))
            continue;
        p1.insert(s[i]);

        set<char> p2;
        for(int j=i+1; j<n-1; j++) {
            if(p2.count(s[j]))
                continue;
            p2.insert(s[j]);

            set<char> p3;
            for(int k=j+1; k<n; k++) {
                if(p3.count(s[k]))
                    continue;
                p3.insert(s[k]);
                ans++;
            }
        }
    }

    cout<<ans<<endl;
}

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
        solve();
}



Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		double N = sc.nextDouble();
		double D = sc.nextDouble();
		
		// 1人が監視できる期の数
		double one = D*2+1;
		
		System.out.println((int)Math.ceil(N/one));
		
		sc.close();	
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int B[N-1];
  for(int i = 0; i < N-1; i++){
    cin >> B[i];
  }
  int sum = B[0];
  for(int i = 1; i < N-1; i++){
    sum+= min(B[i-1],B[i]);
  }
  sum+=B[N-2];
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    ll a, b;
    cin>>a>>b;
    if ((a + b) % 2 == 0) {
        cout<<(a+b)/2<<endl;
    } else {
        cout<<"IMPOSSIBLE"<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;

int n, m;
int h, t, q[N];
char S[N], T[N];

int main() {
	cin >> n;
	scanf("%s", S + 1);
	scanf("%s", T + 1);
	int flag = 1;
	for (int i = 1; i <= n; ++i) {
		if (S[i] != T[i]) flag = 0;
	}
	if (flag) return 0 * puts("0");
	int pos = n, ans = 0;
	h = 1, t = 0;
	for (int i = n; i >= 1; --i) {
		if (T[i] == T[i - 1]) continue;
		pos = min(pos, i);
		while (pos && T[i] != S[pos]) --pos;
		if (!pos) return 0 * puts("-1");
		while (h <= t && q[h] - (t - h + 1) + 1 > i) ++h;
		q[++t] = pos;
		if (i != pos) ans = max(ans, t - h + 1);
	}
	cout << ans + 1 << endl;
	return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
int tmpmin=1e9;
int main(int argc,char const* argv[])
{
  int n;
  cin >> n;
  for(int i=0;i<=100;i++)
    {
      for(int j=0;j<=100;j++)
	{
	  if((4*i+7*j)==n)
	    {
	      cout << "Yes" << endl;
	      return 0;
	    }
	}
    }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

class Program
{
    void Run()
    {
        var sc = new Scanner();
        int[] p = new int[3];
        for (int i = 0; i < 3; i++) p[i] = sc.NextInt();
        Array.Sort(p);
        Console.WriteLine(p[0] + p[1]);
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)

    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

ll memo[100100][100];
ll comb( int x, int y ){
	if( memo[x][y] ) return memo[x][y];
	if( y == 0 || y == x ) return memo[x][y] = 1;
	return memo[x][y] = (comb(x-1, y) + comb(x-1, y-1)) % MOD;
}

int main(){
	int n;
	ll m;
	cin >> n >> m;
	ll x = m;
	ll p = 2;
	ll ans = 1;
	while( p*p <= m ){
		int cnt = 0;
		while( x%p == 0 ){
			x /= p;
			++cnt;
		}
		if( cnt ){
			ans = ( ans * comb(n+cnt-1, cnt) ) % MOD;
		}
		++p;
	}
	if( x != 1 ) ans = ( ans * n ) % MOD;
	cout << ans << endl;
	return 0;
}

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

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) 0
#endif
#define pb push_back
#define mod 1000000007
#define endl '\n'
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = 200005;
int ar[NN];
int n, m, k;
int sum[5000][3];


integer main() {
    ios_base::sync_with_stdio(false);

    int t = 1;
//    cin >> t;
    while (t--) {
        cin >> n;
        string s;
        cin >> s;
        int g = 0;
        int b = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] == 'R') {
                sum[i][0] = 1;
                s[i] = 0;
            } else if (s[i] == 'B') {
                sum[i][1] = 1;
                s[i] = 1;
            } else {
                sum[i][2] = 1;
                s[i] = 2;
            }
            if (i) {
                sum[i][0] += sum[i - 1][0];
                sum[i][1] += sum[i - 1][1];
                sum[i][2] += sum[i - 1][2];
            }
        }
        int ans = 0;
        for (int i = 1; i < n-1; i++){
            if (s[i] == 2){
                ans += sum[i][0] * (sum[n-1][1] - sum[i][1]);
                ans += sum[i][1] * (sum[n-1][0] - sum[i][0]);
            } else if (s[i] == 1){
                ans += sum[i][0] * (sum[n-1][2] - sum[i][2]);
                ans += sum[i][2] * (sum[n-1][0] - sum[i][0]);
            } else {
                ans += sum[i][2] * (sum[n-1][1] - sum[i][1]);
                ans += sum[i][1] * (sum[n-1][2] - sum[i][2]);
            }
        }
        for (int i = 0; i < n; i++) {
            if (s[i] != 0) continue;
            int st = i - 1, en = i + 1;
            while (st >= 0 && en < n) {
                if (s[st] == 1 && s[en] == 2) ans--;
                else if (s[st] == 2 && s[en] == 1) ans--;
                st--;
                en++;
            }
        }
        for (int i = 0; i < n; i++) {
            if (s[i] != 1) continue;
            int st = i - 1, en = i + 1;
            while (st >= 0 && en < n) {
                if (s[st] == 0 && s[en] == 2) ans--;
                else if (s[st] == 2 && s[en] == 0) ans--;
                st--;
                en++;
            }
        }
        for (int i = 0; i < n; i++) {
            if (s[i] != 2) continue;
            int st = i - 1, en = i + 1;
            while (st >= 0 && en < n) {
                if (s[st] == 1 && s[en] == 0) ans--;
                else if (s[st] == 0 && s[en] == 1) ans--;
                st--;
                en++;
            }
        }
        cout << ans << endl;

    }

}



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

int binarysearch(int val, std::vector<int> &array, int left, int right) {
    if (right < left) {
        return 0;
    } else {
        int center = left + (right - left) / 2;
        if (array[center] > val)
            binarysearch(val, array, left, center - 1);
        else if (array[center] < val)
            binarysearch(val, array, center + 1, right);
        else
            return 1;
    }
}

int main(int argc, char const *argv[])
{
    int n;
    std::cin >> n;
    std::vector<int> s(n);
    for (int i = 0; i < n; i++) {
        std::cin >> s[i];
    }

    int q;
    std::cin >> q;
    std::vector<int> t(q);
    for (int i = 0; i < q; i++) {
        std::cin >> t[i];
    }

    int cnt = 0;
    int l = 0;
    int r = n;
    for (int i = 0; i < q; i++) {
        cnt += binarysearch(t[i], s, l, r);
    }

    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 1564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    ll a,b;
    cin>>a>>b;
    ll fa,fb;
    
    if(a==0 && b==0){
        cout<<0<<endl;
        return 0;
    }
    if(a==0 || a==1){
        if(b%4==0) fb=b;
        else if(b%4==1) fb=1;
        else if(b%4==2) fb=b+1;
        else fb=0;
        cout<<fb<<endl;
        return 0;
    }
    
    a=a-1;
    if(a%4==0) fa=a;
    else if(a%4==1) fa=1;
    else if(a%4==2) fa=a+1;
    else fa=0;
    if(b%4==0) fb=b;
    else if(b%4==1) fb=1;
    else if(b%4==2) fb=b+1;
    else fb=0;

    //cout<<fb<<" "<<fa<<endl;
    ll ans=fb^fa;
    cout<<ans<<endl;

}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    int ok = 1;
    rep(i, N) {
        int a;
        cin >> a;
        if((a % 2 == 0) && a % 3 != 0 && a % 5 != 0)
            ok = 0;
    }
    cout << (ok ? "APPROVED" : "DENIED") << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>

using namespace std;


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

  sort(a.begin(), a.end());
  m = 1;

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

}


Measured memory_bytes: 384
const int N = 400005;
const int LG = 21;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(N);
    __ufact.resize(N);
    __rev.resize(N);
    __rev[1] = 1;
    for (int i = 2; i < N; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < N; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    vector<ll> a(n);
    forn(i, n) cin >> a[i];
    int cn2 = 0, cn4 = 0;
    forn(i, n) if (a[i] % 4 == 0) cn4++; else if (a[i] % 2 == 0) cn2++;
    int cn1 = n - cn2 - cn4;
    if (cn2 == 1)
    {
        cn1++;
        cn2--;
    }
    if (cn4 >= cn1)
    {
        cout << "Yes\n";
    }
    else
    {
        if (cn2 == 0 && cn4 + 1 >= cn1)
        {
            cout << "Yes\n";
        }
        else
        {
            cout << "No\n";
        }
    }
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<int>v;
    int n,i,j,sum=0,x;
    cin>>n>>j;
    for(i=0; i<n; i++)
    {
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    for(i=0; i<j; i++)
        sum+=v[i];
    cout<<sum<<endl;
    v.clear();
    return 0;
}


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

using namespace std;

const int M = 1e9 + 7;

void add_self(int& a, int b) {
    a += b;
    if (a >= M) {
        a -= M;
    }
}

int main(int argc, char *argv[])
{
    string K;
    int D;
    cin >> K >> D;
    int len = K.size();
    vector<vector<int>> dp(D, vector<int>(2));
    dp[0][0] = 1;
    for (int where = 0; where < len; where++) {
        auto dp_new = vector<vector<int>>(D, vector<int>(2));
        int limit = K[where] - '0';
        for (int sum = 0; sum < D; sum++) {
            for (int digit = 0; digit < limit; digit++) {
                add_self(dp_new[(sum + digit) % D][1], dp[sum][1] + dp[sum][0]);
            }
            add_self(dp_new[(sum + limit) % D][0], dp[sum][0]);
            add_self(dp_new[(sum + limit) % D][1], dp[sum][1]);
            for (int digit = limit + 1; digit <= 9; digit++) {
                add_self(dp_new[(sum + digit) % D][1], dp[sum][1]);
            }
        }
        dp = dp_new;
    }
    int res = dp[0][0];
    add_self(res, dp[0][1]);
    res -= 1;
    if (res < 0) res += M;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin


def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out


def get_result(data):
    N, K = data[0]
    return len(Base_10_to_n(N, K))

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
 
void Main() {
  ll a[3];
  rep(i,3) R a[i];
  sort(a,a+3);
  pr(a[0]+a[1]);
}
 
int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

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

int main() {
  int a, b;
  cin >> a >> b;
  int d = a / b;
  int r = a % b;
  double f = (double)a / (double) b;
  cout << d << " " << r << " " << fixed << setprecision(5) << f << endl;
}


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

int main(){
  ll n,z,w,a[2010];
  cin>>n>>z>>w;
  fr(i,n) cin>>a[i];
  cout<<(n>1?max(abs(w-a[n-1]),abs(a[n-2]-a[n-1])):abs(w-a[0]))<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cstdio>

using namespace std;

int n;
int s,t;
const int INF=1000000000;

inline void setBit(int &s,int pos,int bit){
    if(bit)s|=(1<<pos);
    else s&=~(1<<pos);
}

class Sit{
public:
    int cost;
    int pos;
    int mask;
    Sit(int cost_,int pos_,int mask_){
        cost=cost_;
        pos=pos_;
        mask=mask_;
    }
    bool operator<(const Sit &s)const {
        return s.cost<this->cost;
    }
};

int d[16][1<<16];
priority_queue<Sit> que;
int bfs(){
    for(int j=0;j<n;j++)for(int k=0;k<(1<<n);k++)d[j][k]=INF;
    for(int i=0;i<n;i++){
        d[i][s]=0;
        que.push(Sit(0,i,s));
    }
    while(!que.empty()){
        Sit s=que.top();que.pop();
        if(d[s.pos][s.mask]<s.cost)continue;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                // ·ÅÉèÏÝ
                if((!(((s.mask>>i)&1)^((t>>i)&1)))||(!(((s.mask>>j)&1)^((t>>j)&1)))){
                    continue;
                }
                //  éêÖÚ®µÄA»ÌêÆð·
                int cost=abs(i-s.pos)+abs(j-i);
                int nmask=s.mask;
                int a=(nmask>>i)&1;
                int b=(nmask>>j)&1;
                setBit(nmask,i,b);
                setBit(nmask,j,a);
                if(d[j][nmask]>d[s.pos][s.mask]+cost){
                    d[j][nmask]=d[s.pos][s.mask]+cost;
                    que.push(Sit(d[j][nmask],j,nmask));
                }
            }
        }
    }
    int res=INF;
    for(int i=0;i<n;i++)res=min(res,d[i][t]);
    return res;
}
//int solve(){
//    return bfs();
//    //for(int tern=n;tern>=0;tern--){
//    //    int nxt=tern%2;
//    //    int cur=(tern+1)%2;
//    //    for(int pos=0;pos<n;pos++){
//    //        for(int sit=0;sit<(1<<n);sit++){
//    //            int res=INF;
//    //            if(tern==n){
//    //                if(sit==t)res=0;
//    //            }
//    //            else{
//    //                for(int to=0;to<n;to++){
//    //                    // ®©·¾¯
//    //                    res=min(res,dp[cur][to][sit]+abs(to-pos));
//    //                    // trade
//    //                    int cost=abs(to-pos);
//    //                    int nsit=sit;
//    //                    int a=(sit>>pos)&1;
//    //                    int b=(sit>>to)&1;
//    //                    setBit(nsit,pos,b);
//    //                    setBit(nsit,to,a);
//    //                    res=min(res,dp[cur][to][nsit]+cost);
//    //                }
//    //            }
//    //            dp[nxt][pos][sit]=res;
//    //        }
//    //    }
//    //}
//    //int res=INF;
//    //for(int i=0;i<n;i++)res=min(res,dp[0][i][s]);
//    //return res;
//}
int main(){

    string ss,tt;
    while(cin>>n&&n){
        s=t=0;
        cin>>ss>>tt;
        for(int i=0;i<n;i++)if(ss[i]=='B')s|=(1<<i);
        for(int i=0;i<n;i++)if(tt[i]=='B')t|=(1<<i);
        printf("%d\n",bfs());
    }

    return 0;
}

Measured memory_bytes: 0
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	int n, u, v, m;
	cin >> n >> u >> v >> m;
	
	int tmp;
	map<int, pii> um, nm;
	REP(i, n) {
		REP(j, n) {
			cin >> tmp;
			um[tmp] = make_pair(i+1, j+1);
		}
	}
	REP(i, n) {
		REP(j, n) {
			cin >> tmp;
			nm[tmp] = make_pair(i+1, j+1);
		}
	}

	vi ux(n, n), uy(n, n), uc(2, n);
	vi nx(n, n), ny(n, n), nc(2, n);
	bool uw = false, nw = false;
	REP(i, m) {
		cin >> tmp;
		if(um[tmp].first) {
			if(--ux[um[tmp].first-1] == 0) {
				--u;
			}
			if(--uy[um[tmp].second-1] == 0) {
				--u;
			}
			if(um[tmp].first == um[tmp].second) {
				if(--uc[0] == 0) {
					--u;
				}
			}
			if(um[tmp].first+um[tmp].second == n+1) {
				if(--uc[1] == 0) {
					--u;
				}
			}
		}
		if(u <= 0) {
			uw = true;
			if(n == 1 && u != -3) {
				uw = false;
			}
		}

		if(nm[tmp].first) {
			if(--nx[nm[tmp].first-1] == 0) {
				--v;
			}
			if(--ny[nm[tmp].second-1] == 0) {
				--v;
			}
			if(nm[tmp].first == nm[tmp].second) {
				if(--nc[0] == 0) {
					--v;
				}
			}
			if(nm[tmp].first+nm[tmp].second == n+1) {
				if(--nc[1] == 0) {
					--v;
				}
			}
		}
		if(v <= 0) {
			nw = true;
			if(n == 1 && v != -3) {
				nw = false;
			}
		}

		if(uw & nw) {
			cout << "DRAW" << endl;
			return 0;
		}
		if(uw) {
			cout << "USAGI" << endl;
			return 0;
		}
		if(nw) {
			cout << "NEKO" << endl;
			return 0;
		}
	}

	cout << "DRAW" << endl;
	return 0;
}

Measured memory_bytes: 20672
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};
/* -- template -- */
const int MAX_H = 10001;

int dp[MAX_H]; // dp[i] : HP i以上減らすための最小MP

int main() {
    int H, N; cin >> H >> N;
    int A[N], B[N];
    rep(i, N) cin >> A[i] >> B[i];
    rep(i, H + 1)dp[i] = INF;
    dp[0] = 0;
    rep(i, H) {
        rep(j, N) {
            if(i + 1 >= A[j])
                dp[i + 1] = min(dp[i + 1], dp[i + 1 - A[j]] + B[j]);
            else
                dp[i + 1] = min(dp[i + 1], B[j]);
        }
    }
    cout << dp[H] << endl;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = list(map(int, list(readline().rstrip().decode())[::-1]))
a = 0
b = 10000
for x in n:
    memo = min(a + x, b + x)
    b = min(a + 11 - x, b + 9 - x)
    a = memo
print(min(a, b))


Measured memory_bytes: 20448
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}

class UnionFind {
public:
  vector<int> _par;
  vector<int> _size;
  UnionFind(int sz_) : _par(sz_), _size(sz_, 1LL) {
    for (int i = 0; i < sz_; i++) _par[i] += i;
  }
  void init(int sz_) {
    _par.resize(sz_);
    _size.assign(sz_, 1LL);
    for (int i = 0; i < sz_; i++) _par[i] = i;
  }
  int root(int x) {
    while (_par[x] != x) {
      x = _par[x] = _par[_par[x]];
    }
    return x;
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (_size[x] < _size[y]) swap(x, y);
    _size[x] += _size[y];
    _par[y] = x;
    return true;
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return _size[root(x)];
  }
};

class DLamp {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    rep(i, H) cin >> S[i];
    vector<UnionFind> x;
    vector<UnionFind> y;
    rep(i, H) {
      x.emplace_back(UnionFind(W));
      x[i].init(W);
      rep(j, W - 1) {
        if (S[i][j] == '.' and S[i][j + 1] == '.') x[i].unite(j, j + 1);
      }
    }
    rep(i, W) {
      y.emplace_back(UnionFind(H));
      y[i].init(H);
      rep(j, H - 1) {
        if (S[j][i] == '.' and S[j + 1][i] == '.') y[i].unite(j, j + 1);
      }
    }
    int ans = 0;
    rep(i, H) {
      rep(j, W) {
        if (S[i][j] == '.') ans = max(ans, x[i].size(j) + y[j].size(i) - 1);
      }
    }
    cout << ans << endl;
  }
};


signed main() {
  DLamp solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

int main(){
  int n;
  cin>>n;
  char a[n],b[n];
  for (int i=0;i<n;i++) cin>>a[i];
  for (int i=0;i<n;i++) cin>>b[i];
  for (int i=0;i<n;i++) cout<<a[i]<<b[i];
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N; cin >> N;
  INTV P(N);
  REP(i, N){
    cin >> P[i]; P[i]--;
  }
  INTV A(N), B(N);
  REP(i, N){
    A[i] = 30000*(i+1);
    B[i] = 30000*(N-i);
  }
  REP(i, N){
    int idx = P[i];
    A[idx] += i;
  }
  for(auto itr : A)
    cout << itr << ' ';
  cout << endl;
  for(auto itr : B)
    cout << itr << ' ';
  cout << endl;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(int argc, char* argv[]){
    int n,b,f,r,v;
    int univ[4][3][10]={0};
    int i,j,k;

    scanf("%d",&n);
    for(i = 0; i<n; i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        univ[b-1][f-1][r-1] += v;
    }

    for(i=0; i<4; i++){
        for(j=0; j<3; j++){
            for(k=0; k<10; k++){
                printf(" %d",univ[i][j][k]);
                if(k==9) printf("\n");
                if(j==2 && k==9 & i<3) printf("####################\n");
            }
        }
    }
    
}


Measured memory_bytes: 2056
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define P_B push_back
#define E_B emplace_back
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  ll A, B, C, D;

  cin >> A >> B >> C >> D;

  if((C-1)/B <= (A-1)/D) cout << "Yes" << endl;
  else cout << "No" << endl;




  return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N, M, P;
  cin >> N >> M >> P;
  i64 a, b, c;
  vvi ABC(M, vi(3));
  rep(i, M){
    cin >> a >> b >> c;
    a--;
    b--;
    c -= P;
    ABC[i] = {a, b, c};
  }

  vvi G_to(N), G_from(N);
  for(auto &p : ABC) {
    G_from[p[0]].emplace_back(p[1]);
    G_to[p[1]].emplace_back(p[0]);
  }

  queue<i64> Q;
  Q.emplace(0);
  v(bool) visited(N, false);
  visited[0] = true;
  while(!Q.empty()){
    i64 crt = Q.front();
    Q.pop();
    for(auto &p : G_from[crt]) {
      if(visited[p]) continue;
      visited[p] = true;
      Q.emplace(p);
    }
  }

  Q.emplace(N-1);
  v(bool) reach(N,false);
  reach[N-1] = true;
  while(!Q.empty()){
    i64 crt = Q.front();
    Q.pop();
    for(auto &p : G_to[crt]) {
      if(reach[p]) continue;
      reach[p] = true;
      Q.emplace(p);
    }
  }

  vvi edges;
  for(auto &p : ABC){
    if(visited[p[0]] and reach[p[1]]) edges.emplace_back(p);
  }

  vi score(N, -1 * INF);
  score[0] = 0;

  rep(i, N){
    for(auto &p : edges) {
      if(score[p[1]] < score[p[0]] + p[2]){
        score[p[1]] = score[p[0]] + p[2];
        if(i == N - 1){
          cout << -1 << "\n";
          return;
        }
      }
    }
  }

  if(score[N-1]<0) score[N-1] = 0;

  cout << score[N-1] << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

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

int main() {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    int c=1;
    for (int i=1; i<int(s.size()); i++) {
        if (s.at(i)==s.at(i-1)) c+=1;
        else {
            if (c%2!=0) {
                cout << "No\n";
                return 0;
            }
            c=1;
        }
    }
    if (c%2!=0) cout << "No\n";
    else cout << "Yes\n";
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << c-min(a-b,c) << "\n";
    return 0;
}

Measured memory_bytes: 256
#import itertools
#import bisect
import math

N = int(input())
L = [i for i in range((N+2)//2+2)]
num = math.floor(pow(2*(N-1),0.5))
    
for i in range(num,len(L)):
    if N == i*(i+1)//2:
        index = i
        Max = i*(i+1)//2
        break
    elif N < i*(i+1)//2:
        index = i
        Max = i*(i+1)//2
        break
Left = Max - N 
#print(num,Left,Max,index,L)
#acu = list(itertools.accumulate([i for i in range((N+1)//2+2)]))
#print(acu) 
#index = bisect.bisect_left(acu,N)
#print(index)
 
#if acu[index] == N:
#    Max = acu[index-1]
#else:
#    Max = acu[index]
#Left = Max - N

for i in range(1,index+1):
    if i == Left:
        continue
    print(i)

Measured memory_bytes: 201240
import copy
N, M, X = map(int, input().split())


C =[]
A = {}

for i in range(N):
    ipt = list(map(int, input().split()))
    C.append(ipt[0])
    A[i] = ipt[1:]

bestscore = 99999999999
def rec(n, score, money):
    global bestscore
    if n==N: return
    s = copy.deepcopy(score)
    rec(n+1, s, money)

    money += C[n]
    for i in range(M):
        score[i] += A[n][i]
    

    for i in range(M):
        if score[i] < X:
            s = copy.deepcopy(score)
            rec(n+1, s, money)
            return
    bestscore = min(bestscore, money)

score = [0 for i in range(M)]

rec(0, score, 0)
if bestscore == 99999999999:
    print(-1)
else:
    print(bestscore)

Measured memory_bytes: 9120