akhauriyash/Code-Regression huggingface dataset:
// Submitted By Subhash Yadav
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;

public class Main {

	static long m = (long) 1e9 + 7;

	static long power(long a, long b) {
		long x = 1, y = a;
		while (b > 0) {
			if (b % 2 == 1) {
				x = (x * y) % m; // multiplying with base
			}
			y = (y * y) % m; // squaring the base
			b /= 2;
		}
		return x % m;
	}

	public static void main(String[] args) throws IOException {

		FastScanner sc = new FastScanner();
		long n = sc.nextLong();

		
		long ans = (power(10, n) + power(8, n) - power(9, n) * 2 + 3*m) % m;
		
		System.out.println(ans);

	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

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

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

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

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

}

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

int n,t[1000],m,p[1000],x[1000];

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>p[i]>>x[i];
    }
    for(int i=0;i<m;i++){
        int ans=0;
        for(int u=0;u<n;u++){
            if(u==p[i]-1){ans+=x[i];}
            else ans+=t[u];
        }
        cout<<ans<<endl;
    }
}


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

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

    int i = 0;
    int min = 1000;
    while(true){
        if(i == str.size() - 2){
            break;
        }
        string tmp = str.substr(i, 3);
        //cout << "tmp:" << tmp << endl;
        int num = stoi(tmp);
        if(num == 753){
            min = 0;
            break;
        }
        int sa = abs(num - 753);
        //cout << "sa:" << sa << endl;
        if(sa < min){
            min = sa;
        }
        i++;
    }

    cout << min << endl;

    return 0;
}

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,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll 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;
  }
};


int main(){
  int n,k;
  cin >> n >> k;
  mint nn = n;
  mint kk = k;

  mint ans=0;
  for(int i = k; i <= n+1; i++){
    mint ii = i;
    mint l = (ii-1)*ii/2;
    mint r = (nn+1)*nn/2 - (nn-ii)*(nn-ii+1)/2;
//    cout << i << " " << l.x << " " << r.x << endl;
    ans += r - l + 1;
  }
  cout << ans.x << endl;

}



Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
#define LIM 36

void Sels(char [LIM][3],int);
void Bubs(char [LIM][3],int);
int Lss(char [LIM][3],char [LIM][3],int);

int main() {

  int N;
  int i;
  char num[LIM][3],num1[LIM][3],num2[LIM][3];
    
  scanf("%d",&N);
  for(i=0;i<N;i++) {
    scanf(" %s",num[i]);
  }

  for(i=0;i<N;i++) strcpy(num1[i],num[i]);
  for(i=0;i<N;i++) strcpy(num2[i],num[i]);

  Bubs(num1,N);
  for(i=0;i<N;i++) {
    if(i>0) printf(" ");
    printf("%s",num1[i]);
  }
  printf("\n");

  if(Lss(num,num1,N) == 1) printf("Stable\n");
  else printf("Not stable\n");
  
  Sels(num2,N);
  for(i=0;i<N;i++) {
    if(i>0) printf(" ");
    printf("%s",num2[i]);
  }
  printf("\n");

  if(Lss(num,num2,N) == 1) printf("Stable\n");
  else printf("Not stable\n");

  return 0;

}

void Bubs(char num[LIM][3],int N) {
  int flag=1;
  int i;
  char a[3];
  
  while(flag==1) {
    flag=0;
    for(i=N-1;i>0;i--) {
      if( num[i][1] < num[i-1][1] ) {
	strcpy(a,num[i]); strcpy(num[i],num[i-1]); strcpy(num[i-1],a);
	flag=1;
      }
    }
  }
}

/*void Bubs(char num[LIM][3],int N) {

  int i,j;
  char a[3];
  
  for(i=0;i<N;i++) {
    for(j=N-1;j>i;j--) {
      if( num[j][1] < num[j-1][1]) {
	strcpy(a,num[j]); strcpy(num[j],num[j-1]); strcpy(num[j],a);
      }
    }
  }
}*/

void Sels(char num[LIM][3],int N) {

  int minj;
  int i,j;
  char a[3];

  for(i=0;i<=N-1;i++) {
    minj = i;

    for(j=i;j<N;j++) {
      if(num[j][1] < num[minj][1]) minj = j;
    }
    strcpy(a,num[i]); strcpy(num[i],num[minj]); strcpy(num[minj],a);
  }
}

int Lss(char in[LIM][3],char out[LIM][3],int N) {

  int i,j,a,b;

  for(i=0;i<N;i++) {
    for(j=i+1;j<N;j++) {
      for(a=0;a<N;a++) {
	for(b=a+1;b<N;b++) {
	  if( in[i][1] == in[j][1] && (strcmp(in[i],out[b])) == 0 && (strcmp(in[j],out[a])) == 0) return 0;
	}
      }
    }
  }

  return 1;
}


Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using namespace std;

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
    };

    // 2次元用の標準入出力
    template<typename T>
    struct inpn {
        std::size_t szi, szj;
        inpn(std::size_t _szi, std::size_t _szj) : szi(_szi), szj(_szj) {}
        operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i)
                for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j];
            return a;
        }
    };

    inp inp1; // input one
}


