akhauriyash/Code-Regression huggingface dataset:
// skip until line 65
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define MO(a) AS_MOD(a,mod)
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
struct Vec;
//set<int, Comparator> S;

// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
ll N;
vector<ll> A(2*100000+10);
map<ll,ll> MA[2*100000+10];
ll INF=(1000*1000*1000ll)*(1000*1000ll)*10;
ll do_dp(ll i, ll j) {
    if (j*2-1>N-i+1  )return -INF;
    if (N/2-j>(i-2+1)/2  )return -INF;
    if (i>=N+1 && j>0) return -INF;
    if (i>=N+1) return 0;
    if (j==0) return 0;
    if (MA[i].count(j)>0)return MA[i][j];
    return MA[i][j]=max(do_dp(i+2,j-1)+A[i-1],do_dp(i+1,j));
}
int main() {
    cout.precision(10);
    cout << fixed;
    cin >> N;
    REP(i,N)
        cin>>A[i];
    cout<<do_dp(1,N/2)<<endl;
}


Measured memory_bytes: 40660
n = int(input())
A = list(map(int, input().split()))
D1 = {}
D2 = {}
def count(D, s):
    if s in D:
        D[s] += 1
    else:
        D[s] = 1
for i, a in enumerate(A):
        count(D1, a+i)
        count(D2, i-a)
ans = 0
for d, num in D1.items():
    if d in D2:
        ans += num * D2[d]
print(ans)

Measured memory_bytes: 56788
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    uvw <- replicateM (n-1) $ do
        [u,v,w] <- getIntList
        return (u-1,v-1,w)
    let edge = V.create $ do
            vec <- VM.replicate n []
            forM_ uvw $ \(u,v,w) -> do
                VM.modify vec ((u,w):) v
                VM.modify vec ((v,w):) u
            return vec
    let result = VU.create $ do
            color <- VUM.replicate n (-1 :: Int)
            VUM.write color 0 0
            let go [] = return ()
                go ((par,this,w) : qs) = do
                    c <- VUM.read color par
                    if even w
                    then VUM.write color this c
                    else VUM.write color this ((c+1) `mod` 2)
                    let next = map (\(a,b) -> (this,a,b)) $ filter ((/= par) . fst) (edge V.! this)
                    go (next ++ qs)
            go [(0,0,0)]
            return color
    VU.mapM_ print result

Measured memory_bytes: 64524
#include<iostream>
#include<vector>
#include<string>
#include <queue>
#include<map>
#include<set>
#include <cstring>
using namespace std;
#define ll long long int


int main()
{
    double n , t , s ;
    cin>>n>>t>>s ;
   
    if(t >= (n/s))
        cout<<"Yes" ;
    else
        cout<<"No" ;

}


