akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define Nmax 100005
#include <cmath>
#define INF 0x3f3f3f3f

using namespace std;

ifstream f("1.in");
ofstream g("1.out");

int n, k, dp[Nmax][4];
int a, b, c;
//0a, 1b, 2c
int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a >> b >> c;
        dp[i][0]=max(dp[i-1][1], dp[i-1][2])+a;
        dp[i][1]=max(dp[i-1][0], dp[i-1][2])+b;
        dp[i][2]=max(dp[i-1][0], dp[i-1][1])+c;
    }
    /*for (int i =1; i <= n; i++)
    {
        for (int j = 0; j <= 3; j++)
            cout << dp[i][j] << " ";
        cout << '\n';
    }*/
    cout << max(dp[n][0], max(dp[n][1], dp[n][2]));

}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.0001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	ll i, n, m, x[50], y[50], least = LL_INF;
	cin >> n >> m;
	for (i = 0; i < n; i++) cin >> x[i] >> y[i];
	for (int p = 0; p < n; p++) {
		for (int q = 0; q < n; q++) {
			for (int u = 0; u < n; u++) {
				for (int v = 0; v < n; v++) {
					ll cnt = 0;
					ll l = x[p], r = x[q], b = y[u], t = y[v];
					for (i = 0; i < n; i++) {
						if (l <= x[i] && x[i] <= r && b <= y[i] && y[i] <= t) cnt++;
					}
					if (cnt >= m) {
						least = min(least, (r - l)*(t - b));
					}
				}
			}
		}
	}
	cout << least << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/



signed main() {
	string s; cin >> s;
	if (s == "SUN")cout << 7 << endl;
	else if (s == "MON")cout << 6 << endl;
	else if (s == "TUE")cout << 5 << endl;
	else if (s == "WED")cout << 4 << endl;
	else if (s == "THU")cout << 3 << endl;
	else if (s == "FRI")cout << 2 << endl;
	else cout << 1 << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AShiritori {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string a, b, c;
	    in >> a >> b >> c;
	    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0]) ans2(true, out);
	    else ans2(false, out);
	}
};


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int w,h;
    cin>>h>>w;
    string s[h];
    for(int i=0; i<h; i++)
        cin>>s[i];
    for(int i=0; i<w+2; i++)
        putchar('#');
        cout<<endl;
    for(int i=0; i<h; i++)
    {
        putchar('#');
        for(int j=0; j<w; j++)
            putchar(s[i][j]);
        putchar('#');
        cout<<endl;
    }
    for(int i=0; i<w+2; i++)
        putchar('#');
        cout<<endl;
}

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

#define ll long long

using namespace std;

int f[200][200];

int main() {
    int w,h,n;
    cin >> w >> h >> n;
    int x,y,a;
    int ww = w, hh = h;
    int maxx = w, maxy = h;
    int minx = 0, miny = 0;
    for(int i = 0;i < n;i++){
        cin >> x >> y >> a;
        switch(a){
            case 1:
                minx = x > minx ? x : minx;
                break;
            case 2:
                maxx = x < maxx ? x : maxx;
                break;
            case 3:
                miny = y > miny ? y : miny;
                break;
            case 4:
                maxy = y < maxy ? y : maxy;
                break;
        }
    }
    if(minx > maxx  || miny > maxy){
        cout << 0 << endl;
    }else{
        cout << (maxx - minx)*(maxy - miny) << endl;
    }
	return 0;
}        


Measured memory_bytes: 256
N, M, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)

temp = 0
asum = A.map{|item| temp += item}
temp = 0
bsum = B.map{|item| temp += item}

result = 0
if bsum[-1] <= K
  result = bsum.length
else
  result = bsum.bsearch_index do |x|
    x > K
  end
end

asum.each_with_index do |a, i|
  nokori = K - a
  if nokori < 0
    break
  end
  if nokori >= bsum[-1]
    res = i + 1 + bsum.length
  else
    res = bsum.bsearch_index do |x|
      x > nokori
    end
    res += i + 1
  end
  if res > result
    result = res
  end
end

puts result