int main() {

    string s, t;
    cin >> s >> t;

    int sn = s.length();
    int tn = t.length();

    // dp[i][j] := sのi文字目まで，tのj文字目まで見たときの最大値
    vector<vector<ll>> dp(sn + 1, vector<ll>(tn + 1, 0LL));

    Rep(i, 1,  sn + 1) {
        Rep(j, 1, tn + 1) {
            if (s[i - 1] == t[j - 1]) {
                chmax(dp[i][j], dp[i - 1][j - 1] + 1);
            }

            chmax(dp[i][j], max(dp[i][j - 1], dp[i - 1][j]));
        }
    }

    // 復元する
    string ans = "";
    int i = sn;
    int j = tn;
    while (i > 0 && j > 0) {
        ll v = dp[i][j];
        if (v == dp[i][j - 1]) {
            --j;
        }
        else if (v == dp[i - 1][j]) {
            --i;
        }
        else {
            ans += s[i - 1];
            --i;
            --j;
        }
    }
    
    reverse(allof(ans));
    Cout(ans);

    return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    string s;
    cin >> s;
    cout << s[0] << (s.size()-2) << s[s.size()-1] << endl;
}


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

int main(){

    int ans=0,b=0,c;
    int n,m;
    cin >> n >> m;
    vector<int> a(n);

    for(int i=0;i<n;i++){
        cin >> a.at(i);
        ans+=a.at(i);
    }

    for(int i=0;i<n;i++){
        if(ans/(4*m)<a.at(i)){
            b++;
        }else if(ans%(4*m)==0 && ans/(4*m)==a.at(i)){
            b++;
        }
    }

    if(b>=m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int N,Q;
    string S;
    cin >>N>>Q>>S;
    vector<int>ok(N,0);
    for(int i=1;i<N;i++){
         ok[i]=ok[i-1];
         if(S[i-1]=='A'&&S[i]=='C'){
                ok[i]++;
            }
    }
    REP(i,Q){
        int a,b;
        cin>>a>>b;
        int ans=ok[b-1]-ok[a-1];
        cout <<ans<<endl;
    }
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll k, a, b;
    cin >> k >> a >> b;
    if(a > b - 2) cout << k + 1 << endl;
    else cout << ((k - (a - 1)) / 2) * (b - a) + k - ((k - (a - 1)) / 2) * 2 + 1 << endl;
}

Measured memory_bytes: 256
<?php
$stack=[];
$top=0;
$data=explode(' ',trim(fgets(STDIN)));

foreach($data as $d) {
  if($d=='+'){
    $stack[$top-1]+=$stack[$top--];
  } elseif($d=='-'){
    $stack[$top-1]-=$stack[$top--];
  }elseif($d=='*'){
    $stack[$top-1]*=$stack[$top--];
  }else{
    $stack[++$top]=$d;
  }

}
echo $stack[1].PHP_EOL;


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

class MainClass
{
    static void Main()
    {
        int N = int.Parse(ReadLine());
        string c = ReadLine();
        int W = c.Count(_ => _ == 'W');
        int R = c.Count(_ => _ == 'R');

        int r = R;
        int count = 0;
        for (int i = 0; i < N; i++)
        {
            if (count == r) break;
            if (c[i] == 'W') count++;
            else r--;
        }
        WriteLine(count);
    }
}


Measured memory_bytes: 28696
N = int(input())
a = list(map(int, input().split()))
count = 0
i = 0
for i in range(N-1):
  if a[i] <= a[i+1]:
    continue
  elif a[i] > a[i+1]:
    diff = a[i] - a[i+1]
    count = count + diff
    a[i+1] = a[i]
print(count)    


Measured memory_bytes: 32008
def examA():
    S = SI()
    T = SI()
    N = len(S)
    ans = "No"
    for i in range(N):
        cur = S[i:] + S[:i]
        #print(cur)
        if cur==T:
            ans = "Yes"
    print(ans)
    return

def examB():
    H, W = LI()
    S = [SI()for _ in range(H)]

    def judge(h, w, S):
        if h < H-1 and S[h+1][w]=="#":
            return True
        if h > 0 and S[h-1][w]=="#":
            return True
        if w < W-1 and S[h][w+1]=="#":
            return True
        if w > 0 and S[h][w-1]=="#":
            return True
        return False

    ans = "Yes"
    for h in range(H):
        for w in range(W):
            if S[h][w]=="#":
                if judge(h,w,S):
                    continue
                ans = "No"
    print(ans)
    return

def examC():
    L, R = LI()
    ans = inf
    if R-L>=3000:
        R = L+3000

    for l in range(L, R + 1):
        for r in range(l+1, R + 1):
            now = (l*r) %2019
            ans = min(ans,now)
    print(ans)
    return

def examD():
    T = {"dream", "dreamer", "erase", "eraser"}
    S = SI()
    ans = "NO"
    t = ""
    for s in S[::-1]:
        t += s
        if t[::-1] in T:
            t = ""
        if len(t)>10:
            print(ans)
            return
    if t=="":
        ans = "YES"
    print(ans)
    return

def examE():
    N = 50
    K = I()
    base = K//N
    A = [base+i for i in range(N)]
    rest = K%N
    for i in range(rest):
        A[-i-1] += 1
    print(N)
    print(" ".join(map(str,A)))
    return

def examF():
    N = 20
    C = [2**i for i in range(N)]
    L = I()
    cur = 1
    V = [[i+1, i+2, 0]for i in range(N-1)]
    now = 1
    while(now<N):
        if C[now]<=L:
            cur = C[now]
            V.append([now,now+1,C[now-1]])
            now += 1
        else:
            break
    #print(cur)

    for i in range(now)[::-1]:
        if C[i]<=L-cur:
            cost = cur
            V.append([i+1,N,cost])
            cur += C[i]

    print(N,len(V))
    for s,t,c in V:
        print(s,t,c)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define PI pair<int,int>
#define ff first
#define ss second
#define int long long 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)

int nC2(int n){
	if(n==1 or n==0)
		return 0;
	return n*(n-1)/2;
}

int32_t main() {

	boost;
 	
	int n;
	cin>>n;
	int a[n];
	map<int,int>mp,m;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mp[a[i]]++;
	}
	int ans=0;
	for(auto p:mp){
		int tt=nC2(p.ss);
		ans+=tt;
		m[p.ff]=tt;
	}
	for(int i=0;i<n;i++)
		cout<<ans-m[a[i]]+nC2(mp[a[i]]-1)<<endl;
}