Measured memory_bytes: 3716
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main implements Runnable {
	public static void main(String[] args) {
		new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start();
	}

	public void run() {
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		long[] a = new long[n];
		long[] b = new long[n];
		long sum = 0, min = Long.MAX_VALUE / 3;
		boolean flag = true;
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextLong();
			b[i] = sc.nextLong();
			flag &= a[i] == b[i];
			sum += a[i];
			if (a[i] > b[i])
				min = Math.min(min, b[i]);
		}
		if(flag) {
			System.out.println(0);
			return;
		}
		System.out.println(sum-min);

	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

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

	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


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


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


int main() {
	int n, k; cin >> n >> k;
	vector<int>A(n); for (auto&& x : A)cin >> x;
	if (n == 1) { cout << (A[0] == k ? "POSSIBLE" : "IMPOSSIBLE") << endl; return 0; }
	sort(A.begin(), A.end());

	int G = gcd(A[0], A[1]);
	for (int i = 2; i < A.size(); i++) {
		G = gcd(G, A[i]);
	}
	if (k % G == 0 && k <= A[A.size() - 1]) { cout << "POSSIBLE" << endl; }
	else cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &e: a) cin >> e;

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

    for (int i = 1; i < n; ++i) {
        if (ma[i-1] - a[i] > 1) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;


    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(ll i=0;i<(n);++i)
ll mod=7+1e9;
using vec = vector<ll>;
using matrix = vector<vec>;
matrix power(const matrix &a, ll n){
	ll sz = a.size();
	matrix res(sz,vec(sz));
	REP(i,sz)REP(j,sz){
		if(i==j) res[i][j] = 1;
		else res[i][j] = 0;
	}
	matrix r = a;
	while(n>0){
		if(n&1){
			matrix tmp(sz,vec(sz,0));
			REP(i,sz)REP(j,sz)REP(k,sz){
				tmp[i][j] += res[i][k]*r[k][j];
                tmp[i][j] %= mod;
			}
			res = tmp;
		}
		matrix tmp(sz,vec(sz,0));
		REP(i,sz)REP(j,sz)REP(k,sz){
			tmp[i][j] += r[i][k]*r[k][j];
            tmp[i][j] %= mod;
		}
		r = tmp;
		n >>= 1;
	}
	return res;
}
int main(){
    ll n, k;
	cin >> n >> k;
    matrix a(n, vec(n,0));
    for(ll i=0; i<n; ++i){
        for(ll j=0; j<n; ++j){
            cin >> a[i][j];
        }
    }
    a = power(a,k);
    ll cnt=0;
	for(ll i=0; i<n; ++i){
        for(ll j=0; j<n; ++j){
            cnt = (cnt+a[i][j])%mod;
        }
    }
	cout << cnt << endl;
}

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

const string EOT = "END_OF_TEXT";

int main() {
  string T, W;
  cin >> W;
  int ans = 0;
  for (;;) {
    cin >> T;
    if (T == EOT)
      break;
    transform(T.begin(), T.end(), T.begin(), ::tolower);
    if (T == W)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3156
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        // Line Of Code
        boolean flag = false;
        int N = in.nextInt();
        while (N != 0 ){
            if(N%10==7){
                flag = true;
                break;
            }

            N/=10;
        }

        if (flag)   System.out.println("Yes");
        else        System.out.println("No");

    }

    public static int MaxTwo(int x, int y){
        return ((x > y)?x:y);
    }
    public static int MaxThree(int x, int y, int z){
        return MaxTwo(MaxTwo(x,y),z);
    }
    public static int MinTwo(int x, int y){
        return ((x < y)?x:y);
    }
    public static int MinThree(int x, int y, int z){
        return MinTwo(MinTwo(x,y),z);
    }


    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        public int[] nextIntArray(int size){
            int arr[] =new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = Integer.parseInt(next());
//                sum = sum + in.nextInt();
            }
            return arr;
        }

    }
}



Measured memory_bytes: 32604
n = int(input())
s = []
check = True
s .append(input())
for i in range(1,n):
    s.append(input())
    if s[i-1][-1] != s[i][0] or s[i] in s[:i]:
        check = False
        break
if check:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <vector>
#include <functional>
#include <unordered_set>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

const int N = 25;
const int MOD = 1e9 + 7;

int sub(int a, int b) {
	a -= b;
	if (a < 0)
		return a + MOD;
	return a;
}

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

int plus(int a, int b) {
	add(a, b);
	return a;
}

long long sum[N];

long long getsum(int l, int r) {
	if (l == 0)
		return sum[r];
	return sum[r] - sum[l - 1];
}

template <class T>
void relax(T& a, T b) {
	a = min(a, b);
}

int g[N][N];
int dp[1 << 21];
int dp2[1 << 21];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			cin >> g[i][j];
		}
	}
	dp[0] = 1;
	for (int i = 0; i < n; ++i) {
		memset(dp2, 0, sizeof(dp2));
		for (int go = 0; go < n; ++go) {
			if (!g[i][go]) continue;
			int topmask = (1 << n) - 1 - (1 << go);
			for (int s = topmask; ; s = (s - 1) & topmask) {
				if (dp[s]) {
					add(dp2[s ^ (1 << go)], dp[s]);
				}
				if (s == 0)
					break;
			}
		}
		swap(dp, dp2);
	}
	cout << dp[(1 << n) - 1];

	return 0;
}

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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int N = 200005;

int n, k, c;
char word[N];
int suf[N * 2];