Measured memory_bytes: 44872
def 解():
    N = int(input())
    aH = [int(_) for _ in input().split()]

    dp = [0]*3
    dp[1] = abs(aH[0] - aH[1])
    #dp={0:0,1:abs(aH[0]-aH[1]),2:0}
    for i in range(2,N):
        dp[i%3] = min(abs(aH[i]-aH[i-1])+dp[(i-1)%3],abs(aH[i]-aH[i-2]) + dp[(i-2)%3])
    print(dp[(N-1)%3])
解()


Measured memory_bytes: 13980
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
using namespace std;

int main(){
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i, n)rep(j, d) cin >> x[i][j];
  int ans = 0;
  rep(i, n-1)rep2(j, i+1, n){
    int num = 0;
    rep(k, d){
      num += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
    }
    int snum = sqrt(num);
    if (snum * snum == num) ans++;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int mns=b-a;
	long long sum=0;
	for(int i=1;i<=mns;i++)
	{
		sum+=i;
	}
	cout<<sum-b;
	return 0;
}

Measured memory_bytes: 256
package main

import(
  "fmt"
)

func main() {
  var a, b, c int
  ans := 3
  fmt.Scan(&a, &b, &c);
  if a == b {ans--}
  if a == c {ans--}
  if b == c && ans != 1 {ans--}
  fmt.Println(ans)
}


Measured memory_bytes: 512
n=int(input())
check=list(map(int,input().split()))
f=0
for i in range(n):
    if check[i]%2==0:
        if check[i]%3!=0 and check[i]%5!=0:
            f=1
                
if f==1:
    print("DENIED")