Measured memory_bytes: 18944
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

int main()
{
  int d;
  cin >> d;
  string s;
  if (d == 25)s = "Christmas";
  else if (d == 24)s="Christmas Eve";
  else if(d==23)s="Christmas Eve Eve";
  else if(d==22)s="Christmas Eve Eve Eve";

  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
	#include<cstring>
	using namespace std;
	int main(){
		char a,b;
		cin>>a>>b;
		string at,top;
		if(a=='H')
			at='h';
		else if(a=='D')
			at='d';
		if(b=='H')
			top='h';
		else if(b=='D')
			top='d';
		if(at==top)
		cout<<"H";
		else
		cout<<"D";		
	}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, K;
    cin >> N >> K;
    ll c = K;
    REP(i,1,N) c *= K-1;
    PR(c);

    return 0;
}

/*



*/

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

int main(){
    int n;
    cin>>n;
    int a[n];
    long long tmp=2e18;
    int ans;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=-100;i<=100;i++){
        long long sum=0;
        for(int j=0;j<n;j++){
            sum+=(a[j]-i)*(a[j]-i);
        }
        if(tmp>sum){
            tmp=sum;
            ans=i;
        }
    }
    cout<<tmp<<endl;
    return 0;
}

Measured memory_bytes: 3568
#include <cstdio>
#include <algorithm>
//#include <cstring>
//#include <cctype>
using namespace std;
typedef long long ll;
//////////LOCALS//////////
#ifdef OFFLINE
int unused_variable_name=(freopen("in.txt","r",stdin),1);
#endif
//////////LOCALS//////////
int arr[110];
int main(){
	int n,m,flag=0;
	scanf("%d%d%d",&n,&m,&arr[0]);
	if(m==1){
		if(n==1) printf("1\n1\n1\n");
		else printf("%d\n2\n%d 1\n",n,n-1);
		return 0;
	}
	flag=arr[0]%2;
	for(int i=1;i<m;i++){
		scanf("%d",&arr[i-(flag/2)]);
		if(arr[i-(flag/2)]%2){
			switch(flag++){
			case 0:
				arr[i]=arr[0]^arr[i];
				arr[0]=arr[0]^arr[i];
				arr[i]=arr[0]^arr[i];
				break;
			case 1:
				arr[m-1]=arr[i];
				break;
			case 2:
				printf("Impossible\n");
				return 0;
			}
		}
	}
	for(int i=0;i<m;i++){
		printf("%d%c",arr[i],i==m-1?'\n':' ');
	}
	if(arr[0]==1){
		printf("%d\n",m-1);
	} else {
		printf("%d\n%d ",m,arr[0]-1);
	}
	for(int i=1;i<m-1;i++){
		printf("%d ",arr[i]);
	}
	printf("%d\n",arr[m-1]+1);
	return 0;
} 