int main() {
    
    scanf("%d %d %d", &n, &k, &c);
    scanf("%s", &word[1]);
    
    for (int i = n; i >= 1; i--) {
        suf[i] = max(suf[i + 1], suf[i + c + 1] + (word[i] != 'x'));
    }
    
    int i = 1;
    while (i <= n) {
        if (word[i] == 'x') {
            i++;
            continue;
        }
        if (suf[i + 1] < k) {
            printf("%d\n", i);
        }
        k--;
        i += c + 1;
    }
    
    return 0;
}


Measured memory_bytes: 2432
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int K = scanner.nextInt();

		Set<Long> lunlun = new TreeSet<>();
		List<Long> queue = new ArrayList<>();

		queue.add(1l);
		queue.add(2l);
		queue.add(3l);
		queue.add(4l);
		queue.add(5l);
		queue.add(6l);
		queue.add(7l);
		queue.add(8l);
		queue.add(9l);

		lunlun.addAll(queue);

		while (lunlun.size() <= K) {
			long num = queue.get(0);
			List<Long> temp = new ArrayList<>();
			if (num % 10 != 0) temp.add((num * 10) + (num % 10 - 1));
			temp.add((num * 10) + (num % 10));
			if (num % 10 != 9) temp.add((num * 10) + (num % 10 + 1));

			queue.addAll(temp);
			queue.remove(0);
			lunlun.addAll(temp);
		}

		List<Long> lunlunL = new ArrayList<>(lunlun);

		System.out.println(lunlunL.get(K - 1));

	}
}


Measured memory_bytes: 35672
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]
 
for i in range(N - M + 1):  # tate
    for j in range(N - M + 1):  # yoko
        ans = 1
        for k in range(M):
            if B[k] != A[i + k][j:j+M]:
                ans = 0
        if ans == 1:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 9128
x,y = map(int,input().split())
s = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
flag = False
for i in range(3):
    if x in s[i] and y in s[i]:
        flag = True
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
from collections import deque

V,E = map(int,input().split())

dic = {}
pnum = [0] * V

for i in range(E):

    s,t = map(int,input().split())

    pnum[t] += 1
    
    if s not in dic:
        dic[s] = []
    dic[s].append(t)

q = deque([])
ans = []

for i in range(V):

    if pnum[i] == 0:
        q.append(i)
        ans.append(i)

while len(q) > 0:

    now = q.popleft()

    if now not in dic:
        continue

    for i in dic[now]:
        pnum[i] -= 1

        if pnum[i] == 0:
            q.append(i)
            ans.append(i)

for i in range(V):
    print (ans[i])


Measured memory_bytes: 9552
/*
P135
AOJ 2170 Marked Ancestor
*/

#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <functional>
#include <string.h>
#include <cmath>

using namespace std;

const int MAXN = 100005;

int parent[MAXN];
int isMarked[MAXN];
int N, Q;

struct OPER{
    char s[2];
    int p;
    void input(){
        scanf("%s%d", s, &p);
        if(s[0] == 'M') isMarked[p]++;
    };
}op[MAXN];


class UnionSet{
public:
    int Find(int x)
    {
        if(isMarked[x]) return x;
        else {
            int fx = parent[x];
            parent[x] = Find(fx);
            return parent[x];
        }
    }
};

UnionSet us;

bool read()
{
    scanf("%d%d", &N, &Q);
    if(N==0&&Q==0) return false;
    memset(isMarked, 0, sizeof(isMarked));
    parent[1] = 1;
    isMarked[1] = N+1;
    for(int i=2; i<=N; ++i){
        scanf("%d", &parent[i]);
    }
    return true;
}

void solve()
{
    for(int q=0; q<Q; ++q)
        op[q].input();

    long long sum = 0;
    for(int q=Q-1; q>=0; --q){
        int v = op[q].p;
        if(op[q].s[0] == 'M'){
            isMarked[v]--;
        }
        else {
            sum += us.Find(v);
        }
    }
    printf("%lld\n", sum);
}

int main()
{
    while(read()){
        solve();
    }
}

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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");

int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}

vi vis(100001,0);
vi adj[100001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
     int n;
    mapii mps;
    cin>>n;
    vi vec;
    for(int i=0; i<n; ++i)
    {
    	int x;
    	cin>>x;
    	vec.pb(x);
    }
    int maxi=-1;
    for(int i=0; i<n; ++i)
    {
    	if(vec[i]>maxi)
    		maxi=vec[i];
    	if(vec[i]>=maxi)
    		--vec[i];
    }
    for(int i=0; i<n-1; ++i)
    {
    	if(vec[i]>vec[i+1])
    	{
    		cout<<"No"<<"\n";
    		return 0;
    	}
    }
    cout<<"Yes"<<"\n";
}