else:
    print("APPROVED")

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



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector< tuple<int, int, int> > v;
  set<int> st;

  for(int i=0;i<n;i++) {
    int ai, bi;
    cin >> ai >> bi;
    v.push_back(make_tuple(ai, bi, 0));
  }

  for(int i=0;i<n;i++) {
    int ci, di;
    cin >> ci >> di;
    v.push_back(make_tuple(ci, di, 1));
  }
  sort(v.begin(), v.end());

  int ans = 0;

  for(int i=0;i<v.size();i++) {
    int x, y, c;
    tie(x, y, c) = v[i];
    if(c == 0) {
      st.insert(y);
    } else {
      auto it = st.lower_bound(y);
      if(it != st.begin()) {
        st.erase(--it);
        ans++;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define llong long long
#define mp make_pair
#define f first
#define s second
//#define cin fin

using namespace::std;

const int P = 1e9 + 7;

int main()
{
    ios::sync_with_stdio(false);
    ifstream fin("input.txt");
    int N;
    cin >> N;
    string up, down;
    cin >> up >> down;

    llong val = 0, start, prev = 1;
    if (up[0] == down[0]) {
        val = 3;
        start = 1;
        prev = 1;
    }
    else {
        val = 6;
        start = 2;
        prev = 2;
    }
    while(1) {

        if (start >= N) {
            break;
        }
        //cout << start << " " << val << "\n";
        if (up[start] == down[start]) {
            if (prev == 2) {

            }
            else if (prev == 1) {
                val = (val * 2) % P;
            }
            prev = 1;
            start++;
        }
        else {
            if (prev == 1) {
                val = (val * 2) % P;
            }
            else if (prev == 2) {
                val = (val * 3) % P;
            }
            prev = 2;
            start += 2;
        }
    }
    cout << val;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long int n,a=0,b=0,i,sum;
    int s[102];
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>s[i];
    }
    sort(s,s+n);
    for(i=0;i<n;i++)
    {
        if(i%2==0)
        {
         a+=s[i];
        }
        else
        {
            b+=s[i];
        }
    }
    sum=a-b;
    if(sum<0)
    {
        sum=sum*(-1);
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define lout cout
#else
stringstream devnull;
#define lout devnull
#endif
template <class C>
inline void vcin(C &a);
template <class C>
inline void vcout(const C a, const string separate = "\n");

int main()
{
  int n;
  cin >> n;
  vector<int> w(n);
  vcin(w);
  int sum = accumulate(w.begin(), w.end(),0);
  int minsub = 2 << 24;
  for (int k = 1; k < n; k++)
  {
    int s1 = accumulate(w.begin(), next(w.begin(), k), 0);
    int s2 = sum - s1;
    lout << s2 << endl;
    minsub = min(minsub, abs(s1 - s2));
  }
  cout << minsub << endl;
  return 0;
}

template <class C>
inline void vcin(C &c)
{
  for (auto &a : c)
  {
    cin >> a;
  }
}
template <class C>
inline void vcout(const C c, const string separate)
{
  for (auto it = c.begin(); it != c.end(); it++)
  {
    if (it != c.begin())
      cout << separate;
    cout << *it;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int r,c;
char f[22][22];
bool used[22][22][5][22];
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

bool solve(int x,int y,int a,int m){
  if(x < 0) x = c-1;
  if(c <= x) x = 0;
  if(y < 0) y = r-1;
  if(r <= y) y = 0;
  if(m < 0) m = 15;
  if(15 < m) m = 0;
  if(used[x][y][a][m]) return false;
  used[x][y][a][m] = true;
  switch(f[x][y]){
  case '@': return true;
  case '>': return solve(x+dx[0],y+dy[0],0,m);
  case '<': return solve(x+dx[1],y+dy[1],1,m);
  case 'v': return solve(x+dx[2],y+dy[2],2,m);
  case '^': return solve(x+dx[3],y+dy[3],3,m);
  case '.': return solve(x+dx[a],y+dy[a],a,m);
  case '+': return solve(x+dx[a],y+dy[a],a,m+1);
  case '-': return solve(x+dx[a],y+dy[a],a,m-1);
  case '_': return solve(x+dx[m?1:0],y+dy[m?1:0],m?1:0,m);
  case '|': return solve(x+dx[m?3:2],y+dy[m?3:2],m?3:2,m);
  case '?': for(int i = 0; i <4; i++)if(solve(x+dx[i],y+dy[i],i,m))return true; return false;
  default : return solve(x+dx[a],y+dy[a],a,f[x][y]-'0');
  }
}

int main(void){
  cin >> r >> c;
  for(int y = 0; y < r; y++){
    for(int x = 0; x < c; x++){
      cin >> f[x][y];
    }
  }
  if(solve(0,0,0,0)){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 2440
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int N;
int A[101];

int main()
{
	cin >> N;
	int sum = 0;
	rep(i,0,N) {
		cin >> A[i];
		sum += A[i];
	}
	int h = ceil((double)sum/N);
	int l = floor((double)sum/N);

	int ha = 0, la = 0;
	rep(i,0,N) {
		ha += abs(h - A[i]) * abs(h - A[i]);
		la += abs(l - A[i]) * abs(l - A[i]);
	}

	cout << min(ha,la) << endl;

	return 0;
}

Measured memory_bytes: 256
import sys

B, W = map(int, sys.stdin.readline().split())
MOD = 10**9 + 7

L = B+W
fact = [1]*(L+1)
rfact = [1]*(L+1)
for i in range(L):
    fact[i+1] = r = fact[i] * (i+1) % MOD
    rfact[i+1] = pow(r, MOD-2, MOD)

rev2 = pow(2, MOD-2, MOD)

p = q = 0
base = 1
ans = ["%d\n" % rev2]
for i in range(1, B+W):
    base = rev2 * base % MOD
    if i-B >= 0:
        p = (p + ((fact[i-1]*rfact[B-1] % MOD)*rfact[i-B] % MOD)*base % MOD) % MOD
    if i-W >= 0:
        q = (q + ((fact[i-1]*rfact[W-1] % MOD)*rfact[i-W] % MOD)*base % MOD) % MOD
    ans.append("%d\n" % ((1-p+q)*rev2 % MOD))
sys.stdout.writelines(ans)

Measured memory_bytes: 65912
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll n, q;
    cin >> n >> q;
    vector<pair<ll, ll>> vec;

    rep(i, n) {
        ll s, t, x;
        cin >> s >> t >> x;
        vec.emplace_back(max(0LL, s - x), -x);
        vec.emplace_back(max(0LL, t - x), x);
    }
    rep(i, q) {
        ll d;
        cin >> d;
        vec.emplace_back(d, LINF);
    }
    sort(all(vec));

    multiset<ll> st;
    st.insert(LINF);
    ll cnt = 0;
    for (auto p : vec) {
        assert(p.second != 0);
        if (p.second == LINF) {
            cout << (*st.begin() == LINF ? -1 : *st.begin()) << endl;
            cnt++;
        } else {
            if (p.second < 0) {
                st.insert(-p.second);
            } else {
                if (st.find(p.second) != st.end()) {
                    st.erase(st.find(p.second));
                }
            }
        }
        // cout << p.first << " " << p.second << endl;
    }
    assert(cnt == q);
}


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

int main(){
    long long n, a, b;
    cin >> n >> a >> b;

    long long ans = 0;
    int ch = a;
    int st = 0, mo = 0;

    for(int i = 0; i <= n; i++){
        st = 0;
        mo = 100;
        st += i % 10;
        for(int j = 2; j <= to_string(i).length(); j++){
            st += (i % mo) / (mo/10); 
            mo *= 10;
        }
        if(st >= a && st <= b) {
            ans += i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import sys


def main():
    n = int(input())
    s = []
    t = []
    for i in range(n):
        tmp = input().split()
        if len(tmp):
            s.append(str(tmp[0]))
            t.append(int(tmp[1]))
    x = input()
    tmp = s.index(x.replace("\n", ""))
    res = 0
    for i in range(tmp+1, n):
        res += t[i]
    print(res)


if __name__ == '__main__':
    input = sys.stdin.readline
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>

using namespace std;  //このネームスペースを使う

int main(){
  
  int a,b;
  int mod;

  cin >> a ;
  cin >> b ;
  
  mod = b % a;

  if(mod == 0){
  	cout << b + a ;
  }
  else{
  	cout << b - a ;
  }


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
  string s;
  cin>>s;
  cout<<s.substr(0,s.size()-8)<<endl;
}


Measured memory_bytes: 256
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int shihab;
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
    FI(); /// skip this line for compile
    int a,b;
    cin >> a >> b;
    if((a*b)%2) cout << "Odd\n";
    else cout << "Even\n";
    return 0;
    //code end
}
//okbye


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

int main() {
    int h, w;

    cin >> h >> w;

    vector<vector<char>> a(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a.at(i).at(j);
        }
    }

    vector<int> show_i;
    for (int i = 0; i < h; i++) {
        int c = 0;
        for (int j = 0; j < w; j++) {
            if (a.at(i).at(j) == '.') c++;
        }
        if (c < w) show_i.push_back(i);
    }

    vector<int> show_j;
    for (int j = 0; j < w; j++) {
        int c = 0;
        for (int i = 0; i < h; i++) {
            if (a.at(i).at(j) == '.') c++;
        }
        if (c < h) show_j.push_back(j);
    }

    for (int i : show_i) {
        for (int j : show_j) {
            cout << a.at(i).at(j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);

const int MAXN = 105;
int a[MAXN];
int main()
{
    //FIN;
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int sum = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    int m;
    cin >> m;
    for(int i = 0; i < m; i++)
    {
        int p, x;
        cin >> p >> x;
        cout << sum -a[p-1] + x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for (int mid = 1; mid < N-1; mid++) {
    bool hit[26][2] = {false};
    for (int l = 0; l < mid; l++) {
      char c = S[l];
      hit[(int)(c-'a')][0] = true;
    }
    for (int r = mid; r < N; r++) {
      char c = S[r];
      hit[(int)(c-'a')][1] = true;
    }
    int same = 0;
    for (int i = 0; i < 26; i++) {
      if (hit[i][0] && hit[i][1]) same++;
    }
    ans = max(ans, same);
  }
  cout << ans << endl;
  return 0;
}


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

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif

//改造
typedef long long int ll;
using namespace std;

//ここから編集する

int main() {
    vector<int> teiki[200001];
    int n,m;
    cin >> n >> m;

    for(int i = 0;i < m; i++){
        int a,b;
        scanf("%d%d",&a,&b);
        teiki[a].push_back(b);
    }


    for(int i = 0; i < teiki[1].size(); i++ ){
        //1番目の島から行ける場所を取得
        int secound_sima = teiki[1][i];
        for(int j = 0; j < teiki[secound_sima].size(); j++){
            if(teiki[secound_sima][j] == n){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }

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

Measured memory_bytes: 8576
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
const ll MAX = 200010;//設定して

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;//＊１
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
//階乗
long long factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return (fac[n]*finv[k])%mod;
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//aの逆元求めるならn=mod-2
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll dp[3000][3000];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,k;
cin>>n>>k;
COMinit();
for(int i=1;i<=k;i++){
  ll ans=1;
    (ans*=COM(n-k+1,i)*COM(k-1,i-1)%mod)%=mod;
  cout<<ans<<endl;
}
}


Measured memory_bytes: 5632
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	string s; cin >> s;

	//↑0→1↓2←3
	int direction = 0;
	bool isClockwise = true;
	int ans = 0;

	for (int i = 0; i < s.length(); i++) {
		char order = s[i];

		if (order == 'R') {
			direction++;
		}
		else {
			direction--;
		}

		if (direction == -4) {
			isClockwise = true;
			direction = 0;
		}

		if (direction == 4) {
			ans++;
			direction = 0;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3204
N = int(input())
h = list(map(int, input().split()))

counter = 0

while h != [0]*N:
    for l in range(N):
        if h[l] != 0:
            break
    r = N-1
    for r in range(l+1,N):
        if h[r] == 0:
            r -= 1
            break
    for n in range(l,r+1):
        h[n] -= 1
    counter += 1
    continue

print(counter)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>

using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
const ll MOD = 1e9 + 7;


int main() {
	ll H, W;
	cin >> H >> W;
	vll ans;
	if (H % 3 == 0 || W % 3 == 0) {
		cout << 0 << endl;
	}
	else if (H == 1 || W == 1) {
		cout << 1 << endl;
	}
	else {
		ll S1, S2, S3;
		ll maxi;
		ll mini;
		ll kouho;
		repp(i, H-1) {
			S1 = i * W;
			S2 = (H - i) * (W / 2);
			S3 = H * W - S1 - S2;
			maxi = max(S1, max(S2, S3));
			mini = min(S1, min(S2, S3));
			kouho =  maxi - mini;
			ans.push_back(kouho);
		}
		repp(i, W-1) {
			S1 = i * H;
			S2 = (W - i) * (H / 2);
			S3 = H * W - S1 - S2;
			maxi = max(S1, max(S2, S3));
			mini = min(S1, min(S2, S3));
			kouho = maxi - mini;
			ans.push_back(kouho);
		}
		ans.push_back(H);
		ans.push_back(W);
		sort(ans);
		cout << ans[0] << endl;
	}
}

Measured memory_bytes: 2420
#include <iostream>
using namespace std;
long long i,cifra,suma;
string s;
int main ()
{
    cin>>s;
    for (i=0;i<s.length();++i)
    {
        cifra = s[i]-'0';
        suma += cifra;
    }
    if (suma%9==0) cout<<"Yes";
    else cout<<"No";
}


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

ll dfs(ll prev, ll now, vector<vector<ll>>& adj, vector<ll>& dp, set<ll>& st) {
	if (dp[now] > 0) return dp[now];
	if (st.find(now) != st.end()) return -1;
	st.insert(now);
	ll ret = 0;
	for (auto i : adj[now]) {
		if (i == prev) continue;
		ll x = dfs(now, i, adj, dp, st);
		if (x == -1) return -1;
		ret = max(ret, x);
	}
	return dp[now] = ret + 1;
}

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

	auto idx = [&] (ll i, ll j) {
		if (i > j) swap(i, j);
		ll ret = n * (n - 1) / 2 - (n - i) * (n - i - 1) / 2;
		return ret + j - i - 1;
	}; // {i, j} が対戦する試合の頂点番号

	ll m = n * (n - 1) / 2;
	vector<vector<ll>> adj(m);
	vector<ll> cnt(m, 0);
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < n - 2; j++) {
			ll u = idx(i, a[i][j]), v = idx(i, a[i][j + 1]);
			adj[u].push_back(v);
			cnt[v]++;
		}
	}

	vector<ll> dp(m, 0);
	ll ans = 0;
	for (ll i = 0; i < m; i++) {
		if (cnt[i] == 0) {
			set<ll> st;
			ll x = dfs(-1, i, adj, dp, st);
			if (x == -1) {
				cout << -1 << endl;
				return 0;
			} else ans = max(ans, x);
		}
	}

	for (ll i = 0; i < m; i++) {
		for (auto j : adj[i]) {
			if (dp[i] <= dp[j]) {
				cout << -1 << endl;
				return 0;
			}
		}
	}

	cout << ans << endl;
}

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

int main(){
	int ans;
	double l[10], sum;
	double v1, v2, t;
	char k;

	while(1){
		sum=ans=0;
		for(int i=0; i<10; i++){
			cin>>l[i]>>k;
			sum+=l[i];
		}
		cin>>v1>>k>>v2;
		if(cin.eof())break;

		t=sum/(v1+v2);//ツ猟キツ人ツ算

		sum=0;

		while(t*v1>sum){//t*v1ツづ債つキツづェツ暗。ツつ、ツ仰猟猟」
			sum+=l[ans];
			ans++;
		}
		cout<<ans<<"\n";

	}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
using namespace std;
using ll=long long;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

  int N;
  string S;
  cin>>N; cin>>S;
  int len = S.length();
  int ans=INF;

  int cntAllD=0;
  int cntAllH=0;
  REP(i,len){
    if(S[i]=='.') ++cntAllD;
    else ++cntAllH;
  }

  bool flag=false;
  if(cntAllD==0 or cntAllH==0) flag=true;

  if(!flag){
    char lastS;
    int cntD=0;
    int cntH=0;
    REP(i,len){
      if(i==0){}
      else{
        if(lastS=='.' and S[i]=='#'){
          ans=min(ans, cntH+(cntAllD-cntD));
        }
      }
      if(S[i]=='.') ++cntD;
      else if(S[i]=='#') ++cntH;

      lastS=S[i];
    }
    ans = min(ans, len-cntAllD);
    ans = min(ans, len-cntAllH);
  }

  if(flag) cout<<"0"<<endl;
  else cout<<ans<<endl;
  return 0;
}

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

const int inf = LLONG_MAX/3;

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n+1);
	for (int i=1; i<=n; ++i){
		cin >> a[i];
	}
	vector<vector<int>> dp(n+1,vector<int>(n+1,inf));
	for (int i=0; i<=n; ++i){
		dp[i][i] = 0;
	}
	vector<int> psum(n+1);
	for (int i=1; i<=n; ++i){
		psum[i] += psum[i-1];
		psum[i] += a[i];
	}
	for (int len=1; len<n; ++len){
		for (int start=1; start<=n-len; ++start){
			int beg = start, end = len+start;
			for (int i=beg; i<end; ++i){
				dp[beg][end] = min(dp[beg][end],dp[beg][i]+dp[i+1][end]+psum[end]-psum[beg-1]);
			}
		}
	}
	cout << dp[1][n];
	return 0;
}


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

int main() {
   int N;
   cin >> N;
   int A=0,W=0,T=0,R=0;
   for (int i=0; i<N; i++) {
       string S;
       cin >> S;
       if (S=="AC") A++;
       else if (S=="WA") W++;
       else if (S=="TLE") T++;
       else R++; 
   }
   cout << "AC x " << A << endl;
   cout << "WA x " << W << endl;
   cout << "TLE x " << T << endl;
   cout << "RE x " << R << endl;
}

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

int main(){
    int n;
    bool ans = true;
    string s;
    cin >> n >> s;
    string str1, str2;
    if(n % 2 == 1) ans = false;
    else{
        for(int i = 0; i < n / 2; i++){
            if(s[i] != s[i + n / 2]){
                ans = false;
                break;
            }
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define loop(i,n) for(int i=0;i<n;++i)
int main(){
int t;
  cin>>t;
  long long int arr[t];
  long long int multi=1;
  bool flag=0;
  loop(i,t)
  {cin>>arr[i];
   if(arr[i]==0)
   {flag=1;
    break;
   }
  }
 if(flag==1)
 cout<<0<<endl;
 else
 {loop(i,t)
   {multi*=arr[i];
    if(arr[i]>multi||multi>1000000000000000000)
    {cout<<-1<<endl;
   	return 0;
   	}
   }
   cout<<multi<<endl;
  }
 return 0;
}

Measured memory_bytes: 4344
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back

const int N = 1e5;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
int n;

int main(){
  string s;
  cin >> s;
  if(s.find("AC") != -1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    LL a; cin >> a;
    cout << a + a * a + a * a * a << '\n';
}

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

int main(){
    int n;
    cin >> n;
    long long int T = 1, A = 1;
    long long int sum = T + A;
    for(int i = 0; i < n; i++){
        long long int t, a;
        cin >> t;
        cin >> a;
        long long int k = max(1+((A-1)/a), 1+((T-1)/t));
        T = k * t;
        A = k * a;
        //cout << "t,a:" << T << " " << A << "\n";
        sum = T + A; 
    }
    cout << sum << "\n";
    return 0;
}

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

int main(){
	int a, b;
	cin >> a >> b;
	if(a >= 13){
		cout << b << endl;
		return 0;
	}else if(a >= 6 && a <= 12){
		cout << b/2 << endl;
		return 0;
	}else{
		cout << "0" << endl;
		return 0;
	}
	return 0;
}

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

using namespace std;

const unsigned long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}


priority_queue<pair<long long, pair<int, int>>> da;

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n; cin >> n;

    for(int i = 0; i < n; ++i){
        long long j, k; cin >> j >> k;
        da.push(make_pair(j + k, make_pair(j, k)));
    }

    long long a = 0, b = 0;

    for(int i = 0; i < n; ++i){
        if(i % 2 == 0){
            a += da.top().second.first;
            da.pop();
        } else {
            b += da.top().second.second;
            da.pop();
        }
    }

    cout << a - b << "\n";

    return 0;

}


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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll h, w; cin >> h >> w;
  vector<string> s(h);
  FOR(i,h){ cin >> s[i]; }
  
  //main
  map<ll,ll> mh,mw;
  ll ch=0, cw=0;
  FOR(i,h){ 
    FOR(j,w){ 
      if(s[i][j]=='#'){ 
        mh.insert(mp(i,ch));
        ch ++;
        break;
      } 
    } 
  }
  FOR(j,w){ 
    FOR(i,h){ 
      if(s[i][j]=='#'){ 
        mw.insert(mp(j,cw));
        cw ++;
        break;
      } 
    } 
  }
  
  vector<vector<char>> ans(ch,vector<char>(cw,'.'));
  FOR(i,h){
    FOR(j,w){
      if(s[i][j]=='#'){
        ans[mh[i]][mw[j]] = '#'; 
      }
    }
  }
  
  // output
  FOR(i,ch){
    FOR(j,cw){
      cout << ans[i][j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    int H, W;
    cin >> H >> W;
    vector<vector<char> > field(H, vector<char>(W));
    for (int y = 0; y < H; ++y) {
        for (int x = 0; x < W; ++x) {
            cin >> field.at(y).at(x);
            if (field.at(y).at(x) == '.') {
                field.at(y).at(x) = '0';
            }
        }
    }

    for (int y = 0; y < H; ++y) {
        for (int x = 0; x < W; ++x) {
            if (field.at(y).at(x) == '#') {
                for (int dy = -1; dy <= 1; ++dy) {
                    for (int dx = -1; dx <= 1; ++dx) {
                        if (dy == 0 && dx == 0) continue;
                        int ny = y + dy;
                        int nx = x + dx;
                        if (ny < 0 || H <= ny) continue;
                        if (nx < 0 || W <= nx) continue;
                        if (field.at(ny).at(nx) != '#') {
                            field.at(ny).at(nx) += 1;
                        }
                    }
                }
            }
        }
    }

    for (int y = 0; y < H; ++y) {
        for (int x = 0; x < W; ++x) {
            cout << field.at(y).at(x);
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

ll _pow(ll a, ll n) {
	if(n==0) return 1;
	else {
		ll res = 1;
		ll buf = a;
		while(n>0) {
			if(n%2==1) {
				res *= buf;
				res %= MOD;
			}
			buf *= buf;
			buf %= MOD;
			n/=2;
		}
		return res;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	vector<ll> cnt1(4,0);
	vector<ll> cnt2(4,0);
	REP(i,s.size()) {
		if(s[i]=='A') cnt2[0]++;
		if(s[i]=='B') cnt2[1]++;
		if(s[i]=='C') cnt2[2]++;
		if(s[i]=='?') cnt2[3]++;
	}
	ll ans=0;
	REP(i,s.size()) {
		if(s[i]=='A') cnt2[0]--;
		if(s[i]=='B') cnt2[1]--;
		if(s[i]=='C') cnt2[2]--;
		if(s[i]=='?') cnt2[3]--;
		if(s[i]=='B'||s[i]=='?') {
			ans+=((cnt1[0]*cnt2[2])%MOD)*_pow(3,cnt1[3]+cnt2[3]);
			ans%=MOD;
			ans+=((cnt1[3]*cnt2[2])%MOD)*_pow(3,cnt1[3]+cnt2[3]-1);
			ans%=MOD;
			ans+=((cnt1[0]*cnt2[3])%MOD)*_pow(3,cnt1[3]+cnt2[3]-1);
			ans%=MOD;
			ans+=((cnt1[3]*cnt2[3])%MOD)*_pow(3,cnt1[3]+cnt2[3]-2);
			ans%=MOD;
		}
		if(s[i]=='A') cnt1[0]++;
		if(s[i]=='B') cnt1[1]++;
		if(s[i]=='C') cnt1[2]++;
		if(s[i]=='?') cnt1[3]++;
	}
	cout<<ans<<endl;
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

ll N, A, B;

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

  cin >> N >> A >> B;
  ll ans = (B - A) * (N - 2) + 1;
  if (A > B) ans = 0;
  if (N == 1) {
    if (A == B) ans = 1;
    else ans = 0;
  }
  
  cout << ans << endl;
  
  return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,d,o;
  while(cin>>d,d){
    int p[100001]={0},h[100001];
    cin>>n>>o;
    for(int i=1;i<n;i++)cin>>p[i];
    for(int i=0;i<o;i++)cin>>h[i];
    p[n]=d;sort(h,h+o);
    sort(p,p+n+1);
    long long ans=0,dd=1;
    for(int i=0;i<o;i++){
      while(h[i]>=p[dd])dd++;
      ans+=min(abs(p[dd]-h[i]),abs(h[i]-p[dd-1]));
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3416
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = numeric_limits<int>::max();
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

// cut begin ----------------------------------------

// 0-indexed bottom up Segment Tree
// UNIT is the identity element of operation func
template <typename T = int>
struct SegmentTree {
    using F = function<T(T, T)>;
    int n;
    vector<T> dat;
    F func;
    T UNIT;

    SegmentTree(int n_, F func_, T UNIT_) : func(func_), UNIT(UNIT_) {
        n = 1;
        // full binary tree: num of leaves = n = 2^k >= n_
        while (n < n_)
            n *= 2;
        dat.assign(2 * n - 1, UNIT);
    }
    SegmentTree(vector<T> v_, F func_, T UNIT_) : func(func_), UNIT(UNIT_) {
        n = 1;
        while (n < v_.size())
            n *= 2;
        dat.assign(2 * n - 1, UNIT);
        for (int i = 0; i < v_.size(); ++i) {
            dat[n - 1 + i] = v_[i];
        }
        for (int i = n - 2; i >= 0; --i) {
            dat[i] = func(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }
    void update(int k, T a) {
        // leaves are at index n-1 to 2*n-2
        k += n - 1;
        dat[k] = a;
        while (k > 0) {
            // k -> parent node
            k = (k - 1) / 2;
            // func(child nodes)
            dat[k] = func(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }
    // get result of func() in [l, r)
    T query(int l, int r) {
        l += n - 1;
        r += n - 1;
        T ret = UNIT;
        while (l < r) {
            if ((l & 1) == 0)
                ret = func(ret, dat[l]);
            if ((r & 1) == 0)
                ret = func(ret, dat[r - 1]);
            l = l / 2;
            r = (r - 1) / 2;
        }
        return ret;
    }
};

// cut end ------------------------------------------

// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3600039#1
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    auto f = [](int l, int r) { return min(l, r); };
    SegmentTree<int> seg(n, f, INF);
    vector<int> com(q), x(q), y(q);
    for (int i = 0; i < q; ++i) {
        cin >> com[i] >> x[i] >> y[i];
    }
    for (int i = 0; i < q; ++i) {
        if (com[i] == 0) {
            seg.update(x[i], y[i]);
        } else {
            cout << seg.query(x[i], y[i] + 1) << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long double r;cin >> r;
    cout << 2*3.141592653589793238*r;
    }

Measured memory_bytes: 3800
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll ans=0;
  string s;cin>>s;
  rep(i,s.size())ans+=s[i]-'0';
  cout<<ans<<endl;
}

Measured memory_bytes: 256