Measured memory_bytes: 128
#include <algorithm>
        #include <iostream>
        #include <cstring>
        #include <vector>
        #include <cstdio>
        #include <string>
        #include <cmath>
        #include <queue>
        #include <set>
        #include <map>
        #include <complex>
        #include <stack>
        using namespace std;
        typedef long long ll;
        typedef long double db;
        typedef pair<int,int> pii;
        typedef vector<int> vi;
        #define dd(x) cout << #x << "=" << x << ", "
        #define de(x) cout << #x << "=" << x << endl
        #define ds() puts("---stop here---")
        #define mset(a,i) memset(a,i,sizeof(a))
        #define rep(i,a,b) for(int i=a;i<(b);++i)
        #define rrep(i,j,k) for(int i=j;i>=k;i--)
        #define all(x) (x).begin(),(x).end()
        #define sz(x) (int)(x).size()
        #define mp make_pair
        #define pb push_back
        #define fi first
        #define se second
        #define E 1e-6
        void open(){freopen("data.txt","r",stdin);}
        void out(){freopen("out.txt","w",stdout);}
        const int INF = 0x3f3f3f3f;
        const int maxn = 101010;
        const int MOD = 1e9 + 7;

        int arr[maxn];
        int main()
        {
            vector<pii> vec;
            int n , maxx = -INF , minn = INF , minid , maxid;
            scanf("%d",&n);
            rep(i,1,n+1) scanf("%d",&arr[i]);
            rep(i,1,n+1){
                if(arr[i]>maxx){
                    maxx = arr[i];
                    maxid = i;
                }
                if(arr[i]<minn){
                    minn = arr[i];
                    minid = i;
                }
            }
            if(maxx == minn){
                puts("0");
                return 0;
            }

            bool ok = true;
            rep(i,2,n+1) if(arr[i]<arr[i-1]) ok = false;
            if(ok){
                puts("0");
                return 0;
            }
            if(minn>=0){                //全部大于0
                rep(i,1,n) vec.pb(mp(i,i+1));
                printf("%d\n",sz(vec));
                rep(i,0,sz(vec)) printf("%d %d\n",vec[i].fi ,vec[i].se);
                return 0;
            }
            if(maxx<=0){
                rrep(i,n,2) vec.pb(mp(i,i-1));
                printf("%d\n",sz(vec));
                rep(i,0,sz(vec)) printf("%d %d\n",vec[i].fi , vec[i].se);
                return 0;
            }
            if(abs(maxx)>abs(minn)){
                rep(i,1,n+1) vec.pb(mp(maxid,i));
                rep(i,1,n) vec.pb(mp(i,i+1));
                printf("%d\n",sz(vec));
                rep(i,0,sz(vec)) printf("%d %d\n",vec[i].fi , vec[i].se);
                return 0;
            }
            else{
                rep(i,1,n+1) vec.pb(mp(minid,i));
                rrep(i,n,2) vec.pb(mp(i,i-1));
                printf("%d\n",sz(vec));
                rep(i,0,sz(vec)) printf("%d %d\n",vec[i].fi , vec[i].se);
                return 0;
            }
        }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,h[100010];
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	for(int i=n;i>1;--i)
	{
		if(h[i-1]-h[i]>1)
		{
			cout<<"No";
			return 0;
		}
		if(h[i-1]-h[i]>0)
			h[i-1]-=1;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <string.h>
#include <cstdarg>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


// Extended Print Func
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& input){
    os << "[ ";
    REP(i, input.size()){
        os << input[i];
        if (i < input.size()-1) { os << " "; }
    }
    os << " ]";
    return os;
}
void print() { cout << "\n"; }
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
template<class... A> void print(const A&... rest) { print(rest...); }



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll H, W;
  cin >> H >> W;
  vector<vector<ll>> A(H, vector<ll>(W));
  REP(i,H){
    REP(j,W){
      cin >> A[i][j];
    }
  }
  vector<vector<ll>> B(H, vector<ll>(W));
  REP(i,H){
    REP(j,W){
      cin >> B[i][j];
    }
  }

  ll M = 0;
  REP(i,H){
      REP(j,W){
        M = max(M, abs(A[i][j]-B[i][j]));
      }
  }
  M *= H+W;
  
  vector<vector<vector<bool>>> dp(H,vector<vector<bool>>(W, vector<bool>(M, false)));
  dp[0][0][abs(A[0][0]-B[0][0])] = true;
  REP(i,H){
    REP(j,W){
      ll cij = abs(A[i][j] - B[i][j]);
      REP(k,M){
        if (i > 0 && dp[i-1][j][k]){
            dp[i][j][k + cij] = true;
            dp[i][j][abs(k - cij)] = true;
        }
        if (j > 0 && dp[i][j-1][k]){
            dp[i][j][k + cij] = true;
            dp[i][j][abs(k - cij)] = true;
        }
      }
    }
  }

  ll ans = M;  
  REP(i,M){
    if (dp[H-1][W-1][i]){
        ans = i;
        break;
    }
  }
  
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 10880
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

int DAI=200;
int SYO=195;

int main() {
    int n;
    cin>>n;

    int maxn=0;
    int dy=(1000-1)*195;
    int dl=(1000/3)*5;
    int dm=0;
    int dd=0;
    maxn=dy+dl+dm+dd;




    while(n>0){
    int y,m,d;
    cin>>y>>m>>d;
    if(n==0)break;
    dy=(y-1)*195;
    dl=((y-1)/3)*5;
    dm=0;
    bool f=false;
    if(y%3==0)f=true;

    for(int i=1;i<m;i++){
        if(f||i%2)dm+=20;
        else{
            dm+=19;
        }
    }

    int in=dy+dl+dm+d-1;

    cout<<maxn-in<<endl;
    //cout<<maxn-in<<endl;




        n--;
    }

    return 0;
}



Measured memory_bytes: 2984
N, D = map(int, input().split())

X = [list(map(int, input().split())) for i in range(N)]

sq = set()
for i in range(1, 1000):
  sq.add(i**2)