Measured memory_bytes: 3708
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    string ta, tb, tc;
    cin >> ta >> tb >> tc;
    deque<char> a, b, c;
    rep(i, ta.size())
    {
        a.push_back(ta[i]);
    }
    rep(i, tb.size())
    {
        b.push_back(tb[i]);
    }
    rep(i, tc.size())
    {
        c.push_back(tc[i]);
    }
    char now = 'a';
    while (true)
    {
        if (now == 'a')
        {
            if (a.empty())
            {
                cout << 'A' << endl;
                return 0;
            }
            now = a.front();
            a.pop_front();
        }
        else if (now == 'b')
        {
            if (b.empty())
            {
                cout << 'B' << endl;
                return 0;
            }
            now = b.front();
            b.pop_front();
        }
        else if (now == 'c')
        {
            if (c.empty())
            {
                cout << 'C' << endl;
                return 0;
            }
            now = c.front();
            c.pop_front();
        }
    }
}


Measured memory_bytes: 256
import math


def main():

    mod = 1000000007
    N = int(input())

    A = [0]
    B = [0]

    for n in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)

    calc = dict()
    non_count = 0

    for i in range(1, N + 1):

        if A[i] == 0 and B[i] == 0:
            non_count += 1
        elif A[i] == 0:
            k = (0, 1)
            if calc.get(k):
                calc[k][0] += 1
            else:
                calc[k] = [1, 0]
        elif B[i] == 0:
            k = (0, 1)
            if calc.get(k):
                calc[k][1] += 1
            else:
                calc[k] = [0, 1]
        else:
            r = math.gcd(A[i], B[i])
            m = 1
            if A[i] * B[i] < 0:
                m = -1
            k1 = (m * abs(A[i] // r), abs(B[i] // r))
            k2 = (-m * abs(B[i] // r), abs(A[i] // r))
            if calc.get(k1):
                calc[k1][0] += 1
            elif not calc.get(k2):
                calc[k1] = [1, 0]
            else:
                calc[k2][1] += 1

    N = N - non_count

    count = 0
    for k, v in calc.items():
        if not v[0] * v[1] == 0:
            count += v[0] + v[1]

    ans = pow(2, N - count, mod)
    for k, v in calc.items():
        if not v[0] * v[1] == 0:
            comb = (pow(2, v[0]) + pow(2, v[1]) - 1)
            ans = (ans * comb) % mod

    print((ans - 1 + non_count) % mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 79480
#include <bits/stdc++.h>
using namespace std;
int W, a, b;
int main() {
    cin >> W >> a >> b;
    int less, greater = 0;
    if(a < b) {
        less = a;
        greater = b;
    }else {
        less = b;
        greater = a;
    }

    if((less+W) > greater) {
        cout << 0 << endl;
    }else {
        cout << greater-(less+W) << endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

template <int DEFAULT_MOD=998244353>
class Mint {
public:
  typedef long long val_type;

  Mint(val_type x=0, int m=DEFAULT_MOD) : val((x%m+m)%m), mod(m) {}
  val_type value() const { return val; }
  Mint& operator+=(const Mint a) {
    if ((val += a.val) >= mod) val -= mod;
    return *this;
  }
  Mint& operator-=(const Mint a) {
    if ((val += mod-a.val) >= mod) val -= mod;
    return *this;
  }
  Mint& operator*=(const Mint a) {
    (val *= a.val) %= mod;
    return *this;
  }
  Mint operator+(const Mint a) const {
    Mint res(*this);
    return res+=a;
  }
  Mint operator-(const Mint a) const {
    Mint res(*this);
    return res-=a;
  }
  Mint operator*(const Mint a) const {
    Mint res(*this);
    return res*=a;
  }
  Mint pow(val_type t) const {
    if (!t) return 1;
    Mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  Mint inv() const {
    return pow(mod-2);
  }
  Mint& operator/=(const Mint a) {
    return (*this) *= a.inv();
  }
  Mint operator/(const Mint a) const {
    Mint res(*this);
    return res/=a;
  }

private:
  val_type val;
  int mod;
};

int main()
{
    const int MOD = 998244353;

	cin.tie(0);
	ios::sync_with_stdio(0);

    int N;
    cin >> N;
    vector<int> D(N);
    rep(i, N) cin >> D[i];

    LL ans = 0;
    if (D[0] == 0) {
        vector<int> distCount(N); 
        int maxLen = 0;
        rep(i, N) {
            maxLen = max(maxLen, D[i]);
            ++distCount[D[i]];
        }
        if (distCount[0] == 1) {
            ans = 1;
            for (int i = 2; i <= maxLen; ++i) {
                int a = distCount[i-1];
                int b = distCount[i];
                // cout << "a = " << a << ", b = " << b << endl;
                rep(j, b) {
                    ans = (ans * a) % MOD;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

typedef long long ll;

int n;
string s;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>s;
    bool ok = true;
    if (n & 1) {
        ok = false;
    } else {
        n /= 2;
        if (s.substr(0, n) != s.substr(n, n)) {
            ok = false;
        }
    }
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}



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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int32> x(5);
  REP(i,5)cin >> x[i];
  REP(i,5){
    if(x[i] != i+1){
      ANS(i+1);
    }
  }
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
// #include <numeric>
// #include <set>
// #include <cmath>
// #include <string>
// #include <map>
// #include <iomanip>

// #define MOD 1000000007

using namespace std;
// typedef unsigned long long ull;
typedef long long ll;

void p() {
    cout << "\n";
}
template<class Head, class... Body>
void p(Head head, Body... body) {
    cout << head << ",";
    p(body...);
}


int main(int argc, char const *argv[]) {
    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;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;
int main()
{
    int n, lmin = INT_MAX, s = 0;
    int l;
    cin >> n >> l;
    for(int i = 0; i < n; i++){
        s += l + i;
        lmin = min(lmin, abs(l+i));
    }
    // s = n * (n-1) / 2 * (l - 1);
    cout << s - lmin * (s < 0 ? -1 : 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int h, w; cin >> h >> w;
	vector<string> s(h);
	rep(i, 0, h - 1)cin >> s[i];
	vector<vector<int>> yoko(h, vector<int>(w,0));
	vector<vector<int>> tate(h, vector<int>(w,0));
	rep(i, 0, h - 1)
	{
		int cnt = 0;
		rep(j, 0, w - 1)
		{
			if (s[i][j] == '.')
			{
				++cnt;
				yoko[i][j] = cnt;
			}
			else
			{
				cnt = 0;
			}
		}
		int tmp = 0;
		for (int j = w - 1; 0 <= j; --j)
		{
			if (yoko[i][j] != 0)
			{
				tmp = yoko[i][j];
				while (0 <= j && yoko[i][j] != 0)
				{
					yoko[i][j] = tmp;
					--j;
				}
			}
		}
	}
	rep(i, 0, w - 1)
	{
		int cnt = 0;
		rep(j, 0, h - 1)
		{
			if (s[j][i] == '.')
			{
				++cnt;
				tate[j][i] = cnt;
			}
			else
			{
				cnt = 0;
			}
		}
		int tmp = 0;
		for (int j = h - 1; 0 <= j; --j)
		{
			if (tate[j][i] != 0)
			{
				tmp = tate[j][i];
				while (0 <= j && tate[j][i] != 0)
				{
					tate[j][i] = tmp;
					--j;
				}
			}
		}
	}
	int ans = 0;
	rep(i, 0, h - 1)rep(j, 0, w - 1)
	{
		if (s[i][j] == '.')
		{
			ans = max(ans, yoko[i][j] + tate[i][j] - 1);
		}
	}
	cout << ans << endl;
}

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

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

	if (a == 7 && b == 5 && c == 5) {
		cout << "YES" << endl;
	}
	else if (a == 5 && b == 7 && c == 5) {
		cout << "YES" << endl;
	}
	else if (a == 5 && b == 5 && c == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n;

void solve(){
    cin >> n;
    int p=n%10;
    if(p==3){
        cout << "bon" << endl;
    }
    else if(p==0 || p==1 || p==6 || p==8){
        cout << "pon" << endl;
    }
    else{
        cout << "hon" << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 3660
/*
 * main.c
 *
 *  Created on: 2019/01/13
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int num[4] = {0};
	int i = 0;
	int ok = 0;

	for(i = 0; i < 4; i++) {
		scanf("%d", &num[i]);
		switch(num[i]) {
		case 1:
			ok |= 0x8;
			break;
		case 9:
			ok |= 0x4;
			break;
		case 7:
			ok |= 0x2;
			break;
		case 4:
			ok |= 0x1;
			break;
			break;
		default:
			break;
		}
	}

	if (ok == 0x0f) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
struct fr{
	ll int d;//ぶんぼ
	ll int n;//ぶんし
};

fr normalize(fr in){
	bool rst = false;
	if(in.n<0){
		in.n *= -1;
		rst = true;
	}
	while(1){
		int g = gcd(in.d,in.n);
		if(g==1) break;
		in.d /= g;
		in.n /= g;
	}
	if(rst) in.n *= -1;
	return in;
}

fr addfr(fr a,fr b){
	fr tmp;
	tmp.d = lcm(a.d,b.d);
	tmp.n = tmp.d/a.d*a.n + tmp.d/b.d*b.n;
	return tmp;
}

ll int njou(int n){
	ll int tmp = 1;
	REP(i,n) tmp*=2;
	return tmp;
}

int main(){
	while(1){
		string in_str;
		cin >> in_str;
		if(in_str[0]=='#') break;
		string astr="";
		REP(i,in_str.size()){
			if(in_str[i]=='w') astr+='w';
			if(in_str[i]=='n') astr+='n';
		}
		fr ans;
		if(astr[astr.size()-1]=='w'){
			ans.n = 90;
			ans.d = 1;
		}else{
			ans.n = 0;
			ans.d = 1;
		}
		for(int i=0;i<astr.size()-1;i++){
			fr tmp;
			if(astr[i]=='n') tmp.n = -90;
			else tmp.n = 90;
			tmp.d = njou(astr.size()-i-1);
			ans = normalize(addfr(ans,tmp));
		}
		if(ans.d==1) cout << ans.n << endl;
		else cout << ans.n << "/" << ans.d << endl;
	}
}

Measured memory_bytes: 1200
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		vector<int> know[100];
		rep(i,n){
			int m; scanf("%d",&m);
			rep(j,m){
				int a; scanf("%d",&a); a--;
				know[i].push_back(a);
			}
		}

		int k; scanf("%d",&k);
		vector<int> leak(k);
		rep(i,k) scanf("%d",&leak[i]), leak[i]--;

		int ans=-1;
		rep(i,n){
			bool ok=false;
			rep(j,k) if(count(know[i].begin(),know[i].end(),leak[j])==0) ok=true;
			if(!ok){
				if(ans==-1) ans=i;
				else        ans=-2;
			}
		}
		printf("%d\n",ans>=0?ans+1:-1);
	}

	return 0;
}

Measured memory_bytes: 864
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    int N;
    cin >> N;
    vector<int> P(N);
    for(int i=0; i<N; i++) cin >> P[i];
    int m = N+1;
    int ans = 0;
    for(int i=0; i<N; i++){
        if(m > P[i]) ans++;
        m = min(m, P[i]);
    }

    cout << ans << endl;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    
    vector<vector<char>> a(n,vector<char>(n));
    vector<vector<char>> b(m,vector<char>(m));
    
    rep(i,n){
        rep(j,n) cin >> a[i][j];
    }
    
    rep(i,m){
        rep(j,m) cin >> b[i][j];
    }
    
    int d = n - m;
    bool flag = false;
    
    for(int i = 0; i <= d; i++){//基準点の移動
        for(int f = 0; f <= d; f++){
            int cnt = 0;
            for(int j = i; j < i+m; j++){
                for(int k = f; k < f+m; k++){
                    if(a[j][k]==b[j-i][k-f]) cnt++;
                    if(cnt==m*m) flag = true;
                }
            }
            cnt = 0;
        }
    }
    
    if(flag) cout << "Yes";
    else cout << "No";
    
}

Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1;

//{
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();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int n,x,ans;

main(){
	cin>>n>>x;
	int a[n];
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	for(int i=0;x>=0&&i<n;i++){
		ans++;
		x-=a[i];
	}
	if(x!=0)ans--;
	dans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define MOD 1000000007
#define ull unsigned long long
#define all(x) (x).begin(), (x).end()
#define read(a, n) for(ll i = 0;i<n;i++) cin>>a[i];
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define print(x) for(auto it:x) cout<<it<<" "; cout<<<"\n";
#define FileIO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
const int INF = 1e9 + 5;

void solve() {
	ll n;
	cin>>n;
	
	ll a[n];
	read(a, n);
	
	ll max = 0;
	ll ans = 0;
	for(int i = 0;i<n;i++) {
		if(a[i] > max) {
			max = a[i];
		}
		ans += (max - a[i]);
	}
	
	cout<<ans<<"\n";
}

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


Measured memory_bytes: 5144
def main():
	N = int(input())
	V = list(map(int, input().split()))
	C = list(map(int, input().split()))
	ans = 0
	for i in range(N):
		this_value = V[i] - C[i]
		if this_value > 0:
			ans += this_value

	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
#define MAX 10010000000
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL n;
    LL k;
    cin >> n >> k;
    vector<LL> p(n);
    vector<LL> c(n);
    for(LL i=0; i<n; i++){
        cin >> p[i];
        p[i]--;
    }
    for(LL i=0; i<n; i++){
        cin >> c[i];
    }

    LL max_ans=-1*MAX;
    LL ans;
    LL idx;
    LL loop_sum;
    LL loop_cnt;
    //cout << loop_sum << endl;
    if(k<2*n){
        for(LL i=0; i<n; i++){
            idx=i;
            ans=0;
            idx=p[idx];
            ans+=c[idx];
            max_ans=max(max_ans,ans);
            for(LL j=1; j<k; j++){
                idx=p[idx];
                ans+=c[idx];
                max_ans=max(max_ans,ans);
            }
        }
    }else{
        for(LL i=0; i<n; i++){
            idx=i;
            loop_sum=0;
            idx=p[idx];
            loop_sum+=c[idx];
            loop_cnt=1;
            while(idx!=i){
            idx=p[idx];
            loop_sum+=c[idx];
            loop_cnt++;                
            }
            //cout << loop_cnt << endl;
            if(loop_sum<0){
                idx=i;
                ans=0;
                idx=p[idx];
                ans+=c[idx];
                max_ans=max(max_ans,ans);
                for(LL j=1; j<loop_cnt; j++){
                    idx=p[idx];
                    ans+=c[idx];
                    max_ans=max(max_ans,ans);
                }
            }else{
                LL num_loop=k/loop_cnt-2;
                LL res_k=k%loop_cnt+loop_cnt;
                idx=i;
                ans=0;
                idx=p[idx];
                ans+=c[idx];
                max_ans=max(max_ans,ans);
                //cout << res_k << " " << num_loop << " " << loop_cnt << endl;
                for(LL j=1; j<res_k; j++){
                    idx=p[idx];
                    ans+=c[idx];
                    max_ans=max(max_ans,ans);
                }
                ans+=loop_sum*num_loop;
                max_ans=max(max_ans,ans);
                for(LL j=0; j<loop_cnt; j++){
                    idx=p[idx];
                    ans+=c[idx];
                    max_ans=max(max_ans,ans);
                }
            }
        }
    }

    cout << max_ans << endl;

    return 0;
}


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

int main() {

    long long int h,w,n;

    cin >> h >> w >> n;

    map<pair<long long int,long long int>,bool> m;

    long long int ans[10];

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

    ans[0] = (h-2)*(w-2);

    for(long long int i=0; i<n; i++){

        long long int a,b;

        cin >> a >> b;

        a--; b--;

        m[make_pair(a,b)] = true;

        for(long long int r=-2; r<1; r++){
            for(long long int k=-2; k<1; k++){

                bool flag = true;

                for(int x=0; x<3; x++){
                    for(int y=0; y<3; y++){
                        if(a+r+x<0 || b+k+y<0 || a+r+x >= h || b+k+y >= w){
                            flag = false;
                            break;
                        }
                    }
                }

                if(!flag){
                    continue;
                }

                int count = 0;
                for(long long int ii=a+r; ii<a+r+3; ii++){
                    for(long long int jj=b+k; jj<b+k+3; jj++) {
                        if (m[make_pair(ii,jj)]){
                            count++;
                        }
                    }
                }
                ans[count]++;
                ans[count-1]--;
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 156544
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

cs = ([row[j:j+m] for row in a[i:i+m]]
      for i in range(n-m+1) for j in range(n-m+1))
print('Yes' if any(c == b for c in cs) else 'No')


Measured memory_bytes: 3060
import copy

n,m = map(int,input().split())
h = list(map(int,input().split()))
p = copy.copy(h)
# path = list(list(map(int,input().split())) for x in range(m))
for i in range(m):
    x,y = map(int,input().split())
    if h[x-1] > h[y-1]:
        p[y-1] = 0
    elif h[x-1] < h[y-1]:
        p[x -1] = 0
    elif  h[x-1] == h[y-1]:
        p[y-1] = 0
        p[x-1] = 0
cnt = 0
for k in p:
    if k != 0:
        cnt += 1
# print(h)
print(cnt)

Measured memory_bytes: 20944
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const ll INF = 10000000000;
int main() {
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
typedef long long int lli;
int main(void)
{
    int n;
    char s[101],t[101];

    scanf("%d %s %s",&n,s,t);
    for(int i=0;i<n;i++){
        printf("%c%c",s[i],t[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int main(){
	int l;cin>>l;
	l--;
	int n=20;
	vvp G(n);
	int m=0;
	loop(i,1,n-1){
		G[i].pb({i+1,0});
		G[i].pb({i+1,1<<(n-2-i)});
		m+=2;
	}
	loop(i,1,n){
		int t=1<<(n-1-i);
		while(l>=t-1){
			G[0].pb({i,l-t+1});
			m++;
			l-=t;
		}
	}
	cout<<n<<" "<<m<<endl;
	rep(i,n)rep(j,G[i].size())
		cout<<i+1<<" "<<G[i][j].first+1<<" "<<G[i][j].second<<endl;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node{
	int num,pos;
}aa[200005],bb[200005];
bool cmp(node x,node y){
	return x.num<y.num;
}
int mo[200005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&aa[i].num);
		aa[i].pos=i;
	}
	for(int i=0;i<n;i++){
		scanf("%d",&bb[i].num);
		bb[i].pos=i;
	}
	sort(aa,aa+n,cmp);
	sort(bb,bb+n,cmp);
	for(int i=0;i<n;i++)
		if(aa[i].num>bb[i].num){
			printf("No");
			return 0;
		}
	for(int i=1;i<n;i++)
		if(aa[i].num<=bb[i-1].num){
			printf("Yes");
			return 0;
		}
	for(int i=0;i<n;i++)
		mo[aa[i].pos]=bb[i].pos;
	vector<int>pp;
	pp.push_back(0);
	int now=mo[0];
	while(true){
		pp.push_back(now);
		if(pp[0]==pp[pp.size()-1]){
			if(pp.size()==n+1)
				printf("No");
			else
				printf("Yes");
			return 0;
		}
		now=mo[now];
	}	
}

Measured memory_bytes: 2812
import java.util.*;
public class Main{
	public static void main(String[] args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt(),m=in.nextInt(),x=in.nextInt();
		int[][] arr=new int[n][m+1];
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<=m;j++)
			{
				arr[i][j]=in.nextInt();
			}
		}
		int ans=1000000007;
		for(int i=1;i<(1<<n);i++)
		{
			boolean f=true;
			int[] ar=new int[m];
			int sum=0;
			for(int j=0;j<n;j++)
			{
				if((1&(i>>j))==1)
				{
					sum+=arr[j][0];
					for(int k=1;k<=m;k++)
					{
						ar[k-1]+=arr[j][k];
					}
				}
			}
			for(int j=0;j<m;j++)
			{
				if(ar[j]<x)
					f=false;
			}
			if(f)
			{
				ans=Math.min(ans,sum);
			}

		}
		if(ans==1000000007)
		{
			System.out.println(-1);
		}
		else
		{
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 37324