akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

template <class T>
class SegTree {
    int n;
    vector<T> data;
    T def;
    function<T(T, T)> operation;
    function<T(T, T)> update;

    T _query(int a, int b, int k, int l, int r) {
        if (r <= a or b <= l) return def;
        if (a <= l and r <= b) return data[k];
        else {
            T c1 = _query(a, b, 2*k+1, l, (l+r)/2);
            T c2 = _query(a, b, 2*k+2, (l+r)/2, r);
            return operation(c1, c2);
        }
    }

    public:
    SegTree(ll _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update) : def(_def), operation(_operation), update(_update) {
        n = 1;
        while (n <= _n) {
            n *= 2;
        }
        data = vector<T>(2*n-1, def);
    }

    void change(int i, T x) {
        i += n-1;
        data[i] = update(data[i], x);
        while (i > 0) {
            i = (i-1) / 2;
            data[i] = operation(data[i*2+1], data[i*2+2]);
        }
    }

    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    T operator[] (int i) {
        return data[i+n-1];
    }
};

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

    ll N;
    cin >> N;
    vector<pair<ll, ll>> section(N);
    Rep (i, N) {
        ll L, R;
        cin >> L >> R;
        L--;
        section[i] = {L, R};
    }

    sort(section.begin(), section.end());

    SegTree<ll> st1(N, -inf, [](ll a, ll b){return max(a, b);}, [](ll a, ll b){return b;});
    SegTree<ll> st2(N, inf, [](ll a, ll b){return min(a, b);}, [](ll a, ll b){return b;});

    Rep (i, N) {
        st1.change(i, section[i].first);
        st2.change(i, section[i].second);
    }

    ll ans = 0;
    Rep (i, N) {
        ll tmp = section[i].second - section[i].first;
        tmp += max<ll>(0, min(st2.query(0, i), st2.query(i+1, N)) - max(st1.query(0, i), st1.query(i+1, N)));
        chmax(ans, tmp);

        if (i < N-1) {
            tmp = max<ll>(0, st2.query(0, i+1) - st1.query(0, i+1));
            tmp += max<ll>(0, st2.query(i+1, N) - st1.query(i+1, N));
            chmax(ans, tmp);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int a = 0;
  int b = 0;
  int c = 0;
  int d = 0;
  char tmp = S[0];
  for(int i=1; i<S.size(); i++){
    if(S[i] != tmp){
      tmp = S[i];
    }else{
      a++;
      if(S[i] == '0'){
        tmp = '1';
      }else{
        tmp = '0';
      }
    }
  }
  
  if(S[0] == S[1]) c++;
  for(int i=2; i<S.size(); i++){
    if(S[i] != tmp){
      tmp = S[i];
    }else{
      c++;
      if(S[i] == '0'){
        tmp = '1';
      }else{
        tmp = '0';
      }
    }
  }
  
  reverse(S.begin(),S.end());
  tmp = S[0];
  for(int i=1; i<S.size(); i++){
    if(S[i] != tmp){
      tmp = S[i];
    }else{
      b++;
      if(S[i] == '0'){
        tmp = '1';
      }else{
        tmp = '0';
      }
    }
  }
  
  if(S[0] == S[1]) d++;
  for(int i=2; i<S.size(); i++){
    if(S[i] != tmp){
      tmp = S[i];
    }else{
      d++;
      if(S[i] == '0'){
        tmp = '1';
      }else{
        tmp = '0';
      }
    }
  }
  
  cout << min(a,min(b,min(c,d) ) ) << endl;
  return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;

class pg{
  static void Main(string[] args){
    var a = Console.ReadLine();
    string[] num = a.Split(" "); 
    var col = Int32.Parse(num[1]);
    var b = Console.ReadLine();
	string[] price = b.Split(" ");
    List<int> pList = new List<int>();
    foreach(string p in price)
    {
      pList.Add(Int32.Parse(p));
    }
    pList.Sort();
	int result = 0;
    int cnt = 0;
    foreach(int p in pList){
      result += p;
      cnt ++;
      if(cnt == col){
      break;
      }
	}
    Console.WriteLine(result);
}}


Measured memory_bytes: 28032
ab = [[], [], [], [], []]
for i in range(3):
    a, b = map(int, input().split())
    ab[a].append(b)
    ab[b].append(a)

ways = [False] * 4


def f(now, count):
    if count > 4:
        return False
    for n in ab[now]:
        if ways[n - 1]:
            continue
        ways[n - 1] = True
        if all(ways):
            print("YES")
            exit()
        f(n, count + 1)
        ways[n - 1] = False

for i in range(1, 5):
    ways = [False] * 4
    ways[i - 1] = True
    f(i, 1)
    ways[i - 1] = False
print("NO")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    ll n;
    cin>>n;
    ll sum=0,a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
        sum-=a[i];
        ans+=a[i]*sum;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;

int main(void)
{
   int n;
   while(cin>>n){
       if(n==0) return 0;
       int ans =0;
       while(n>0){
           ans += n/5;
           n/=5;
       }
       cout<<ans<<endl;
   }
   return 0;
}


Measured memory_bytes: 3056
N = int(input())

ac, wa, tle, re, = 0, 0, 0, 0

for i in range(0, N):
    s = input()
    if s == 'AC':
        ac += 1
    elif s == 'WA':
        wa += 1
    elif s == 'TLE':
        tle += 1
    elif s == 'RE':
        re += 1

print(f'AC x {ac}')
print(f'WA x {wa}')
print(f'TLE x {tle}')
print(f'RE x {re}')


Measured memory_bytes: 9192
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};

//a^n (mod)
in modpow(in a, in n, in mod) {
    in res = 1ll;
    while (n > 0ll) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n;
    cin>>n;
    in ket=0;
    in cnt=0;
    rep(i,100){
        if((modpow(26ll,i,INF)-1ll)/25ll>n) break;
        ket=i;
    }

    in a=modpow(26ll,ket,INF)-1ll;
    a /=25ll;
    rep(i,ket){
        rep(j,26ll){
            if(a+modpow(26ll,ket-1-i,INF)*j<=n && n<a+modpow(26ll,ket-1-i,INF)*(j+1ll)){
                char ans='a';
                ans +=j;
                cout<<ans;
                a =a+modpow(26ll,ket-1-i,INF)*j;
                break;
            }
        }
    }
    cout<<endl;
}/*
./problem.exe
*/

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

int main() {
  vector<string> c(3);
  for (int i = 0; i < 3; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < 3; i++) {
    cout << c[i][i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int max(int a, int b){
  return (a>b)?a:b;
}
int min(int a, int b){
  return (a<b)?a:b;
}
int main(){
  int n,mm,count;
  int x[55]={},y[55]={};
  long long int m=0,h=0,u=0,s=0;
  unsigned long long int ans;
  scanf("%d%d",&n,&mm);
  for(int i=0;i<n;i++){
    scanf("%d%d",&x[i],&y[i]);
    m=max(x[i],m); h=min(x[i],h);
    u=max(y[i],u); s=min(y[i],s);
  }
  ans=(m-h)*(u-s);
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=j;k<n;k++){
        for(int l=k;l<n;l++){
          m=max(max(x[i],x[j]),max(x[k],x[l]));
          h=min(min(x[i],x[j]),min(x[k],x[l]));
          u=max(max(y[i],y[j]),max(y[k],y[l]));
          s=min(min(y[i],y[j]),min(y[k],y[l]));
          count=0;
          for(int g=0;g<n;g++){
            if(h<=x[g] && x[g]<=m && s<=y[g] && y[g]<=u) count++;
          }
          if(count>=mm && ans>(m-h)*(u-s)){
            ans=(m-h)*(u-s);
          }
        }
      }
    }
  }
  printf("%llu",ans);
  return 0;
}

Measured memory_bytes: 128
# 参考URL https://note.nkmk.me/python-union-find/
class UnionFind():
    # 各要素の親要素の番号を格納するリスト
    # 要素が根（ルート）の場合は-(そのグループの要素数)を格納する
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # 要素xが属するグループの根を返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # 要素xが属するグループと要素yが属するグループとを併合する
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # 要素x, yが同じグループに属するかどうかを返す
    def same(self, x, y):
        return self.find(x) == self.find(y)

def main():
    from sys import stdin
    def input():
        return stdin.readline().strip()

    n, q = map(int, input().split())

    uf = UnionFind(n)

    ans = []
    for _ in range(q):
        t, u, v = map(int, input().split())
        if t == 0:
            uf.union(u, v)
        else:
            if uf.same(u, v):
                ans.append(1)
            else:
                ans.append(0)
    
    for i in ans:
        print(i)

main()

Measured memory_bytes: 12496
#include <iostream>

using namespace std;

int main()
{
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int R = (-H1*60 - M1 + H2*60 +M2 + 1440)%1440;
    cout << R-K;
    return 0;
}


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

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

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

Measured memory_bytes: 256
#include <stdio.h>

#define MAX_N 100
#define INF 1e8

int main(){
  int N,i,j,k,l,q,r[MAX_N],c[MAX_N],p[MAX_N+1];
  int dp[MAX_N+1][MAX_N+1];
  scanf("%d",&N);
  for(i = 0 ; i < N ; i++){
    scanf("%d%d",&r[i],&c[i]);
  }
  p[0] = r[0];
  for(i = 1 ; i <= N ; i++){
    p[i] = c[i-1];
  }
  N++;
  for(i = 0 ; i < N ; i++){
    dp[i][i] = 0;
  }
  for(l = 2 ; l < N ; l++){
    for(i = 1 ; i < N-l+1 ; i++){
      j = i + l - 1;
      dp[i][j] = INF;
      for(k = i ; k <= j-1 ; k++){
        q = dp[i][k] + dp[k+1][j] + p[i-1]*p[k]*p[j];
        if(q < dp[i][j]){
          dp[i][j] = q;
        }
      }
    }
  }
  printf("%d\n",dp[1][N-1]);
  return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    ll a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    
    using ld = long double;
    ld maxp = -1;
    ll sum = 0, sugar = 0;
    for(int i = 0; 100 * a * i <= f; ++i){
        for(int j = 0; 100 * (a * i + b * j) <= f; ++j){
            for(int k = 0; 100 * (a * i + b * j) + k * c <= f; ++k){
                if(k * c > e * (a * i + b * j)) break;
                for(int l = 0; 100 * (a * i + b * j) + k * c + l * d <= f; ++l){
                    if(k * c + l * d > e * (a * i + b * j)) break;
                    ll s = k * c + l * d;
                    ll w = 100 * (a * i + b * j);
                    ld p = 100.0 * s / (s + w);
                    if(p > maxp){
                        maxp = p;
                        sum = w + s;
                        sugar = s;
                    }
                }
            }
        }
    }

    cout << sum << ' ' << sugar << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
	int i,j,k,lt,lb;
	long long int ans;
	char t[1001],b[1001];
	static unsigned long long int dp[1001][1001];
	cin>>t>>b;
	lb=strlen(b);
	lt=strlen(t);
	for (i=0;i<lt;i++)
	{
		for (j=0;j<lb;j++)
		{
			dp[i][j]=1;
		}
	}
	//昇
	j=0;
	for (i=0;i<lt;i++)
	{
		if (t[i]==b[j])
		{
			//printf(",%d(%d)",i,j);
			for (k=0;k<i;k++)
			{
				dp[k][j]=0;//バツ
			}
			j++;
		}
	}
	//降
	j=lb-1;
	for (i=lt-1;i>=0;i--)
	{
		if (t[i]==b[j])
		{
			//printf(",%d(%d)",i,j);
			for (k=i+1;k<lt;k++)
			{
				dp[k][j]=0;
			}
			j--;
		}
	}
	//一列目
	for (i=0;i<lt;i++)
	{
		if (t[i]==b[0]&&dp[i][0]) dp[i][0]=1;
		else dp[i][0]=0;
	}
	//bが1文字でないとき
	for (j=1;j<lb;j++)
	{
		for (i=0;i<lt;i++)
		{
			if (t[i]==b[j]&&dp[i][j])
			{
				dp[i][j]=0;
				for (k=0;k<i;k++)
				{
					dp[i][j]+=dp[k][j-1]%1000000007;
				}
				dp[i][j]=dp[i][j]%1000000007;
			} else {
				dp[i][j]=0;
			}
		}
	}
	ans=0;
	for (i=0;i<lt;i++)
	{
		ans+=dp[i][lb-1]%1000000007;
	}
	ans=ans%1000000007;
	cout<<ans<<endl;
	return 0;
}


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

#ifdef _LOCAL_DEBUG
#include "templates/debug.h"
#else
#define debug(...) 
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> dp(n);
    for (int& it : a)
        cin >> it;
    dp[1] = abs(a[1] - a[0]);
    for (int i = 2; i < n; i++)
        dp[i] = min(abs(a[i] - a[i - 1]) + dp[i - 1],
                    abs(a[i] - a[i - 2]) + dp[i - 2]);
    // debug(dp);
    cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 3992
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <tuple>
#include <cmath>
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;

int main(){
    int N;
    cin>>N;
    vector<int64_t> V(N);
    for(int i=0;i<N;i++){
        cin>>V[i];
        if(i)V[i]+=V[i-1];
    }
    int64_t ans = 1LL<<60;
    for(int i=0;i<N-1;i++){
        ans = min(ans, abs(V[N-1]-2*V[i]));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a := make([]int, n)
	x := 0
	for i := range a {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
		x += a[i]
	}

	for i := 2; i < n; i += 2 {
		x -= 2 * a[i-1]
	}
	fmt.Print(x)

	wr := bufio.NewWriter(os.Stdout)
	for i := 0; i < n-1; i++ {
		x = a[i]*2 - x
		wr.WriteString(" " + strconv.Itoa(x))
	}
	wr.WriteString("\n")
	wr.Flush()
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll a,b,c;
    cin >> a >> b >> c;
    if(a==b && b==c) cout << "Yes" << "\n";
    else cout << "No" << "\n";
    return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	var A1, A2, A3 int
	fmt.Scanln(&A1, &A2, &A3)
	sum := A1 + A2 + A3
	if sum < 22 {
		fmt.Println("win")
	} else {
		fmt.Println("bust")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ft first
#define sd second
using ll = long long;
const int INF = 1e9+7;
const int EPS = -1e6;
const int maxn = 100000+5;
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}


int main(){
    //freopen("input.txt", "r", stdin);
    fastio();

    ll a,b ,c, d,e,n;
    cin>>n>>a>>b>>c>>d>>e;

    ll time = (n-1) / min({a,b,c,d,e}) +5;

    cout<< time <<endl;

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            Console.WriteLine(Char.IsUpper(s[0])?"A":"a");
            
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 25880
N = int(input())
s_list = []
last_a_count = 0
first_b_count = 0
both_ab_count = 0
contain_ab_count = 0
for s in range(N):
    s_list.append(input().strip())
    if(s_list[-1][-1] == "A" and s_list[-1][0] != "B"):
        last_a_count += 1
    if(s_list[-1][-1] != "A" and s_list[-1][0] == "B"):
        first_b_count += 1
    if(s_list[-1][-1] == "A" and s_list[-1][0] == "B"):
        both_ab_count += 1
    contain_ab_count += s_list[-1].count("AB")
    
ans = contain_ab_count
if(both_ab_count > 0):
    ans += both_ab_count - 1
    ans += first_b_count > 0
    ans += last_a_count > 0
    ans += max(min(first_b_count - 1, last_a_count - 1), 0)
else:
    ans += min(first_b_count , last_a_count )

print(ans)

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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

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

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

const int Nmax=100010;
vi g[Nmax],ch[Nmax];
int par[Nmax],a[Nmax],b[Nmax],c[Nmax];

int Find(int v){
	return par[v]==-1?v:(par[v]=Find(par[v]));
}

pi dfs(int v){
	vi cost,sum;
	for(auto to:ch[v]){
		pi d=dfs(to);
		cost.PB(d.first);
		sum.PB(d.second);
	}
	int s=b[v]+accumulate(ALL(sum),int(0));
	int res=c[v]+s;
	REP(i,cost.size())
		chmin(res,max(cost[i],c[v])+s-sum[i]);
	return pi(res,s);
}

signed main(){
	int n=read(),m=read();
	REP(i,n){
		a[i]=read();
		b[i]=read();
		c[i]=max(a[i]-b[i],int(0));
	}
	REP(i,m){
		int u=read()-1,v=read()-1;
		g[u].PB(v);
		g[v].PB(u);
	}
	
	vector<pi> idx(n);
	REP(i,n)idx[i]=pi(c[i],i);
	sort(ALL(idx));
	
	ONE(par);
	for(auto wi:idx){
		int v=wi.second;
		for(auto to:g[v])if(pi(c[to],to)<wi){
			to=Find(to);
			if(to!=v){
				par[to]=v;
				ch[v].PB(to);
			}
		}
	}
	
	pi ans=dfs(idx.back().second);
	print(ans.first);
}


Measured memory_bytes: 24056
#include <iostream>
#include <cstdio>
using namespace std;
long long n;
long long a[200010];
long long dp[200010];
long long sum[200010];
int main() {
	scanf("%lld", &n);
	for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
	sum[1] = a[1];
	for (long long i = 3; i <= n; i += 2) {
		sum[i] = sum[i - 2] + a[i];
	}
	for (long long i = 2; i <= n; i++) {
		if (i & 1) {
			dp[i] = max(dp[i - 1], dp[i - 2] + a[i]);
		} else {
			dp[i] = max(sum[i - 1], dp[i - 2] + a[i]);
		}
	}
	printf("%lld", dp[n]);
	return 0;
}

Measured memory_bytes: 8512
#include<bits/stdc++.h>
using namespace std;
int n,w,a[120],tot,ppp,res;
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		tot+=a[i];
	}
	res=1000000007;
	for(int i=1;i<n;i++){
		ppp+=a[i];
		tot-=a[i];
		res=min(res,abs(tot-ppp));
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
<?php
  declare(strict_types=1);

  fscanf(STDIN, "%i %i", $n, $m);
  $g = (int)0;
  for ($i = 0; $i < $m; $i++)
  {
      fscanf(STDIN, "%i %i", $a, $b);
      $g |= (int)1 << (($a - 1) * $n + $b - 1);
      $g |= (int)1 << (($b - 1) * $n + $a - 1);
  }

  $limit = 1 << $n;
  for ($passing = (int)1; $passing < $limit; $passing++)
  {
      for ($i = 0; $i < $n; $i++)
      {
          $dp[$passing][$i] = 0;
      }
  }  
  for ($i = 0; $i < $n; $i++)
  {
      $dp[1 << $i][$i] = 1; // trivial paths
  }
  for ($passing = (int)1; $passing < $limit; $passing += 2)
  {
      for ($i = 0; $i < $n; $i++)
      {
          if ($dp[$passing][$i] <= 0 || ($passing & (1 << $i)) === 0)
          {
              continue;
          }

          $unexplored = ~$passing & ($g >> ($i * $n));
          for ($j = 0; $j < $n; $j++)
          {
              $dp[$passing | (1 << $j)][$j] += (int)(($unexplored & (1 << $j)) !== 0) * $dp[$passing][$i];
          }
      }
  }
  
  echo array_sum($dp[$limit - 1]).PHP_EOL;


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

string X;
deque<char> dchar;

int main()
{
    cin>>X;

    for (int i=0; i<X.size(); i++)
    {
        dchar.push_back(X[i]);

        if (dchar.size()>=2 && dchar[dchar.size()-2]=='S' && dchar[dchar.size()-1]=='T')
        {
            dchar.pop_back();
            dchar.pop_back();
        }
    }

    cout<<dchar.size()<<endl;
}

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

int a[1000][1000],b[1000],ans,c,d,h,w,n,m;

int main(){
    cin>>n>>m>>c;
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        for(int u=0;u<m;u++){
            cin>>a[i][u];
        }
    }
    for(int i=0;i<n;i++){
        int ch=0;
        for(int u=0;u<m;u++){
            ch+=a[i][u]*b[u];
        }
        if(ch+c>0)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007ll
#define mod1 998244353ll
#define endl "\n"
#define inf (ll)1e18+1
using namespace std::chrono;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    vector<pair<string,ll>> ar(n);
    for(ll x=0;x<n;x++){
        cin>>ar[x].first>>ar[x].second;
    }
    string s;
    cin>>s;
    ll ans=0;
    ll x;
    for(x=0;x<n;x++){
        if(ar[x].first==s){
            x++;
            break;
        }
    }
    for(;x<n;x++){
        ans+=ar[x].second;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;

map<PLL,ll> ma;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	cin>>n;
	ll ans = 0;
	repi(i,1,n+1){
		string s = to_string(i);
		PLL p = mp(s[0],s[s.size()-1]);
		ma[p]++;
	}
	repi(i,1,n+1){
		string s = to_string(i);
		PLL p = mp(s[s.size()-1],s[0]);
		ans += ma[p];
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j * i <= n; j++) {
            v[j * i]++;
        }
    }
    long long int res = 0;
    for (long long int i = 1; i <= n; i++) {
        res += i * v[i];
    }
    cout << res << endl;
}


Measured memory_bytes: 42316
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<string>
using namespace std;

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

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int main(){

	int A,B;
	int N;
	cin>>N;
	cin>>A>>B;
	string str;
	cin>>str;

	int A_count = 0;
	int B_count = 0;
	int max_clear = A+B;
	vector<int> kekka_A;


	for(int i = 0; i < N; i++){

		switch(str[i]){

			case 'a':
				if(A_count + B_count < max_clear){
					A_count++;
					kekka_A.push_back(1);
				}else{
					kekka_A.push_back(0);
				}	
				break;

			case 'b':
				if( (A_count + B_count < max_clear) && (B_count < B) ){
					B_count++;
					kekka_A.push_back(1);
				}else{
					kekka_A.push_back(0);
				}
				break;

			case 'c':
				kekka_A.push_back(0);
				break;
		}
	}
	REP(i,N){

		if(kekka_A[i] == 1){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}

	}

	return 0;
}


Measured memory_bytes: 1272
#include<iostream>
 
using namespace std;
 
int main(){
 
  int n;
 
  while(cin>>n){
 
 
 
    if(n==0){
      break;
    }
    int a[n];
    int max,min;
 
    max=0;
    min=1000;
 
    for(int i=0;i<n;i++){
      cin>>a[i];
 
      if(a[i]>max){
    max=a[i];
      }
 
      if(a[i]<min){
    min=a[i];
      }
    }
 
    int sum;
 
    sum=0;
 
    for(int p=0;p<n;p++){
      sum=sum+a[p];
    }
 
    sum=sum-max-min;
 
   
 
    cout << sum/(n-2) << endl; 
 
    
 
  }
 
   
 
 
 
  return 0;
}

Measured memory_bytes: 3032
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;

int main(void)
{

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	int t=read<int>();

	bool flag=false;

	while(t--)
	{
		int n=read<int>();
		int x=read<int>();
		int y=read<int>();
		if(x+y>n){flag=true;break;}
		if((n-x-y)&1){flag=true;break;}
	}

	if(flag) puts("No");
	else puts("Yes");

	return 0;

}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int n; cin >> n;

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

    sort(a.begin(), a.end());

    cout << a[n-1] - a[0] << endl;
}

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

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

    int n;
    cin >> n;
    double ans = 0;
    for(int i = 0; i < n; i++){
        double a;
        cin >> a;
        ans += 1 / a;
    }

    ans = 1 / ans;

    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

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

namespace SandboxCSharp
{
    class Solver
    {
        public void Solve()
        {
            int x = io.ScanInt();
            int t = io.ScanInt();
            io.Write(Math.Max(0, x - t));
        }

        // =================================================
        // =================================================

        Stdio io;
        bool isjdg;
        static void Main()
        {
            var s = new Solver();
            s.Solve();
            s.io.Flush();
        }
        public Solver(Stdio _io = null)
        {
            isjdg = _io == null;
            io = _io == null ? new Stdio() : _io;
        }

        void Exit()
        {
            if (isjdg)
            {
                io.Flush();
                Environment.Exit(0);
            }
            else
                throw new HaltException();
        }
    }
    class Stdio
    {
        protected string[] stack = new string[0];
        protected int stackptr = 0;
        protected StringBuilder outbuff = new StringBuilder();

        public virtual int ScanInt()
        {
            return Check() ? int.Parse(stack[stackptr++]) : 0;
        }
        public virtual long ScanLong()
        {
            return Check() ? long.Parse(stack[stackptr++]) : 0;
        }
        public virtual string ScanString()
        {
            return Check() ? stack[stackptr++] : string.Empty;
        }
        public virtual double ScanDouble()
        {
            return Check() ? double.Parse(stack[stackptr++]) : 0;
        }
        protected virtual bool Check()
        {
            if (stackptr < stack.Length) return true;
            var l = Console.ReadLine();
            if (l == null) return false;
            stack = l.Split(' ').ToArray(); stackptr = 0;
            return Check();
        }
        public Stdio Write(long v) { return Write($"{v}"); }
        public Stdio WriteLine(long v) { return WriteLine($"{v}"); }
        public Stdio Write(string str)
        {
            outbuff.Append(str);
            return this;
        }
        public Stdio WriteLine(string str = "")
        {
            outbuff.AppendLine(str);
            return this;
        }
        public virtual Stdio Flush()
        {
            Console.Write(outbuff.ToString());
            outbuff.Clear();
            return this;
        }
    }
    class HaltException : Exception { }

}


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

int main()
{
  int n;
  while(cin >> n){
    int sum = 0;
    int s[100];
    if(n == 0) break;
    else{
      for(int i = 0; i < n; i++){
	cin >> s[i];
      }
      sort(s, s + n);
      s[0] = 0;
      s[n - 1] = 0;
      for(int i = 0; i < n; i++){
	sum += s[i];
      }
      cout << sum / (n - 2) << endl;
    }
  }
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    int begin;
    int end;
    int ans;
    for (size_t i = 0; i < s.size(); i++)
    {
        if (s.at(i) == 'A')
        {
            begin = i;
            break;
        }
        
    }
    for (size_t i = begin; i < s.size(); i++)
    {
        if (s.at(s.size()+begin-i-1) == 'Z')
        {
            end = s.size()+begin-i;
            break;
        }
        
    }
    cout << end - begin << endl;

    return 0;
}

Measured memory_bytes: 3756
#include<stdio.h>

int main(void)
{
	int d,T[100]={0},i=0,j=0,kai[100];

	while(scanf("%d",&d) != EOF)
	{
		if(d==0)
		{
			j-=1;
		    kai[i]=T[j];
     	    T[j]=0;
			i+=1;
		}
		else
		{
			T[j]=d;
	        j+=1;
		}
	}
    for(j=0;j<i;j++)
	{
		printf("%d\n",kai[j]);
	}
  return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 305;

int n;
vector <int> red[MAXN], blue[MAXN];

int main() { 

  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    red[a].push_back(b);
  }
  for (int i = 0; i < n; i++) {
    int c, d;
    scanf("%d %d", &c, &d);
    blue[c].push_back(d);
  }

  int ans = 0;
  multiset<int> st;
  for (int i = 0; i < 2 * n; i++) {
    sort(all(blue[i]));
    for (int y : blue[i]) {
      auto it = st.upper_bound(y);
      if (it != st.begin()) {
        it--;
        ans++;
        st.erase(it);
      }
    }
    for (int y : red[i]) {
      st.insert(y);
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  vector<int> p(n);
  
  for(int i = 0; i < n; i++){
    cin >> p.at(i);
  }
  
  int ans = 0;
  
  for(int i = 0; i < n; i++){
    if(p.at(i)!=(i+1)){
      ans++;
    }
  }
  
  if(ans<=2){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  
}

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

int main(){
	string s;
	int a, n;
	cin >> s;
	n = (int)s.size();
	a = 0;
	for (int i = 0; i < n; ++i){
		if (s[i] == '0') a++;
	}
	cout << (2*min(a, n-a));
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

// g++ -std=c++11 prac.cpp
ll Max=-1e9,Min=1e9+1;
 
int main(){
    ll x,c,y=0,n,m,l,w,sum=0,sum2=0;
    string t,ans;
    bool f=true;
    cin >> n;
    VII alpha(n, vector<int>(26));
    VS s(n);
    rep(i,n){
        cin >> s[i];
        rep(j,s[i].size()){
            alpha[i][s[i][j]-'a']++;
        }
    }
    rep(j,26){
        rep(i,n){
            if(Min > alpha[i][j]){
                Min = alpha[i][j];
            }
        }
        if(Min > 0){
            while(Min!=0){
                ans += j+'a';
                Min--;
            }
        }
        Min = 1e9+1;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int a, b, x;
    cin >> a >> b;

    x=(a+b)%2;

    if(x==0) {
     x = (a+b)/2;
    }

    else{
     x = (a+b)/2+1;
    }

    cout << x << endl;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int H = sc.nextInt();
		int W = sc.nextInt();

		int[][] s = new int[H + 2][W + 2];

		for (int i = 0; i < H; i++) {
			String l = sc.next();
			for (int j = 0; j < W; j++) {
				s[i + 1][j + 1] = l.charAt(j) == '#' ? 1 : 0;
			}
		}
		sc.close();

		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				if (s[i][j] == 1 && s[i - 1][j] == 0 && s[i + 1][j] == 0 && s[i][j - 1] == 0 && s[i][j + 1] == 0) {
					out.println("No");
					return;
				}
			}
		}
		out.println("Yes");

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 23636
#include <iostream>
#include<string>

using namespace std;

int main(){
        string s;
        int count=0,ans=0;

        cin>>s;

        for(int i=0; i<s.size(); i++){
                if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T') count++;
                else {
                        count=0;
                }
                ans=max(ans,count);
        }

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


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define input freopen("1.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#define ll long long int
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
#define pii pair<int, int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpi vector<pii>
#define vpl vector<pll> 
#define ss second 
#define ff first

using namespace std;

const int p = 1e9 + 7;
const int maxn = 1e5 + 1;

void solve() {
    ll x, k , d;
    cin >> x >> k >> d;
    x = abs(x);
    if(x < d) {
        if(k&1) cout << abs(x - d);
        else cout << x;
    }
    else {
        if(k < x/d) {
            cout << x - k*d;
        }
        else {
            ll ans = x - x/d*d;
            k -= x/d;
            if(k&1) { ans = abs(ans - d); }
            cout << ans;
        }
    }
}

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

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


int main (void){
        int N,big=0,small=0,even=0;
        long long int A[200000],nibu=0,haba=1073741824,ans=0;
        scanf("%d",&N);
        for (int i = 0; i < N; i++) {
          scanf("%lld",&A[i]);
          A[i]-=(i+1);
        }
        while (haba>0) {
          big=0;
          small=0;
          even=0;
          for (int i = 0; i < N; i++) {
            if ((A[i]-nibu)>0) {
              big++;
            }
            if ((A[i]-nibu)<0) {
              small++;
            }
            if ((A[i]-nibu)==0) {
              even++;
            }
          }
          if (big>small+even) {
            nibu+=haba;
          }else if (small>big+even) {
            nibu-=haba;
          }else{
            break;
          }
          haba/=2;
        }
        for (int i = 0; i < N; i++) {
          ans+=abs(A[i]-nibu);
        }
        printf("%lld",ans);
        return 0;
}


Measured memory_bytes: 1664
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().rstrip().split()
def S(): return sys.stdin.readline().rstrip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]

mod=924844033

n,k=LI()
fac = [1] * (n + 1)
for j in range(1, n + 1):
    fac[j] = fac[j-1] * j % mod

dp=[[0]*2 for _ in range(n+1)]
dp[0][0]=1
last=0
for i in range(min(n,2*k)):
    idx=i
    while idx<n:
        ndp = [[0] * 2 for _ in range(n+1)]
        if idx==i:
            for ll in range(n+1):
                dp[ll][0]+=dp[ll][1]
                dp[ll][1]=0
        for l in range(1,n+1):
            ndp[l][0]=sum(dp[l])
            if idx-k>=0:
                ndp[l][0]+=dp[l-1][0]
            if idx+k<n:
                ndp[l][1]=sum(dp[l-1])
            ndp[l][0]%=mod
        ndp[0][0]=1
        dp=ndp
        idx+=2*k

ans=fac[n]
for m in range(1,n+1):
    if m%2:
        ans-=sum(dp[m])*fac[n-m]%mod
    else:
        ans+=sum(dp[m])*fac[n-m]%mod
    ans%=mod

print(ans)












Measured memory_bytes: 191764
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		String s = in.next();
        int a = s.length();
		char[] s_chars = s.toCharArray();
      
      for(int i = 1; i <= a ;i++){
        if(i%2!=0){
		System.out.print(s_chars[i-1]);
        }
      }

	}
}


Measured memory_bytes: 29516
#input
N = int(input())
B = list(map(int, input().split()))

#output
A = [0] * N
A[0] = B[0]
A[N-1] = B[N-2]

for n in range(1, N-1):
    A[n] = min(B[n], B[n-1])
print(sum(A))

Measured memory_bytes: 38256
#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;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x, y; cin >> x >> y;
    if(x == 0){
        if(y >= 0) cout << y << endl;
        else cout << abs(y)+1 << endl;
    }
    else if(x > 0){
        if(abs(y) >= x){
            if(y > 0) cout << y-x << endl;
            else cout << abs(y)-x+1 << endl;
        }
        else{
            if(y <= 0) cout << y - (-x) + 1 << endl;
            else cout << 1 + (-y) - (-x) + 1 << endl;
        }
    }
    else{
        if(abs(x) > abs(y)){
            if(y <= 0) cout << y-x << endl;
            else cout << (-y) - x + 1 << endl;
        }
        else{
            if(x < y) cout << 1 + y - (-x) << endl;
            else cout << 1 + (-y) - (-x) + 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

void solve(long long A, long long B, long long K){
    ll cnt=0;
    fore(i,1,100){
        if(A%i==0&&B%i==0)cnt++;
    }
    fore(i,1,100){
        if(A%i==0&&B%i==0)cnt--;
        if(cnt==K-1){
            cout<<i<<endl;
            return;
        }
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long K;
    scanf("%lld",&K);
    solve(A, B, K);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <climits>
#include <queue>
#include <cstring>
using namespace std;
#define INF (1<<21)
#define rep(i,n) for(int i=0;i<n;i++)	
int solve(int &m,int &n,vector<int> &book){
	int ret = INF;
	int dp[n][n];	
	memset(dp,0,n*n*4);
	rep(i,n){
		for(int j=i;j<n;j++){
			if(i == j)dp[i][j] = book[j];
			else dp[i][j] = dp[i][j-1] + book[j];
		}
	}
	rep(x,n)rep(y,n){
		rep(i,n){
			int width = dp[x][y];
			int cur = i,p,sum = 0;
			
			if(dp[0][i] > width)continue;
			
			bool flag;
			//cout << "[" << width << "]" << endl;
			int count = 0;
			do{
				flag = true;
				p = cur+1;
				while( cur+1 < book.size() && dp[p][cur+1] <= width){
					cur++; flag = false;
				}
				count++;
			}while(!flag);

			if(cur == book.size()-1 && count <= m)
				ret = min(ret,width);
		}
	}
	return ret;
}
int main(){
	int n,m;
	while(cin >> m >> n,n){
		vector<int> book(n);
		rep(i,n)cin >> book[i];
		cout << solve(m,n,book) << endl;
	}
}

Measured memory_bytes: 0