def foo(x,y):
  t = 0
  for i, j in zip(X[x], X[y]):
    t += (i - j) * (i - j)
  if t in sq:
    return 1
  else:
    return 0
    
ans = 0

for i in range(N):
  for j in range(i+1, N):
    ans += foo(i, j)

print(ans)


Measured memory_bytes: 9064
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
typedef long long ll;
// cd test ; rm -R ./*; cd .. 

int main(void) {
  int h, w;
  cin >> h >> w;
  vector<string> ans;
  rep (i, h) {
    string s;
    cin >> s;
    ans.push_back(s);
    ans.push_back(s);
  }
  rep (i, h * 2) {
    cout << ans[i] << endl;
  }
  
  return 0;
}

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

#define FOR(i,s,e) for(int i = (s);i <= (e);i++)

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


Measured memory_bytes: 256
# それぞれ辞書順に並び替えたものをとっていく
# 辞書にしたうちの最小値をとっていくことでN^3くらいでいけそう
n = int(input())
alphabets = [chr(i) for i in range(97, 97 + 26)]
maps = []
for _ in range(n):
    s = input()
    new_map = dict(zip(alphabets, [0 for _ in range(26)]))
    for si in s:
        new_map[si] += 1
    maps.append(new_map)

ans_map = dict(zip(alphabets, [10**9 for _ in range(26)]))
for m in maps:
    for k, v in m.items():
        ans_map[k] = min(ans_map[k], v)

ans = ""
for k in list(sorted(ans_map.keys())):
    ans += k * ans_map[k]
print(ans)


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

typedef long long unsigned ll;

//const int N = 200002;

int main(){

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

    ll x;
    cin>>x;

    ll ret=0;
    ret+= (x/11)*2;
    ret+= x%11 == 0? 0:(x%11>6? 2:1);

    cout<< ret<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <emmintrin.h>

using namespace std;
static const int INF = 1000000000;
static int costs[301][301];
static int dp[302][302];

int solve(string a, string b){
	const int n = a.size();
	for(int i = 0; i <= n; ++i){
		for(int j = 0; j <= n; ++j){ dp[i][j] = INF; }
	}
	const auto a_ptr = a.c_str();
	const auto b_ptr = b.c_str();
	for(int i = 0; i <= n; ++i){
		for(int j = 0; j <= n; ++j){
			const int m = min(n - i, n - j);
			const auto x_ptr = a_ptr + i;
			const auto y_ptr = b_ptr + j;
			__m128i vsum = _mm_setzero_si128();
			int k = 0;
			for(; k + 15 < m; k += 16){
				const __m128i vx =
					_mm_loadu_si128((const __m128i *)(x_ptr + k));
				const __m128i vy =
					_mm_loadu_si128((const __m128i *)(y_ptr + k));
				const __m128i vz = _mm_cmpeq_epi8(vx, vy);
				vsum = _mm_sub_epi8(vsum, vz);
			}
			int8_t buffer[16] __attribute__((aligned(16)));
			_mm_store_si128((__m128i *)buffer, vsum);
			int sum = 0;
			for(; k < m; ++k){
				if(x_ptr[k] == y_ptr[k]){ ++sum; }
			}
			for(int t = 0; t < 16; ++t){ sum += buffer[t]; }
			costs[i][j] = sum;
		}
	}
	dp[0][0] = 0;
	for(int i = 0; i <= n; ++i){
		for(int j = 0; j <= n; ++j){
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + costs[i][j]);
			dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + costs[i][j]);
		}
	}
	return dp[n][n];
}

