akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main( String[] args ) {
		try {
			BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
			String tmp = br.readLine();
			int numbersSize = Integer.parseInt(tmp);

			String tmp2 = br.readLine();
			String[] plainNumber = tmp2.split(" ");
			int[] Numbers = new int[plainNumber.length];

			for( int i = 0; i < plainNumber.length; i++ ) {
				Numbers[i] = Integer.parseInt(plainNumber[i]);
			}

			if( numbersSize <= 100 ) {
				for(int i = ( Numbers.length - 1 ); i > 0; i--) {
					System.out.print( Numbers[i] + " ");
				}
				System.out.println( Numbers[0] );
			}

		} catch( IOException e ) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24340
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define mem1(x)  memset(x,1,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return pow(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1));
    else {
        ll k=po(x,n/2);
        return (k*k);
    }
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
 
const ll N = 100005;
ll a[N],dp[N];

int32_t main(){
    IOS;
    ll i,j,k,n,m,p;
    cin >> n >> k;
    fori2(n) cin >> a[i];
    for(i = 2 ; i <= n  ; i++){
        // dp[i] = dp[i-1] + abs(a[i]-a[i-1]);
        // if(i>2){
        //     dp[i] = min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
        // }
        dp[i] = 1e12;
        for(j = i-1 ; j >= max((ll)1,i-k) ; j--){
            dp[i] = min(dp[i],dp[j] + abs(a[i]-a[j]));
        }
    }
    cout << dp[n] <<"\n";


} 

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

bool win(int my, int op){
    return (my+1)%3 == op;
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; cin >> N >> K;
    int R, S, P; cin >> R >> S >> P;
    int score[3] = {R,S,P};
    string T; cin >> T;
    int dp[N+1][3]; //グー:0, チョキ:1, パー:2
    map<char, int> mp; mp['r'] = 0; mp['s'] = 1; mp['p'] = 2;
    rep(i, N+1) rep(j, 3) dp[i][j] = 0;
    for(int i = 0; i < K; i++){
        int op = mp[T[i]];
        rep(j, 3){
            if(win(j, op)) dp[i][j] = max(dp[i][j], score[j]);
        }
    }
    for(int i = 0; i < K; i++){
        for(int j = i; j < N; j+=K){
            int to = j+K;
            if(to >= N) break;
            int op = mp[T[to]];
            rep(k, 3){
                rep(l, 3){
                    if(k == l) continue;
                    if(win(l, op)) dp[to][l] = max(dp[to][l], dp[j][k] + score[l]);
                    else dp[to][l] = max(dp[to][l], dp[j][k]);
                }
            }
        }
    }
    int ans = 0;
    for(int i = N-K; i < N; i++){
        int temp = 0;
        rep(j, 3) temp = max(temp, dp[i][j]);
        ans += temp;
    }
    cout << ans << endl;
    /*
    rep(i, N){
        rep(j, 3){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */
    return 0;
}

Measured memory_bytes: 4920
#include<iostream>

int main() {
	int x1,y1,x2,y2,x3,y3,x4,y4;
	std::cin >> x1>>y1>>x2>>y2;

	x3 = x2 - (y2 - y1);
	y3 = y2 + (x2 - x1);

	x4 = x3 - (x2 - x1);

	//std::cout << y3 << y2 << y1 << std::endl;
	y4 = y3 - (y2 - y1);

	std::cout <<x3<<" "<<y3<<" "<<x4<<" "<<y4<< std::endl;
	return 0;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}



int main(){
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;

    if(a==0){
        cout <<1 << endl;
    }else if(b==0){
        cout << 2 << endl;
    }else if(c==0){
        cout << 3 << endl;
    }else if(d==0){
        cout << 4 << endl;
    }else{
        cout << 5 << endl;
    }
}


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

void Main() {
    int n, q, x;
    string s;
    cin >> n >> q;
    queue<pair<int, string>> jobs;
    vector<pair<string, int>> answers;
    for (int i = 0; i < n; i++) {
        cin >> s >> x;
        jobs.push({x, s});
    }
    int ans = 0;
    pair<int, string> xs;
    while (!jobs.empty()) {
        xs = jobs.front();
        jobs.pop();
        if (xs.first <= q) {
            ans += xs.first;
            answers.push_back({xs.second, ans});
        } else {
            ans += q;
            xs.first -= q;
            jobs.push(xs);
        }
    }
    for (auto &e : answers) {
        cout << e.first << " " << e.second << "\n";
    }
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 7056
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_contest_with_drinks_easy(void) {
	int n, m;
	int sum = 0;
	int t[110];
	int p[110];
	int x[110];
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> t[i];
		sum += t[i];
	}
	cin >> m;
	for (int i = 1; i <= m; i++) {
		cin >> p[i] >> x[i];
	}

	int sub = 0;
	for (int i = 1; i <= m; i++) {
		sub = t[p[i]] - x[i];
		cout << sum - sub << endl;
	}
}

int main()
{
	b_contest_with_drinks_easy();
    return 0;
}

Measured memory_bytes: 3624
object Main {
  def main(args: Array[String]): Unit = {
    io.Source.stdin.getLines foreach (n => println(pi(n.toInt)))
  }
  val primes: IndexedSeq[Int] = prime_sieve(100000)
  val pi_cache: collection.mutable.Map[Int, Int] = collection.mutable.Map.empty
  val phi_cache: collection.mutable.Map[(Int, Int), Int] = collection.mutable.Map.empty

  def prime_sieve(x: Int): IndexedSeq[Int] = {
    val n = x - x % 6 + 6
    val correction = if (x % 6 > 1) 1 else 2
    val sieve = Array.fill(n/3)(true)
    for (i <- 1 to (Math.sqrt(n) / 3).toInt if sieve(i)) {
      val k = (3 * i + 1) | 1
      for (j <- (k * k) / 3 until sieve.length by 2*k) sieve(j) = false
      for (j <- (k*(k-2*(i&1)+4))/3 until sieve.length by 2*k) sieve(j) = false
    }
    2 +: 3 +: (for (i <- 1 until n / 3 - correction if sieve(i)) yield (3*i+1)|1)
  }
  def bisect(n: Int): Int = {
    def loop(left: Int, right: Int): Int = {
      val mid = (left + right) / 2
      if (primes(mid) <= n && n < primes(mid+1)) mid+1
      else if (n < primes(mid)) loop(left, mid)
      else loop(mid+1, right)
    }
    if (n < primes.head) 0
    else if (n >= primes.last) primes.length
    else loop(0, primes.length)
  }
  def pi(x: Int): Int =
    pi_cache.getOrElseUpdate(x,
      if (x <= primes.last) bisect(x)
      else {
        val a = pi(Math.sqrt(Math.sqrt(x)).toInt)
        val b = pi(Math.sqrt(x).toInt)
        val c = pi(Math.cbrt(x).toInt)
        var result = phi(x, a) + ((b + a - 2) * (b - a + 1)) / 2
        for (i <- a + 1 to b) {
          val w = x / primes(i - 1)
          val b_i = pi(Math.sqrt(w).toInt)
          result -= pi(w)
          if (i <= c)
            for (j <- i to b_i)
              result = result - pi(w / primes(j - 1)) + j - 1
        }
        result
      }
    )
  def phi(x: Int, a:Int): Int =
    phi_cache.getOrElseUpdate(
      (x,a),
      {
        if (a == 1) (x + 1) / 2
        else phi(x, a - 1) - phi(x / primes(a - 1), a - 1)
      }
    )
}

Measured memory_bytes: 46220
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
    int n,k,q;
    cin >> n >> k >> q;

    vector<int> a(q);
    for (int i=0; i<q; i++) {
        cin >> a[i];
    }
    
    vector<int> player(n);
    for (int i=0; i<n; i++) {
        player[i] = 0;
    }

    for (int i=0; i<q; i++) {
        int winner = a[i];
        player[winner-1] += 1;
        // for (int j=0; j<n; j++) {
        //     if (j != winner-1) player[j] -= 1;
        // }
    }

    for (int i=0; i<n; i++) {
        if (player[i] <= q-k) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }

    return 0;
}