int main(){
	ios_base::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	vector<string> field(h);
	for(int i = 0; i < h; ++i){ cin >> field[i]; }
	vector<string> rotated(w, string(h, ' '));
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){ rotated[j][h - i - 1] = field[i][j]; }
	}
	int answer = 0;
	for(int i = 0; i + 1 < w; ++i){
		answer += solve(rotated[i], rotated[i + 1]);
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 1280
# https://atcoder.jp/contests/abc115/tasks/abc115_d
# 真面目に再帰関数によって文字列を生成すると、長さが爆発してしまう
# 問題の再帰構造を観察すると、二分探索のような処理でPの数を確定できる


def ret_length(L):
    ret = 1
    for _ in range(L):
        ret = 2 * ret + 3
    return ret


def ret_nP(L):
    ret = 1
    for _ in range(L):
        ret = 2 * ret + 1
    return ret


N, X = list(map(int, input().split()))
X -= 1  # X枚目まで食べるという扱いにする (0based index)

lng = ret_length(N)
nP = ret_nP(N)

# print(lng, nP, X)

ans = 0
l = 0
r = lng - 1
# while r - l > 0:  # lrが隣り合ったら終わり
# for _ in range(N + 1):
while r - l >= 0:
    m = (r + l) // 2  # 必ず真ん中を指す
    if r == X:
        ans += nP
        break
    elif l == X:
        break

    nP = nP // 2
    if X == m:
        ans += nP + 1
        break
    if X > m:
        # Bの数を足す
        ans += nP + 1
        l = m + 1
        r -= 1
    else:
        l += 1
        r = m - 1

print(ans)


Measured memory_bytes: 3064
import numpy as np

h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
q = int(input())
b = [list(map(int,input().split())) for _ in range(q)]
p =[0]*(h*w+1)
    
for i in range(h):
    for j in range(w):
        tmp = a[i][j]
        p[tmp] = [i,j]
cost = [0]*(h*w+1)
i = d+1
while i <= h*w:
    cost[i] = cost[i-d] + abs(p[i][0]-p[i-d][0]) + abs(p[i][1]-p[i-d][1])
    i += 1
for k in range(q):
    r = b[k][0]
    l = b[k][1]
    print(cost[l]-cost[r])

Measured memory_bytes: 51184
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

using namespace std;

int main(){

	int n,m;
	vector<int> p;
	map<int,vector<int>> xy;
	char flag[100010];

	for(int i=0;i<100010;i++){
		flag[i]=0;
	}

	cin>>n>>m;
	for(int i=0;i<n;i++){
		int tmp;
		cin>>tmp;
		p.push_back(tmp-1);
	}
	for(int i=0;i<m;i++){
		int tmpX,tmpY;
		cin>>tmpX>>tmpY;
		xy[tmpX-1].push_back(tmpY-1);
		xy[tmpY-1].push_back(tmpX-1);
	}

	/*学習実施、どことどこが繋がってるのか？*/
	
	int ans=0;
	for(int i=0;i<n;i++){
		if(flag[i]==1)continue;
		queue<int> q;
		q.push(i);
		set<int> touch;
		touch.insert(i);
		flag[i]=1;
		while(q.size()!=0){
			int now = q.front();
			q.pop();
			if(xy[now].size()==0)continue;
			int size = xy[now].size();
			for(int j=0;j<size;j++){
				int next = xy[now].at(j);
				if(flag[next]==0){
					touch.insert(next);
					flag[next]=1;
					q.push(next);
				}
			}
		}
		for(auto itr = touch.begin(); itr != touch.end();itr++){
			int targetPos = p[*itr];
			if(touch.count(targetPos)==1){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;

}

Measured memory_bytes: 16376
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


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

// flip pair
template <typename A, typename B>
pair<B, A> flip_pair(pair<A, B> src) {
	return pair<B, A> (src.second, src.first);
}

// flip map
template <typename A, typename B>
multimap<B, A> flip_map(map<A, B> src) {
	multimap<B, A> dst;
	for(auto it = src.begin(); it != src.end(); ++it) {
		auto a = flip_pair(*it);
		dst.insert(a);
	}
	return dst;
}

// get frequency mapping from vector
template <typename Tval>
multimap<int, Tval> freq(vector<Tval> src) {
	map<Tval, int> counter;
	for(auto it = src.begin(); it != src.end(); ++it) {
		auto it2 = counter.find(*it);
		if(it2 != counter.end()) counter[*it]++;
		else counter[*it] = 1;
	}
	auto dst = flip_map(counter);
	return dst;
}

int main(){
	int x, y;
	cin >> x >> y;
	cout << x + y / 2 << endl;

}



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

using namespace std;

int SolveDaruma(const vector<int> &w) {
    const int n = w.size();
    vector<vector<int>> s(n, vector<int>(n, 0));

    for (int l = 0; l + 1 < n; ++l)
        if (abs(w[l] - w[l + 1]) <= 1)
            s[l][l + 1] = 2;

    for (int i = 3; i <= n; ++i)
        for (int l = 0; l + i <= n; ++l) {
            const int r = l + i - 1;

            if (abs(w[l] - w[r]) <= 1 && s[l + 1][r - 1] == i - 2)
                s[l][r] = i;

            for (int m = l + 1; m <= r; ++m)
                s[l][r] = max(s[l][r], s[l][m - 1] + s[m][r]);
        }

    return s[0][n - 1];
}

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

    int n;

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

        cout << SolveDaruma(w) << '\n';
    }

    return 0;
}

Measured memory_bytes: 3280
#include<stdio.h>
int main(){
int a[11]={1,2,4,8,16,32,64,128,256,512},b,i,c=0,d[10],j=0,p,k;
while(scanf("%d\n",&b)!=EOF){
for(i=9;i>=0;i--){
if(b>=a[i]){
d[j]=a[i];
j++;
b=b-a[i];
}
}
for(i=0;i<j;i++){
for(p=j-1;p>i;p--){
if(d[p]<d[p-1]){
k=d[p];
d[p]=d[p-1];
d[p-1]=k;
}
}
}
for(i=0;i<j;i++){
if(c==0){
printf("%d",d[i]);
c++;
}
else{
printf(" %d",d[i]);
}
}
printf("\n");
c=0,j=0;
}
return 0;
}


Measured memory_bytes: 1924
H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]
ans = [["r" for _ in range(W)]] + [["." for _ in range(W)] for _ in range(H-2)] + [["b" for _ in range(W)]]

for h in range(1, H-1):
	for w in range(W):
		if a[h][w] == "#":
			ans[h][w] = "p"
		elif w % 2 == 0:
			ans[h][w] = "r"
		else:
			ans[h][w] = "b"

r = [["." for _ in range(W)] for _ in range(H)]
for h in range(H):
	for w in range(W):
		if ans[h][w] == "p" or ans[h][w] == "r":
			r[h][w] = "#"
for h in range(H):
	print("".join(r[h]))

print("\n")

b = [["." for _ in range(W)] for _ in range(H)]
for h in range(H):
	for w in range(W):
		if ans[h][w] == "p" or ans[h][w] == "b":
			b[h][w] = "#"
for h in range(H):
	print("".join(b[h]))

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

int main(){
  ll x; cin>>x;
  ll res=0;
  
  res+=x/11*2;
  x%=11;
  if(x!=0)
    res++;
  if(x>6)
    res++;
  
  cout<<res;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a,b;
int main()
{
	cin>>n>>a>>b;
	if((b-a)%2==0) cout<<(b-a)/2;
	else cout<<min((a-1)+(b-a+1)/2,(n-b)+(b-a+1)/2);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

#define pbds tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
    int a,p; cin >> a >> p;
    cout << (a*3 + p)/2; 
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	solve();
	return 0;
}
 


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

#define MAX 100000

std::vector<int>Graph[MAX];
bool visited[MAX];

int N;

int prenum[MAX], parent[MAX], lowest[MAX], timer;

struct compare {
    bool operator() (const std::pair<int,int> &lhs, const std::pair<int,int> &rhs) const{
        if (lhs.first == rhs.first) return lhs.second < rhs.second;
        return (lhs.first < rhs.first);
    }
};

std::set<std::pair< int, int>, compare > bridges;

void dfs(int current, int prev) {

    prenum[current] = lowest[current] = timer;
    timer++;

    visited[current] = true;

    int next;

    for (int i = 0; i < Graph[current].size(); i++) {
        next = Graph[current][i];
        if (!visited[next]) {
            parent[next] = current;
            dfs(next, current);

            lowest[current] = std::min(lowest[current], lowest[next]);
            
            if (lowest[next] > prenum[current]) {
                if (next > current) bridges.insert({current, next});
                else bridges.insert({next, current});

            }


        }
        else if (prev != next) {
            lowest[current] = std::min(lowest[current], prenum[next]);
        }
    }
}

void bridge() {
    for (int i = 0; i < N; i++) visited[i] = false;

    timer = 1;

    dfs(0, -1); //0 == root

    for(std::set< std::pair<int, int> >::iterator it = bridges.begin(); it != bridges.end(); it++) {
        std::cout << it->first << " " << it->second << std::endl;
    }
}


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

    int start, target;

    for (int i = 0; i < Edges; i++) {
        std::scanf("%d %d", &start, &target);
        Graph[start].push_back(target);
        Graph[target].push_back(start);
    }

    bridge();


    return 0;
}



Measured memory_bytes: 7256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  int h,w;cin>>h>>w;
  vector<vector<char>> f(h,vector<char>(w));
  rep(i,h)rep(j,w)cin>>f[i][j];
  rep(i,h)rep(j,w){
    if(f[i][j]=='.'){
      int cnt=0;
      if(i<h-1&&f[i+1][j]=='#')cnt++;
      if(j<w-1&&f[i][j+1]=='#')cnt++;
      if(i>0&&f[i-1][j]=='#')cnt++;
      if(j>0&&f[i][j-1]=='#')cnt++;
      if(i<h-1&&j<w-1&&f[i+1][j+1]=='#')cnt++;
      if(i<h-1&&j>0&&f[i+1][j-1]=='#')cnt++;
      if(i>0&&j<w-1&&f[i-1][j+1]=='#')cnt++;
      if(i>0&&j>0&&f[i-1][j-1]=='#')cnt++;
      f[i][j]='0'+cnt;
    }
  }
  rep(i,h){
    rep(j,w)cout<<f[i][j];
    cout<<endl;
  }
  return 0;
}

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

using namespace std;

const int MAXN = 100010;
const int INF = 1e9;

int N, M;
vector < int >  G[MAXN];

void solver() {

	queue <int> Q;
	Q.push(1);

	vector <int> dist(N + 1, INF);
	dist[1] = 0;

	vector<int> parent(N + 1, -1);
	parent[1] = 1;

	while(!Q.empty()) {
		int u = Q.front();
		Q.pop();

		for(int v : G[u]) {
			if (dist[v] == INF) {
				parent[v] = u;
				dist[v] = dist[u] + 1;
				Q.push(v);
			}
		}
	}


	bool ok = true;

	for(int i = 1; i <= N; ++i) {
		if (dist[i] >= INF) {
			ok = false;
			break;
		}
	}

	if (!ok) {
		cout << "No" << '\n';
		return;
	}

	cout << "Yes" << '\n';

	for(int i = 2; i <= N; ++i) {
		cout << parent[i] << '\n';
	}

}


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

	cin >> N >> M;

	for(int i = 0, a, b; i < M; ++i) {
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);	
	}

	solver();


	return 0;	
}

Measured memory_bytes: 10628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    vector<bool> good(n, true);
    for (int i = 0; i < n; i++) {
        cin >> h.at(i);
    }
    vector<vector<int>> ab(m, vector<int> (2));
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < 2; j++) {
            cin >> ab.at(i).at(j);
        }
    }
    for (int i = 0; i < m; i++) {
        if (h.at(ab.at(i).at(0) - 1) >= h.at(ab.at(i).at(1) - 1)) {
            good.at(ab.at(i).at(1) - 1) = false;
        }
        if (h.at(ab.at(i).at(0) - 1) <= h.at(ab.at(i).at(1) - 1)) good.at(ab.at(i).at(0) - 1) = false;
    }
    int count = 0;
    for (int i = 0; i < n; i++) {
        if (good.at(i)) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 9068
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n , m , r ;
    cin >> n >> m >> r ;
    vector<int> v(r) ;
    for(int i = 0; i < r; i++){
        cin >> v[i] ;
        v[i]--;
    }
    vector<vector<int> > g(n, vector<int>(n, INF)) ;
    vector<vector<int> > dist(n, vector<int>(n, INF)) ;
    for(int i = 0; i < m; i++){
        int a , b , c ;
        cin >> a >> b >> c ; 
        a--, b-- ;
        g[a][b] = c ;
        g[b][a] = c ; 
        dist[a][b] = c; 
        dist[b][a] = c ;
    }
    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if ( dist[i][k] + dist[k][j] < dist[i][j] ) {
                    dist[i][j] = dist[i][k] + dist[k][j] ;
                }
            }
        }
    }
    sort(v.begin(), v.end());
    int ans = INF ;
    do{
        int sum = 0 ;
        for(int i = 1; i < r; i++){
            sum += dist[v[i - 1]][v[i]] ; 
        }
        ans = min(ans, sum) ;
    }while(next_permutation(v.begin(), v.end())) ;
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 3952
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");
      	int r = Integer.parseInt(line[0]) * 100;
       	int g = Integer.parseInt(line[1]) * 10;
      	int b = Integer.parseInt(line[2]);
    	
      	int result = r + g + b;
      	
      	if(result % 4 == 0){
        	System.out.println("YES");
          	return;
        }
        
      	System.out.println("NO");
    	
    }
}