// https://atcoder.jp/contests/abc141/tasks

// 3 3 3 3 3 3
// 0 0 0 0 0 0



Measured memory_bytes: 1408
import sys
input=sys.stdin.readline
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
for i in range(y):
    print('U',end='')
for i in range(x):
    print('R',end='')
for i in range(y):
    print('D',end='')
for i in range(x):
    print('L',end='')
print('L',end='')
for i in range(y+1):
    print('U',end='')
for i in range(x+1):
    print('R',end='')
print('D',end='')
print('R',end='')
for i in range(y+1):
    print('D',end='')
for i in range(x+1):
    print('L',end='')
print('U')
            



Measured memory_bytes: 51820
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define 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() {
    int n;
    string s;
    cin>>n>>s;

    int ans=0;
    for(int i=0;i<=999;i++){
        string t=to_string(i);
        int m=t.size();
        if(m==1) t="00"+t;
        else if(m==2) t='0'+t;
        int ind=0;
        bool ok=false;
        rep(j,n){
            if(s[j]==t[ind]) ind++;
            if(ind==3) ok=true;
        }
        if(ok) ans++;
    }

    cout<<ans<<endl;
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

ll N;
ll h[200000];
vector<ll> dp(200000, 1e10);

signed main() {
  cin >> N;
  rep(i, N)
    cin >> h[i];
  dp[0] = 0;
  rep(i, N) {
    ll j = i+1;
    if (j<N) chmin(dp[j], dp[i] + abs(h[i]-h[j]));
    j = i+2;
    if (j<N) chmin(dp[j], dp[i] + abs(h[i]-h[j]));
  }
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 300004
#define INF 1e9+7

using namespace std;

ll n,ans=1,ar[N];
ll dp[N][3];
ll mod=1e9+7;

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

    cin >> n;

    rep(i,0,n)
    {
        cin >> ar[i];
    }

    ll blue = 0;
    ll red = 0;
    ll green = 0;

    // always blue >= red >= green XBTG

    rep(i,0,n)
    {
        if(ar[i] == blue)
        {
            if(blue == red)
            {
                if(blue == green)
                    ans = (ans*3)%mod;
                else
                    ans = (ans*2)%mod;
            }

            blue++;
        }
        else if(ar[i] == red)
        {
            if(red==green)
            {
                ans=(ans*2)%mod;
            }

            red++;
        }
        else if(ar[i]==green)
        {
            green++;
        }
        else
            ans = 0;
    }

    cout << ans;

    return 0;
}




Measured memory_bytes: 2304
#include <stdio.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
int dp[1001][1001] = {};

int getLCS(string X, string Y)
{
    for (int i = 1; i <= X.size(); i++)
    {
        for (int j = 1; j <= Y.size(); j++)
        {
            dp[i][j] = X[i - 1] == Y[j - 1] ? dp[i - 1][j - 1] + 1 : max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    return dp[X.size()][Y.size()];
}

int main()
{
    int q;
    string X, Y;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        cin >> X >> Y;
        cout << getLCS(X, Y) << "\n";
    }
    return 0;
}


Measured memory_bytes: 6936
#include <iostream>
#include <cstdlib>
#define MAX 50
using namespace std;

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

int main(){
  int n;
  cin >> n;
  fib(n);
  return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    int st,e;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='A'){
            st=i;
            break;            
        }
    }
    for(int i=s.length();i>=0;i--){
        if(s[i]=='Z'){
            e=i;
            break;
        }
    }
    cout<<e-st+1<<endl;
}

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

using namespace std;

#define forn(i, s, f) for(int i = (s); i <= (f); ++i)
#define for1(i, f, s) for(int i = (f); i >= (s); --i)
#define fora(i, x) for (auto i : x)
#define show(x) cout << #x << " = " << x << " ";
#define skip continue;
#define pb push_back
#define _1 first
#define _2 second

typedef long long ll;

const int N3 = 1e3 + 5;
const int N4 = 1e4 + 5;
const int N5 = 1e5 + 5;
const int N6 = 1e6 + 5;
const int N7 = 1e7 + 5;
const int N8 = 1e8 + 5;
const int N9 = 1e9 + 5;

int n, ans;

int a[N5], can[N5];

ll now[N5];

int main()
{
    cin >> n;
    forn (i, 1, n)
    {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    forn (i, 1, n)
    {
        now[i] += a[i] + now[i - 1];
    }
    for1 (i, n, 1)
    {
        if (i == n)
        {
            can[i] = 1;
            ++ans;
        }
        else
        {
            if (now[i] * 2 >= a[i + 1] && can[i + 1])
                can[i] = 1, ++ans;
        }
    }
    cout << ans;
}


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

int main(){
  int a,b;
  //string a, b, c, d;
  cin >> a >> b;// >> c >> d;
  //cin >> s;
  if(a<9&&b<9)cout << "Yay!" << endl;
  //else if(abs(a-b)<=d&&abs(b-c)<=d)cout << "Yes" << endl;
  else cout << ":(" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int n, m;  cin >> n >> m;
	if(n == m)  cout << "Yes" << endl;
	else        cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    val t = readLine()!!.toInt()

    repeat(t) {
        val (n, m, a, b) = readLine()!!.split(" ").map { it.toLong() }
        println(floorSum(n, m, a, b))
    }
}

private fun floorSum(n: Long, m: Long, a: Long, b: Long): Long {
    var ans = 0L
    var aa = a
    var bb = b

    if (aa >= m) {
        ans += (n - 1) * n * (aa / m) / 2
        aa %= m
    }
    if (bb >= m) {
        ans += n * (bb / m)
        bb %= m
    }

    var yMax = (aa * n + bb) / m
    var xMax = (yMax * m - bb)

    if (yMax == 0L) return ans

    ans += (n - (xMax + aa - 1) / aa) * yMax
    ans += floorSum(yMax, aa, m, (aa - xMax % aa) % aa)

    return ans
}

Measured memory_bytes: 60864
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 2e5;
string s;
int c[N], n;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> s;
  int a = 0;
  FOR(i, 0, n){
    if(s[i]=='#') a++;
    c[i] = a;
  }
  a = 0;
  int ans = IINF;
  FORR(i, n-1, 1){
    if(s[i]=='.') a++;
    mins(ans, a+c[i-1]);
  }
  mins(ans, a);
  mins(ans, c[n-1]);
  cout << ans << endl;
}