Measured memory_bytes: 20948
#include<iostream>
#include<string>
#define MAX_NUM 20000

struct Puddle{
    int left;
    int right;
    int area;
    void setStatus(int x,int y,int z){
        this->left = x;
        this->right = y;
        this->area = z;
    }
    
    void outStatus(){
        std::cout << this->left << ' ' << this->right << ' ' << this->area << '\n';
    }
};

int stack[MAX_NUM];
int sp=0;
Puddle pud[MAX_NUM/2];
int pp=0;

void push(int x){
    stack[sp++] = x;
}

int pop(){
    return stack[--sp];
}

void push_P(Puddle p){
    pud[pp++] = p;
}

Puddle pop_P(){
    return pud[--pp];
}

Puddle makePuddle(int start){
    Puddle p;
    p.setStatus(sp,start,start-sp);
    for(int i=sp;i<=start;i++) push(0);
    return p;
}

bool chk_valley(){
    while(sp>0){
        if(pop() == -1){
            return true;
        }
    }
    return false;
}

int containPuddle(Puddle p){
    int start = pp;
    if(pp==0){
        
        return 0;
    
    }else if(pp>0){
        int count=0;
        while(pp>0){
            Puddle before = pop_P();
            if( before.left < p.left ){
                pp = start;
                return count;
            }else{
                count++;
            }
        }
        pp = start;
        return count;
    }
    return 0;
}

void mergePuddle(Puddle p){
    int count = containPuddle(p);
    if(count == 0){
        push_P(p);
        return;
    }
    int r = p.right;
    int l = p.left;
    int area_sum = p.area;
    for(int i=0;i<count;i++){
        Puddle tmp = pop_P();
        area_sum += tmp.area;
    }
    p.setStatus(l,r,area_sum);
    push_P(p);
}

int main(){
    char ch[MAX_NUM] = {};
    int space=0;
    std::cin >> ch;
    
    for(int i=0;i<MAX_NUM;i++){
        //std::cout << i ;
        if(ch[i] == '\\'){
            push(-1);
            //std::cout << i << "(-1)\n";
        }else if(ch[i] == '/'){
            int start = sp;
            if(chk_valley()){
                Puddle p = makePuddle(start);
                mergePuddle(p);
            }else{
                sp = start;
                push(1);
            }
            //std::cout << i << "(1)\n";
        }else if(ch[i] == '_'){
            push(0);
            //std::cout << i << "(0)\n";
        }else{
            space++;
        }
        //std::cout << '\n';
    }
    
    /*for(int i=0;i<MAX_NUM-space;i++){
        std::cout << pop() << ' ' ;
    }
    std::cout << '\n';*/
    
    int area_sum=0;
    int p=pp;
    
    while(pp>0){
        Puddle p = pop_P();
        area_sum += p.area;
        //p.outStatus();
    }
    
    std::cout << area_sum << '\n';
    std::cout << p ;
    for(int i=0;i<p;i++){
        std::cout << ' ' << pud[i].area ;
    }
    
    std::cout << '\n';
    
    return 0;
    
}



Measured memory_bytes: 3208