Measured memory_bytes: 1428
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

template<typename T, T mod, T base>
struct RollingHash {
    vector<T> hash, pow;

    RollingHash(const string &s){
        int n=s.size();
        hash.assign(n+1,0);
        pow.assign(n+1,1);
        for(int i=0; i<n; i++){
            hash[i+1] = (hash[i]*base+s[i])%mod;
            pow[i+1]=pow[i]*base%mod;
        }
    }

    T get(int l,int r){
        T res= ((hash[r] - hash[l]*pow[r-l]) % mod + mod) % mod;
        return res;
    }

    T concat(T h1, T h2, int h2len) {
        return (h1*pow[h2len] + h2) % mod;
    }

    int LCP(const RollingHash<T, mod, base> &b, int l1, int r1, int l2, int r2) {
        int len = min(r1 - l1, r2 - l2);
        int low = -1, high = len + 1;
        while(high-low > 1) {
        int mid = (low + high) / 2;
        if(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
        else high = mid;
        }
        return (low);
    }
};

using RH = RollingHash<LL, (LL)1e9+97, 10009>;

int main(){
    fastcin();

    string t, p;
    cin >> t >> p;
    RH rh1(t), rh2(p);
    for(int i=0; i+p.size()<=t.size(); i++){
        if(rh1.get(i, i + p.size()) == rh2.get(0, p.size())) {
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 19676
import numpy as np

N, W = map(int, input().split())
pairs = list(tuple(map(int, input().split())) for _ in range(N))

dp = np.zeros((N+1, W+1), np.int64)

for (i, (w, v)) in enumerate(pairs):
    dp[i+1] = dp[i]
    dp[i+1, w:] = np.maximum(dp[i+1, w:], dp[i, :W-w+1] + v)

print(np.amax(dp[N]))


Measured memory_bytes: 92324
def solve():
    n = int(input())
    xu = [list(input().split()) for _ in range(n)]
    total = 0
    for x, u in xu:
        if u == "BTC":
            total += float(x) * 380000
        else:
            total += float(x)
    return total


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


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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MAXN 10005
#define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii> > dij;

int N;

int A[100005];

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

	cin >> N;

	for(int i = 0; i < N; i++){
		cin >> A[i];
	}

	sort(A, A+N);

	int mid = N/2;

	int ABC = A[(N/2)-1];
	int ARC = A[N/2];
 
	int ans = ARC - ABC;

	cout << ans << "\n";

	return 0;		
}

Measured memory_bytes: 640
// Problem : E - Hopscotch Addict
// Contest : AtCoder - AtCoder Beginner Contest 132
// URL : https://atcoder.jp/contests/abc132/tasks/abc132_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vlli vector<int>
#define slli set<int>
#define mlli map<int,int>
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fint fast;test
#define SI(a,n) int a[n];FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 1000000007
using namespace std;
map<pair<int,int>,bool>edg;
vector<vector<int>>adj;
vector<bool>vis;
vector<int>temp;
map<pair<int,int>,bool>dp;
void go(int node,int dis)
{
	dp[{node,dis}]=true;
	if(dis==3)
	{
		if(vis[node])return ;
		vis[node]=true;
		temp.pb(node);
		return ;
	}
	for(auto child:adj[node])
	{
		if(dp[{child,dis+1}])continue;
		else dp[{child,dis+1}]=true,go(child,dis+1);
	}
}
void solve(){
	int n,m;
	cin>>n>>m;
	adj.resize(n+1,vector<int>());
	vis.resize(n+1,false);
	FOR(i,m)
	{
		int u,v;
		cin>>u>>v;
		edg[{u,v}]=false;
		adj[u].pb(v);
	}
	int S,T;
	cin>>S>>T;
	queue<pair<int,int>>q;
	q.push({S,0});
	vis[S]=true;
	while(q.size())
	{
		auto Top=q.front();
		q.pop();
		int node=Top.ft,dis=Top.se;
		if(node==T)
		{
			cout<<(dis);
			return ;
		}
		temp.clear();
		go(node,0);
		for(auto child:temp)
		{
			// cerr<<child<<endl;
			q.push({child,dis+1});
		}
	}
	cout<<-1;
	return;	
}


int32_t main() {
    // fint{
    	fast;
    	solve();
    // }
    return 0;
}

Measured memory_bytes: 39884
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int N, K, p[1050];
vector<int> V;

int main(void) {

	cin >> N >> K;
	for (int i = 1; i <= N; i++) {
		cin >> p[i];
		V.push_back(p[i]);
	}
	sort(V.begin(), V.end());

	int ans = 0;

	for (int i = 0; i < K; i++) {
		ans += V[i];
	}

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

Measured memory_bytes: 3648
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ub              upper_bound
#define lb              lower_bound
#define isrt            insert
#define clr             clear
#define rsz             resize
#define ff              first
#define ss              second
#define lli             long long int
#define pb              push_back
#define pf              push_front
#define mkp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<int>
#define mii             map<lli,lli>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define INF             1e9
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define endl            "\n"


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

lli maxm(lli a, lli b)
{
    return (a >= b ? a : b);
}


lli minm(lli a, lli b)
{
    return (a <= b ? a : b);
}

lli power(lli x, lli y, lli p)
{
    lli res = 1;

    x = x % p;
    if (x == 0)
        return 0;

    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;


        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

lli nCrmodp(lli n, lli r, lli p)
{
    if (r == 0)
        return 1;
    if (r == 1)
        return n;


    lli pro = 1, k = n;
    while (k > r)
    {
        pro *= k;
        pro %= p;
        --k;
    }

    k = 2;
    while (k <= (n - r))
    {
        pro *= power(k, (p - 2), p);
        pro %= p;
        ++k;
    }

    return pro;
}


string num_str(lli n, lli k)
{
    string str = "";
    lli x = n;
    while (x != 0)
    {
        string s = to_string(x % k);
        str = s + str;
        x /= k;
    }

    return str;
}


lli first_big(lli n, lli k, lli arr[])
{
    lli l = 0;
    lli r = n - 1;

    lli leftGreater = n;

    while (l <= r) {
        lli m = l + (r - l) / 2;

        if (arr[m] > k) {
            leftGreater = m;
            r = m - 1;
        }

        else
            l = m + 1;
    }

    return leftGreater;
}

void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main()
{
    c_p_c();

    int n;
    cin >> n;

    n %= 1000;
    if (n != 0)
        n = (1000 - n);
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for(int i=1; i<50000; i++) {
    if(floor(i*1.08)==n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

int main()
{
    int n, ans = 0;
    cin >> n;
    int y[15][15];
    for (int i = 0; i < 15; i++)
    {
        for (int j = 0; j < 15; j++)
        {
            y[i][j] = -1;
        }
    }
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        for (int j = 0; j < a; j++)
        {
            int x;
            cin >> x;
            x--;
            cin >> y[i][x];
        }
    }

    for (int i = 0; i < 1 << n; i++)
    {
        vector<int> d(n, 0);
        for (int j = 0; j < n; j++)
        {
            if (i >> j & 1 == 1)
            {
                d[j] = 1;
            }
        }

        bool f = true;
        for (int j = 0; j < n; j++)
        {
            if (d[j] == 1)
            {
                for (int m = 0; m < n; m++)
                {
                    if (y[j][m] == -1)
                    {
                        continue;
                    }
                    if (y[j][m] != d[m])
                    {
                        f = false;
                    }
                }
            }
        }

        if (f)
        {
            int count = 0;
            for (int j = 0; j < n; j++)
            {
                if (d[j] == 1)
                {
                    count++;
                }
            }
            ans = max(ans, count);
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  string a[100];
  for (int i = 0; i < H; i++) cin >> a[i];

  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      if (i == 0 || i == H + 1 || j == 0 || j == W + 1) cout << "#";
      else cout << a[i - 1][j - 1];
    }

    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
using namespace std;

#define prec(i) cout << fixed << setprecision(i)

void outPut_YN(bool isYes) {
	if(isYes)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

const long long MOD = 1000000007;

long long fact(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum *= i;

	return sum;
}

long long fact_mod(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum = (sum * i) % MOD;

	return sum;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

long long pow_mod(int a, int b) {
	long long ans = 1;
	for (int i = 0; i < b; i++)
		ans = (ans * a) % MOD;

	return ans;
}

long long powll(long long a, long long  b) {
	long long ans = 1;
	for (long long i = 0; i < b; i++)
		ans = ans * a;

	return ans;
}

long long modinv(long long a) {

	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;

	return u;
}

long long _gcd(long long a, long long b)
{
	if (a < b)
		swap(a, b);

	if (a % b == 0)
		return b;
	else
		return _gcd(b, a % b);
}

long long _lcm(long long a, long long b)
{
	return (((a * b) % MOD) * modinv(_gcd(a, b))) % MOD;
}

int main()
{
	long long a, b, lcm, sum = 0;
	string s;

	cin >> s;

	for(int i = 0; i < s.size(); i++)
		cout << "x";

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
const ll MOD = 998244353;
const ll INF = 1e18;
using namespace std;

vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define deb(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define deb(...) 42
#endif

pair<int, int> f(string &s){
    int l = 0, tot = 0;
    for(auto ch : s){
        if(ch == '(')   tot++;
        else    tot--;
        l = min(l, tot);
    }
    return {l, tot};
}

main(){    
    #ifdef XOX
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\Input.txt", "r", stdin);
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\OPT.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    cin >> n;
    string s;
    int lo[n], tot[n];
    int t = 0;

    for(int i = 0; i < n; i++){
        cin >> s;
        auto tmp = f(s);
        lo[i] = tmp.first, tot[i] = tmp.second;
        t += tot[i];
    }

    if(t) {
        cout << "No";
        return 0;
    }

    int arr[n];
    for(int i = 0; i < n; i++)  arr[i] = i;
    sort(arr, arr + n, [&](int a, int b) -> bool {
        return min(lo[a], lo[a] + lo[b] + (tot[a] - lo[a])) > min(lo[b], lo[a] + lo[b] + (tot[b] - lo[b]));

    });

    int cur = 0;
    for(auto x : arr){
        if(cur + lo[x] < 0) {
            cout << "No";
            return 0;
        } 
        cur += tot[x];
    }

    cout << "Yes";

}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n, K;
    cin >> n >> K;

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

    for (int i = 0; i < K; i++) {
        vector<int> b(n + 1, 0);
        for (int j = 0; j < n; j++) {
            b[max(j - a[j], 0)]++;
            b[min(j + a[j] + 1, n)]--;
        }

        int cnt = 0;
        for (int j = 0; j < n; j++) {
            if (j > 0) b[j] += b[j - 1];
            a[j] = b[j];
            cnt += (a[j] == n);
        }
        if (cnt == n) break;
    }

    for (int i = 0; i < n; i++) {
        cout << a[i] << " \n"[i + 1 == n];
    }

    return 0;
}

Measured memory_bytes: 4836
#include <stdio.h>
#include <deque>
#include <utility>

using namespace std;
using ll = long long;

ll max(ll x, ll y) {
	if (x < y) {
		return y;
	} else {
		return x;
	}
}

int main(void) {
	ll ans = 0;
	deque<pair<char, ll>> v = {make_pair(getchar(), 1)};
	int d;
	while ((d = getchar()) != EOF) {
		if (d != '<' && d != '>') {
			continue;
		}
		if (d != v.back().first) {
			v.push_back(make_pair(d, 0));
		}
		v.back().second++;
	}
	if (v.front().first == '>') {
		ans += (v.front().second + 1) * v.front().second / 2;
		v.pop_front();
	}
	if (v.back().first == '<') {
		ans += (v.back().second + 1) * v.back().second / 2;
		v.pop_back();
	}
	while (!v.empty()) {
		ll open, close;
		open = v.front().second;
		v.pop_front();
		close = v.front().second;
		v.pop_front();
		ans += (open - 1) * open / 2
					 + (close - 1) * close / 2
					 + max(open, close);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 14 17:37:26 2020

@author: liang
"""
N = int(input())
A = [int(x) for x in input().split()]

from math import gcd

A.sort()
g = A[0]
for i in range(1,N):
    g = gcd(g,A[i]) 
    #print(g)
print(g)

Measured memory_bytes: 19988
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
 
vector<int> occ[26];

int main() {
    string a, b;
    cin >> a >> b;
    for (int ctr1 = 0; ctr1 < a.length(); ++ctr1)
        occ[a[ctr1] - 'a'].push_back(ctr1);
    ll rez = 0;

    int cur = -1;
    for (int ctr1 = 0; ctr1 < b.length(); ++ctr1) {
        int nxt = b[ctr1] - 'a';
        if (!occ[nxt].size()) {
            cout << -1;
            return 0;
        }
        auto it = upper_bound(occ[nxt].begin(), occ[nxt].end(), cur);
        if (it == occ[nxt].end()) {
            rez += a.length();
            cur = occ[nxt][0];
        } else {
            cur = *it;
        }
    }

    cout << rez + cur + 1 << "\n";
    return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  string s;
  cin >> s;

  int n = s.length();

  string t = s;
  int count = 0;
  for(int i = 1; i < n; i++){
    if(t[i - 1] == t[i]){
      t[i] = (t[i] == '0' ? '1' : '0');
      ++count;
    }
  }

  int ans = count;
  t = s;
  t[0] = (t[0] == '0' ? '1' : '0');
  count = 1;
  for(int i = 1; i < n; i++){
    if(t[i - 1] == t[i]){
      t[i] = (t[i] == '0' ? '1' : '0');
      ++count;
    }
  }
  ans = min(ans, count);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
X,Y = map(int,input().split())
F = list(list(input()) for _ in range(X))
DX = [-1,-1,-1,0,0,1,1,1]
DY = [-1,0,1,-1,1,-1,0,1]

for i in range(X):
  for j in range(Y):
    if F[i][j] == '.':
      cnt = 0
      for k in range(8):
        x = i + DX[k]
        y = j + DY[k]
        if 0 <= x < X and 0 <= y < Y and F[x][y] == '#':
          cnt += 1
      F[i][j] = str(cnt)
      
for f in F:
  print(''.join(f))

Measured memory_bytes: 9332
n = int(input()); arr = [list(map(int,input().split())) for _ in range(n)]

mod = 998244353
ans = 0
arr.sort(key=lambda x: x[0],reverse=True)
pos = [i[0] for i in arr]
moved = [sum(i) for i in arr]
children = [i for i in range(-1,n)]

for i in range(1,n):
    parent = moved[i]
    child = children[i]
    cmp = pos[child]
    while cmp < parent:
        child = children[child]
        if child == -1:
            break
        cmp = pos[child]
    children[i] = child
    
dp = [0] * (n+1)
dp[n] = 1
for i in range(n):
    dp[i] = dp[i-1] + dp[children[i]]
    dp[i] %= mod
    
print(dp[n-1])

Measured memory_bytes: 73536
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<int> cnt(4, 0);
    rep(i, n){
        string s;
        cin >> s;
        if(s == "AC")cnt[0]++;
        else if(s == "WA")cnt[1]++;
        else if(s == "TLE")cnt[2]++;
        else cnt[3]++;
    }
    cout << "AC x " << cnt[0] << endl;
    cout << "WA x " << cnt[1] << endl;
    cout << "TLE x " << cnt[2] << endl;
    cout << "RE x " << cnt[3] << endl;
}

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

int main() {
  int n;
  cin >> n;
  P ans;
  vector<int>a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  ll h,p;
  int lb = 0; //lower bound(下限)
  int ub = n-1; //upper bound(上限)
  int mid = (lb+ub)/2; //ここで二分
  while(ub-lb != 1){
    if(a[mid] <= a[n-1]/2){ //src以下（大事！！！！）になる最後の要素
      lb = mid; 
      mid = (lb+ub)/2;
    }
    else{
      ub = mid;
      mid = (lb+ub)/2;
    }
  }
  if(abs(a[lb]-a[n-1]/2) >= abs(a[ub]-a[n-1]/2) && ub != n-1){
    h = a[ub];
    p = ub;
  }
  else{
    h = a[lb];
    p = lb;
  }
  ans.first = a[n-1];
  ans.second = a[p];
  cout << ans.first << " " << ans.second << endl;
}

Measured memory_bytes: 640
from collections import Counter
n = int(input())
a = list(map(int,input().split()))

a.sort()

m = a[-1]
dp = [True] * m
for i in range(n):
    if dp[a[i]-1]:
        t = a[i]
        j = 2
        while True:
            if t*j-1 < m:
                dp[t*j-1] = False
                j += 1
            else:
                break
a = Counter(a)
ans = 0
for i, j in a.items():
    if j == 1 and dp[i-1]:
        ans += 1
print(ans)

Measured memory_bytes: 120872
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	s := nextStr()
	palindrome := strings.Split(s, "")
	//index=0の要素は使わない
	palindrome = append(palindrome[:1], palindrome[0:]...)
	palindrome[0] = " "
	length := len(palindrome) - 1
	ans := "Yes"

	for i := 1; i <= length/2; i++ {
		//fmt.Println("条件1 前：", i, "後：", length-i+1)
		if palindrome[i] != palindrome[length-i+1] {
			ans = "No"
		}
	}
	for i := 1; i <= (length-1)/2; i++ {
		//fmt.Println("条件2 前：", i, "後：", (length+1)/2-i)
		if palindrome[i] != palindrome[(length+1)/2-i] {
			ans = "No"
		}
	}
	for i := (length + 3) / 2; i <= length; i++ {
		//fmt.Println("条件3 前：", i, "後：", (3*length+3)/2-i)
		if palindrome[i] != palindrome[(3*length+3)/2-i] {
			ans = "No"
		}
	}
	fmt.Println(ans)
}

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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
  
typedef pair<int,int> P;
typedef vector<int> vi;

int N,M,INF=1e9+7;

signed main() {
    cin>>N>>M;
    vi b(N+1,0);
    rep(i,0,M) {
        int A; cin >>A; b[A]=1;
    }

    int dp[N+1]={};
    // dp[i] i段目にいる時の場合の数
    
    dp[0]=0;
    int ans;
    if(N==1) {
        if(b[1]==1) ans=0;
        else ans=1;
    }else if(b[1]==1 and b[2]==1) {
        ans=0;
    }else{
        if(b[1]==1) {
            dp[1]=0;
            dp[2]=1;
        }else if(b[2]==1) {
            dp[2]=0;
            dp[1]=1;
        }else{
            dp[1]=1;
            dp[2]=2;
        }

        rep(i,3,N+1) {
            if(b[i]==1) {
                dp[i]=0;
                continue;
            }

            dp[i]=dp[i-1]+dp[i-2];
            if(dp[i]>=INF) dp[i]=dp[i]%INF;
        }
        ans=dp[N];
    }
    cout<<ans<<endl;
    return 0;
}







Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main() {
    char field[5][5];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> field[i][j];
        }
    }
    for (int i = 0; i < 3; i++) {
        cout << field[i][i];
    }
    cout << endl;
}

Measured memory_bytes: 256
public class Main {
    private static long[][][][] memo = new long[101][85][85][85];
    public static void main(String[]$) {
        System.out.println(dfs(new java.util.Scanner(System.in).nextInt(), ' ', ' ', ' '));
    }

    private static long dfs(int r, char l1, char l2, char l3) {
        return memo[r][l1][l2][l3] != 0 ? memo[r][l1][l2][l3] : (memo[r][l1][l2][l3] = ((r == 1 ? 2 : dfs(r - 1, l2, l3, 'A') + dfs(r - 1, l2, l3, 'T')) + (l2 != 'G' && l3 != 'G' || l1 != 'A' && l2 != 'A' && l3 != 'A' ? r == 1 ? 1 : dfs(r - 1, l2, l3, 'C') : 0) + (l2 != 'A' || l3 != 'C' ? r == 1 ? 1 : dfs(r - 1, l2, l3, 'G') : 0)) % 1000000007);
    }
}

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

int main(){
    // find the mmc
    ll a, b;
    cin >> a >> b;
    if (b > a){
        int aux = a;
        a = b;
        b = aux; 
    }
    // a is bigger now
    int counter = 1;
    ll result = a; 
    while (true){
        if (result % b == 0) break; 
        else {
            result = a * counter;
            counter++;
        }
    }

    cout << result << "\n";
    
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

  int s,h,m;

  cin>> s ;

   h = s/3600 ; 

   s %= 3600 ;

   m = s/60 ;

   s %= 60 ;

   cout<< h << ":" << m << ":" << s << endl;


  
  


  return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define INF 0x3f3f3f3f
int a[15];
char str[10];
int flag[20];
int main()
{
  int k;
  scanf("%s%d",str,&k);
  memset(flag,0,sizeof(flag));
  for(int i=0;i<k;i++)
  {
    scanf("%d",&a[i]);
    flag[a[i]]=1;
  }
  int len=strlen(str);
  int fflag=0;int ans,ssum,pos=0,tt;
  for(int i=0;i<len;i++)
  {
    ssum=0;
    for(int j=0;j<=9;j++)
    {
      if((j>(str[i]-'0'))&&flag[j]==0)
      {
        printf("%d",j);
        fflag=1;
        ans=i;
        ssum=1;
        break;
      }
      else if((j==(str[i]-'0'))&&flag[j]==0)
      {
        printf("%d",j);
        ssum=1;
        break;
      }
    }
    if(ssum==0) {pos=1;tt=i;break;}
    if(fflag) break;
  }
  int cnt=0;
  for(int i=0;i<=9;i++)
  {
    if(flag[i]==0)
    {
      cnt=i;break;
    }
  }
  if(fflag)
  {for(int i=ans+1;i<len;i++)
    printf("%d",cnt);}
  if(pos)
  {
    for(int i=tt;i<len+1;i++)
    printf("%d",cnt);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long int a,b,c,d;
    char e;
    scanf("%ld %c %ld",&a,&e,&b);
    c=a+b;
    d=a-b;
    if(e=='+')
    {
        printf("%ld",c);
    }
    else if(e=='-')
    {


        printf("%ld",d);
    }


    return 0;
}


Measured memory_bytes: 128